diff options
Diffstat (limited to 'src/test/ui')
1281 files changed, 16885 insertions, 4676 deletions
diff --git a/src/test/ui/abi/homogenous-floats-target-feature-mixup.rs b/src/test/ui/abi/homogenous-floats-target-feature-mixup.rs new file mode 100644 index 000000000..d7f5e1921 --- /dev/null +++ b/src/test/ui/abi/homogenous-floats-target-feature-mixup.rs @@ -0,0 +1,192 @@ +// This test check that even if we mixup target feature of function with homogenous floats, +// the abi is sound and still produce the right answer. +// +// This is basically the same test as src/test/ui/simd/target-feature-mixup.rs but for floats and +// without #[repr(simd)] + +// run-pass +// ignore-emscripten +// ignore-sgx no processes + +#![feature(avx512_target_feature)] + +#![allow(overflowing_literals)] +#![allow(unused_variables)] + +use std::process::{Command, ExitStatus}; +use std::env; + +fn main() { + if let Some(level) = env::args().nth(1) { + return test::main(&level) + } + + match std::env::var("TARGET") { + Ok(s) => { + // Skip this tests on i586-unknown-linux-gnu where sse2 is disabled + if s.contains("i586") { + return + } + } + Err(_) => return, + } + + let me = env::current_exe().unwrap(); + for level in ["sse", "avx", "avx512"].iter() { + let status = Command::new(&me).arg(level).status().unwrap(); + if status.success() { + println!("success with {}", level); + continue + } + + // We don't actually know if our computer has the requisite target features + // for the test below. Testing for that will get added to libstd later so + // for now just assume sigill means this is a machine that can't run this test. + if is_sigill(status) { + println!("sigill with {}, assuming spurious", level); + continue + } + panic!("invalid status at {}: {}", level, status); + } +} + +#[cfg(unix)] +fn is_sigill(status: ExitStatus) -> bool { + use std::os::unix::prelude::*; + status.signal() == Some(4) +} + +#[cfg(windows)] +fn is_sigill(status: ExitStatus) -> bool { + status.code() == Some(0xc000001d) +} + +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[allow(nonstandard_style)] +mod test { + #[derive(PartialEq, Debug, Clone, Copy)] + struct f32x2(f32, f32); + + #[derive(PartialEq, Debug, Clone, Copy)] + struct f32x4(f32, f32, f32, f32); + + #[derive(PartialEq, Debug, Clone, Copy)] + struct f32x8(f32, f32, f32, f32, f32, f32, f32, f32); + + pub fn main(level: &str) { + unsafe { + main_normal(level); + main_sse(level); + if level == "sse" { + return + } + main_avx(level); + if level == "avx" { + return + } + main_avx512(level); + } + } + + macro_rules! mains { + ($( + $(#[$attr:meta])* + unsafe fn $main:ident(level: &str) { + ... + } + )*) => ($( + $(#[$attr])* + unsafe fn $main(level: &str) { + let m128 = f32x2(1., 2.); + let m256 = f32x4(3., 4., 5., 6.); + let m512 = f32x8(7., 8., 9., 10., 11., 12., 13., 14.); + assert_eq!(id_sse_128(m128), m128); + assert_eq!(id_sse_256(m256), m256); + assert_eq!(id_sse_512(m512), m512); + + if level == "sse" { + return + } + assert_eq!(id_avx_128(m128), m128); + assert_eq!(id_avx_256(m256), m256); + assert_eq!(id_avx_512(m512), m512); + + if level == "avx" { + return + } + assert_eq!(id_avx512_128(m128), m128); + assert_eq!(id_avx512_256(m256), m256); + assert_eq!(id_avx512_512(m512), m512); + } + )*) + } + + mains! { + unsafe fn main_normal(level: &str) { ... } + #[target_feature(enable = "sse2")] + unsafe fn main_sse(level: &str) { ... } + #[target_feature(enable = "avx")] + unsafe fn main_avx(level: &str) { ... } + #[target_feature(enable = "avx512bw")] + unsafe fn main_avx512(level: &str) { ... } + } + + #[target_feature(enable = "sse2")] + unsafe fn id_sse_128(a: f32x2) -> f32x2 { + assert_eq!(a, f32x2(1., 2.)); + a.clone() + } + + #[target_feature(enable = "sse2")] + unsafe fn id_sse_256(a: f32x4) -> f32x4 { + assert_eq!(a, f32x4(3., 4., 5., 6.)); + a.clone() + } + + #[target_feature(enable = "sse2")] + unsafe fn id_sse_512(a: f32x8) -> f32x8 { + assert_eq!(a, f32x8(7., 8., 9., 10., 11., 12., 13., 14.)); + a.clone() + } + + #[target_feature(enable = "avx")] + unsafe fn id_avx_128(a: f32x2) -> f32x2 { + assert_eq!(a, f32x2(1., 2.)); + a.clone() + } + + #[target_feature(enable = "avx")] + unsafe fn id_avx_256(a: f32x4) -> f32x4 { + assert_eq!(a, f32x4(3., 4., 5., 6.)); + a.clone() + } + + #[target_feature(enable = "avx")] + unsafe fn id_avx_512(a: f32x8) -> f32x8 { + assert_eq!(a, f32x8(7., 8., 9., 10., 11., 12., 13., 14.)); + a.clone() + } + + #[target_feature(enable = "avx512bw")] + unsafe fn id_avx512_128(a: f32x2) -> f32x2 { + assert_eq!(a, f32x2(1., 2.)); + a.clone() + } + + #[target_feature(enable = "avx512bw")] + unsafe fn id_avx512_256(a: f32x4) -> f32x4 { + assert_eq!(a, f32x4(3., 4., 5., 6.)); + a.clone() + } + + #[target_feature(enable = "avx512bw")] + unsafe fn id_avx512_512(a: f32x8) -> f32x8 { + assert_eq!(a, f32x8(7., 8., 9., 10., 11., 12., 13., 14.)); + a.clone() + } +} + +#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] +mod test { + pub fn main(level: &str) {} +} diff --git a/src/test/ui/abi/issues/issue-22565-rust-call.rs b/src/test/ui/abi/issues/issue-22565-rust-call.rs index a08e0bfb5..a572666c8 100644 --- a/src/test/ui/abi/issues/issue-22565-rust-call.rs +++ b/src/test/ui/abi/issues/issue-22565-rust-call.rs @@ -1,32 +1,31 @@ #![feature(unboxed_closures)] extern "rust-call" fn b(_i: i32) {} -//~^ ERROR functions with the "rust-call" ABI must take a single non-self argument that is a tuple +//~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument trait Tr { extern "rust-call" fn a(); + //~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument extern "rust-call" fn b() {} - //~^ ERROR functions with the "rust-call" ABI must take a single non-self argument + //~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument } struct Foo; impl Foo { extern "rust-call" fn bar() {} - //~^ ERROR functions with the "rust-call" ABI must take a single non-self argument + //~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument } impl Tr for Foo { extern "rust-call" fn a() {} - //~^ ERROR functions with the "rust-call" ABI must take a single non-self argument + //~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument } -fn main () { +fn main() { b(10); - Foo::bar(); - <Foo as Tr>::a(); <Foo as Tr>::b(); } diff --git a/src/test/ui/abi/issues/issue-22565-rust-call.stderr b/src/test/ui/abi/issues/issue-22565-rust-call.stderr index 3eee10bc5..9d205b444 100644 --- a/src/test/ui/abi/issues/issue-22565-rust-call.stderr +++ b/src/test/ui/abi/issues/issue-22565-rust-call.stderr @@ -1,26 +1,33 @@ -error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple +error[E0277]: functions with the "rust-call" ABI must take a single non-self tuple argument --> $DIR/issue-22565-rust-call.rs:3:1 | LL | extern "rust-call" fn b(_i: i32) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `i32` -error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple - --> $DIR/issue-22565-rust-call.rs:9:5 - | -LL | extern "rust-call" fn b() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple - --> $DIR/issue-22565-rust-call.rs:16:5 +error: functions with the "rust-call" ABI must take a single non-self tuple argument + --> $DIR/issue-22565-rust-call.rs:17:5 | LL | extern "rust-call" fn bar() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple - --> $DIR/issue-22565-rust-call.rs:21:5 +error: functions with the "rust-call" ABI must take a single non-self tuple argument + --> $DIR/issue-22565-rust-call.rs:22:5 | LL | extern "rust-call" fn a() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +error: functions with the "rust-call" ABI must take a single non-self tuple argument + --> $DIR/issue-22565-rust-call.rs:7:5 + | +LL | extern "rust-call" fn a(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: functions with the "rust-call" ABI must take a single non-self tuple argument + --> $DIR/issue-22565-rust-call.rs:10:5 + | +LL | extern "rust-call" fn b() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/abi/rustcall-generic.rs b/src/test/ui/abi/rustcall-generic.rs index 411c98e10..6eaccc436 100644 --- a/src/test/ui/abi/rustcall-generic.rs +++ b/src/test/ui/abi/rustcall-generic.rs @@ -2,9 +2,9 @@ // check-pass //[opt] compile-flags: -Zmir-opt-level=3 -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] -extern "rust-call" fn foo<T>(_: T) {} +extern "rust-call" fn foo<T: std::marker::Tuple>(_: T) {} fn main() { foo(()); diff --git a/src/test/ui/alloc-error/alloc-error-handler-bad-signature-1.rs b/src/test/ui/alloc-error/alloc-error-handler-bad-signature-1.rs index 41c9a265c..cd06423e3 100644 --- a/src/test/ui/alloc-error/alloc-error-handler-bad-signature-1.rs +++ b/src/test/ui/alloc-error/alloc-error-handler-bad-signature-1.rs @@ -8,8 +8,8 @@ use core::alloc::Layout; #[alloc_error_handler] fn oom( - info: &Layout, //~ ERROR argument should be `Layout` -) -> () //~ ERROR return type should be `!` + info: &Layout, //~^ ERROR mismatched types +) -> () //~^^ ERROR mismatched types { loop {} } diff --git a/src/test/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr b/src/test/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr index 34e09da45..dd3665f22 100644 --- a/src/test/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr +++ b/src/test/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr @@ -1,14 +1,50 @@ -error: return type should be `!` - --> $DIR/alloc-error-handler-bad-signature-1.rs:12:6 +error[E0308]: mismatched types + --> $DIR/alloc-error-handler-bad-signature-1.rs:10:1 | -LL | ) -> () - | ^^ - -error: argument should be `Layout` - --> $DIR/alloc-error-handler-bad-signature-1.rs:11:11 +LL | #[alloc_error_handler] + | ---------------------- in this procedural macro expansion +LL | fn oom( + | __^ + | | _| + | || +LL | || info: &Layout, +LL | || ) -> () + | ||_______- arguments to this function are incorrect +LL | | { +LL | | loop {} +LL | | } + | |__^ expected `&Layout`, found struct `Layout` + | +note: function defined here + --> $DIR/alloc-error-handler-bad-signature-1.rs:10:4 | +LL | fn oom( + | ^^^ LL | info: &Layout, - | ^^^^^^^ + | ------------- + = note: this error originates in the attribute macro `alloc_error_handler` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0308]: mismatched types + --> $DIR/alloc-error-handler-bad-signature-1.rs:10:1 + | +LL | #[alloc_error_handler] + | ---------------------- in this procedural macro expansion +LL | fn oom( + | __^ + | | _| + | || +LL | || info: &Layout, +LL | || ) -> () + | ||_______^ expected `!`, found `()` +LL | | { +LL | | loop {} +LL | | } + | |__- expected `!` because of return type + | + = note: expected type `!` + found unit type `()` + = note: this error originates in the attribute macro `alloc_error_handler` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/alloc-error/alloc-error-handler-bad-signature-2.rs b/src/test/ui/alloc-error/alloc-error-handler-bad-signature-2.rs index 49ea3105f..4f76257fc 100644 --- a/src/test/ui/alloc-error/alloc-error-handler-bad-signature-2.rs +++ b/src/test/ui/alloc-error/alloc-error-handler-bad-signature-2.rs @@ -8,8 +8,8 @@ struct Layout; #[alloc_error_handler] fn oom( - info: Layout, //~ ERROR argument should be `Layout` -) { //~ ERROR return type should be `!` + info: Layout, //~^ ERROR mismatched types +) { //~^^ ERROR mismatched types loop {} } diff --git a/src/test/ui/alloc-error/alloc-error-handler-bad-signature-2.stderr b/src/test/ui/alloc-error/alloc-error-handler-bad-signature-2.stderr index 85544b0c3..adb652fe6 100644 --- a/src/test/ui/alloc-error/alloc-error-handler-bad-signature-2.stderr +++ b/src/test/ui/alloc-error/alloc-error-handler-bad-signature-2.stderr @@ -1,14 +1,59 @@ -error: return type should be `!` - --> $DIR/alloc-error-handler-bad-signature-2.rs:12:3 +error[E0308]: mismatched types + --> $DIR/alloc-error-handler-bad-signature-2.rs:10:1 | -LL | ) { - | ^ - -error: argument should be `Layout` - --> $DIR/alloc-error-handler-bad-signature-2.rs:11:11 +LL | #[alloc_error_handler] + | ---------------------- in this procedural macro expansion +LL | fn oom( + | __^ + | | _| + | || +LL | || info: Layout, +LL | || ) { + | ||_- arguments to this function are incorrect +LL | | loop {} +LL | | } + | |__^ expected struct `Layout`, found struct `core::alloc::Layout` + | + = note: struct `core::alloc::Layout` and struct `Layout` have similar names, but are actually distinct types +note: struct `core::alloc::Layout` is defined in crate `core` + --> $SRC_DIR/core/src/alloc/layout.rs:LL:COL + | +LL | pub struct Layout { + | ^^^^^^^^^^^^^^^^^ +note: struct `Layout` is defined in the current crate + --> $DIR/alloc-error-handler-bad-signature-2.rs:7:1 + | +LL | struct Layout; + | ^^^^^^^^^^^^^ +note: function defined here + --> $DIR/alloc-error-handler-bad-signature-2.rs:10:4 | +LL | fn oom( + | ^^^ LL | info: Layout, - | ^^^^^^ + | ------------ + = note: this error originates in the attribute macro `alloc_error_handler` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0308]: mismatched types + --> $DIR/alloc-error-handler-bad-signature-2.rs:10:1 + | +LL | #[alloc_error_handler] + | ---------------------- in this procedural macro expansion +LL | fn oom( + | __^ + | | _| + | || +LL | || info: Layout, +LL | || ) { + | ||_^ expected `!`, found `()` +LL | | loop {} +LL | | } + | |__- expected `!` because of return type + | + = note: expected type `!` + found unit type `()` + = note: this error originates in the attribute macro `alloc_error_handler` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/alloc-error/alloc-error-handler-bad-signature-3.rs b/src/test/ui/alloc-error/alloc-error-handler-bad-signature-3.rs index 321fd954d..8430fabe8 100644 --- a/src/test/ui/alloc-error/alloc-error-handler-bad-signature-3.rs +++ b/src/test/ui/alloc-error/alloc-error-handler-bad-signature-3.rs @@ -7,7 +7,7 @@ struct Layout; #[alloc_error_handler] -fn oom() -> ! { //~ ERROR function should have one argument +fn oom() -> ! { //~ ERROR this function takes 0 arguments but 1 argument was supplied loop {} } diff --git a/src/test/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr b/src/test/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr index 8575e7508..77ea8ef05 100644 --- a/src/test/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr +++ b/src/test/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr @@ -1,8 +1,25 @@ -error: function should have one argument +error[E0061]: this function takes 0 arguments but 1 argument was supplied --> $DIR/alloc-error-handler-bad-signature-3.rs:10:1 | +LL | #[alloc_error_handler] + | ---------------------- in this procedural macro expansion +LL | fn oom() -> ! { + | _-^^^^^^^^^^^^ +LL | | loop {} +LL | | } + | |_- argument of type `core::alloc::Layout` unexpected + | +note: function defined here + --> $DIR/alloc-error-handler-bad-signature-3.rs:10:4 + | LL | fn oom() -> ! { - | ^^^^^^^^^^^^^ + | ^^^ + = note: this error originates in the attribute macro `alloc_error_handler` (in Nightly builds, run with -Z macro-backtrace for more info) +help: remove the extra argument + | +LL | fn oom() -> !() { + | ++ error: aborting due to previous error +For more information about this error, try `rustc --explain E0061`. diff --git a/src/test/ui/argument-suggestions/formal-and-expected-differ.rs b/src/test/ui/argument-suggestions/formal-and-expected-differ.rs new file mode 100644 index 000000000..5e3b55ca5 --- /dev/null +++ b/src/test/ui/argument-suggestions/formal-and-expected-differ.rs @@ -0,0 +1,25 @@ +pub trait Foo { + type T; +} + +impl Foo for i32 { + type T = f32; +} + +pub struct U<T1, T2>(T1, S<T2>) +where + T1: Foo<T = T2>; + +pub struct S<T>(T); + +fn main() { + // The error message here isn't great -- it has to do with the fact that the + // `expected_inputs_for_expected_output` deduced inputs differs from the inputs + // that we infer from the constraints of the signature. + // + // I am not really sure what the best way of presenting this error message is, + // since right now it just suggests changing `3u32` <=> `3f32` back and forth. + let _: U<_, u32> = U(1, S(3u32)); + //~^ ERROR mismatched types + //~| ERROR mismatched types +} diff --git a/src/test/ui/argument-suggestions/formal-and-expected-differ.stderr b/src/test/ui/argument-suggestions/formal-and-expected-differ.stderr new file mode 100644 index 000000000..905875b52 --- /dev/null +++ b/src/test/ui/argument-suggestions/formal-and-expected-differ.stderr @@ -0,0 +1,30 @@ +error[E0308]: mismatched types + --> $DIR/formal-and-expected-differ.rs:22:29 + | +LL | let _: U<_, u32> = U(1, S(3u32)); + | - ^^^^^^^ expected `f32`, found `u32` + | | + | arguments to this struct are incorrect + | + = note: expected struct `S<f32>` + found struct `S<u32>` +note: tuple struct defined here + --> $DIR/formal-and-expected-differ.rs:9:12 + | +LL | pub struct U<T1, T2>(T1, S<T2>) + | ^ + +error[E0308]: mismatched types + --> $DIR/formal-and-expected-differ.rs:22:24 + | +LL | let _: U<_, u32> = U(1, S(3u32)); + | --------- ^^^^^^^^^^^^^ expected `u32`, found `f32` + | | + | expected due to this + | + = note: expected struct `U<_, u32>` + found struct `U<i32, f32>` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/array-slice-vec/array-break-length.stderr b/src/test/ui/array-slice-vec/array-break-length.stderr index 93f1c238b..2df7b6d7f 100644 --- a/src/test/ui/array-slice-vec/array-break-length.stderr +++ b/src/test/ui/array-slice-vec/array-break-length.stderr @@ -1,8 +1,8 @@ -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/array-break-length.rs:3:17 | LL | |_: [_; break]| {} - | ^^^^^ cannot `break` outside of a loop + | ^^^^^ cannot `break` outside of a loop or labeled block error[E0268]: `continue` outside of a loop --> $DIR/array-break-length.rs:7:17 diff --git a/src/test/ui/array-slice-vec/slice_is_sorted_by_borrow.rs b/src/test/ui/array-slice-vec/slice_is_sorted_by_borrow.rs new file mode 100644 index 000000000..073280d0f --- /dev/null +++ b/src/test/ui/array-slice-vec/slice_is_sorted_by_borrow.rs @@ -0,0 +1,20 @@ +// check-pass +// regression test for https://github.com/rust-lang/rust/issues/53485#issuecomment-885393452 + +#![feature(is_sorted)] + +struct A { + name: String, +} + +fn main() { + let a = &[ + A { + name: "1".to_string(), + }, + A { + name: "2".to_string(), + }, + ]; + assert!(a.is_sorted_by_key(|a| a.name.as_str())); +} diff --git a/src/test/ui/array-slice-vec/vec-macro-with-comma-only.stderr b/src/test/ui/array-slice-vec/vec-macro-with-comma-only.stderr index abbee347c..ec4a001f4 100644 --- a/src/test/ui/array-slice-vec/vec-macro-with-comma-only.stderr +++ b/src/test/ui/array-slice-vec/vec-macro-with-comma-only.stderr @@ -3,6 +3,8 @@ error: no rules expected the token `,` | LL | vec![,]; | ^ no rules expected this token in macro call + | + = note: while trying to match end of macro error: aborting due to previous error diff --git a/src/test/ui/asm/aarch64/llvm-58384.rs b/src/test/ui/asm/aarch64/llvm-58384.rs new file mode 100644 index 000000000..308f78908 --- /dev/null +++ b/src/test/ui/asm/aarch64/llvm-58384.rs @@ -0,0 +1,16 @@ +// only-aarch64 +// run-pass +// needs-asm-support + +// Test that we properly work around this LLVM issue: +// https://github.com/llvm/llvm-project/issues/58384 + +use std::arch::asm; + +fn main() { + let a: i32; + unsafe { + asm!("", inout("x0") 435 => a); + } + assert_eq!(a, 435); +} diff --git a/src/test/ui/asm/issue-92378.rs b/src/test/ui/asm/issue-92378.rs index 6e3c26e98..809b0d155 100644 --- a/src/test/ui/asm/issue-92378.rs +++ b/src/test/ui/asm/issue-92378.rs @@ -3,7 +3,7 @@ // needs-asm-support // build-pass -#![feature(no_core, lang_items, rustc_attrs, isa_attribute)] +#![feature(no_core, lang_items, rustc_attrs)] #![no_core] #![crate_type = "rlib"] diff --git a/src/test/ui/asm/naked-invalid-attr.stderr b/src/test/ui/asm/naked-invalid-attr.stderr index 58344be93..e8ddccc85 100644 --- a/src/test/ui/asm/naked-invalid-attr.stderr +++ b/src/test/ui/asm/naked-invalid-attr.stderr @@ -36,7 +36,7 @@ error: attribute should be applied to a function definition --> $DIR/naked-invalid-attr.rs:5:1 | LL | #![naked] - | ^^^^^^^^^ + | ^^^^^^^^^ cannot be applied to crates error: aborting due to 5 previous errors diff --git a/src/test/ui/assoc-inherent.rs b/src/test/ui/assoc-inherent.rs deleted file mode 100644 index c579c962f..000000000 --- a/src/test/ui/assoc-inherent.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Test that inherent associated types work with -// inherent_associated_types feature gate. - -#![feature(inherent_associated_types)] -#![allow(incomplete_features)] - -struct Foo; - -impl Foo { - type Bar = isize; -} - -impl Foo { - type Baz; //~ ERROR associated type in `impl` without body -} - -fn main() { - let x : Foo::Bar; //~ERROR ambiguous associated type - x = 0isize; -} diff --git a/src/test/ui/assoc-inherent.stderr b/src/test/ui/assoc-inherent.stderr deleted file mode 100644 index b703453fa..000000000 --- a/src/test/ui/assoc-inherent.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error: associated type in `impl` without body - --> $DIR/assoc-inherent.rs:14:5 - | -LL | type Baz; - | ^^^^^^^^- - | | - | help: provide a definition for the type: `= <type>;` - -error[E0223]: ambiguous associated type - --> $DIR/assoc-inherent.rs:18:13 - | -LL | let x : Foo::Bar; - | ^^^^^^^^ help: use fully-qualified syntax: `<Foo as Trait>::Bar` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0223`. diff --git a/src/test/ui/associated-consts/defaults-cyclic-fail.stderr b/src/test/ui/associated-consts/defaults-cyclic-fail.stderr index c4cd9c2a4..a1483911b 100644 --- a/src/test/ui/associated-consts/defaults-cyclic-fail.stderr +++ b/src/test/ui/associated-consts/defaults-cyclic-fail.stderr @@ -1,14 +1,14 @@ error[E0391]: cycle detected when const-evaluating + checking `Tr::A` - --> $DIR/defaults-cyclic-fail.rs:5:5 + --> $DIR/defaults-cyclic-fail.rs:5:19 | LL | const A: u8 = Self::B; - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^ | note: ...which requires const-evaluating + checking `Tr::B`... - --> $DIR/defaults-cyclic-fail.rs:8:5 + --> $DIR/defaults-cyclic-fail.rs:8:19 | LL | const B: u8 = Self::A; - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^ = note: ...which again requires const-evaluating + checking `Tr::A`, completing the cycle note: cycle used when const-evaluating + checking `main::promoted[1]` --> $DIR/defaults-cyclic-fail.rs:16:16 diff --git a/src/test/ui/associated-consts/defaults-not-assumed-fail.rs b/src/test/ui/associated-consts/defaults-not-assumed-fail.rs index 6762d7583..495dfb338 100644 --- a/src/test/ui/associated-consts/defaults-not-assumed-fail.rs +++ b/src/test/ui/associated-consts/defaults-not-assumed-fail.rs @@ -31,8 +31,7 @@ impl Tr for u32 { fn main() { assert_eq!(<() as Tr>::A, 255); assert_eq!(<() as Tr>::B, 0); // causes the error above - //~^ ERROR evaluation of constant value failed - //~| ERROR erroneous constant used + //~^ constant assert_eq!(<u8 as Tr>::A, 254); assert_eq!(<u8 as Tr>::B, 255); diff --git a/src/test/ui/associated-consts/defaults-not-assumed-fail.stderr b/src/test/ui/associated-consts/defaults-not-assumed-fail.stderr index aa130f438..fb7159e40 100644 --- a/src/test/ui/associated-consts/defaults-not-assumed-fail.stderr +++ b/src/test/ui/associated-consts/defaults-not-assumed-fail.stderr @@ -4,20 +4,36 @@ error[E0080]: evaluation of `<() as Tr>::B` failed LL | const B: u8 = Self::A + 1; | ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/defaults-not-assumed-fail.rs:33:16 | LL | assert_eq!(<() as Tr>::B, 0); // causes the error above - | ^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^ -error[E0080]: erroneous constant used +note: erroneous constant used --> $DIR/defaults-not-assumed-fail.rs:33:5 | LL | assert_eq!(<() as Tr>::B, 0); // causes the error above - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 3 previous errors +note: erroneous constant used + --> $DIR/defaults-not-assumed-fail.rs:33:5 + | +LL | assert_eq!(<() as Tr>::B, 0); // causes the error above + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) + +note: erroneous constant used + --> $DIR/defaults-not-assumed-fail.rs:33:5 + | +LL | assert_eq!(<() as Tr>::B, 0); // causes the error above + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr index c8c57bccb..be5781761 100644 --- a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr +++ b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr @@ -10,10 +10,10 @@ note: ...which requires const-evaluating + checking `IMPL_REF_BAR`... LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR; | ^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires const-evaluating + checking `IMPL_REF_BAR`... - --> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:1 + --> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:27 | LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 11:19>::BAR`... --> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:12:5 | diff --git a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr index 76ed8d4a6..8347b260b 100644 --- a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr +++ b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr @@ -10,10 +10,10 @@ note: ...which requires const-evaluating + checking `DEFAULT_REF_BAR`... LL | const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires const-evaluating + checking `DEFAULT_REF_BAR`... - --> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:11:1 + --> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:11:30 | LL | const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires const-evaluating + checking `FooDefault::BAR`... --> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:8:5 | diff --git a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr index 6a98f08f3..3955a3120 100644 --- a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr +++ b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr @@ -10,10 +10,10 @@ note: ...which requires const-evaluating + checking `TRAIT_REF_BAR`... LL | const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR; | ^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires const-evaluating + checking `TRAIT_REF_BAR`... - --> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:1 + --> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:28 | LL | const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^ note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 11:28>::BAR`... --> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:12:5 | diff --git a/src/test/ui/associated-consts/issue-47814.rs b/src/test/ui/associated-consts/issue-47814.rs new file mode 100644 index 000000000..a28b1c001 --- /dev/null +++ b/src/test/ui/associated-consts/issue-47814.rs @@ -0,0 +1,14 @@ +struct ArpIPv4<'a> { + s: &'a u8 +} + +impl<'a> ArpIPv4<'a> { + const LENGTH: usize = 20; + + pub fn to_buffer() -> [u8; Self::LENGTH] { + //~^ ERROR: generic `Self` types are currently not permitted in anonymous constants + unimplemented!() + } +} + +fn main() {} diff --git a/src/test/ui/associated-consts/issue-47814.stderr b/src/test/ui/associated-consts/issue-47814.stderr new file mode 100644 index 000000000..2e4ddb811 --- /dev/null +++ b/src/test/ui/associated-consts/issue-47814.stderr @@ -0,0 +1,14 @@ +error: generic `Self` types are currently not permitted in anonymous constants + --> $DIR/issue-47814.rs:8:32 + | +LL | pub fn to_buffer() -> [u8; Self::LENGTH] { + | ^^^^ + | +note: not a concrete type + --> $DIR/issue-47814.rs:5:10 + | +LL | impl<'a> ArpIPv4<'a> { + | ^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/issues/issue-58022.rs b/src/test/ui/associated-consts/issue-58022.rs index 2a8a1eaa6..2a8a1eaa6 100644 --- a/src/test/ui/issues/issue-58022.rs +++ b/src/test/ui/associated-consts/issue-58022.rs diff --git a/src/test/ui/issues/issue-58022.stderr b/src/test/ui/associated-consts/issue-58022.stderr index 56d85c066..56d85c066 100644 --- a/src/test/ui/issues/issue-58022.stderr +++ b/src/test/ui/associated-consts/issue-58022.stderr diff --git a/src/test/ui/associated-consts/issue-93835.rs b/src/test/ui/associated-consts/issue-93835.rs index 5c7b06598..b2a437fcb 100644 --- a/src/test/ui/associated-consts/issue-93835.rs +++ b/src/test/ui/associated-consts/issue-93835.rs @@ -1,9 +1,11 @@ +#![feature(type_ascription)] + fn e() { - p:a<p:p<e=6>> - //~^ ERROR comparison operators + type_ascribe!(p, a<p:p<e=6>>); + //~^ ERROR cannot find type `a` in this scope //~| ERROR cannot find value //~| ERROR associated const equality - //~| ERROR associated const equality + //~| ERROR cannot find trait `p` in this scope //~| ERROR associated type bounds } diff --git a/src/test/ui/associated-consts/issue-93835.stderr b/src/test/ui/associated-consts/issue-93835.stderr index 0406a16a3..be0573a13 100644 --- a/src/test/ui/associated-consts/issue-93835.stderr +++ b/src/test/ui/associated-consts/issue-93835.stderr @@ -1,65 +1,40 @@ -error: comparison operators cannot be chained - --> $DIR/issue-93835.rs:2:8 - | -LL | fn e() { - | - while parsing this struct -LL | p:a<p:p<e=6>> - | ^ ^ - | - = help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments - = help: or use `(...)` if you meant to specify fn arguments - error[E0425]: cannot find value `p` in this scope - --> $DIR/issue-93835.rs:2:5 - | -LL | p:a<p:p<e=6>> - | ^ not found in this scope - | -help: you might have meant to write a `struct` literal - | -LL ~ fn e() { SomeStruct { -LL | p:a<p:p<e=6>> - ... -LL | -LL ~ }} + --> $DIR/issue-93835.rs:4:19 | -help: maybe you meant to write a path separator here - | -LL | p::a<p:p<e=6>> - | ~~ -help: maybe you meant to write an assignment here - | -LL | let p:a<p:p<e=6>> - | ~~~~~ +LL | type_ascribe!(p, a<p:p<e=6>>); + | ^ not found in this scope -error[E0658]: associated const equality is incomplete - --> $DIR/issue-93835.rs:2:13 +error[E0412]: cannot find type `a` in this scope + --> $DIR/issue-93835.rs:4:22 | -LL | p:a<p:p<e=6>> - | ^^^ +LL | type_ascribe!(p, a<p:p<e=6>>); + | ^ not found in this scope + +error[E0405]: cannot find trait `p` in this scope + --> $DIR/issue-93835.rs:4:26 | - = note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information - = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable +LL | type_ascribe!(p, a<p:p<e=6>>); + | ^ not found in this scope error[E0658]: associated const equality is incomplete - --> $DIR/issue-93835.rs:2:13 + --> $DIR/issue-93835.rs:4:28 | -LL | p:a<p:p<e=6>> - | ^^^ +LL | type_ascribe!(p, a<p:p<e=6>>); + | ^^^ | = note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/issue-93835.rs:2:9 + --> $DIR/issue-93835.rs:4:24 | -LL | p:a<p:p<e=6>> - | ^^^^^^^^ +LL | type_ascribe!(p, a<p:p<e=6>>); + | ^^^^^^^^ | = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error: aborting due to 5 previous errors -Some errors have detailed explanations: E0425, E0658. -For more information about an error, try `rustc --explain E0425`. +Some errors have detailed explanations: E0405, E0412, E0425, E0658. +For more information about an error, try `rustc --explain E0405`. diff --git a/src/test/ui/associated-inherent-types/assoc-inherent-no-body.rs b/src/test/ui/associated-inherent-types/assoc-inherent-no-body.rs new file mode 100644 index 000000000..71f65b92e --- /dev/null +++ b/src/test/ui/associated-inherent-types/assoc-inherent-no-body.rs @@ -0,0 +1,10 @@ +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct Foo; + +impl Foo { + type Baz; //~ ERROR associated type in `impl` without body +} + +fn main() {} diff --git a/src/test/ui/associated-inherent-types/assoc-inherent-no-body.stderr b/src/test/ui/associated-inherent-types/assoc-inherent-no-body.stderr new file mode 100644 index 000000000..387a5658d --- /dev/null +++ b/src/test/ui/associated-inherent-types/assoc-inherent-no-body.stderr @@ -0,0 +1,10 @@ +error: associated type in `impl` without body + --> $DIR/assoc-inherent-no-body.rs:7:5 + | +LL | type Baz; + | ^^^^^^^^- + | | + | help: provide a definition for the type: `= <type>;` + +error: aborting due to previous error + diff --git a/src/test/ui/associated-inherent-types/assoc-inherent-private.rs b/src/test/ui/associated-inherent-types/assoc-inherent-private.rs new file mode 100644 index 000000000..531581954 --- /dev/null +++ b/src/test/ui/associated-inherent-types/assoc-inherent-private.rs @@ -0,0 +1,23 @@ +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +mod m { + pub struct T; + impl T { + type P = (); + } +} +type U = m::T::P; //~ ERROR associated type `P` is private + +mod n { + pub mod n { + pub struct T; + impl T { + pub(super) type P = bool; + } + } + type U = n::T::P; +} +type V = n::n::T::P; //~ ERROR associated type `P` is private + +fn main() {} diff --git a/src/test/ui/associated-inherent-types/assoc-inherent-private.stderr b/src/test/ui/associated-inherent-types/assoc-inherent-private.stderr new file mode 100644 index 000000000..d67b45dae --- /dev/null +++ b/src/test/ui/associated-inherent-types/assoc-inherent-private.stderr @@ -0,0 +1,21 @@ +error[E0624]: associated type `P` is private + --> $DIR/assoc-inherent-private.rs:10:10 + | +LL | type P = (); + | ------ associated type defined here +... +LL | type U = m::T::P; + | ^^^^^^^ private associated type + +error[E0624]: associated type `P` is private + --> $DIR/assoc-inherent-private.rs:21:10 + | +LL | pub(super) type P = bool; + | ----------------- associated type defined here +... +LL | type V = n::n::T::P; + | ^^^^^^^^^^ private associated type + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0624`. diff --git a/src/test/ui/associated-inherent-types/assoc-inherent-unstable.rs b/src/test/ui/associated-inherent-types/assoc-inherent-unstable.rs new file mode 100644 index 000000000..34b4e47bf --- /dev/null +++ b/src/test/ui/associated-inherent-types/assoc-inherent-unstable.rs @@ -0,0 +1,6 @@ +// aux-crate:aux=assoc-inherent-unstable.rs +// edition: 2021 + +type Data = aux::Owner::Data; //~ ERROR use of unstable library feature 'data' + +fn main() {} diff --git a/src/test/ui/associated-inherent-types/assoc-inherent-unstable.stderr b/src/test/ui/associated-inherent-types/assoc-inherent-unstable.stderr new file mode 100644 index 000000000..c0be8bfd7 --- /dev/null +++ b/src/test/ui/associated-inherent-types/assoc-inherent-unstable.stderr @@ -0,0 +1,11 @@ +error[E0658]: use of unstable library feature 'data' + --> $DIR/assoc-inherent-unstable.rs:4:13 + | +LL | type Data = aux::Owner::Data; + | ^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(data)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/associated-inherent-types/assoc-inherent-use.rs b/src/test/ui/associated-inherent-types/assoc-inherent-use.rs new file mode 100644 index 000000000..7ae425e2a --- /dev/null +++ b/src/test/ui/associated-inherent-types/assoc-inherent-use.rs @@ -0,0 +1,14 @@ +// check-pass +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct Foo; + +impl Foo { + type Bar = isize; +} + +fn main() { + let x: Foo::Bar; + x = 0isize; +} diff --git a/src/test/ui/associated-inherent-types/auxiliary/assoc-inherent-unstable.rs b/src/test/ui/associated-inherent-types/auxiliary/assoc-inherent-unstable.rs new file mode 100644 index 000000000..6b71ffc97 --- /dev/null +++ b/src/test/ui/associated-inherent-types/auxiliary/assoc-inherent-unstable.rs @@ -0,0 +1,11 @@ +#![feature(staged_api)] +#![feature(inherent_associated_types)] +#![stable(feature = "main", since = "1.0.0")] + +#[stable(feature = "main", since = "1.0.0")] +pub struct Owner; + +impl Owner { + #[unstable(feature = "data", issue = "none")] + pub type Data = (); +} diff --git a/src/test/ui/associated-inherent-types/issue-104260.rs b/src/test/ui/associated-inherent-types/issue-104260.rs new file mode 100644 index 000000000..a73cd1775 --- /dev/null +++ b/src/test/ui/associated-inherent-types/issue-104260.rs @@ -0,0 +1,14 @@ +// check-pass + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct Foo; + +impl Foo { + type Bar<T> = u8; +} + +fn main() { + let a: Foo::Bar<()>; +} diff --git a/src/test/ui/associated-inherent-types/normalize-projection-0.rs b/src/test/ui/associated-inherent-types/normalize-projection-0.rs new file mode 100644 index 000000000..50763ecdd --- /dev/null +++ b/src/test/ui/associated-inherent-types/normalize-projection-0.rs @@ -0,0 +1,22 @@ +// check-pass + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct S<T>(T); + +impl<T: O> S<T> { + type P = <T as O>::P; +} + +trait O { + type P; +} + +impl O for i32 { + type P = String; +} + +fn main() { + let _: S<i32>::P = String::new(); +} diff --git a/src/test/ui/associated-inherent-types/normalize-projection-1.rs b/src/test/ui/associated-inherent-types/normalize-projection-1.rs new file mode 100644 index 000000000..2f7b2551a --- /dev/null +++ b/src/test/ui/associated-inherent-types/normalize-projection-1.rs @@ -0,0 +1,22 @@ +// check-pass + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct S; + +impl S { + type P<T: O> = <T as O>::P; +} + +trait O { + type P; +} + +impl O for i32 { + type P = String; +} + +fn main() { + let _: S::P<i32> = String::new(); +} diff --git a/src/test/ui/associated-inherent-types/struct-generics.rs b/src/test/ui/associated-inherent-types/struct-generics.rs new file mode 100644 index 000000000..8952b3791 --- /dev/null +++ b/src/test/ui/associated-inherent-types/struct-generics.rs @@ -0,0 +1,15 @@ +// check-pass + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct S<T>(T); + +impl<T> S<T> { + type P = T; +} + +fn main() { + type A = S<()>::P; + let _: A = (); +} diff --git a/src/test/ui/associated-type-bounds/duplicate.rs b/src/test/ui/associated-type-bounds/duplicate.rs index 6e464f695..f67410986 100644 --- a/src/test/ui/associated-type-bounds/duplicate.rs +++ b/src/test/ui/associated-type-bounds/duplicate.rs @@ -132,12 +132,15 @@ where } fn FRPIT1() -> impl Iterator<Item: Copy, Item: Send> { + //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] iter::empty() } fn FRPIT2() -> impl Iterator<Item: Copy, Item: Copy> { + //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] iter::empty() } fn FRPIT3() -> impl Iterator<Item: 'static, Item: 'static> { + //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] iter::empty() } fn FAPIT1(_: impl Iterator<Item: Copy, Item: Send>) {} diff --git a/src/test/ui/associated-type-bounds/duplicate.stderr b/src/test/ui/associated-type-bounds/duplicate.stderr index e4f4836f7..c3061327f 100644 --- a/src/test/ui/associated-type-bounds/duplicate.stderr +++ b/src/test/ui/associated-type-bounds/duplicate.stderr @@ -191,7 +191,31 @@ LL | T: Iterator<Item: 'static, Item: 'static>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:143:40 + --> $DIR/duplicate.rs:134:42 + | +LL | fn FRPIT1() -> impl Iterator<Item: Copy, Item: Send> { + | ---------- ^^^^^^^^^^ re-bound here + | | + | `Item` bound here first + +error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified + --> $DIR/duplicate.rs:138:42 + | +LL | fn FRPIT2() -> impl Iterator<Item: Copy, Item: Copy> { + | ---------- ^^^^^^^^^^ re-bound here + | | + | `Item` bound here first + +error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified + --> $DIR/duplicate.rs:142:45 + | +LL | fn FRPIT3() -> impl Iterator<Item: 'static, Item: 'static> { + | ------------- ^^^^^^^^^^^^^ re-bound here + | | + | `Item` bound here first + +error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified + --> $DIR/duplicate.rs:146:40 | LL | fn FAPIT1(_: impl Iterator<Item: Copy, Item: Send>) {} | ---------- ^^^^^^^^^^ re-bound here @@ -199,7 +223,7 @@ LL | fn FAPIT1(_: impl Iterator<Item: Copy, Item: Send>) {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:145:40 + --> $DIR/duplicate.rs:148:40 | LL | fn FAPIT2(_: impl Iterator<Item: Copy, Item: Copy>) {} | ---------- ^^^^^^^^^^ re-bound here @@ -207,7 +231,7 @@ LL | fn FAPIT2(_: impl Iterator<Item: Copy, Item: Copy>) {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:147:43 + --> $DIR/duplicate.rs:150:43 | LL | fn FAPIT3(_: impl Iterator<Item: 'static, Item: 'static>) {} | ------------- ^^^^^^^^^^^^^ re-bound here @@ -215,7 +239,7 @@ LL | fn FAPIT3(_: impl Iterator<Item: 'static, Item: 'static>) {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:150:35 + --> $DIR/duplicate.rs:153:35 | LL | type TAI1<T: Iterator<Item: Copy, Item: Send>> = T; | ---------- ^^^^^^^^^^ re-bound here @@ -223,7 +247,7 @@ LL | type TAI1<T: Iterator<Item: Copy, Item: Send>> = T; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:152:35 + --> $DIR/duplicate.rs:155:35 | LL | type TAI2<T: Iterator<Item: Copy, Item: Copy>> = T; | ---------- ^^^^^^^^^^ re-bound here @@ -231,7 +255,7 @@ LL | type TAI2<T: Iterator<Item: Copy, Item: Copy>> = T; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:154:38 + --> $DIR/duplicate.rs:157:38 | LL | type TAI3<T: Iterator<Item: 'static, Item: 'static>> = T; | ------------- ^^^^^^^^^^^^^ re-bound here @@ -239,7 +263,7 @@ LL | type TAI3<T: Iterator<Item: 'static, Item: 'static>> = T; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:158:29 + --> $DIR/duplicate.rs:161:29 | LL | T: Iterator<Item: Copy, Item: Send>, | ---------- ^^^^^^^^^^ re-bound here @@ -247,7 +271,7 @@ LL | T: Iterator<Item: Copy, Item: Send>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:163:29 + --> $DIR/duplicate.rs:166:29 | LL | T: Iterator<Item: Copy, Item: Copy>, | ---------- ^^^^^^^^^^ re-bound here @@ -255,7 +279,7 @@ LL | T: Iterator<Item: Copy, Item: Copy>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:168:32 + --> $DIR/duplicate.rs:171:32 | LL | T: Iterator<Item: 'static, Item: 'static>, | ------------- ^^^^^^^^^^^^^ re-bound here @@ -263,7 +287,7 @@ LL | T: Iterator<Item: 'static, Item: 'static>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:172:36 + --> $DIR/duplicate.rs:175:36 | LL | type ETAI1<T: Iterator<Item: Copy, Item: Send>> = impl Copy; | ---------- ^^^^^^^^^^ re-bound here @@ -271,7 +295,7 @@ LL | type ETAI1<T: Iterator<Item: Copy, Item: Send>> = impl Copy; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:174:36 + --> $DIR/duplicate.rs:177:36 | LL | type ETAI2<T: Iterator<Item: Copy, Item: Copy>> = impl Copy; | ---------- ^^^^^^^^^^ re-bound here @@ -279,7 +303,7 @@ LL | type ETAI2<T: Iterator<Item: Copy, Item: Copy>> = impl Copy; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:176:39 + --> $DIR/duplicate.rs:179:39 | LL | type ETAI3<T: Iterator<Item: 'static, Item: 'static>> = impl Copy; | ------------- ^^^^^^^^^^^^^ re-bound here @@ -287,7 +311,7 @@ LL | type ETAI3<T: Iterator<Item: 'static, Item: 'static>> = impl Copy; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:178:40 + --> $DIR/duplicate.rs:181:40 | LL | type ETAI4 = impl Iterator<Item: Copy, Item: Send>; | ---------- ^^^^^^^^^^ re-bound here @@ -295,7 +319,7 @@ LL | type ETAI4 = impl Iterator<Item: Copy, Item: Send>; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:180:40 + --> $DIR/duplicate.rs:183:40 | LL | type ETAI5 = impl Iterator<Item: Copy, Item: Copy>; | ---------- ^^^^^^^^^^ re-bound here @@ -303,7 +327,7 @@ LL | type ETAI5 = impl Iterator<Item: Copy, Item: Copy>; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:182:43 + --> $DIR/duplicate.rs:185:43 | LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>; | ------------- ^^^^^^^^^^^^^ re-bound here @@ -311,7 +335,7 @@ LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:185:36 + --> $DIR/duplicate.rs:188:36 | LL | trait TRI1<T: Iterator<Item: Copy, Item: Send>> {} | ---------- ^^^^^^^^^^ re-bound here @@ -319,7 +343,7 @@ LL | trait TRI1<T: Iterator<Item: Copy, Item: Send>> {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:187:36 + --> $DIR/duplicate.rs:190:36 | LL | trait TRI2<T: Iterator<Item: Copy, Item: Copy>> {} | ---------- ^^^^^^^^^^ re-bound here @@ -327,7 +351,7 @@ LL | trait TRI2<T: Iterator<Item: Copy, Item: Copy>> {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:189:39 + --> $DIR/duplicate.rs:192:39 | LL | trait TRI3<T: Iterator<Item: 'static, Item: 'static>> {} | ------------- ^^^^^^^^^^^^^ re-bound here @@ -335,7 +359,7 @@ LL | trait TRI3<T: Iterator<Item: 'static, Item: 'static>> {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:191:34 + --> $DIR/duplicate.rs:194:34 | LL | trait TRS1: Iterator<Item: Copy, Item: Send> {} | ---------- ^^^^^^^^^^ re-bound here @@ -343,7 +367,7 @@ LL | trait TRS1: Iterator<Item: Copy, Item: Send> {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:193:34 + --> $DIR/duplicate.rs:196:34 | LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {} | ---------- ^^^^^^^^^^ re-bound here @@ -351,7 +375,7 @@ LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:195:37 + --> $DIR/duplicate.rs:198:37 | LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {} | ------------- ^^^^^^^^^^^^^ re-bound here @@ -359,7 +383,7 @@ LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:199:29 + --> $DIR/duplicate.rs:202:29 | LL | T: Iterator<Item: Copy, Item: Send>, | ---------- ^^^^^^^^^^ re-bound here @@ -367,7 +391,7 @@ LL | T: Iterator<Item: Copy, Item: Send>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:205:29 + --> $DIR/duplicate.rs:208:29 | LL | T: Iterator<Item: Copy, Item: Copy>, | ---------- ^^^^^^^^^^ re-bound here @@ -375,7 +399,7 @@ LL | T: Iterator<Item: Copy, Item: Copy>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:211:32 + --> $DIR/duplicate.rs:214:32 | LL | T: Iterator<Item: 'static, Item: 'static>, | ------------- ^^^^^^^^^^^^^ re-bound here @@ -383,7 +407,7 @@ LL | T: Iterator<Item: 'static, Item: 'static>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:217:32 + --> $DIR/duplicate.rs:220:32 | LL | Self: Iterator<Item: Copy, Item: Send>, | ---------- ^^^^^^^^^^ re-bound here @@ -391,7 +415,7 @@ LL | Self: Iterator<Item: Copy, Item: Send>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:217:32 + --> $DIR/duplicate.rs:220:32 | LL | Self: Iterator<Item: Copy, Item: Send>, | ---------- ^^^^^^^^^^ re-bound here @@ -399,7 +423,7 @@ LL | Self: Iterator<Item: Copy, Item: Send>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:224:32 + --> $DIR/duplicate.rs:227:32 | LL | Self: Iterator<Item: Copy, Item: Copy>, | ---------- ^^^^^^^^^^ re-bound here @@ -407,7 +431,7 @@ LL | Self: Iterator<Item: Copy, Item: Copy>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:224:32 + --> $DIR/duplicate.rs:227:32 | LL | Self: Iterator<Item: Copy, Item: Copy>, | ---------- ^^^^^^^^^^ re-bound here @@ -415,7 +439,7 @@ LL | Self: Iterator<Item: Copy, Item: Copy>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:231:35 + --> $DIR/duplicate.rs:234:35 | LL | Self: Iterator<Item: 'static, Item: 'static>, | ------------- ^^^^^^^^^^^^^ re-bound here @@ -423,7 +447,7 @@ LL | Self: Iterator<Item: 'static, Item: 'static>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:231:35 + --> $DIR/duplicate.rs:234:35 | LL | Self: Iterator<Item: 'static, Item: 'static>, | ------------- ^^^^^^^^^^^^^ re-bound here @@ -431,7 +455,7 @@ LL | Self: Iterator<Item: 'static, Item: 'static>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:249:40 + --> $DIR/duplicate.rs:252:40 | LL | type TADyn1 = dyn Iterator<Item: Copy, Item: Send>; | ---------- ^^^^^^^^^^ re-bound here @@ -439,7 +463,7 @@ LL | type TADyn1 = dyn Iterator<Item: Copy, Item: Send>; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:251:44 + --> $DIR/duplicate.rs:254:44 | LL | type TADyn2 = Box<dyn Iterator<Item: Copy, Item: Copy>>; | ---------- ^^^^^^^^^^ re-bound here @@ -447,7 +471,7 @@ LL | type TADyn2 = Box<dyn Iterator<Item: Copy, Item: Copy>>; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:253:43 + --> $DIR/duplicate.rs:256:43 | LL | type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>; | ------------- ^^^^^^^^^^^^^ re-bound here @@ -455,7 +479,7 @@ LL | type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:237:34 + --> $DIR/duplicate.rs:240:34 | LL | type A: Iterator<Item: Copy, Item: Send>; | ---------- ^^^^^^^^^^ re-bound here @@ -463,7 +487,7 @@ LL | type A: Iterator<Item: Copy, Item: Send>; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:241:34 + --> $DIR/duplicate.rs:244:34 | LL | type A: Iterator<Item: Copy, Item: Copy>; | ---------- ^^^^^^^^^^ re-bound here @@ -471,13 +495,13 @@ LL | type A: Iterator<Item: Copy, Item: Copy>; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:245:37 + --> $DIR/duplicate.rs:248:37 | LL | type A: Iterator<Item: 'static, Item: 'static>; | ------------- ^^^^^^^^^^^^^ re-bound here | | | `Item` bound here first -error: aborting due to 60 previous errors +error: aborting due to 63 previous errors For more information about this error, try `rustc --explain E0719`. diff --git a/src/test/ui/async-await/async-block-control-flow-static-semantics.rs b/src/test/ui/async-await/async-block-control-flow-static-semantics.rs index 446212ca7..bc9d12793 100644 --- a/src/test/ui/async-await/async-block-control-flow-static-semantics.rs +++ b/src/test/ui/async-await/async-block-control-flow-static-semantics.rs @@ -15,7 +15,7 @@ fn return_targets_async_block_not_fn() -> u8 { return 0u8; }; let _: &dyn Future<Output = ()> = █ - //~^ ERROR expected `impl Future<Output = u8>` to be a future that resolves to `()`, but it resolves to `u8` + //~^ ERROR to be a future that resolves to `()`, but it resolves to `u8` } async fn return_targets_async_block_not_async_fn() -> u8 { @@ -24,7 +24,7 @@ async fn return_targets_async_block_not_async_fn() -> u8 { return 0u8; }; let _: &dyn Future<Output = ()> = █ - //~^ ERROR expected `impl Future<Output = u8>` to be a future that resolves to `()`, but it resolves to `u8` + //~^ ERROR to be a future that resolves to `()`, but it resolves to `u8` } fn no_break_in_async_block() { diff --git a/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr b/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr index 2a08d5d6c..c4487eb84 100644 --- a/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr +++ b/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr @@ -1,8 +1,7 @@ error[E0267]: `break` inside of an `async` block --> $DIR/async-block-control-flow-static-semantics.rs:32:9 | -LL | async { - | ___________- +LL | / async { LL | | break 0u8; | | ^^^^^^^^^ cannot `break` inside of an `async` block LL | | }; @@ -11,8 +10,7 @@ LL | | }; error[E0267]: `break` inside of an `async` block --> $DIR/async-block-control-flow-static-semantics.rs:39:13 | -LL | async { - | _______________- +LL | / async { LL | | break 0u8; | | ^^^^^^^^^ cannot `break` inside of an `async` block LL | | }; @@ -31,13 +29,13 @@ LL | | LL | | } | |_^ expected `u8`, found `()` -error[E0271]: expected `impl Future<Output = u8>` to be a future that resolves to `()`, but it resolves to `u8` +error[E0271]: expected `[async block@$DIR/async-block-control-flow-static-semantics.rs:23:17: 25:6]` to be a future that resolves to `()`, but it resolves to `u8` --> $DIR/async-block-control-flow-static-semantics.rs:26:39 | LL | let _: &dyn Future<Output = ()> = █ | ^^^^^^ expected `()`, found `u8` | - = note: required for the cast from `impl Future<Output = u8>` to the object type `dyn Future<Output = ()>` + = note: required for the cast from `[async block@$DIR/async-block-control-flow-static-semantics.rs:23:17: 25:6]` to the object type `dyn Future<Output = ()>` error[E0308]: mismatched types --> $DIR/async-block-control-flow-static-semantics.rs:12:43 @@ -47,13 +45,13 @@ LL | fn return_targets_async_block_not_fn() -> u8 { | | | implicitly returns `()` as its body has no tail or `return` expression -error[E0271]: expected `impl Future<Output = u8>` to be a future that resolves to `()`, but it resolves to `u8` +error[E0271]: expected `[async block@$DIR/async-block-control-flow-static-semantics.rs:14:17: 16:6]` to be a future that resolves to `()`, but it resolves to `u8` --> $DIR/async-block-control-flow-static-semantics.rs:17:39 | LL | let _: &dyn Future<Output = ()> = █ | ^^^^^^ expected `()`, found `u8` | - = note: required for the cast from `impl Future<Output = u8>` to the object type `dyn Future<Output = ()>` + = note: required for the cast from `[async block@$DIR/async-block-control-flow-static-semantics.rs:14:17: 16:6]` to the object type `dyn Future<Output = ()>` error[E0308]: mismatched types --> $DIR/async-block-control-flow-static-semantics.rs:49:44 diff --git a/src/test/ui/async-await/async-borrowck-escaping-block-error.stderr b/src/test/ui/async-await/async-borrowck-escaping-block-error.stderr index f21c81151..190c59e32 100644 --- a/src/test/ui/async-await/async-borrowck-escaping-block-error.stderr +++ b/src/test/ui/async-await/async-borrowck-escaping-block-error.stderr @@ -1,11 +1,11 @@ error[E0373]: async block may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/async-borrowck-escaping-block-error.rs:6:20 + --> $DIR/async-borrowck-escaping-block-error.rs:6:14 | LL | Box::new(async { x } ) - | ^^-^^ - | | | - | | `x` is borrowed here - | may outlive borrowed value `x` + | ^^^^^^^^-^^ + | | | + | | `x` is borrowed here + | may outlive borrowed value `x` | note: async block is returned here --> $DIR/async-borrowck-escaping-block-error.rs:6:5 @@ -18,13 +18,13 @@ LL | Box::new(async move { x } ) | ++++ error[E0373]: async block may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/async-borrowck-escaping-block-error.rs:11:11 + --> $DIR/async-borrowck-escaping-block-error.rs:11:5 | LL | async { *x } - | ^^--^^ - | | | - | | `x` is borrowed here - | may outlive borrowed value `x` + | ^^^^^^^^--^^ + | | | + | | `x` is borrowed here + | may outlive borrowed value `x` | note: async block is returned here --> $DIR/async-borrowck-escaping-block-error.rs:11:5 diff --git a/src/test/ui/async-await/auxiliary/issue-107036.rs b/src/test/ui/async-await/auxiliary/issue-107036.rs new file mode 100644 index 000000000..c3f6141b2 --- /dev/null +++ b/src/test/ui/async-await/auxiliary/issue-107036.rs @@ -0,0 +1,12 @@ +// edition:2021 + +pub trait T {} +impl T for () {} + +pub struct S {} + +impl S { + pub async fn f<'a>(&self) -> impl T + 'a { + () + } +} diff --git a/src/test/ui/async-await/drop-track-bad-field-in-fru.rs b/src/test/ui/async-await/drop-track-bad-field-in-fru.rs new file mode 100644 index 000000000..28ad77675 --- /dev/null +++ b/src/test/ui/async-await/drop-track-bad-field-in-fru.rs @@ -0,0 +1,10 @@ +// compile-flags: -Zdrop-tracking +// edition: 2021 + +fn main() {} + +async fn foo() { + None { value: (), ..Default::default() }.await; + //~^ ERROR `Option<_>` is not a future + //~| ERROR variant `Option<_>::None` has no field named `value` +} diff --git a/src/test/ui/async-await/drop-track-bad-field-in-fru.stderr b/src/test/ui/async-await/drop-track-bad-field-in-fru.stderr new file mode 100644 index 000000000..819b64ad7 --- /dev/null +++ b/src/test/ui/async-await/drop-track-bad-field-in-fru.stderr @@ -0,0 +1,23 @@ +error[E0559]: variant `Option<_>::None` has no field named `value` + --> $DIR/drop-track-bad-field-in-fru.rs:7:12 + | +LL | None { value: (), ..Default::default() }.await; + | ^^^^^ `Option<_>::None` does not have this field + +error[E0277]: `Option<_>` is not a future + --> $DIR/drop-track-bad-field-in-fru.rs:7:45 + | +LL | None { value: (), ..Default::default() }.await; + | ^^^^^^ + | | + | `Option<_>` is not a future + | help: remove the `.await` + | + = help: the trait `Future` is not implemented for `Option<_>` + = note: Option<_> must be a future or must implement `IntoFuture` to be awaited + = note: required for `Option<_>` to implement `IntoFuture` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0277, E0559. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/async-await/drop-tracking-unresolved-typeck-results.rs b/src/test/ui/async-await/drop-tracking-unresolved-typeck-results.rs new file mode 100644 index 000000000..7f7294295 --- /dev/null +++ b/src/test/ui/async-await/drop-tracking-unresolved-typeck-results.rs @@ -0,0 +1,106 @@ +// compile-flags: -Zdrop-tracking +// incremental +// edition: 2021 + +use std::future::*; +use std::marker::PhantomData; +use std::pin::Pin; +use std::task::*; + +fn send<T: Send>(_: T) {} + +pub trait Stream { + type Item; + + fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>; +} + +struct Empty<T>(PhantomData<fn() -> T>); + +impl<T> Stream for Empty<T> { + type Item = T; + + fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { + todo!() + } +} + +pub trait FnOnce1<A> { + type Output; + fn call_once(self, arg: A) -> Self::Output; +} + +impl<T, A, R> FnOnce1<A> for T +where + T: FnOnce(A) -> R, +{ + type Output = R; + fn call_once(self, arg: A) -> R { + self(arg) + } +} + +pub trait FnMut1<A>: FnOnce1<A> { + fn call_mut(&mut self, arg: A) -> Self::Output; +} + +impl<T, A, R> FnMut1<A> for T +where + T: FnMut(A) -> R, +{ + fn call_mut(&mut self, arg: A) -> R { + self(arg) + } +} + +struct Map<St, F>(St, F); + +impl<St, F> Stream for Map<St, F> +where + St: Stream, + F: FnMut1<St::Item>, +{ + type Item = F::Output; + + fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { + todo!() + } +} + +struct FuturesOrdered<T: Future>(PhantomData<fn() -> T::Output>); + +pub struct Buffered<St: Stream>(St, FuturesOrdered<St::Item>, usize) +where + St::Item: Future; + +impl<St> Stream for Buffered<St> +where + St: Stream, + St::Item: Future, +{ + type Item = <St::Item as Future>::Output; + + fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { + todo!() + } +} + +struct Next<'a, T: ?Sized>(&'a T); + +impl<St: ?Sized + Stream + Unpin> Future for Next<'_, St> { + type Output = Option<St::Item>; + + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { + todo!() + } +} + +fn main() { + send(async { + //~^ ERROR implementation of `FnOnce` is not general enough + //~| ERROR implementation of `FnOnce` is not general enough + //~| ERROR implementation of `FnOnce` is not general enough + //~| ERROR implementation of `FnOnce` is not general enough + Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await + }); +} diff --git a/src/test/ui/async-await/drop-tracking-unresolved-typeck-results.stderr b/src/test/ui/async-await/drop-tracking-unresolved-typeck-results.stderr new file mode 100644 index 000000000..aa9a22e9e --- /dev/null +++ b/src/test/ui/async-await/drop-tracking-unresolved-typeck-results.stderr @@ -0,0 +1,62 @@ +error: implementation of `FnOnce` is not general enough + --> $DIR/drop-tracking-unresolved-typeck-results.rs:99:5 + | +LL | / send(async { +LL | | +LL | | +LL | | +LL | | +LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await +LL | | }); + | |______^ implementation of `FnOnce` is not general enough + | + = note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&(),)>` + +error: implementation of `FnOnce` is not general enough + --> $DIR/drop-tracking-unresolved-typeck-results.rs:99:5 + | +LL | / send(async { +LL | | +LL | | +LL | | +LL | | +LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await +LL | | }); + | |______^ implementation of `FnOnce` is not general enough + | + = note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&(),)>` + +error: implementation of `FnOnce` is not general enough + --> $DIR/drop-tracking-unresolved-typeck-results.rs:99:5 + | +LL | / send(async { +LL | | +LL | | +LL | | +LL | | +LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await +LL | | }); + | |______^ implementation of `FnOnce` is not general enough + | + = note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&(),)>` + +error: implementation of `FnOnce` is not general enough + --> $DIR/drop-tracking-unresolved-typeck-results.rs:99:5 + | +LL | / send(async { +LL | | +LL | | +LL | | +LL | | +LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await +LL | | }); + | |______^ implementation of `FnOnce` is not general enough + | + = note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&(),)>` + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/async-await/feature-self-return-type.rs b/src/test/ui/async-await/feature-self-return-type.rs new file mode 100644 index 000000000..41f887430 --- /dev/null +++ b/src/test/ui/async-await/feature-self-return-type.rs @@ -0,0 +1,28 @@ +// edition:2018 +#![feature(impl_trait_projections)] + +// This test checks that we emit the correct borrowck error when `Self` is used as a return type. +// See #61949 for context. + +pub struct Foo<'a> { + pub bar: &'a i32, +} + +impl<'a> Foo<'a> { + pub async fn new(_bar: &'a i32) -> Self { + Foo { + bar: &22 + } + } +} + +pub async fn foo() { + let x = { + let bar = 22; + Foo::new(&bar).await + //~^ ERROR `bar` does not live long enough + }; + drop(x); +} + +fn main() { } diff --git a/src/test/ui/async-await/feature-self-return-type.stderr b/src/test/ui/async-await/feature-self-return-type.stderr new file mode 100644 index 000000000..892468368 --- /dev/null +++ b/src/test/ui/async-await/feature-self-return-type.stderr @@ -0,0 +1,15 @@ +error[E0597]: `bar` does not live long enough + --> $DIR/feature-self-return-type.rs:22:18 + | +LL | let x = { + | - borrow later stored here +LL | let bar = 22; +LL | Foo::new(&bar).await + | ^^^^ borrowed value does not live long enough +LL | +LL | }; + | - `bar` dropped here while still borrowed + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/async-await/generator-desc.stderr b/src/test/ui/async-await/generator-desc.stderr index 2494c3feb..1686153ac 100644 --- a/src/test/ui/async-await/generator-desc.stderr +++ b/src/test/ui/async-await/generator-desc.stderr @@ -1,20 +1,20 @@ error[E0308]: mismatched types - --> $DIR/generator-desc.rs:10:25 + --> $DIR/generator-desc.rs:10:19 | LL | fun(async {}, async {}); - | -- ^^ - | | | - | | expected `async` block, found a different `async` block - | | arguments to this function are incorrect - | the expected `async` block + | -------- ^^^^^^^^ + | | | + | | expected `async` block, found a different `async` block + | | arguments to this function are incorrect + | the expected `async` block | - = note: expected `async` block `[static generator@$DIR/generator-desc.rs:10:15: 10:17]` - found `async` block `[static generator@$DIR/generator-desc.rs:10:25: 10:27]` + = note: expected `async` block `[async block@$DIR/generator-desc.rs:10:9: 10:17]` + found `async` block `[async block@$DIR/generator-desc.rs:10:19: 10:27]` note: function defined here --> $SRC_DIR/core/src/future/mod.rs:LL:COL | -LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return> - | ^^^^^^^^^^^^^^ +LL | pub const fn identity_future<O, Fut: Future<Output = O>>(f: Fut) -> Fut { + | ^^^^^^^^^^^^^^^ error[E0308]: mismatched types --> $DIR/generator-desc.rs:12:16 @@ -53,16 +53,8 @@ LL | fun((async || {})(), (async || {})()); | | the expected `async` closure body | arguments to this function are incorrect | - ::: $SRC_DIR/core/src/future/mod.rs:LL:COL - | -LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return> - | ------------------------------- - | | - | the expected opaque type - | the found opaque type - | - = note: expected opaque type `impl Future<Output = ()>` (`async` closure body) - found opaque type `impl Future<Output = ()>` (`async` closure body) + = note: expected `async` closure body `[async closure body@$DIR/generator-desc.rs:14:19: 14:21]` + found `async` closure body `[async closure body@$DIR/generator-desc.rs:14:36: 14:38]` note: function defined here --> $DIR/generator-desc.rs:8:4 | diff --git a/src/test/ui/async-await/generator-not-future.rs b/src/test/ui/async-await/generator-not-future.rs new file mode 100644 index 000000000..37d7cfa6f --- /dev/null +++ b/src/test/ui/async-await/generator-not-future.rs @@ -0,0 +1,45 @@ +// edition:2018 +#![feature(generators, generator_trait)] + +use std::future::Future; +use std::ops::Generator; + +async fn async_fn() {} +fn returns_async_block() -> impl Future<Output = ()> { + async {} +} +fn returns_generator() -> impl Generator<(), Yield = (), Return = ()> { + || { + let _: () = yield (); + } +} + +fn takes_future(_f: impl Future<Output = ()>) {} +fn takes_generator<ResumeTy>(_g: impl Generator<ResumeTy, Yield = (), Return = ()>) {} + +fn main() { + // okay: + takes_future(async_fn()); + takes_future(returns_async_block()); + takes_future(async {}); + takes_generator(returns_generator()); + takes_generator(|| { + let _: () = yield (); + }); + + // async futures are not generators: + takes_generator(async_fn()); + //~^ ERROR the trait bound + takes_generator(returns_async_block()); + //~^ ERROR the trait bound + takes_generator(async {}); + //~^ ERROR the trait bound + + // generators are not futures: + takes_future(returns_generator()); + //~^ ERROR is not a future + takes_future(|ctx| { + //~^ ERROR is not a future + ctx = yield (); + }); +} diff --git a/src/test/ui/async-await/generator-not-future.stderr b/src/test/ui/async-await/generator-not-future.stderr new file mode 100644 index 000000000..1b81b461f --- /dev/null +++ b/src/test/ui/async-await/generator-not-future.stderr @@ -0,0 +1,81 @@ +error[E0277]: the trait bound `impl Future<Output = ()>: Generator<_>` is not satisfied + --> $DIR/generator-not-future.rs:31:21 + | +LL | takes_generator(async_fn()); + | --------------- ^^^^^^^^^^ the trait `Generator<_>` is not implemented for `impl Future<Output = ()>` + | | + | required by a bound introduced by this call + | +note: required by a bound in `takes_generator` + --> $DIR/generator-not-future.rs:18:39 + | +LL | fn takes_generator<ResumeTy>(_g: impl Generator<ResumeTy, Yield = (), Return = ()>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_generator` + +error[E0277]: the trait bound `impl Future<Output = ()>: Generator<_>` is not satisfied + --> $DIR/generator-not-future.rs:33:21 + | +LL | takes_generator(returns_async_block()); + | --------------- ^^^^^^^^^^^^^^^^^^^^^ the trait `Generator<_>` is not implemented for `impl Future<Output = ()>` + | | + | required by a bound introduced by this call + | +note: required by a bound in `takes_generator` + --> $DIR/generator-not-future.rs:18:39 + | +LL | fn takes_generator<ResumeTy>(_g: impl Generator<ResumeTy, Yield = (), Return = ()>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_generator` + +error[E0277]: the trait bound `[async block@$DIR/generator-not-future.rs:35:21: 35:29]: Generator<_>` is not satisfied + --> $DIR/generator-not-future.rs:35:21 + | +LL | takes_generator(async {}); + | --------------- ^^^^^^^^ the trait `Generator<_>` is not implemented for `[async block@$DIR/generator-not-future.rs:35:21: 35:29]` + | | + | required by a bound introduced by this call + | +note: required by a bound in `takes_generator` + --> $DIR/generator-not-future.rs:18:39 + | +LL | fn takes_generator<ResumeTy>(_g: impl Generator<ResumeTy, Yield = (), Return = ()>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_generator` + +error[E0277]: `impl Generator<Yield = (), Return = ()>` is not a future + --> $DIR/generator-not-future.rs:39:18 + | +LL | takes_future(returns_generator()); + | ------------ ^^^^^^^^^^^^^^^^^^^ `impl Generator<Yield = (), Return = ()>` is not a future + | | + | required by a bound introduced by this call + | + = help: the trait `Future` is not implemented for `impl Generator<Yield = (), Return = ()>` + = note: impl Generator<Yield = (), Return = ()> must be a future or must implement `IntoFuture` to be awaited +note: required by a bound in `takes_future` + --> $DIR/generator-not-future.rs:17:26 + | +LL | fn takes_future(_f: impl Future<Output = ()>) {} + | ^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_future` + +error[E0277]: `[generator@$DIR/generator-not-future.rs:41:18: 41:23]` is not a future + --> $DIR/generator-not-future.rs:41:18 + | +LL | takes_future(|ctx| { + | _____------------_^ + | | | + | | required by a bound introduced by this call +LL | | +LL | | ctx = yield (); +LL | | }); + | |_____^ `[generator@$DIR/generator-not-future.rs:41:18: 41:23]` is not a future + | + = help: the trait `Future` is not implemented for `[generator@$DIR/generator-not-future.rs:41:18: 41:23]` + = note: [generator@$DIR/generator-not-future.rs:41:18: 41:23] must be a future or must implement `IntoFuture` to be awaited +note: required by a bound in `takes_future` + --> $DIR/generator-not-future.rs:17:26 + | +LL | fn takes_future(_f: impl Future<Output = ()>) {} + | ^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_future` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/async-await/in-trait/async-associated-types.rs b/src/test/ui/async-await/in-trait/async-associated-types.rs index a6f928f3b..974f5aaff 100644 --- a/src/test/ui/async-await/in-trait/async-associated-types.rs +++ b/src/test/ui/async-await/in-trait/async-associated-types.rs @@ -1,8 +1,8 @@ -// check-fail -// known-bug: #102682 +// check-pass // edition: 2021 #![feature(async_fn_in_trait)] +#![feature(impl_trait_projections)] #![allow(incomplete_features)] use std::fmt::Debug; diff --git a/src/test/ui/async-await/in-trait/async-associated-types.stderr b/src/test/ui/async-await/in-trait/async-associated-types.stderr deleted file mode 100644 index 0985150ee..000000000 --- a/src/test/ui/async-await/in-trait/async-associated-types.stderr +++ /dev/null @@ -1,57 +0,0 @@ -error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements - --> $DIR/async-associated-types.rs:19:43 - | -LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) { - | ^^^^^^^^^^^^^^ - | -note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/async-associated-types.rs:16:6 - | -LL | impl<'a, 'b, T: Debug + Sized + 'b, U: 'a> MyTrait<'a, 'b, T> for U { - | ^^ -note: ...so that the types are compatible - --> $DIR/async-associated-types.rs:19:43 - | -LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) { - | ^^^^^^^^^^^^^^ - = note: expected `(&'a U, &'b T)` - found `(&U, &T)` - = note: but, the lifetime must be valid for the static lifetime... -note: ...so that the types are compatible - --> $DIR/async-associated-types.rs:19:43 - | -LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) { - | ^^^^^^^^^^^^^^ - = note: expected `MyTrait<'static, 'static, T>` - found `MyTrait<'_, '_, T>` - -error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting requirements - --> $DIR/async-associated-types.rs:19:43 - | -LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) { - | ^^^^^^^^^^^^^^ - | -note: first, the lifetime cannot outlive the lifetime `'b` as defined here... - --> $DIR/async-associated-types.rs:16:10 - | -LL | impl<'a, 'b, T: Debug + Sized + 'b, U: 'a> MyTrait<'a, 'b, T> for U { - | ^^ -note: ...so that the types are compatible - --> $DIR/async-associated-types.rs:19:43 - | -LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) { - | ^^^^^^^^^^^^^^ - = note: expected `(&'a U, &'b T)` - found `(&U, &T)` - = note: but, the lifetime must be valid for the static lifetime... -note: ...so that the types are compatible - --> $DIR/async-associated-types.rs:19:43 - | -LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) { - | ^^^^^^^^^^^^^^ - = note: expected `MyTrait<'static, 'static, T>` - found `MyTrait<'_, '_, T>` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/async-await/in-trait/async-generics-and-bounds.stderr b/src/test/ui/async-await/in-trait/async-generics-and-bounds.stderr index 5c8d64fc6..f1f0d7e59 100644 --- a/src/test/ui/async-await/in-trait/async-generics-and-bounds.stderr +++ b/src/test/ui/async-await/in-trait/async-generics-and-bounds.stderr @@ -4,11 +4,11 @@ error[E0311]: the parameter type `U` may not live long enough LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^^^ | -note: the parameter type `U` must be valid for the anonymous lifetime as defined here... +note: the parameter type `U` must be valid for the anonymous lifetime defined here... --> $DIR/async-generics-and-bounds.rs:12:18 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; - | ^ + | ^^^^^ note: ...so that the reference type `&(T, U)` does not outlive the data it points at --> $DIR/async-generics-and-bounds.rs:12:28 | @@ -21,11 +21,11 @@ error[E0311]: the parameter type `T` may not live long enough LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^^^ | -note: the parameter type `T` must be valid for the anonymous lifetime as defined here... +note: the parameter type `T` must be valid for the anonymous lifetime defined here... --> $DIR/async-generics-and-bounds.rs:12:18 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; - | ^ + | ^^^^^ note: ...so that the reference type `&(T, U)` does not outlive the data it points at --> $DIR/async-generics-and-bounds.rs:12:28 | diff --git a/src/test/ui/async-await/in-trait/async-generics.stderr b/src/test/ui/async-await/in-trait/async-generics.stderr index 6ae73d9e3..2f0556456 100644 --- a/src/test/ui/async-await/in-trait/async-generics.stderr +++ b/src/test/ui/async-await/in-trait/async-generics.stderr @@ -4,11 +4,11 @@ error[E0311]: the parameter type `U` may not live long enough LL | async fn foo(&self) -> &(T, U); | ^^^^^^^ | -note: the parameter type `U` must be valid for the anonymous lifetime as defined here... +note: the parameter type `U` must be valid for the anonymous lifetime defined here... --> $DIR/async-generics.rs:9:18 | LL | async fn foo(&self) -> &(T, U); - | ^ + | ^^^^^ note: ...so that the reference type `&(T, U)` does not outlive the data it points at --> $DIR/async-generics.rs:9:28 | @@ -21,11 +21,11 @@ error[E0311]: the parameter type `T` may not live long enough LL | async fn foo(&self) -> &(T, U); | ^^^^^^^ | -note: the parameter type `T` must be valid for the anonymous lifetime as defined here... +note: the parameter type `T` must be valid for the anonymous lifetime defined here... --> $DIR/async-generics.rs:9:18 | LL | async fn foo(&self) -> &(T, U); - | ^ + | ^^^^^ note: ...so that the reference type `&(T, U)` does not outlive the data it points at --> $DIR/async-generics.rs:9:28 | diff --git a/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.rs b/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.rs index 3f7448cec..d5481d277 100644 --- a/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.rs +++ b/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.rs @@ -1,5 +1,4 @@ -// check-fail -// known-bug: #102682 +// check-pass // edition: 2021 #![feature(async_fn_in_trait)] diff --git a/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.stderr b/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.stderr deleted file mode 100644 index 0f0242027..000000000 --- a/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0309]: the parameter type `Self` may not live long enough - --> $DIR/async-lifetimes-and-bounds.rs:11:43 - | -LL | async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T) where T: Debug + Sized; - | ^^^^^^^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `Self: 'a`... - = note: ...so that the reference type `&'a Self` does not outlive the data it points at - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/async-lifetimes-and-bounds.rs:11:43 - | -LL | async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T) where T: Debug + Sized; - | ^^^^^^^^^^^^^^^^^ ...so that the reference type `&'b T` does not outlive the data it points at - | -help: consider adding an explicit lifetime bound... - | -LL | trait MyTrait<'a, 'b, T: 'b> { - | ++++ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/async-await/in-trait/async-lifetimes.rs b/src/test/ui/async-await/in-trait/async-lifetimes.rs index acbac471c..f298e45d2 100644 --- a/src/test/ui/async-await/in-trait/async-lifetimes.rs +++ b/src/test/ui/async-await/in-trait/async-lifetimes.rs @@ -1,5 +1,4 @@ -// check-fail -// known-bug: #102682 +// check-pass // edition: 2021 #![feature(async_fn_in_trait)] diff --git a/src/test/ui/async-await/in-trait/async-lifetimes.stderr b/src/test/ui/async-await/in-trait/async-lifetimes.stderr deleted file mode 100644 index 9a7d294bb..000000000 --- a/src/test/ui/async-await/in-trait/async-lifetimes.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0309]: the parameter type `Self` may not live long enough - --> $DIR/async-lifetimes.rs:9:43 - | -LL | async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T); - | ^^^^^^^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `Self: 'a`... - = note: ...so that the reference type `&'a Self` does not outlive the data it points at - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/async-lifetimes.rs:9:43 - | -LL | async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T); - | ^^^^^^^^^^^^^^^^^ ...so that the reference type `&'b T` does not outlive the data it points at - | -help: consider adding an explicit lifetime bound... - | -LL | trait MyTrait<'a, 'b, T: 'b> { - | ++++ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/async-await/in-trait/early-bound-1.rs b/src/test/ui/async-await/in-trait/early-bound-1.rs new file mode 100644 index 000000000..6b3b14201 --- /dev/null +++ b/src/test/ui/async-await/in-trait/early-bound-1.rs @@ -0,0 +1,17 @@ +// check-pass +// edition:2021 + +#![feature(async_fn_in_trait)] +#![allow(incomplete_features)] + +pub trait Foo { + async fn foo(&mut self); +} + +struct MyFoo<'a>(&'a mut ()); + +impl<'a> Foo for MyFoo<'a> { + async fn foo(&mut self) {} +} + +fn main() {} diff --git a/src/test/ui/async-await/in-trait/early-bound-2.rs b/src/test/ui/async-await/in-trait/early-bound-2.rs new file mode 100644 index 000000000..270443229 --- /dev/null +++ b/src/test/ui/async-await/in-trait/early-bound-2.rs @@ -0,0 +1,15 @@ +// check-pass +// edition:2021 + +#![feature(async_fn_in_trait)] +#![allow(incomplete_features)] + +pub trait Foo { + async fn foo(&mut self); +} + +impl<T: Foo> Foo for &mut T { + async fn foo(&mut self) {} +} + +fn main() {} diff --git a/src/test/ui/async-await/in-trait/implied-bounds.rs b/src/test/ui/async-await/in-trait/implied-bounds.rs new file mode 100644 index 000000000..52bceb3cc --- /dev/null +++ b/src/test/ui/async-await/in-trait/implied-bounds.rs @@ -0,0 +1,13 @@ +// check-pass +// edition: 2021 + +#![feature(async_fn_in_trait)] +#![allow(incomplete_features)] + +trait TcpStack { + type Connection<'a>: Sized where Self: 'a; + fn connect<'a>(&'a self) -> Self::Connection<'a>; + async fn async_connect<'a>(&'a self) -> Self::Connection<'a>; +} + +fn main() {} diff --git a/src/test/ui/async-await/in-trait/lifetime-mismatch.rs b/src/test/ui/async-await/in-trait/lifetime-mismatch.rs new file mode 100644 index 000000000..45ede193c --- /dev/null +++ b/src/test/ui/async-await/in-trait/lifetime-mismatch.rs @@ -0,0 +1,20 @@ +// edition:2021 + +#![feature(async_fn_in_trait)] +//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + +trait MyTrait { + async fn foo<'a>(&self); + async fn bar(&self); +} + +impl MyTrait for i32 { + async fn foo(&self) {} + //~^ ERROR lifetime parameters or bounds on method `foo` do not match the trait declaration + + async fn bar(&self) { + self.foo(); + } +} + +fn main() {} diff --git a/src/test/ui/async-await/in-trait/lifetime-mismatch.stderr b/src/test/ui/async-await/in-trait/lifetime-mismatch.stderr new file mode 100644 index 000000000..d87adcc78 --- /dev/null +++ b/src/test/ui/async-await/in-trait/lifetime-mismatch.stderr @@ -0,0 +1,21 @@ +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/lifetime-mismatch.rs:3:12 + | +LL | #![feature(async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration + --> $DIR/lifetime-mismatch.rs:12:17 + | +LL | async fn foo<'a>(&self); + | ---- lifetimes in impl do not match this method in trait +... +LL | async fn foo(&self) {} + | ^ lifetimes do not match method in trait + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0195`. diff --git a/src/test/ui/async-await/in-trait/nested-rpit.rs b/src/test/ui/async-await/in-trait/nested-rpit.rs new file mode 100644 index 000000000..41d72ebb4 --- /dev/null +++ b/src/test/ui/async-await/in-trait/nested-rpit.rs @@ -0,0 +1,19 @@ +// edition: 2021 +// known-bug: #105197 +// failure-status:101 +// dont-check-compiler-stderr + +#![feature(async_fn_in_trait)] +#![feature(return_position_impl_trait_in_trait)] +#![allow(incomplete_features)] + +use std::future::Future; +use std::marker::PhantomData; + +trait Lockable<K, V> { + async fn lock_all_entries(&self) -> impl Future<Output = Guard<'_>>; +} + +struct Guard<'a>(PhantomData<&'a ()>); + +fn main() {} diff --git a/src/test/ui/async-await/in-trait/object-safety.rs b/src/test/ui/async-await/in-trait/object-safety.rs new file mode 100644 index 000000000..a8bc35f7e --- /dev/null +++ b/src/test/ui/async-await/in-trait/object-safety.rs @@ -0,0 +1,13 @@ +// edition:2021 + +#![feature(async_fn_in_trait)] +//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + +trait Foo { + async fn foo(&self); +} + +fn main() { + let x: &dyn Foo = todo!(); + //~^ ERROR the trait `Foo` cannot be made into an object +} diff --git a/src/test/ui/async-await/in-trait/object-safety.stderr b/src/test/ui/async-await/in-trait/object-safety.stderr new file mode 100644 index 000000000..0b318f71f --- /dev/null +++ b/src/test/ui/async-await/in-trait/object-safety.stderr @@ -0,0 +1,27 @@ +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/object-safety.rs:3:12 + | +LL | #![feature(async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/object-safety.rs:11:12 + | +LL | let x: &dyn Foo = todo!(); + | ^^^^^^^^ `Foo` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> + --> $DIR/object-safety.rs:7:14 + | +LL | trait Foo { + | --- this trait cannot be made into an object... +LL | async fn foo(&self); + | ^^^ ...because method `foo` is `async` + = help: consider moving `foo` to another trait + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/async-await/in-trait/return-type-suggestion.rs b/src/test/ui/async-await/in-trait/return-type-suggestion.rs new file mode 100644 index 000000000..3446761d1 --- /dev/null +++ b/src/test/ui/async-await/in-trait/return-type-suggestion.rs @@ -0,0 +1,14 @@ +// edition: 2021 + +#![feature(async_fn_in_trait)] +//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + +trait A { + async fn e() { + Ok(()) + //~^ ERROR mismatched types + //~| HELP consider using a semicolon here + } +} + +fn main() {} diff --git a/src/test/ui/async-await/in-trait/return-type-suggestion.stderr b/src/test/ui/async-await/in-trait/return-type-suggestion.stderr new file mode 100644 index 000000000..5a9b15e54 --- /dev/null +++ b/src/test/ui/async-await/in-trait/return-type-suggestion.stderr @@ -0,0 +1,23 @@ +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/return-type-suggestion.rs:3:12 + | +LL | #![feature(async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0308]: mismatched types + --> $DIR/return-type-suggestion.rs:8:9 + | +LL | Ok(()) + | ^^^^^^- help: consider using a semicolon here: `;` + | | + | expected `()`, found enum `Result` + | + = note: expected unit type `()` + found enum `Result<(), _>` + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/async-await/issue-107036.rs b/src/test/ui/async-await/issue-107036.rs new file mode 100644 index 000000000..6a22de2c9 --- /dev/null +++ b/src/test/ui/async-await/issue-107036.rs @@ -0,0 +1,14 @@ +// aux-build:issue-107036.rs +// edition:2021 +// check-pass + +extern crate issue_107036; +use issue_107036::S; + +async fn f() { + S{}.f().await; +} + +fn main() { + let _ = f(); +} diff --git a/src/test/ui/async-await/issue-61949-self-return-type.rs b/src/test/ui/async-await/issue-61949-self-return-type.rs index 43429ba23..d73dbc6e8 100644 --- a/src/test/ui/async-await/issue-61949-self-return-type.rs +++ b/src/test/ui/async-await/issue-61949-self-return-type.rs @@ -1,4 +1,5 @@ // edition:2018 +// gate-test-impl_trait_projections // This test checks that `Self` is prohibited as a return type. See #61949 for context. @@ -19,6 +20,7 @@ async fn foo() { let x = { let bar = 22; Foo::new(&bar).await + //~^ ERROR `bar` does not live long enough }; drop(x); } diff --git a/src/test/ui/async-await/issue-61949-self-return-type.stderr b/src/test/ui/async-await/issue-61949-self-return-type.stderr index 52b726e18..638b197bc 100644 --- a/src/test/ui/async-await/issue-61949-self-return-type.stderr +++ b/src/test/ui/async-await/issue-61949-self-return-type.stderr @@ -1,9 +1,25 @@ -error[E0760]: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope - --> $DIR/issue-61949-self-return-type.rs:10:40 +error[E0658]: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope + --> $DIR/issue-61949-self-return-type.rs:11:40 | LL | pub async fn new(_bar: &'a i32) -> Self { | ^^^^ help: consider spelling out the type instead: `Foo<'a>` + | + = note: see issue #103532 <https://github.com/rust-lang/rust/issues/103532> for more information + = help: add `#![feature(impl_trait_projections)]` to the crate attributes to enable + +error[E0597]: `bar` does not live long enough + --> $DIR/issue-61949-self-return-type.rs:22:18 + | +LL | let x = { + | - borrow later stored here +LL | let bar = 22; +LL | Foo::new(&bar).await + | ^^^^ borrowed value does not live long enough +LL | +LL | }; + | - `bar` dropped here while still borrowed -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0760`. +Some errors have detailed explanations: E0597, E0658. +For more information about an error, try `rustc --explain E0597`. diff --git a/src/test/ui/async-await/issue-67252-unnamed-future.stderr b/src/test/ui/async-await/issue-67252-unnamed-future.stderr index af99b608c..fcba4410b 100644 --- a/src/test/ui/async-await/issue-67252-unnamed-future.stderr +++ b/src/test/ui/async-await/issue-67252-unnamed-future.stderr @@ -8,7 +8,7 @@ LL | | AFuture.await; LL | | }); | |_____^ future created by async block is not `Send` | - = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `*mut ()` + = help: within `[async block@$DIR/issue-67252-unnamed-future.rs:18:11: 21:6]`, the trait `Send` is not implemented for `*mut ()` note: future is not `Send` as this value is used across an await --> $DIR/issue-67252-unnamed-future.rs:20:16 | diff --git a/src/test/ui/async-await/issue-68112.drop_tracking.stderr b/src/test/ui/async-await/issue-68112.drop_tracking.stderr index c915164cf..f2802698f 100644 --- a/src/test/ui/async-await/issue-68112.drop_tracking.stderr +++ b/src/test/ui/async-await/issue-68112.drop_tracking.stderr @@ -59,10 +59,10 @@ LL | fn make_non_send_future2() -> impl Future<Output = Arc<RefCell<i32>>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: required because it captures the following types: `ResumeTy`, `impl Future<Output = Arc<RefCell<i32>>>`, `()`, `Ready<i32>` note: required because it's used within this `async` block - --> $DIR/issue-68112.rs:60:26 + --> $DIR/issue-68112.rs:60:20 | LL | let send_fut = async { - | __________________________^ + | ____________________^ LL | | let non_send_fut = make_non_send_future2(); LL | | let _ = non_send_fut.await; LL | | ready(0).await; diff --git a/src/test/ui/async-await/issue-68112.no_drop_tracking.stderr b/src/test/ui/async-await/issue-68112.no_drop_tracking.stderr index 11b7d1aaa..38eb85b30 100644 --- a/src/test/ui/async-await/issue-68112.no_drop_tracking.stderr +++ b/src/test/ui/async-await/issue-68112.no_drop_tracking.stderr @@ -59,10 +59,10 @@ LL | fn make_non_send_future2() -> impl Future<Output = Arc<RefCell<i32>>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: required because it captures the following types: `ResumeTy`, `impl Future<Output = Arc<RefCell<i32>>>`, `()`, `i32`, `Ready<i32>` note: required because it's used within this `async` block - --> $DIR/issue-68112.rs:60:26 + --> $DIR/issue-68112.rs:60:20 | LL | let send_fut = async { - | __________________________^ + | ____________________^ LL | | let non_send_fut = make_non_send_future2(); LL | | let _ = non_send_fut.await; LL | | ready(0).await; diff --git a/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr b/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr index 7fb881166..721234aa4 100644 --- a/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr +++ b/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr @@ -20,10 +20,9 @@ LL | | } | |_^ = note: required because it captures the following types: `ResumeTy`, `impl Future<Output = ()>`, `()` note: required because it's used within this `async` block - --> $DIR/issue-70935-complex-spans.rs:16:16 + --> $DIR/issue-70935-complex-spans.rs:16:5 | -LL | async move { - | ________________^ +LL | / async move { LL | | baz(|| async{ LL | | foo(tx.clone()); LL | | }).await; diff --git a/src/test/ui/async-await/issue-86507.stderr b/src/test/ui/async-await/issue-86507.stderr index 0e21dba98..8c2c06da2 100644 --- a/src/test/ui/async-await/issue-86507.stderr +++ b/src/test/ui/async-await/issue-86507.stderr @@ -13,7 +13,7 @@ note: captured value is not `Send` because `&` references cannot be sent unless | LL | let x = x; | ^ has type `&T` which is not `Send`, because `T` is not `Sync` - = note: required for the cast from `impl Future<Output = ()>` to the object type `dyn Future<Output = ()> + Send` + = note: required for the cast from `[async block@$DIR/issue-86507.rs:18:17: 20:18]` to the object type `dyn Future<Output = ()> + Send` help: consider further restricting this bound | LL | fn bar<'me, 'async_trait, T: Send + std::marker::Sync>(x: &'me T) diff --git a/src/test/ui/async-await/issues/issue-65159.rs b/src/test/ui/async-await/issues/issue-65159.rs index 1dbf5db6c..df2ca0257 100644 --- a/src/test/ui/async-await/issues/issue-65159.rs +++ b/src/test/ui/async-await/issues/issue-65159.rs @@ -6,7 +6,6 @@ async fn copy() -> Result<()> //~^ ERROR this enum takes 2 generic arguments { Ok(()) - //~^ ERROR type annotations needed } fn main() { } diff --git a/src/test/ui/async-await/issues/issue-65159.stderr b/src/test/ui/async-await/issues/issue-65159.stderr index 9918f569c..45f5ec40c 100644 --- a/src/test/ui/async-await/issues/issue-65159.stderr +++ b/src/test/ui/async-await/issues/issue-65159.stderr @@ -16,18 +16,6 @@ help: add missing generic argument LL | async fn copy() -> Result<(), E> | +++ -error[E0282]: type annotations needed - --> $DIR/issue-65159.rs:8:5 - | -LL | Ok(()) - | ^^ cannot infer type of the type parameter `E` declared on the enum `Result` - | -help: consider specifying the generic arguments - | -LL | Ok::<(), E>(()) - | +++++++++ - -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0107, E0282. -For more information about an error, try `rustc --explain E0107`. +For more information about this error, try `rustc --explain E0107`. diff --git a/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr b/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr index a72350377..ab196dca2 100644 --- a/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr +++ b/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr @@ -8,7 +8,7 @@ LL | | bar(Foo(std::ptr::null())).await; LL | | }) | |_____^ future created by async block is not `Send` | - = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `*const u8` + = help: within `[async block@$DIR/issue-65436-raw-ptr-not-send.rs:16:17: 19:6]`, the trait `Send` is not implemented for `*const u8` note: future is not `Send` as this value is used across an await --> $DIR/issue-65436-raw-ptr-not-send.rs:18:35 | diff --git a/src/test/ui/async-await/issues/issue-78600.stderr b/src/test/ui/async-await/issues/issue-78600.stderr index 92b661471..37eafa996 100644 --- a/src/test/ui/async-await/issues/issue-78600.stderr +++ b/src/test/ui/async-await/issues/issue-78600.stderr @@ -1,11 +1,14 @@ -error[E0760]: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope +error[E0658]: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope --> $DIR/issue-78600.rs:6:33 | LL | async fn new(i: &'a i32) -> Result<Self, ()> { | ^^^^^^^----^^^^^ | | | help: consider spelling out the type instead: `S<'a>` + | + = note: see issue #103532 <https://github.com/rust-lang/rust/issues/103532> for more information + = help: add `#![feature(impl_trait_projections)]` to the crate attributes to enable error: aborting due to previous error -For more information about this error, try `rustc --explain E0760`. +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/async-await/issues/issue-78938-async-block.stderr b/src/test/ui/async-await/issues/issue-78938-async-block.stderr index 29aa8372f..c1a4b467f 100644 --- a/src/test/ui/async-await/issues/issue-78938-async-block.stderr +++ b/src/test/ui/async-await/issues/issue-78938-async-block.stderr @@ -1,8 +1,8 @@ error[E0373]: async block may outlive the current function, but it borrows `room_ref`, which is owned by the current function - --> $DIR/issue-78938-async-block.rs:8:39 + --> $DIR/issue-78938-async-block.rs:8:33 | LL | let gameloop_handle = spawn(async { - | _______________________________________^ + | _________________________________^ LL | | game_loop(Arc::clone(&room_ref)) | | -------- `room_ref` is borrowed here LL | | }); diff --git a/src/test/ui/async-await/large_moves.attribute.stderr b/src/test/ui/async-await/large_moves.attribute.stderr index da34f44b2..0c5452475 100644 --- a/src/test/ui/async-await/large_moves.attribute.stderr +++ b/src/test/ui/async-await/large_moves.attribute.stderr @@ -1,5 +1,5 @@ error: moving 10024 bytes - --> $DIR/large_moves.rs:12:13 + --> $DIR/large_moves.rs:13:13 | LL | let x = async { | _____________^ @@ -18,7 +18,7 @@ LL | #![deny(large_assignments)] | ^^^^^^^^^^^^^^^^^ error: moving 10024 bytes - --> $DIR/large_moves.rs:18:14 + --> $DIR/large_moves.rs:19:14 | LL | let z = (x, 42); | ^ value moved from here @@ -26,7 +26,7 @@ LL | let z = (x, 42); = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` error: moving 10024 bytes - --> $DIR/large_moves.rs:18:13 + --> $DIR/large_moves.rs:19:13 | LL | let z = (x, 42); | ^^^^^^^ value moved from here @@ -34,7 +34,7 @@ LL | let z = (x, 42); = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` error: moving 10024 bytes - --> $DIR/large_moves.rs:20:13 + --> $DIR/large_moves.rs:21:13 | LL | let a = z.0; | ^^^ value moved from here diff --git a/src/test/ui/async-await/large_moves.option.stderr b/src/test/ui/async-await/large_moves.option.stderr index da34f44b2..0c5452475 100644 --- a/src/test/ui/async-await/large_moves.option.stderr +++ b/src/test/ui/async-await/large_moves.option.stderr @@ -1,5 +1,5 @@ error: moving 10024 bytes - --> $DIR/large_moves.rs:12:13 + --> $DIR/large_moves.rs:13:13 | LL | let x = async { | _____________^ @@ -18,7 +18,7 @@ LL | #![deny(large_assignments)] | ^^^^^^^^^^^^^^^^^ error: moving 10024 bytes - --> $DIR/large_moves.rs:18:14 + --> $DIR/large_moves.rs:19:14 | LL | let z = (x, 42); | ^ value moved from here @@ -26,7 +26,7 @@ LL | let z = (x, 42); = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` error: moving 10024 bytes - --> $DIR/large_moves.rs:18:13 + --> $DIR/large_moves.rs:19:13 | LL | let z = (x, 42); | ^^^^^^^ value moved from here @@ -34,7 +34,7 @@ LL | let z = (x, 42); = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` error: moving 10024 bytes - --> $DIR/large_moves.rs:20:13 + --> $DIR/large_moves.rs:21:13 | LL | let a = z.0; | ^^^ value moved from here diff --git a/src/test/ui/async-await/large_moves.rs b/src/test/ui/async-await/large_moves.rs index 18bb538a8..d43d0eec0 100644 --- a/src/test/ui/async-await/large_moves.rs +++ b/src/test/ui/async-await/large_moves.rs @@ -7,6 +7,7 @@ // [option]compile-flags: -Zmove-size-limit=1000 // edition:2018 +// compile-flags: -Zmir-opt-level=0 fn main() { let x = async { //~ ERROR large_assignments diff --git a/src/test/ui/async-await/track-caller/async-closure-gate.rs b/src/test/ui/async-await/track-caller/async-closure-gate.rs new file mode 100644 index 000000000..d9d556855 --- /dev/null +++ b/src/test/ui/async-await/track-caller/async-closure-gate.rs @@ -0,0 +1,9 @@ +// edition:2021 + +#![feature(async_closure, stmt_expr_attributes)] + +fn main() { + let _ = #[track_caller] async || { + //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] + }; +} diff --git a/src/test/ui/async-await/track-caller/async-closure-gate.stderr b/src/test/ui/async-await/track-caller/async-closure-gate.stderr new file mode 100644 index 000000000..498f1b43b --- /dev/null +++ b/src/test/ui/async-await/track-caller/async-closure-gate.stderr @@ -0,0 +1,12 @@ +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/async-closure-gate.rs:6:13 + | +LL | let _ = #[track_caller] async || { + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/async-await/track-caller/issue-105134.rs b/src/test/ui/async-await/track-caller/issue-105134.rs new file mode 100644 index 000000000..4e52b8e25 --- /dev/null +++ b/src/test/ui/async-await/track-caller/issue-105134.rs @@ -0,0 +1,11 @@ +// check-pass +// edition:2021 + +#[track_caller] +fn f() { + let _ = async {}; +} + +fn main() { + f(); +} diff --git a/src/test/ui/async-await/track-caller/panic-track-caller.nofeat.stderr b/src/test/ui/async-await/track-caller/panic-track-caller.nofeat.stderr new file mode 100644 index 000000000..51ea225f4 --- /dev/null +++ b/src/test/ui/async-await/track-caller/panic-track-caller.nofeat.stderr @@ -0,0 +1,29 @@ +warning: `#[track_caller]` on async functions is a no-op + --> $DIR/panic-track-caller.rs:50:1 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ +LL | / async fn bar_track_caller() { +LL | | panic!() +LL | | } + | |_- this function will not propagate the caller location + | + = note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + = note: `#[warn(ungated_async_fn_track_caller)]` on by default + +warning: `#[track_caller]` on async functions is a no-op + --> $DIR/panic-track-caller.rs:62:5 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ +LL | / async fn bar_assoc() { +LL | | panic!(); +LL | | } + | |_____- this function will not propagate the caller location + | + = note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +warning: 2 warnings emitted + diff --git a/src/test/ui/async-await/track-caller/panic-track-caller.rs b/src/test/ui/async-await/track-caller/panic-track-caller.rs new file mode 100644 index 000000000..118361d6c --- /dev/null +++ b/src/test/ui/async-await/track-caller/panic-track-caller.rs @@ -0,0 +1,100 @@ +// run-pass +// edition:2021 +// revisions: feat nofeat +// needs-unwind +#![feature(async_closure, stmt_expr_attributes)] +#![cfg_attr(feat, feature(closure_track_caller))] + +use std::future::Future; +use std::panic; +use std::sync::{Arc, Mutex}; +use std::task::{Context, Poll, Wake}; +use std::thread::{self, Thread}; + +/// A waker that wakes up the current thread when called. +struct ThreadWaker(Thread); + +impl Wake for ThreadWaker { + fn wake(self: Arc<Self>) { + self.0.unpark(); + } +} + +/// Run a future to completion on the current thread. +fn block_on<T>(fut: impl Future<Output = T>) -> T { + // Pin the future so it can be polled. + let mut fut = Box::pin(fut); + + // Create a new context to be passed to the future. + let t = thread::current(); + let waker = Arc::new(ThreadWaker(t)).into(); + let mut cx = Context::from_waker(&waker); + + // Run the future to completion. + loop { + match fut.as_mut().poll(&mut cx) { + Poll::Ready(res) => return res, + Poll::Pending => thread::park(), + } + } +} + +async fn bar() { + panic!() +} + +async fn foo() { + bar().await +} + +#[track_caller] //[nofeat]~ WARN `#[track_caller]` on async functions is a no-op +async fn bar_track_caller() { + panic!() +} + +async fn foo_track_caller() { + bar_track_caller().await +} + +struct Foo; + +impl Foo { + #[track_caller] //[nofeat]~ WARN `#[track_caller]` on async functions is a no-op + async fn bar_assoc() { + panic!(); + } +} + +async fn foo_assoc() { + Foo::bar_assoc().await +} + +fn panicked_at(f: impl FnOnce() + panic::UnwindSafe) -> u32 { + let loc = Arc::new(Mutex::new(None)); + + let hook = panic::take_hook(); + { + let loc = loc.clone(); + panic::set_hook(Box::new(move |info| { + *loc.lock().unwrap() = info.location().map(|loc| loc.line()) + })); + } + panic::catch_unwind(f).unwrap_err(); + panic::set_hook(hook); + let x = loc.lock().unwrap().unwrap(); + x +} + +fn main() { + assert_eq!(panicked_at(|| block_on(foo())), 43); + + #[cfg(feat)] + assert_eq!(panicked_at(|| block_on(foo_track_caller())), 56); + #[cfg(nofeat)] + assert_eq!(panicked_at(|| block_on(foo_track_caller())), 52); + + #[cfg(feat)] + assert_eq!(panicked_at(|| block_on(foo_assoc())), 69); + #[cfg(nofeat)] + assert_eq!(panicked_at(|| block_on(foo_assoc())), 64); +} diff --git a/src/test/ui/async-await/try-on-option-in-async.stderr b/src/test/ui/async-await/try-on-option-in-async.stderr index a55850d76..4c7b4fa41 100644 --- a/src/test/ui/async-await/try-on-option-in-async.stderr +++ b/src/test/ui/async-await/try-on-option-in-async.stderr @@ -1,8 +1,7 @@ error[E0277]: the `?` operator can only be used in an async block that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/try-on-option-in-async.rs:8:10 | -LL | async { - | ___________- +LL | / async { LL | | let x: Option<u32> = None; LL | | x?; | | ^ cannot use the `?` operator in an async block that returns `{integer}` diff --git a/src/test/ui/attributes/key-value-non-ascii.rs b/src/test/ui/attributes/key-value-non-ascii.rs index 12942eabd..e14e2fc05 100644 --- a/src/test/ui/attributes/key-value-non-ascii.rs +++ b/src/test/ui/attributes/key-value-non-ascii.rs @@ -1,4 +1,4 @@ #![feature(rustc_attrs)] -#[rustc_dummy = b"ffi.rs"] //~ ERROR non-ASCII character in byte constant +#[rustc_dummy = b"ffi.rs"] //~ ERROR non-ASCII character in byte string literal fn main() {} diff --git a/src/test/ui/attributes/key-value-non-ascii.stderr b/src/test/ui/attributes/key-value-non-ascii.stderr index 422107867..23d482de6 100644 --- a/src/test/ui/attributes/key-value-non-ascii.stderr +++ b/src/test/ui/attributes/key-value-non-ascii.stderr @@ -1,8 +1,8 @@ -error: non-ASCII character in byte constant +error: non-ASCII character in byte string literal --> $DIR/key-value-non-ascii.rs:3:19 | LL | #[rustc_dummy = b"ffi.rs"] - | ^ byte constant must be ASCII + | ^ must be ASCII | help: if you meant to use the UTF-8 encoding of 'ffi', use \xHH escapes | diff --git a/src/test/ui/attributes/unused-item-in-attr.rs b/src/test/ui/attributes/unused-item-in-attr.rs new file mode 100644 index 000000000..70dcd5413 --- /dev/null +++ b/src/test/ui/attributes/unused-item-in-attr.rs @@ -0,0 +1,6 @@ +#[w = { extern crate alloc; }] +//~^ ERROR unexpected expression: `{ +//~| ERROR cannot find attribute `w` in this scope +fn f() {} + +fn main() {} diff --git a/src/test/ui/attributes/unused-item-in-attr.stderr b/src/test/ui/attributes/unused-item-in-attr.stderr new file mode 100644 index 000000000..92a8f5858 --- /dev/null +++ b/src/test/ui/attributes/unused-item-in-attr.stderr @@ -0,0 +1,16 @@ +error: unexpected expression: `{ + extern crate alloc; + }` + --> $DIR/unused-item-in-attr.rs:1:7 + | +LL | #[w = { extern crate alloc; }] + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: cannot find attribute `w` in this scope + --> $DIR/unused-item-in-attr.rs:1:3 + | +LL | #[w = { extern crate alloc; }] + | ^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/auto-traits/bad-generics-on-dyn.rs b/src/test/ui/auto-traits/bad-generics-on-dyn.rs new file mode 100644 index 000000000..3f8ac14c7 --- /dev/null +++ b/src/test/ui/auto-traits/bad-generics-on-dyn.rs @@ -0,0 +1,11 @@ +#![feature(auto_traits)] + +auto trait Trait1<'a> {} +//~^ ERROR auto traits cannot have generic parameters + +fn f<'a>(x: &dyn Trait1<'a>) +{} + +fn main() { + f(&1); +} diff --git a/src/test/ui/auto-traits/bad-generics-on-dyn.stderr b/src/test/ui/auto-traits/bad-generics-on-dyn.stderr new file mode 100644 index 000000000..ade69ced6 --- /dev/null +++ b/src/test/ui/auto-traits/bad-generics-on-dyn.stderr @@ -0,0 +1,11 @@ +error[E0567]: auto traits cannot have generic parameters + --> $DIR/bad-generics-on-dyn.rs:3:18 + | +LL | auto trait Trait1<'a> {} + | ------^^^^ help: remove the parameters + | | + | auto trait cannot have generic parameters + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0567`. diff --git a/src/test/ui/binding/issue-53114-borrow-checks.stderr b/src/test/ui/binding/issue-53114-borrow-checks.stderr index 489bf70d9..0ec2ae883 100644 --- a/src/test/ui/binding/issue-53114-borrow-checks.stderr +++ b/src/test/ui/binding/issue-53114-borrow-checks.stderr @@ -17,6 +17,10 @@ LL | match mm { (_, _y) => { } } | ^^ value used here after partial move | = note: partial move occurs because `mm.0` has type `M`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | match mm { (ref _x, _) => { } } + | +++ error[E0382]: use of partially moved value: `mm` --> $DIR/issue-53114-borrow-checks.rs:29:11 @@ -28,6 +32,10 @@ LL | match mm { (_, _) => { } } | ^^ value used here after partial move | = note: partial move occurs because `mm.1` has type `M`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | match mm { (_, ref _y) => { } } + | +++ error[E0382]: use of moved value: `m` --> $DIR/issue-53114-borrow-checks.rs:36:16 @@ -48,6 +56,10 @@ LL | if let (_, _y) = mm { } | ^^ value used here after partial move | = note: partial move occurs because `mm.0` has type `M`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | if let (ref _x, _) = mm { } + | +++ error[E0382]: use of partially moved value: `mm` --> $DIR/issue-53114-borrow-checks.rs:43:21 @@ -59,6 +71,10 @@ LL | if let (_, _) = mm { } | ^^ value used here after partial move | = note: partial move occurs because `mm.1` has type `M`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | if let (_, ref _y) = mm { } + | +++ error: aborting due to 6 previous errors diff --git a/src/test/ui/binop/binop-move-semantics.stderr b/src/test/ui/binop/binop-move-semantics.stderr index 695b01d5e..994eaf9d8 100644 --- a/src/test/ui/binop/binop-move-semantics.stderr +++ b/src/test/ui/binop/binop-move-semantics.stderr @@ -32,6 +32,10 @@ LL | + LL | x.clone(); | ^^^^^^^^^ value borrowed here after move | +help: consider cloning the value if the performance cost is acceptable + | +LL | x.clone() + | ++++++++ help: consider further restricting this bound | LL | fn move_then_borrow<T: Add<Output=()> + Clone + Copy>(x: T) { diff --git a/src/test/ui/binop/binop-mul-i32-f32.stderr b/src/test/ui/binop/binop-mul-i32-f32.stderr index 21c490965..c986bc3fd 100644 --- a/src/test/ui/binop/binop-mul-i32-f32.stderr +++ b/src/test/ui/binop/binop-mul-i32-f32.stderr @@ -6,15 +6,10 @@ LL | x * y | = help: the trait `Mul<f32>` is not implemented for `i32` = help: the following other types implement trait `Mul<Rhs>`: - <&'a f32 as Mul<f32>> - <&'a f64 as Mul<f64>> - <&'a i128 as Mul<i128>> - <&'a i16 as Mul<i16>> <&'a i32 as Mul<i32>> - <&'a i64 as Mul<i64>> - <&'a i8 as Mul<i8>> - <&'a isize as Mul<isize>> - and 49 others + <&i32 as Mul<&i32>> + <i32 as Mul<&i32>> + <i32 as Mul> error: aborting due to previous error diff --git a/src/test/ui/borrowck/async-reference-generality.rs b/src/test/ui/borrowck/async-reference-generality.rs new file mode 100644 index 000000000..487d1ac81 --- /dev/null +++ b/src/test/ui/borrowck/async-reference-generality.rs @@ -0,0 +1,35 @@ +// check-fail +// known-bug: #99492 +// edition: 2021 + +use std::marker::PhantomData; + +pub struct Struct<I, T>(PhantomData<fn() -> <Self as It>::Item>) +where + Self: It; + +impl<I> It for Struct<I, I::Item> +where + I: It, +{ + type Item = (); +} + +pub trait It { + type Item; +} + +fn f() -> impl Send { + async { + let _x = Struct::<Empty<&'static ()>, _>(PhantomData); + async {}.await; + } +} + +pub struct Empty<T>(PhantomData<fn() -> T>); + +impl<T> It for Empty<T> { + type Item = T; +} + +fn main() {} diff --git a/src/test/ui/borrowck/async-reference-generality.stderr b/src/test/ui/borrowck/async-reference-generality.stderr new file mode 100644 index 000000000..af720ad29 --- /dev/null +++ b/src/test/ui/borrowck/async-reference-generality.stderr @@ -0,0 +1,27 @@ +error[E0308]: mismatched types + --> $DIR/async-reference-generality.rs:23:5 + | +LL | / async { +LL | | let _x = Struct::<Empty<&'static ()>, _>(PhantomData); +LL | | async {}.await; +LL | | } + | |_____^ one type is more general than the other + | + = note: expected reference `&()` + found reference `&()` + +error[E0308]: mismatched types + --> $DIR/async-reference-generality.rs:23:5 + | +LL | / async { +LL | | let _x = Struct::<Empty<&'static ()>, _>(PhantomData); +LL | | async {}.await; +LL | | } + | |_____^ one type is more general than the other + | + = note: expected reference `&()` + found reference `&()` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/borrowck/bindings-after-at-or-patterns-slice-patterns-box-patterns.stderr b/src/test/ui/borrowck/bindings-after-at-or-patterns-slice-patterns-box-patterns.stderr index 1fd1eb128..50eee1049 100644 --- a/src/test/ui/borrowck/bindings-after-at-or-patterns-slice-patterns-box-patterns.stderr +++ b/src/test/ui/borrowck/bindings-after-at-or-patterns-slice-patterns-box-patterns.stderr @@ -27,6 +27,11 @@ LL | a @ [.., _] => (), ... LL | &x; | ^^ value borrowed here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref a @ [.., _] => (), + | +++ error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable --> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:28:5 @@ -71,13 +76,15 @@ LL | fn bindings_after_at_or_patterns_move(x: Option<Test>) { | - move occurs because `x` has type `Option<Test>`, which does not implement the `Copy` trait LL | match x { LL | foo @ Some(Test::Foo | Test::Bar) => (), - | --- - | | - | value moved here - | value moved here + | --- value moved here ... LL | &x; | ^^ value borrowed here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref foo @ Some(Test::Foo | Test::Bar) => (), + | +++ error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable --> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:86:5 @@ -122,13 +129,15 @@ LL | fn bindings_after_at_slice_patterns_or_patterns_moves(x: [Option<Test>; 4]) | - move occurs because `x` has type `[Option<Test>; 4]`, which does not implement the `Copy` trait LL | match x { LL | a @ [.., Some(Test::Foo | Test::Bar)] => (), - | - - | | - | value moved here - | value moved here + | - value moved here ... LL | &x; | ^^ value borrowed here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref a @ [.., Some(Test::Foo | Test::Bar)] => (), + | +++ error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable --> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:144:5 diff --git a/src/test/ui/borrowck/borrow-immutable-upvar-mutation.rs b/src/test/ui/borrowck/borrow-immutable-upvar-mutation.rs index e2f016614..a3350024e 100644 --- a/src/test/ui/borrowck/borrow-immutable-upvar-mutation.rs +++ b/src/test/ui/borrowck/borrow-immutable-upvar-mutation.rs @@ -1,4 +1,4 @@ -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] // Tests that we can't assign to or mutably borrow upvars from `Fn` // closures (issue #17780) @@ -7,10 +7,10 @@ fn set(x: &mut usize) { *x = 5; } -fn to_fn<A, F: Fn<A>>(f: F) -> F { +fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F { f } -fn to_fn_mut<A, F: FnMut<A>>(f: F) -> F { +fn to_fn_mut<A: std::marker::Tuple, F: FnMut<A>>(f: F) -> F { f } diff --git a/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr b/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr index 093589ed0..a0eaf1f16 100644 --- a/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr +++ b/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr @@ -1,8 +1,8 @@ error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation.rs:21:27 | -LL | fn to_fn<A, F: Fn<A>>(f: F) -> F { - | - change this to accept `FnMut` instead of `Fn` +LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F { + | - change this to accept `FnMut` instead of `Fn` ... LL | let _f = to_fn(|| x = 42); | ----- -- ^^^^^^ cannot assign @@ -13,8 +13,8 @@ LL | let _f = to_fn(|| x = 42); error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation.rs:24:31 | -LL | fn to_fn<A, F: Fn<A>>(f: F) -> F { - | - change this to accept `FnMut` instead of `Fn` +LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F { + | - change this to accept `FnMut` instead of `Fn` ... LL | let _g = to_fn(|| set(&mut y)); | ----- -- ^^^^^^ cannot borrow as mutable @@ -25,8 +25,8 @@ LL | let _g = to_fn(|| set(&mut y)); error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation.rs:29:22 | -LL | fn to_fn<A, F: Fn<A>>(f: F) -> F { - | - change this to accept `FnMut` instead of `Fn` +LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F { + | - change this to accept `FnMut` instead of `Fn` ... LL | to_fn(|| z = 42); | ----- -- ^^^^^^ cannot assign @@ -37,8 +37,8 @@ LL | to_fn(|| z = 42); error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation.rs:36:32 | -LL | fn to_fn<A, F: Fn<A>>(f: F) -> F { - | - change this to accept `FnMut` instead of `Fn` +LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F { + | - change this to accept `FnMut` instead of `Fn` ... LL | let _f = to_fn(move || x = 42); | ----- ------- ^^^^^^ cannot assign @@ -49,8 +49,8 @@ LL | let _f = to_fn(move || x = 42); error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation.rs:39:36 | -LL | fn to_fn<A, F: Fn<A>>(f: F) -> F { - | - change this to accept `FnMut` instead of `Fn` +LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F { + | - change this to accept `FnMut` instead of `Fn` ... LL | let _g = to_fn(move || set(&mut y)); | ----- ------- ^^^^^^ cannot borrow as mutable @@ -61,8 +61,8 @@ LL | let _g = to_fn(move || set(&mut y)); error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation.rs:44:27 | -LL | fn to_fn<A, F: Fn<A>>(f: F) -> F { - | - change this to accept `FnMut` instead of `Fn` +LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F { + | - change this to accept `FnMut` instead of `Fn` ... LL | to_fn(move || z = 42); | ----- ------- ^^^^^^ cannot assign diff --git a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr index a6af129bf..4eeec09b9 100644 --- a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr +++ b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr @@ -4,7 +4,7 @@ error[E0716]: temporary value dropped while borrowed LL | let x = defer(&vec!["Goodbye", "world!"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | creates a temporary which is freed while still in use + | creates a temporary value which is freed while still in use LL | x.x[0]; | ------ borrow later used here | diff --git a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.stderr b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.stderr index dea8ac90b..c62d5f903 100644 --- a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.stderr +++ b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.stderr @@ -4,7 +4,7 @@ error[E0716]: temporary value dropped while borrowed LL | buggy_map.insert(42, &*Box::new(1)); | ^^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | creates a temporary which is freed while still in use + | creates a temporary value which is freed while still in use ... LL | buggy_map.insert(43, &*tmp); | --------------------------- borrow later used here diff --git a/src/test/ui/borrowck/borrowck-consume-unsize-vec.stderr b/src/test/ui/borrowck/borrowck-consume-unsize-vec.stderr index 17b931066..d2e9497d0 100644 --- a/src/test/ui/borrowck/borrowck-consume-unsize-vec.stderr +++ b/src/test/ui/borrowck/borrowck-consume-unsize-vec.stderr @@ -7,6 +7,18 @@ LL | consume(b); | - value moved here LL | consume(b); | ^ value used here after move + | +note: consider changing this parameter type in function `consume` to borrow instead if owning the value isn't necessary + --> $DIR/borrowck-consume-unsize-vec.rs:3:15 + | +LL | fn consume(_: Box<[i32]>) { + | ------- ^^^^^^^^^^ this parameter takes ownership of the value + | | + | in this function +help: consider cloning the value if the performance cost is acceptable + | +LL | consume(b.clone()); + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr b/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr index 4e20bbf17..ed7e883ca 100644 --- a/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr +++ b/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr @@ -7,6 +7,14 @@ LL | consume(b); | - value moved here LL | consume(b); | ^ value used here after move + | +note: consider changing this parameter type in function `consume` to borrow instead if owning the value isn't necessary + --> $DIR/borrowck-consume-upcast-box.rs:5:15 + | +LL | fn consume(_: Box<dyn Foo>) { + | ------- ^^^^^^^^^^^^ this parameter takes ownership of the value + | | + | in this function error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-drop-from-guard.stderr b/src/test/ui/borrowck/borrowck-drop-from-guard.stderr index cd0d2fee9..eaf4bb38b 100644 --- a/src/test/ui/borrowck/borrowck-drop-from-guard.stderr +++ b/src/test/ui/borrowck/borrowck-drop-from-guard.stderr @@ -9,6 +9,11 @@ LL | Some(_) if { drop(my_str); false } => {} LL | Some(_) => {} LL | None => { foo(my_str); } | ^^^^^^ value used here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | Some(_) if { drop(my_str.clone()); false } => {} + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.stderr b/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.stderr index 0dd720ff6..e1b991620 100644 --- a/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.stderr +++ b/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.stderr @@ -7,6 +7,11 @@ LL | let _y = {x} + x.clone(); // the `{x}` forces a move to occur | - ^^^^^^^^^ value borrowed here after move | | | value moved here + | +help: consider cloning the value if the performance cost is acceptable + | +LL | let _y = {x.clone()} + x.clone(); // the `{x}` forces a move to occur + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-move-by-capture.rs b/src/test/ui/borrowck/borrowck-move-by-capture.rs index f26edef17..6f0eb1870 100644 --- a/src/test/ui/borrowck/borrowck-move-by-capture.rs +++ b/src/test/ui/borrowck/borrowck-move-by-capture.rs @@ -1,7 +1,7 @@ -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] -fn to_fn_mut<A,F:FnMut<A>>(f: F) -> F { f } -fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f } +fn to_fn_mut<A:std::marker::Tuple,F:FnMut<A>>(f: F) -> F { f } +fn to_fn_once<A:std::marker::Tuple,F:FnOnce<A>>(f: F) -> F { f } pub fn main() { let bar: Box<_> = Box::new(3); diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-match.stderr b/src/test/ui/borrowck/borrowck-move-out-from-array-match.stderr index 346b82a26..67b00c1dd 100644 --- a/src/test/ui/borrowck/borrowck-move-out-from-array-match.stderr +++ b/src/test/ui/borrowck/borrowck-move-out-from-array-match.stderr @@ -8,6 +8,10 @@ LL | [.., _y] => {} | ^^ value used here after move | = note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [_, _, ref _x] => {} + | +++ error[E0382]: use of partially moved value: `a[..]` --> $DIR/borrowck-move-out-from-array-match.rs:23:14 @@ -19,6 +23,10 @@ LL | [.., _y] => {} | ^^ value used here after partial move | = note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [_, _, (ref _x, _)] => {} + | +++ error[E0382]: use of moved value: `a[..].0` --> $DIR/borrowck-move-out-from-array-match.rs:33:15 @@ -30,6 +38,10 @@ LL | [.., (_y, _)] => {} | ^^ value used here after move | = note: move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [_, _, (ref _x, _)] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-match.rs:44:11 @@ -41,6 +53,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [ref _x, _, _] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-match.rs:55:11 @@ -52,6 +68,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [.., ref _x] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-match.rs:66:11 @@ -63,6 +83,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [(ref _x, _), _, _] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-match.rs:77:11 @@ -74,6 +98,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [.., (ref _x, _)] => {} + | +++ error[E0382]: use of moved value: `a[..].0` --> $DIR/borrowck-move-out-from-array-match.rs:89:11 @@ -85,6 +113,10 @@ LL | [(_x, _), _, _] => {} | ^^ value used here after move | = note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [ref _y @ .., _, _] => {} + | +++ error[E0382]: use of moved value: `a[..].0` --> $DIR/borrowck-move-out-from-array-match.rs:99:15 @@ -96,6 +128,10 @@ LL | [.., (_x, _)] => {} | ^^ value used here after move | = note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [_, _, ref _y @ ..] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-match.rs:110:11 @@ -107,6 +143,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [ref x @ .., _] => {} + | +++ error: aborting due to 10 previous errors diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-no-overlap-match.stderr b/src/test/ui/borrowck/borrowck-move-out-from-array-no-overlap-match.stderr index 6c6a25c25..47429ea3e 100644 --- a/src/test/ui/borrowck/borrowck-move-out-from-array-no-overlap-match.stderr +++ b/src/test/ui/borrowck/borrowck-move-out-from-array-no-overlap-match.stderr @@ -8,6 +8,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [_, _, ref _x] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:28:11 @@ -19,6 +23,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [_, _, (ref _x, _)] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:41:11 @@ -30,6 +38,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [ref _x, _, _] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:52:11 @@ -41,6 +53,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [.., ref _x] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:63:11 @@ -52,6 +68,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [(ref _x, _), _, _] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:74:11 @@ -63,6 +83,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [.., (ref _x, _)] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:85:11 @@ -74,6 +98,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [_, ref _y @ ..] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:96:11 @@ -85,6 +113,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [ref _y @ .., _] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:109:11 @@ -96,6 +128,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [ref x @ .., _, _] => {} + | +++ error: aborting due to 9 previous errors diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-use-match.stderr b/src/test/ui/borrowck/borrowck-move-out-from-array-use-match.stderr index 77702e145..bfab13d42 100644 --- a/src/test/ui/borrowck/borrowck-move-out-from-array-use-match.stderr +++ b/src/test/ui/borrowck/borrowck-move-out-from-array-use-match.stderr @@ -8,6 +8,10 @@ LL | [.., ref _y] => {} | ^^^^^^ value borrowed here after move | = note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [_, _, ref _x] => {} + | +++ error[E0382]: borrow of partially moved value: `a[..]` --> $DIR/borrowck-move-out-from-array-use-match.rs:23:14 @@ -19,6 +23,10 @@ LL | [.., ref _y] => {} | ^^^^^^ value borrowed here after partial move | = note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [_, _, (ref _x, _)] => {} + | +++ error[E0382]: borrow of moved value: `a[..].0` --> $DIR/borrowck-move-out-from-array-use-match.rs:33:15 @@ -30,6 +38,10 @@ LL | [.., (ref _y, _)] => {} | ^^^^^^ value borrowed here after move | = note: move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [_, _, (ref _x, _)] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use-match.rs:44:11 @@ -41,6 +53,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [ref _x, _, _] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use-match.rs:55:11 @@ -52,6 +68,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [.., ref _x] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use-match.rs:66:11 @@ -63,6 +83,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [(ref _x, _), _, _] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use-match.rs:77:11 @@ -74,6 +98,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [.., (ref _x, _)] => {} + | +++ error[E0382]: borrow of moved value: `a[..]` --> $DIR/borrowck-move-out-from-array-use-match.rs:89:11 @@ -85,6 +113,10 @@ LL | [(ref _x, _), _, _] => {} | ^^^^^^ value borrowed here after move | = note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [ref _y @ .., _, _] => {} + | +++ error[E0382]: borrow of moved value: `a[..]` --> $DIR/borrowck-move-out-from-array-use-match.rs:99:15 @@ -96,6 +128,10 @@ LL | [.., (ref _x, _)] => {} | ^^^^^^ value borrowed here after move | = note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [_, _, ref _y @ ..] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use-match.rs:110:11 @@ -107,6 +143,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [ref x @ .., _] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use-match.rs:123:5 @@ -118,6 +158,10 @@ LL | a[2] = Default::default(); | ^^^^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [_, _, ref _x] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use-match.rs:131:5 @@ -129,6 +173,10 @@ LL | a[2].1 = Default::default(); | ^^^^ value used here after partial move | = note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [_, _, (ref _x, _)] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use-match.rs:139:5 @@ -140,6 +188,10 @@ LL | a[0] = Default::default(); | ^^^^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [_, _, ref _x @ ..] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use-match.rs:147:5 @@ -151,6 +203,10 @@ LL | a[0].1 = Default::default(); | ^^^^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [_, _, ref _x @ ..] => {} + | +++ error: aborting due to 14 previous errors diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap-match.stderr b/src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap-match.stderr index 6cc2c2f7a..8412c24fe 100644 --- a/src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap-match.stderr +++ b/src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap-match.stderr @@ -8,6 +8,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [_, _, ref _x] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:28:11 @@ -19,6 +23,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [_, _, (ref _x, _)] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:41:11 @@ -30,6 +38,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [ref _x, _, _] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:52:11 @@ -41,6 +53,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [.., ref _x] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:63:11 @@ -52,6 +68,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [(ref _x, _), _, _] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:74:11 @@ -63,6 +83,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [.., (ref _x, _)] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:85:11 @@ -74,6 +98,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [_, ref _y @ ..] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:96:11 @@ -85,6 +113,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [ref _y @ .., _] => {} + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:109:11 @@ -96,6 +128,10 @@ LL | match a { | ^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | [ref x @ .., _, _] => {} + | +++ error: aborting due to 9 previous errors diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-use.stderr b/src/test/ui/borrowck/borrowck-move-out-from-array-use.stderr index 9add7553a..e2aeaafc6 100644 --- a/src/test/ui/borrowck/borrowck-move-out-from-array-use.stderr +++ b/src/test/ui/borrowck/borrowck-move-out-from-array-use.stderr @@ -7,6 +7,10 @@ LL | let [.., ref _y] = a; | ^^^^^^ value borrowed here after move | = note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [_, _, ref _x] = a; + | +++ error[E0382]: borrow of partially moved value: `a[..]` --> $DIR/borrowck-move-out-from-array-use.rs:16:14 @@ -17,6 +21,10 @@ LL | let [.., ref _y] = a; | ^^^^^^ value borrowed here after partial move | = note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [_, _, (ref _x, _)] = a; + | +++ error[E0382]: borrow of moved value: `a[..].0` --> $DIR/borrowck-move-out-from-array-use.rs:22:15 @@ -27,6 +35,10 @@ LL | let [.., (ref _y, _)] = a; | ^^^^^^ value borrowed here after move | = note: move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [_, _, (ref _x, _)] = a; + | +++ error[E0382]: borrow of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use.rs:30:10 @@ -37,6 +49,10 @@ LL | let [ref _y @ .., _, _] = a; | ^^^^^^ value borrowed here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [ref _x, _, _] = a; + | +++ error[E0382]: borrow of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use.rs:36:16 @@ -47,6 +63,10 @@ LL | let [_, _, ref _y @ ..] = a; | ^^^^^^ value borrowed here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [.., ref _x] = a; + | +++ error[E0382]: borrow of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use.rs:42:10 @@ -57,6 +77,10 @@ LL | let [ref _y @ .., _, _] = a; | ^^^^^^ value borrowed here after partial move | = note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [(ref _x, _), _, _] = a; + | +++ error[E0382]: borrow of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use.rs:48:16 @@ -67,6 +91,10 @@ LL | let [_, _, ref _y @ ..] = a; | ^^^^^^ value borrowed here after partial move | = note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [.., (ref _x, _)] = a; + | +++ error[E0382]: borrow of moved value: `a[..]` --> $DIR/borrowck-move-out-from-array-use.rs:54:11 @@ -77,6 +105,10 @@ LL | let [(ref _x, _), _, _] = a; | ^^^^^^ value borrowed here after move | = note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [ref _y @ .., _, _] = a; + | +++ error[E0382]: borrow of moved value: `a[..]` --> $DIR/borrowck-move-out-from-array-use.rs:60:15 @@ -87,6 +119,10 @@ LL | let [.., (ref _x, _)] = a; | ^^^^^^ value borrowed here after move | = note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [_, _, ref _y @ ..] = a; + | +++ error[E0382]: borrow of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use.rs:68:13 @@ -97,6 +133,10 @@ LL | let [_, ref _y @ ..] = a; | ^^^^^^ value borrowed here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [ref x @ .., _] = a; + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use.rs:76:5 @@ -107,6 +147,10 @@ LL | a[2] = Default::default(); | ^^^^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [_, _, ref _x] = a; + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use.rs:82:5 @@ -117,6 +161,10 @@ LL | a[2].1 = Default::default(); | ^^^^ value used here after partial move | = note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [_, _, (ref _x, _)] = a; + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use.rs:88:5 @@ -127,6 +175,10 @@ LL | a[0] = Default::default(); | ^^^^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [_, _, ref _x @ ..] = a; + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array-use.rs:94:5 @@ -137,6 +189,10 @@ LL | a[0].1 = Default::default(); | ^^^^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [_, _, ref _x @ ..] = a; + | +++ error: aborting due to 14 previous errors diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array.stderr b/src/test/ui/borrowck/borrowck-move-out-from-array.stderr index 363effcfe..dd456681f 100644 --- a/src/test/ui/borrowck/borrowck-move-out-from-array.stderr +++ b/src/test/ui/borrowck/borrowck-move-out-from-array.stderr @@ -7,6 +7,10 @@ LL | let [.., _y] = a; | ^^ value used here after move | = note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [_, _, ref _x] = a; + | +++ error[E0382]: use of partially moved value: `a[..]` --> $DIR/borrowck-move-out-from-array.rs:16:14 @@ -17,6 +21,10 @@ LL | let [.., _y] = a; | ^^ value used here after partial move | = note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [_, _, (ref _x, _)] = a; + | +++ error[E0382]: use of moved value: `a[..].0` --> $DIR/borrowck-move-out-from-array.rs:22:15 @@ -27,6 +35,10 @@ LL | let [.., (_y, _)] = a; | ^^ value used here after move | = note: move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [_, _, (ref _x, _)] = a; + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array.rs:30:10 @@ -37,6 +49,10 @@ LL | let [_y @ .., _, _] = a; | ^^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [ref _x, _, _] = a; + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array.rs:36:16 @@ -47,6 +63,10 @@ LL | let [_, _, _y @ ..] = a; | ^^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [.., ref _x] = a; + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array.rs:42:10 @@ -57,6 +77,10 @@ LL | let [_y @ .., _, _] = a; | ^^ value used here after partial move | = note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [(ref _x, _), _, _] = a; + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array.rs:48:16 @@ -67,6 +91,10 @@ LL | let [_, _, _y @ ..] = a; | ^^ value used here after partial move | = note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [.., (ref _x, _)] = a; + | +++ error[E0382]: use of moved value: `a[..].0` --> $DIR/borrowck-move-out-from-array.rs:54:11 @@ -77,6 +105,10 @@ LL | let [(_x, _), _, _] = a; | ^^ value used here after move | = note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [ref _y @ .., _, _] = a; + | +++ error[E0382]: use of moved value: `a[..].0` --> $DIR/borrowck-move-out-from-array.rs:60:15 @@ -87,6 +119,10 @@ LL | let [.., (_x, _)] = a; | ^^ value used here after move | = note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [_, _, ref _y @ ..] = a; + | +++ error[E0382]: use of partially moved value: `a` --> $DIR/borrowck-move-out-from-array.rs:68:13 @@ -97,6 +133,10 @@ LL | let [_, _y @ ..] = a; | ^^ value used here after partial move | = note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let [ref x @ .., _] = a; + | +++ error: aborting due to 10 previous errors diff --git a/src/test/ui/borrowck/borrowck-multiple-captures.stderr b/src/test/ui/borrowck/borrowck-multiple-captures.stderr index 86d2955e2..f94cbc30d 100644 --- a/src/test/ui/borrowck/borrowck-multiple-captures.stderr +++ b/src/test/ui/borrowck/borrowck-multiple-captures.stderr @@ -40,6 +40,11 @@ LL | thread::spawn(move|| { ... LL | drop(x1); | -- use occurs due to use in closure + | +help: consider cloning the value if the performance cost is acceptable + | +LL | drop(x1.clone()); + | ++++++++ error[E0382]: use of moved value: `x2` --> $DIR/borrowck-multiple-captures.rs:27:19 @@ -53,6 +58,11 @@ LL | thread::spawn(move|| { ... LL | drop(x2); | -- use occurs due to use in closure + | +help: consider cloning the value if the performance cost is acceptable + | +LL | drop(x2.clone()); + | ++++++++ error[E0382]: use of moved value: `x` --> $DIR/borrowck-multiple-captures.rs:41:14 @@ -100,6 +110,11 @@ LL | thread::spawn(move|| { LL | LL | drop(x); | - use occurs due to use in closure + | +help: consider cloning the value if the performance cost is acceptable + | +LL | drop(x.clone()); + | ++++++++ error: aborting due to 8 previous errors diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-move-index.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-move-index.stderr index e01c26adc..fb0e274c2 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-move-index.stderr +++ b/src/test/ui/borrowck/borrowck-overloaded-index-move-index.stderr @@ -33,6 +33,11 @@ LL | println!("{}", f[s]); ... LL | f[s] = 10; | ^ value used here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | println!("{}", f[s.clone()]); + | ++++++++ error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/borrowck-reinit.stderr b/src/test/ui/borrowck/borrowck-reinit.stderr index 22253cd96..f785900d5 100644 --- a/src/test/ui/borrowck/borrowck-reinit.stderr +++ b/src/test/ui/borrowck/borrowck-reinit.stderr @@ -8,6 +8,11 @@ LL | drop(x); | - value moved here LL | let _ = (1,x); | ^ value used here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | drop(x.clone()); + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/borrowck/issue-11493.stderr b/src/test/ui/borrowck/issue-11493.stderr index a5d1f2816..2720b09b0 100644 --- a/src/test/ui/borrowck/issue-11493.stderr +++ b/src/test/ui/borrowck/issue-11493.stderr @@ -4,7 +4,7 @@ error[E0716]: temporary value dropped while borrowed LL | let y = x.as_ref().unwrap_or(&id(5)); | ^^^^^ - temporary value is freed at the end of this statement | | - | creates a temporary which is freed while still in use + | creates a temporary value which is freed while still in use LL | let _ = &y; | -- borrow later used here | diff --git a/src/test/ui/borrowck/issue-17545.stderr b/src/test/ui/borrowck/issue-17545.stderr index 79a1e09bd..3ae7e64d2 100644 --- a/src/test/ui/borrowck/issue-17545.stderr +++ b/src/test/ui/borrowck/issue-17545.stderr @@ -5,7 +5,7 @@ LL | pub fn foo<'a, F: Fn(&'a ())>(bar: F) { | -- lifetime `'a` defined here LL | / bar.call(( LL | | &id(()), - | | ^^^^^^ creates a temporary which is freed while still in use + | | ^^^^^^ creates a temporary value which is freed while still in use LL | | )); | | -- temporary value is freed at the end of this statement | |______| diff --git a/src/test/ui/borrowck/issue-31287-drop-in-guard.stderr b/src/test/ui/borrowck/issue-31287-drop-in-guard.stderr index d33115988..ad898fcab 100644 --- a/src/test/ui/borrowck/issue-31287-drop-in-guard.stderr +++ b/src/test/ui/borrowck/issue-31287-drop-in-guard.stderr @@ -8,6 +8,11 @@ LL | Some(_) if { drop(a); false } => None, | - value moved here LL | x => x, | ^ value used here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | Some(_) if { drop(a.clone()); false } => None, + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/borrowck/issue-36082.fixed b/src/test/ui/borrowck/issue-36082.fixed index 8640ca7a5..8fc963a85 100644 --- a/src/test/ui/borrowck/issue-36082.fixed +++ b/src/test/ui/borrowck/issue-36082.fixed @@ -10,7 +10,7 @@ fn main() { let val: &_ = binding.0; //~^ ERROR temporary value dropped while borrowed [E0716] //~| NOTE temporary value is freed at the end of this statement - //~| NOTE creates a temporary which is freed while still in use + //~| NOTE creates a temporary value which is freed while still in use //~| HELP consider using a `let` binding to create a longer lived value println!("{}", val); //~^ borrow later used here diff --git a/src/test/ui/borrowck/issue-36082.rs b/src/test/ui/borrowck/issue-36082.rs index 877d372fb..20f66b4d4 100644 --- a/src/test/ui/borrowck/issue-36082.rs +++ b/src/test/ui/borrowck/issue-36082.rs @@ -9,7 +9,7 @@ fn main() { let val: &_ = x.borrow().0; //~^ ERROR temporary value dropped while borrowed [E0716] //~| NOTE temporary value is freed at the end of this statement - //~| NOTE creates a temporary which is freed while still in use + //~| NOTE creates a temporary value which is freed while still in use //~| HELP consider using a `let` binding to create a longer lived value println!("{}", val); //~^ borrow later used here diff --git a/src/test/ui/borrowck/issue-36082.stderr b/src/test/ui/borrowck/issue-36082.stderr index 4bd586db1..a6357f818 100644 --- a/src/test/ui/borrowck/issue-36082.stderr +++ b/src/test/ui/borrowck/issue-36082.stderr @@ -4,7 +4,7 @@ error[E0716]: temporary value dropped while borrowed LL | let val: &_ = x.borrow().0; | ^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | creates a temporary which is freed while still in use + | creates a temporary value which is freed while still in use ... LL | println!("{}", val); | --- borrow later used here diff --git a/src/test/ui/borrowck/issue-41962.stderr b/src/test/ui/borrowck/issue-41962.stderr index b20cc6d8c..716cc9d0c 100644 --- a/src/test/ui/borrowck/issue-41962.stderr +++ b/src/test/ui/borrowck/issue-41962.stderr @@ -5,7 +5,7 @@ LL | if let Some(thing) = maybe { | ^^^^^ value moved here, in previous iteration of loop | = note: move occurs because value has type `Vec<bool>`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving `maybe.0` +help: borrow this binding in the pattern to avoid moving the value | LL | if let Some(ref thing) = maybe { | +++ diff --git a/src/test/ui/borrowck/issue-81899.rs b/src/test/ui/borrowck/issue-81899.rs index 24b20b650..1f1af5c7e 100644 --- a/src/test/ui/borrowck/issue-81899.rs +++ b/src/test/ui/borrowck/issue-81899.rs @@ -2,13 +2,14 @@ // The `panic!()` below is important to trigger the fixed ICE. const _CONST: &[u8] = &f(&[], |_| {}); -//~^ ERROR constant +//~^ constant const fn f<F>(_: &[u8], _: F) -> &[u8] where F: FnMut(&u8), { - panic!() //~ ERROR: evaluation of constant value failed + panic!() //~ ERROR evaluation of constant value failed + //~^ panic } fn main() {} diff --git a/src/test/ui/borrowck/issue-81899.stderr b/src/test/ui/borrowck/issue-81899.stderr index 12e80b9df..1b03bc3af 100644 --- a/src/test/ui/borrowck/issue-81899.stderr +++ b/src/test/ui/borrowck/issue-81899.stderr @@ -1,23 +1,27 @@ error[E0080]: evaluation of constant value failed --> $DIR/issue-81899.rs:11:5 | -LL | const _CONST: &[u8] = &f(&[], |_| {}); - | -------------- inside `_CONST` at $DIR/issue-81899.rs:4:24 -... +LL | panic!() + | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/issue-81899.rs:11:5 + | +note: inside `f::<[closure@$DIR/issue-81899.rs:4:31: 4:34]>` + --> $DIR/issue-81899.rs:11:5 + | LL | panic!() | ^^^^^^^^ - | | - | the evaluated program panicked at 'explicit panic', $DIR/issue-81899.rs:11:5 - | inside `f::<[closure@$DIR/issue-81899.rs:4:31: 4:34]>` at $SRC_DIR/std/src/panic.rs:LL:COL +note: inside `_CONST` + --> $DIR/issue-81899.rs:4:24 | +LL | const _CONST: &[u8] = &f(&[], |_| {}); + | ^^^^^^^^^^^^^^ = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/issue-81899.rs:4:23 | LL | const _CONST: &[u8] = &f(&[], |_| {}); - | ^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs b/src/test/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs index 2c8a700bc..dd0320bc5 100644 --- a/src/test/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs +++ b/src/test/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs @@ -17,7 +17,6 @@ async fn buy_lock(generator: &Mutex<MarketMultiplier>) -> LockedMarket<'_> { //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument was supplied //~^^ ERROR this struct takes 1 generic argument but 0 generic arguments were supplied LockedMarket(generator.lock().unwrap().buy()) - //~^ ERROR cannot return value referencing temporary } struct LockedMarket<T>(T); diff --git a/src/test/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr b/src/test/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr index 4bd066730..d2b927fb6 100644 --- a/src/test/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr +++ b/src/test/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr @@ -7,7 +7,7 @@ LL | async fn buy_lock(generator: &Mutex<MarketMultiplier>) -> LockedMarket<'_> | expected 0 lifetime arguments | note: struct defined here, with 0 lifetime parameters - --> $DIR/issue-82126-mismatched-subst-and-hir.rs:23:8 + --> $DIR/issue-82126-mismatched-subst-and-hir.rs:22:8 | LL | struct LockedMarket<T>(T); | ^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | async fn buy_lock(generator: &Mutex<MarketMultiplier>) -> LockedMarket<'_> | ^^^^^^^^^^^^ expected 1 generic argument | note: struct defined here, with 1 generic parameter: `T` - --> $DIR/issue-82126-mismatched-subst-and-hir.rs:23:8 + --> $DIR/issue-82126-mismatched-subst-and-hir.rs:22:8 | LL | struct LockedMarket<T>(T); | ^^^^^^^^^^^^ - @@ -28,16 +28,6 @@ help: add missing generic argument LL | async fn buy_lock(generator: &Mutex<MarketMultiplier>) -> LockedMarket<'_, T> { | +++ -error[E0515]: cannot return value referencing temporary value - --> $DIR/issue-82126-mismatched-subst-and-hir.rs:19:5 - | -LL | LockedMarket(generator.lock().unwrap().buy()) - | ^^^^^^^^^^^^^-------------------------^^^^^^^ - | | | - | | temporary value created here - | returns a value referencing data owned by the current function - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0107, E0515. -For more information about an error, try `rustc --explain E0107`. +For more information about this error, try `rustc --explain E0107`. diff --git a/src/test/ui/borrowck/issue-83760.stderr b/src/test/ui/borrowck/issue-83760.stderr index beeda5685..2552fff86 100644 --- a/src/test/ui/borrowck/issue-83760.stderr +++ b/src/test/ui/borrowck/issue-83760.stderr @@ -8,6 +8,10 @@ LL | val = None; | ---------- this reinitialization might get skipped | = note: move occurs because value has type `Struct`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | while let Some(ref foo) = val { + | +++ error[E0382]: use of moved value: `foo` --> $DIR/issue-83760.rs:21:14 diff --git a/src/test/ui/borrowck/issue-88434-minimal-example.rs b/src/test/ui/borrowck/issue-88434-minimal-example.rs index 983a02310..b75abcb73 100644 --- a/src/test/ui/borrowck/issue-88434-minimal-example.rs +++ b/src/test/ui/borrowck/issue-88434-minimal-example.rs @@ -1,13 +1,14 @@ // Regression test related to issue 88434 const _CONST: &() = &f(&|_| {}); -//~^ ERROR constant +//~^ constant const fn f<F>(_: &F) where F: FnMut(&u8), { panic!() //~ ERROR evaluation of constant value failed + //~^ panic } fn main() { } diff --git a/src/test/ui/borrowck/issue-88434-minimal-example.stderr b/src/test/ui/borrowck/issue-88434-minimal-example.stderr index dc87c4c2b..a5a571c6d 100644 --- a/src/test/ui/borrowck/issue-88434-minimal-example.stderr +++ b/src/test/ui/borrowck/issue-88434-minimal-example.stderr @@ -1,23 +1,27 @@ error[E0080]: evaluation of constant value failed --> $DIR/issue-88434-minimal-example.rs:10:5 | -LL | const _CONST: &() = &f(&|_| {}); - | ---------- inside `_CONST` at $DIR/issue-88434-minimal-example.rs:3:22 -... +LL | panic!() + | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/issue-88434-minimal-example.rs:10:5 + | +note: inside `f::<[closure@$DIR/issue-88434-minimal-example.rs:3:25: 3:28]>` + --> $DIR/issue-88434-minimal-example.rs:10:5 + | LL | panic!() | ^^^^^^^^ - | | - | the evaluated program panicked at 'explicit panic', $DIR/issue-88434-minimal-example.rs:10:5 - | inside `f::<[closure@$DIR/issue-88434-minimal-example.rs:3:25: 3:28]>` at $SRC_DIR/std/src/panic.rs:LL:COL +note: inside `_CONST` + --> $DIR/issue-88434-minimal-example.rs:3:22 | +LL | const _CONST: &() = &f(&|_| {}); + | ^^^^^^^^^^ = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/issue-88434-minimal-example.rs:3:21 | LL | const _CONST: &() = &f(&|_| {}); - | ^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/borrowck/issue-88434-removal-index-should-be-less.rs b/src/test/ui/borrowck/issue-88434-removal-index-should-be-less.rs index a99c5b76a..f9134e669 100644 --- a/src/test/ui/borrowck/issue-88434-removal-index-should-be-less.rs +++ b/src/test/ui/borrowck/issue-88434-removal-index-should-be-less.rs @@ -1,13 +1,14 @@ // Regression test for issue 88434 const _CONST: &[u8] = &f(&[], |_| {}); -//~^ ERROR constant +//~^ constant const fn f<F>(_: &[u8], _: F) -> &[u8] where F: FnMut(&u8), { panic!() //~ ERROR evaluation of constant value failed + //~^ panic } fn main() { } diff --git a/src/test/ui/borrowck/issue-88434-removal-index-should-be-less.stderr b/src/test/ui/borrowck/issue-88434-removal-index-should-be-less.stderr index 4b4a25d7b..00023c459 100644 --- a/src/test/ui/borrowck/issue-88434-removal-index-should-be-less.stderr +++ b/src/test/ui/borrowck/issue-88434-removal-index-should-be-less.stderr @@ -1,23 +1,27 @@ error[E0080]: evaluation of constant value failed --> $DIR/issue-88434-removal-index-should-be-less.rs:10:5 | -LL | const _CONST: &[u8] = &f(&[], |_| {}); - | -------------- inside `_CONST` at $DIR/issue-88434-removal-index-should-be-less.rs:3:24 -... +LL | panic!() + | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/issue-88434-removal-index-should-be-less.rs:10:5 + | +note: inside `f::<[closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:34]>` + --> $DIR/issue-88434-removal-index-should-be-less.rs:10:5 + | LL | panic!() | ^^^^^^^^ - | | - | the evaluated program panicked at 'explicit panic', $DIR/issue-88434-removal-index-should-be-less.rs:10:5 - | inside `f::<[closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:34]>` at $SRC_DIR/std/src/panic.rs:LL:COL +note: inside `_CONST` + --> $DIR/issue-88434-removal-index-should-be-less.rs:3:24 | +LL | const _CONST: &[u8] = &f(&[], |_| {}); + | ^^^^^^^^^^^^^^ = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/issue-88434-removal-index-should-be-less.rs:3:23 | LL | const _CONST: &[u8] = &f(&[], |_| {}); - | ^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/borrowck/move-in-pattern-mut-in-loop.stderr b/src/test/ui/borrowck/move-in-pattern-mut-in-loop.stderr index c6931ba72..55948afca 100644 --- a/src/test/ui/borrowck/move-in-pattern-mut-in-loop.stderr +++ b/src/test/ui/borrowck/move-in-pattern-mut-in-loop.stderr @@ -5,7 +5,7 @@ LL | if let Some(mut _x) = opt {} | ^^^^^^ value moved here, in previous iteration of loop | = note: move occurs because value has type `&mut i32`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving `opt.0` +help: borrow this binding in the pattern to avoid moving the value | LL | if let Some(ref mut _x) = opt {} | +++ diff --git a/src/test/ui/borrowck/move-in-pattern-mut.stderr b/src/test/ui/borrowck/move-in-pattern-mut.stderr index 2bf34b321..dd3471e2c 100644 --- a/src/test/ui/borrowck/move-in-pattern-mut.stderr +++ b/src/test/ui/borrowck/move-in-pattern-mut.stderr @@ -8,7 +8,7 @@ LL | foo(s); | ^ value used here after partial move | = note: partial move occurs because value has type `S`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving `s.0` +help: borrow this binding in the pattern to avoid moving the value | LL | if let Some(ref mut x) = s { | +++ @@ -23,7 +23,7 @@ LL | bar(e); | ^ value used here after partial move | = note: partial move occurs because value has type `S`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving `e.s` +help: borrow this binding in the pattern to avoid moving the value | LL | let E::V { s: ref mut x } = e; | +++ diff --git a/src/test/ui/borrowck/move-in-pattern.stderr b/src/test/ui/borrowck/move-in-pattern.stderr index 6b84c0032..250acbe59 100644 --- a/src/test/ui/borrowck/move-in-pattern.stderr +++ b/src/test/ui/borrowck/move-in-pattern.stderr @@ -8,7 +8,7 @@ LL | foo(s); | ^ value used here after partial move | = note: partial move occurs because value has type `S`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving `s.0` +help: borrow this binding in the pattern to avoid moving the value | LL | if let Some(ref x) = s { | +++ @@ -23,7 +23,7 @@ LL | bar(e); | ^ value used here after partial move | = note: partial move occurs because value has type `S`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving `e.s` +help: borrow this binding in the pattern to avoid moving the value | LL | let E::V { s: ref x } = e; | +++ diff --git a/src/test/ui/borrowck/mut-borrow-in-loop-2.stderr b/src/test/ui/borrowck/mut-borrow-in-loop-2.stderr index 8b05b2388..74e7067c9 100644 --- a/src/test/ui/borrowck/mut-borrow-in-loop-2.stderr +++ b/src/test/ui/borrowck/mut-borrow-in-loop-2.stderr @@ -4,9 +4,17 @@ error[E0382]: use of moved value: `value` LL | fn this_does_not<'a, R>(value: &'a mut Events<R>) { | ----- move occurs because `value` has type `&mut Events<R>`, which does not implement the `Copy` trait LL | for _ in 0..3 { + | ------------- inside of this loop LL | Other::handle(value); | ^^^^^ value moved here, in previous iteration of loop | +note: consider changing this parameter type in function `handle` to borrow instead if owning the value isn't necessary + --> $DIR/mut-borrow-in-loop-2.rs:9:22 + | +LL | fn handle(value: T) -> Self; + | ------ ^ this parameter takes ownership of the value + | | + | in this function help: consider creating a fresh reborrow of `value` here | LL | Other::handle(&mut *value); diff --git a/src/test/ui/borrowck/or-patterns.stderr b/src/test/ui/borrowck/or-patterns.stderr index dd5797c3f..9501798bb 100644 --- a/src/test/ui/borrowck/or-patterns.stderr +++ b/src/test/ui/borrowck/or-patterns.stderr @@ -8,6 +8,10 @@ LL | &x.0 .0; | ^^^^^^^ value borrowed here after move | = note: move occurs because `x.0.0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | ((ref y, _) | (_, y),) => (), + | +++ error[E0382]: borrow of moved value: `x.0.1` --> $DIR/or-patterns.rs:10:5 @@ -19,6 +23,10 @@ LL | &x.0 .1; | ^^^^^^^ value borrowed here after move | = note: move occurs because `x.0.1` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | ((y, _) | (_, ref y),) => (), + | +++ error[E0502]: cannot borrow `x.0.0` as mutable because it is also borrowed as immutable --> $DIR/or-patterns.rs:18:5 @@ -77,6 +85,10 @@ LL | &x.0 .0; | ^^^^^^^ value borrowed here after move | = note: move occurs because `x.0.0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ((ref y, _) | (_, y),) = x; + | +++ error[E0382]: borrow of moved value: `x.0.1` --> $DIR/or-patterns.rs:40:5 @@ -88,6 +100,10 @@ LL | &x.0 .1; | ^^^^^^^ value borrowed here after move | = note: move occurs because `x.0.1` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ((y, _) | (_, ref y),) = x; + | +++ error[E0502]: cannot borrow `x.0.0` as mutable because it is also borrowed as immutable --> $DIR/or-patterns.rs:46:5 diff --git a/src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.rs b/src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.rs new file mode 100644 index 000000000..087743e50 --- /dev/null +++ b/src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.rs @@ -0,0 +1,19 @@ +#![feature(abi_efiapi)] + +fn efiapi(f: extern "efiapi" fn(usize, ...)) { + //~^ ERROR: C-variadic function must have a compatible calling convention, like `C` or `cdecl` + //~^^ ERROR: using calling conventions other than `C` or `cdecl` for varargs functions is unstable + f(22, 44); +} +fn sysv(f: extern "sysv64" fn(usize, ...)) { + //~^ ERROR: C-variadic function must have a compatible calling convention, like `C` or `cdecl` + //~^^ ERROR: using calling conventions other than `C` or `cdecl` for varargs functions is unstable + f(22, 44); +} +fn win(f: extern "win64" fn(usize, ...)) { + //~^ ERROR: C-variadic function must have a compatible calling convention, like `C` or `cdecl` + //~^^ ERROR: using calling conventions other than `C` or `cdecl` for varargs functions is unstable + f(22, 44); +} + +fn main() {} diff --git a/src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.stderr b/src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.stderr new file mode 100644 index 000000000..007d7d795 --- /dev/null +++ b/src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.stderr @@ -0,0 +1,49 @@ +error[E0658]: using calling conventions other than `C` or `cdecl` for varargs functions is unstable + --> $DIR/feature-gate-extended_varargs_abi_support.rs:3:14 + | +LL | fn efiapi(f: extern "efiapi" fn(usize, ...)) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #100189 <https://github.com/rust-lang/rust/issues/100189> for more information + = help: add `#![feature(extended_varargs_abi_support)]` to the crate attributes to enable + +error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl` + --> $DIR/feature-gate-extended_varargs_abi_support.rs:3:14 + | +LL | fn efiapi(f: extern "efiapi" fn(usize, ...)) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention + +error[E0658]: using calling conventions other than `C` or `cdecl` for varargs functions is unstable + --> $DIR/feature-gate-extended_varargs_abi_support.rs:8:12 + | +LL | fn sysv(f: extern "sysv64" fn(usize, ...)) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #100189 <https://github.com/rust-lang/rust/issues/100189> for more information + = help: add `#![feature(extended_varargs_abi_support)]` to the crate attributes to enable + +error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl` + --> $DIR/feature-gate-extended_varargs_abi_support.rs:8:12 + | +LL | fn sysv(f: extern "sysv64" fn(usize, ...)) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention + +error[E0658]: using calling conventions other than `C` or `cdecl` for varargs functions is unstable + --> $DIR/feature-gate-extended_varargs_abi_support.rs:13:11 + | +LL | fn win(f: extern "win64" fn(usize, ...)) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #100189 <https://github.com/rust-lang/rust/issues/100189> for more information + = help: add `#![feature(extended_varargs_abi_support)]` to the crate attributes to enable + +error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl` + --> $DIR/feature-gate-extended_varargs_abi_support.rs:13:11 + | +LL | fn win(f: extern "win64" fn(usize, ...)) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0045, E0658. +For more information about an error, try `rustc --explain E0045`. diff --git a/src/test/ui/c-variadic/issue-86053-1.stderr b/src/test/ui/c-variadic/issue-86053-1.stderr index 60b379faf..075bd1fc4 100644 --- a/src/test/ui/c-variadic/issue-86053-1.stderr +++ b/src/test/ui/c-variadic/issue-86053-1.stderr @@ -66,8 +66,8 @@ LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize | ::: $SRC_DIR/core/src/ops/function.rs:LL:COL | -LL | pub trait Fn<Args>: FnMut<Args> { - | ------------------------------- similarly named trait `Fn` defined here +LL | pub trait Fn<Args: Tuple>: FnMut<Args> { + | -------------------------------------- similarly named trait `Fn` defined here | help: a trait with a similar name exists | diff --git a/src/test/ui/c-variadic/variadic-ffi-1.rs b/src/test/ui/c-variadic/variadic-ffi-1.rs index a76efd9a2..24407a71c 100644 --- a/src/test/ui/c-variadic/variadic-ffi-1.rs +++ b/src/test/ui/c-variadic/variadic-ffi-1.rs @@ -6,7 +6,9 @@ trait Sized { } extern "stdcall" { - fn printf(_: *const u8, ...); //~ ERROR: variadic function must have C or cdecl calling + fn printf(_: *const u8, ...); + //~^ ERROR: C-variadic function must have a compatible calling convention, + // like C, cdecl, win64, sysv64 or efiapi } extern "C" { diff --git a/src/test/ui/c-variadic/variadic-ffi-1.stderr b/src/test/ui/c-variadic/variadic-ffi-1.stderr index 2ffb80f7e..4beea83d8 100644 --- a/src/test/ui/c-variadic/variadic-ffi-1.stderr +++ b/src/test/ui/c-variadic/variadic-ffi-1.stderr @@ -1,17 +1,17 @@ -error[E0045]: C-variadic function must have C or cdecl calling convention +error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl` --> $DIR/variadic-ffi-1.rs:9:5 | LL | fn printf(_: *const u8, ...); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadics require C or cdecl calling convention + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention error[E0060]: this function takes at least 2 arguments but 0 arguments were supplied - --> $DIR/variadic-ffi-1.rs:20:9 + --> $DIR/variadic-ffi-1.rs:22:9 | LL | foo(); | ^^^-- two arguments of type `isize` and `u8` are missing | note: function defined here - --> $DIR/variadic-ffi-1.rs:13:8 + --> $DIR/variadic-ffi-1.rs:15:8 | LL | fn foo(f: isize, x: u8, ...); | ^^^ @@ -21,13 +21,13 @@ LL | foo(/* isize */, /* u8 */); | ~~~~~~~~~~~~~~~~~~~~~~~ error[E0060]: this function takes at least 2 arguments but 1 argument was supplied - --> $DIR/variadic-ffi-1.rs:21:9 + --> $DIR/variadic-ffi-1.rs:23:9 | LL | foo(1); | ^^^--- an argument of type `u8` is missing | note: function defined here - --> $DIR/variadic-ffi-1.rs:13:8 + --> $DIR/variadic-ffi-1.rs:15:8 | LL | fn foo(f: isize, x: u8, ...); | ^^^ @@ -37,7 +37,7 @@ LL | foo(1, /* u8 */); | ~~~~~~~~~~~~~ error[E0308]: mismatched types - --> $DIR/variadic-ffi-1.rs:23:56 + --> $DIR/variadic-ffi-1.rs:25:56 | LL | let x: unsafe extern "C" fn(f: isize, x: u8) = foo; | ------------------------------------- ^^^ expected non-variadic fn, found variadic function @@ -48,7 +48,7 @@ LL | let x: unsafe extern "C" fn(f: isize, x: u8) = foo; found fn item `unsafe extern "C" fn(_, _, ...) {foo}` error[E0308]: mismatched types - --> $DIR/variadic-ffi-1.rs:24:54 + --> $DIR/variadic-ffi-1.rs:26:54 | LL | let y: extern "C" fn(f: isize, x: u8, ...) = bar; | ----------------------------------- ^^^ expected variadic fn, found non-variadic function @@ -59,37 +59,37 @@ LL | let y: extern "C" fn(f: isize, x: u8, ...) = bar; found fn item `extern "C" fn(_, _) {bar}` error[E0617]: can't pass `f32` to variadic function - --> $DIR/variadic-ffi-1.rs:26:19 + --> $DIR/variadic-ffi-1.rs:28:19 | LL | foo(1, 2, 3f32); | ^^^^ help: cast the value to `c_double`: `3f32 as c_double` error[E0617]: can't pass `bool` to variadic function - --> $DIR/variadic-ffi-1.rs:27:19 + --> $DIR/variadic-ffi-1.rs:29:19 | LL | foo(1, 2, true); | ^^^^ help: cast the value to `c_int`: `true as c_int` error[E0617]: can't pass `i8` to variadic function - --> $DIR/variadic-ffi-1.rs:28:19 + --> $DIR/variadic-ffi-1.rs:30:19 | LL | foo(1, 2, 1i8); | ^^^ help: cast the value to `c_int`: `1i8 as c_int` error[E0617]: can't pass `u8` to variadic function - --> $DIR/variadic-ffi-1.rs:29:19 + --> $DIR/variadic-ffi-1.rs:31:19 | LL | foo(1, 2, 1u8); | ^^^ help: cast the value to `c_uint`: `1u8 as c_uint` error[E0617]: can't pass `i16` to variadic function - --> $DIR/variadic-ffi-1.rs:30:19 + --> $DIR/variadic-ffi-1.rs:32:19 | LL | foo(1, 2, 1i16); | ^^^^ help: cast the value to `c_int`: `1i16 as c_int` error[E0617]: can't pass `u16` to variadic function - --> $DIR/variadic-ffi-1.rs:31:19 + --> $DIR/variadic-ffi-1.rs:33:19 | LL | foo(1, 2, 1u16); | ^^^^ help: cast the value to `c_uint`: `1u16 as c_uint` diff --git a/src/test/ui/c-variadic/variadic-ffi-2.rs b/src/test/ui/c-variadic/variadic-ffi-2.rs index 224ac16f4..96cea8754 100644 --- a/src/test/ui/c-variadic/variadic-ffi-2.rs +++ b/src/test/ui/c-variadic/variadic-ffi-2.rs @@ -1,7 +1,20 @@ // ignore-arm stdcall isn't supported +#![feature(extended_varargs_abi_support)] +#![feature(abi_efiapi)] fn baz(f: extern "stdcall" fn(usize, ...)) { - //~^ ERROR: variadic function must have C or cdecl calling convention + //~^ ERROR: C-variadic function must have a compatible calling convention, + // like C, cdecl, win64, sysv64 or efiapi + f(22, 44); +} + +fn sysv(f: extern "sysv64" fn(usize, ...)) { + f(22, 44); +} +fn win(f: extern "win64" fn(usize, ...)) { + f(22, 44); +} +fn efiapi(f: extern "efiapi" fn(usize, ...)) { f(22, 44); } diff --git a/src/test/ui/c-variadic/variadic-ffi-2.stderr b/src/test/ui/c-variadic/variadic-ffi-2.stderr index 4c8b8d2b2..4e74c9d92 100644 --- a/src/test/ui/c-variadic/variadic-ffi-2.stderr +++ b/src/test/ui/c-variadic/variadic-ffi-2.stderr @@ -1,8 +1,8 @@ -error[E0045]: C-variadic function must have C or cdecl calling convention - --> $DIR/variadic-ffi-2.rs:3:11 +error[E0045]: C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `win64`, `sysv64` or `efiapi` + --> $DIR/variadic-ffi-2.rs:5:11 | LL | fn baz(f: extern "stdcall" fn(usize, ...)) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadics require C or cdecl calling convention + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention error: aborting due to previous error diff --git a/src/test/ui/cannot-mutate-captured-non-mut-var.rs b/src/test/ui/cannot-mutate-captured-non-mut-var.rs index a83884acb..952dab25b 100644 --- a/src/test/ui/cannot-mutate-captured-non-mut-var.rs +++ b/src/test/ui/cannot-mutate-captured-non-mut-var.rs @@ -1,8 +1,8 @@ -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] use std::io::Read; -fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f } +fn to_fn_once<A:std::marker::Tuple,F:FnOnce<A>>(f: F) -> F { f } fn main() { let x = 1; diff --git a/src/test/ui/cast/cast-pointee-projection.rs b/src/test/ui/cast/cast-pointee-projection.rs new file mode 100644 index 000000000..f51c5f20f --- /dev/null +++ b/src/test/ui/cast/cast-pointee-projection.rs @@ -0,0 +1,17 @@ +// check-pass + +trait Tag<'a> { + type Type: ?Sized; +} + +trait IntoRaw: for<'a> Tag<'a> { + fn into_raw(this: *const <Self as Tag<'_>>::Type) -> *mut <Self as Tag<'_>>::Type; +} + +impl<T: for<'a> Tag<'a>> IntoRaw for T { + fn into_raw(this: *const <Self as Tag<'_>>::Type) -> *mut <Self as Tag<'_>>::Type { + this as *mut T::Type + } +} + +fn main() {} diff --git a/src/test/ui/chalkify/bugs/async.stderr b/src/test/ui/chalkify/bugs/async.stderr index f53ed53f7..4804df133 100644 --- a/src/test/ui/chalkify/bugs/async.stderr +++ b/src/test/ui/chalkify/bugs/async.stderr @@ -1,39 +1,54 @@ -error[E0277]: the trait bound `[static generator@$DIR/async.rs:7:29: 9:2]: Generator<ResumeTy>` is not satisfied +error[E0277]: `[async fn body@$DIR/async.rs:7:29: 9:2]` is not a future --> $DIR/async.rs:7:29 | LL | async fn foo(x: u32) -> u32 { - | _____________________________^ + | _____________________________- LL | | x LL | | } - | |_^ the trait `Generator<ResumeTy>` is not implemented for `[static generator@$DIR/async.rs:7:29: 9:2]` + | | ^ + | | | + | |_`[async fn body@$DIR/async.rs:7:29: 9:2]` is not a future + | required by a bound introduced by this call | -note: required by a bound in `std::future::from_generator` + = help: the trait `Future` is not implemented for `[async fn body@$DIR/async.rs:7:29: 9:2]` + = note: [async fn body@$DIR/async.rs:7:29: 9:2] must be a future or must implement `IntoFuture` to be awaited +note: required by a bound in `identity_future` --> $SRC_DIR/core/src/future/mod.rs:LL:COL | -LL | T: Generator<ResumeTy, Yield = ()>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `std::future::from_generator` +LL | pub const fn identity_future<O, Fut: Future<Output = O>>(f: Fut) -> Fut { + | ^^^^^^^^^^^^^^^^^^ required by this bound in `identity_future` -error[E0280]: the requirement `<[static generator@$DIR/async.rs:7:29: 9:2] as Generator<ResumeTy>>::Yield == ()` is not satisfied +error[E0277]: the size for values of type `<[async fn body@$DIR/async.rs:7:29: 9:2] as Future>::Output` cannot be known at compilation time --> $DIR/async.rs:7:29 | LL | async fn foo(x: u32) -> u32 { | _____________________________^ LL | | x LL | | } - | |_^ + | |_^ doesn't have a size known at compile-time | -note: required by a bound in `std::future::from_generator` + = help: the trait `Sized` is not implemented for `<[async fn body@$DIR/async.rs:7:29: 9:2] as Future>::Output` +note: required by a bound in `identity_future` --> $SRC_DIR/core/src/future/mod.rs:LL:COL | -LL | T: Generator<ResumeTy, Yield = ()>, - | ^^^^^^^^^^ required by this bound in `std::future::from_generator` +LL | pub const fn identity_future<O, Fut: Future<Output = O>>(f: Fut) -> Fut { + | ^ required by this bound in `identity_future` + +error[E0277]: `[async fn body@$DIR/async.rs:7:29: 9:2]` is not a future + --> $DIR/async.rs:7:25 + | +LL | async fn foo(x: u32) -> u32 { + | ^^^ `[async fn body@$DIR/async.rs:7:29: 9:2]` is not a future + | + = help: the trait `Future` is not implemented for `[async fn body@$DIR/async.rs:7:29: 9:2]` + = note: [async fn body@$DIR/async.rs:7:29: 9:2] must be a future or must implement `IntoFuture` to be awaited -error[E0280]: the requirement `<impl Future<Output = u32> as Future>::Output == u32` is not satisfied +error[E0280]: the requirement `<[async fn body@$DIR/async.rs:7:29: 9:2] as Future>::Output == u32` is not satisfied --> $DIR/async.rs:7:25 | LL | async fn foo(x: u32) -> u32 { | ^^^ -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/chalkify/closure.rs b/src/test/ui/chalkify/closure.rs index 81114d491..568e2e30c 100644 --- a/src/test/ui/chalkify/closure.rs +++ b/src/test/ui/chalkify/closure.rs @@ -1,4 +1,3 @@ -// check-fail // compile-flags: -Z chalk fn main() -> () { diff --git a/src/test/ui/chalkify/closure.stderr b/src/test/ui/chalkify/closure.stderr index 515e0cf01..a33c0ba0d 100644 --- a/src/test/ui/chalkify/closure.stderr +++ b/src/test/ui/chalkify/closure.stderr @@ -1,5 +1,5 @@ error[E0382]: borrow of moved value: `b` - --> $DIR/closure.rs:28:5 + --> $DIR/closure.rs:27:5 | LL | let mut c = b; | - value moved here @@ -8,7 +8,7 @@ LL | b(); | ^ value borrowed here after move | note: closure cannot be moved more than once as it is not `Copy` due to moving the variable `a` out of its environment - --> $DIR/closure.rs:21:9 + --> $DIR/closure.rs:20:9 | LL | a = 1; | ^ diff --git a/src/test/ui/check-cfg/well-known-values.stderr b/src/test/ui/check-cfg/well-known-values.stderr index 4ec74494f..29ececea5 100644 --- a/src/test/ui/check-cfg/well-known-values.stderr +++ b/src/test/ui/check-cfg/well-known-values.stderr @@ -6,7 +6,7 @@ LL | #[cfg(target_os = "linuz")] | | | help: did you mean: `"linux"` | - = note: expected values for `target_os` are: android, cuda, dragonfly, emscripten, espidf, freebsd, fuchsia, haiku, hermit, horizon, illumos, ios, l4re, linux, macos, netbsd, none, openbsd, psp, redox, solaris, solid_asp3, tvos, uefi, unknown, vxworks, wasi, watchos, windows, xous + = note: expected values for `target_os` are: aix, android, cuda, dragonfly, emscripten, espidf, freebsd, fuchsia, haiku, hermit, horizon, illumos, ios, l4re, linux, macos, netbsd, none, nto, openbsd, psp, redox, solaris, solid_asp3, tvos, uefi, unknown, vxworks, wasi, watchos, windows, xous = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value diff --git a/src/test/ui/cleanup-rvalue-scopes-cf.stderr b/src/test/ui/cleanup-rvalue-scopes-cf.stderr index 40f14c389..425cd7514 100644 --- a/src/test/ui/cleanup-rvalue-scopes-cf.stderr +++ b/src/test/ui/cleanup-rvalue-scopes-cf.stderr @@ -4,7 +4,7 @@ error[E0716]: temporary value dropped while borrowed LL | let x1 = arg(&AddFlags(1)); | ^^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | creates a temporary which is freed while still in use + | creates a temporary value which is freed while still in use ... LL | (x1, x2, x3, x4, x5, x6, x7); | -- borrow later used here @@ -21,7 +21,7 @@ error[E0716]: temporary value dropped while borrowed LL | let x2 = AddFlags(1).get(); | ^^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | creates a temporary which is freed while still in use + | creates a temporary value which is freed while still in use ... LL | (x1, x2, x3, x4, x5, x6, x7); | -- borrow later used here @@ -38,7 +38,7 @@ error[E0716]: temporary value dropped while borrowed LL | let x3 = &*arg(&AddFlags(1)); | ^^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | creates a temporary which is freed while still in use + | creates a temporary value which is freed while still in use ... LL | (x1, x2, x3, x4, x5, x6, x7); | -- borrow later used here @@ -55,7 +55,7 @@ error[E0716]: temporary value dropped while borrowed LL | let ref x4 = *arg(&AddFlags(1)); | ^^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | creates a temporary which is freed while still in use + | creates a temporary value which is freed while still in use ... LL | (x1, x2, x3, x4, x5, x6, x7); | -- borrow later used here @@ -72,7 +72,7 @@ error[E0716]: temporary value dropped while borrowed LL | let &ref x5 = arg(&AddFlags(1)); | ^^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | creates a temporary which is freed while still in use + | creates a temporary value which is freed while still in use ... LL | (x1, x2, x3, x4, x5, x6, x7); | -- borrow later used here @@ -89,7 +89,7 @@ error[E0716]: temporary value dropped while borrowed LL | let x6 = AddFlags(1).get(); | ^^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | creates a temporary which is freed while still in use + | creates a temporary value which is freed while still in use ... LL | (x1, x2, x3, x4, x5, x6, x7); | -- borrow later used here @@ -106,7 +106,7 @@ error[E0716]: temporary value dropped while borrowed LL | let StackBox { f: x7 } = StackBox { f: AddFlags(1).get() }; | ^^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | creates a temporary which is freed while still in use + | creates a temporary value which is freed while still in use LL | LL | (x1, x2, x3, x4, x5, x6, x7); | -- borrow later used here diff --git a/src/test/ui/closures/2229_closure_analysis/match/issue-87097.stderr b/src/test/ui/closures/2229_closure_analysis/match/issue-87097.stderr index 384010859..39ec71ba2 100644 --- a/src/test/ui/closures/2229_closure_analysis/match/issue-87097.stderr +++ b/src/test/ui/closures/2229_closure_analysis/match/issue-87097.stderr @@ -16,7 +16,7 @@ LL | / || match out_ref { LL | | Variant::A => (), LL | | Variant::B => (), LL | | }; - | |______^ + | |_____^ | = note: closures are lazy and do nothing unless called = note: `#[warn(unused_must_use)]` on by default @@ -28,7 +28,7 @@ LL | / || match here.field { LL | | Variant::A => (), LL | | Variant::B => (), LL | | }; - | |______^ + | |_____^ | = note: closures are lazy and do nothing unless called diff --git a/src/test/ui/closures/binder/late-bound-in-body.rs b/src/test/ui/closures/binder/late-bound-in-body.rs new file mode 100644 index 000000000..bb5c7552f --- /dev/null +++ b/src/test/ui/closures/binder/late-bound-in-body.rs @@ -0,0 +1,9 @@ +// check-pass + +#![feature(closure_lifetime_binder)] + +fn main() { + let _ = for<'a> || -> () { + let _: &'a bool = &true; + }; +} diff --git a/src/test/ui/closures/binder/nested-closures-regions.rs b/src/test/ui/closures/binder/nested-closures-regions.rs new file mode 100644 index 000000000..6bfc6c80b --- /dev/null +++ b/src/test/ui/closures/binder/nested-closures-regions.rs @@ -0,0 +1,9 @@ +// check-pass + +#![feature(closure_lifetime_binder)] +#![feature(rustc_attrs)] + +#[rustc_regions] +fn main() { + for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; }; +} diff --git a/src/test/ui/closures/binder/nested-closures-regions.stderr b/src/test/ui/closures/binder/nested-closures-regions.stderr new file mode 100644 index 000000000..b385e0ed6 --- /dev/null +++ b/src/test/ui/closures/binder/nested-closures-regions.stderr @@ -0,0 +1,38 @@ +note: external requirements + --> $DIR/nested-closures-regions.rs:8:24 + | +LL | for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: defining type: main::{closure#0}::{closure#0} with closure substs [ + i8, + extern "rust-call" fn((&(),)), + (), + ] + = note: late-bound region is '_#4r + = note: late-bound region is '_#2r + = note: number of external vids: 3 + = note: where '_#1r: '_#2r + = note: where '_#2r: '_#1r + +note: no external requirements + --> $DIR/nested-closures-regions.rs:8:5 + | +LL | for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; }; + | ^^^^^^^^^^^^^^^^ + | + = note: defining type: main::{closure#0} with closure substs [ + i8, + extern "rust-call" fn(()), + (), + ] + = note: late-bound region is '_#2r + +note: no external requirements + --> $DIR/nested-closures-regions.rs:7:1 + | +LL | fn main() { + | ^^^^^^^^^ + | + = note: defining type: main + diff --git a/src/test/ui/closures/binder/nested-closures.rs b/src/test/ui/closures/binder/nested-closures.rs new file mode 100644 index 000000000..b3c36e7ee --- /dev/null +++ b/src/test/ui/closures/binder/nested-closures.rs @@ -0,0 +1,7 @@ +// check-pass + +#![feature(closure_lifetime_binder)] + +fn main() { + for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; }; +} diff --git a/src/test/ui/closures/closure-array-break-length.stderr b/src/test/ui/closures/closure-array-break-length.stderr index 2b8ab9bfc..7e0b0027a 100644 --- a/src/test/ui/closures/closure-array-break-length.stderr +++ b/src/test/ui/closures/closure-array-break-length.stderr @@ -10,11 +10,11 @@ error[E0268]: `continue` outside of a loop LL | while |_: [_; continue]| {} {} | ^^^^^^^^ cannot `continue` outside of a loop -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/closure-array-break-length.rs:6:19 | LL | while |_: [_; break]| {} {} - | ^^^^^ cannot `break` outside of a loop + | ^^^^^ cannot `break` outside of a loop or labeled block error: aborting due to 3 previous errors diff --git a/src/test/ui/closures/issue-23012-supertrait-signature-inference.rs b/src/test/ui/closures/issue-23012-supertrait-signature-inference.rs new file mode 100644 index 000000000..5899b703e --- /dev/null +++ b/src/test/ui/closures/issue-23012-supertrait-signature-inference.rs @@ -0,0 +1,29 @@ +// check-pass +// Checks that we can infer a closure signature even if the `FnOnce` bound is +// a supertrait of the obligations we have currently registered for the Ty var. + +pub trait Receive<T, E>: FnOnce(Result<T, E>) { + fn receive(self, res: Result<T, E>); +} + +impl<T, E, F: FnOnce(Result<T, E>)> Receive<T, E> for F { + fn receive(self, res: Result<T, E>) { + self(res) + } +} + +pub trait Async<T, E> { + fn receive<F: Receive<T, E>>(self, f: F); +} + +impl<T, E> Async<T, E> for Result<T, E> { + fn receive<F: Receive<T, E>>(self, f: F) { + f(self) + } +} + +pub fn main() { + Ok::<u32, ()>(123).receive(|res| { + res.unwrap(); + }); +} diff --git a/src/test/ui/closures/issue-78720.stderr b/src/test/ui/closures/issue-78720.stderr index 3dd138772..da3f539a0 100644 --- a/src/test/ui/closures/issue-78720.stderr +++ b/src/test/ui/closures/issue-78720.stderr @@ -12,8 +12,8 @@ LL | _func: F, | ::: $SRC_DIR/core/src/ops/function.rs:LL:COL | -LL | pub trait Fn<Args>: FnMut<Args> { - | ------------------------------- similarly named trait `Fn` defined here +LL | pub trait Fn<Args: Tuple>: FnMut<Args> { + | -------------------------------------- similarly named trait `Fn` defined here | help: a trait with a similar name exists | diff --git a/src/test/ui/closures/issue-90871.rs b/src/test/ui/closures/issue-90871.rs index 9c70bbc85..7ce061cd3 100644 --- a/src/test/ui/closures/issue-90871.rs +++ b/src/test/ui/closures/issue-90871.rs @@ -1,5 +1,7 @@ +#![feature(type_ascription)] + fn main() { - 2: n([u8; || 1]) + type_ascribe!(2, n([u8; || 1])) //~^ ERROR cannot find type `n` in this scope //~| ERROR mismatched types } diff --git a/src/test/ui/closures/issue-90871.stderr b/src/test/ui/closures/issue-90871.stderr index 1e102cc98..a482750fb 100644 --- a/src/test/ui/closures/issue-90871.stderr +++ b/src/test/ui/closures/issue-90871.stderr @@ -1,21 +1,26 @@ error[E0412]: cannot find type `n` in this scope - --> $DIR/issue-90871.rs:2:8 + --> $DIR/issue-90871.rs:4:22 | -LL | 2: n([u8; || 1]) - | ^ expecting a type here because of type ascription +LL | type_ascribe!(2, n([u8; || 1])) + | ^ help: a trait with a similar name exists: `Fn` + | + ::: $SRC_DIR/core/src/ops/function.rs:LL:COL + | +LL | pub trait Fn<Args: Tuple>: FnMut<Args> { + | -------------------------------------- similarly named trait `Fn` defined here error[E0308]: mismatched types - --> $DIR/issue-90871.rs:2:15 + --> $DIR/issue-90871.rs:4:29 | -LL | 2: n([u8; || 1]) - | ^^^^ expected `usize`, found closure +LL | type_ascribe!(2, n([u8; || 1])) + | ^^^^ expected `usize`, found closure | = note: expected type `usize` - found closure `[closure@$DIR/issue-90871.rs:2:15: 2:17]` + found closure `[closure@$DIR/issue-90871.rs:4:29: 4:31]` help: use parentheses to call this closure | -LL | 2: n([u8; (|| 1)()]) - | + +++ +LL | type_ascribe!(2, n([u8; (|| 1)()])) + | + +++ error: aborting due to 2 previous errors diff --git a/src/test/ui/closures/supertrait-hint-references-assoc-ty.rs b/src/test/ui/closures/supertrait-hint-references-assoc-ty.rs new file mode 100644 index 000000000..270bf14c3 --- /dev/null +++ b/src/test/ui/closures/supertrait-hint-references-assoc-ty.rs @@ -0,0 +1,17 @@ +// check-pass + +pub trait Fn0: Fn(i32) -> Self::Out { + type Out; +} + +impl<F: Fn(i32) -> ()> Fn0 for F { + type Out = (); +} + +pub fn closure_typer(_: impl Fn0) {} + +fn main() { + closure_typer(move |x| { + let _: i64 = x.into(); + }); +} diff --git a/src/test/ui/codegen/issue-99551.rs b/src/test/ui/codegen/issue-99551.rs index f24874c99..b223aff4e 100644 --- a/src/test/ui/codegen/issue-99551.rs +++ b/src/test/ui/codegen/issue-99551.rs @@ -1,6 +1,5 @@ // build-pass #![feature(trait_upcasting)] -#![allow(incomplete_features)] pub trait A {} pub trait B {} diff --git a/src/test/ui/codemap_tests/tab_3.stderr b/src/test/ui/codemap_tests/tab_3.stderr index 9072cc925..080f6c394 100644 --- a/src/test/ui/codemap_tests/tab_3.stderr +++ b/src/test/ui/codemap_tests/tab_3.stderr @@ -15,6 +15,10 @@ note: this function takes ownership of the receiver `self`, which moves `some_ve LL | fn into_iter(self) -> Self::IntoIter; | ^^^^ = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider cloning the value if the performance cost is acceptable + | +LL | some_vec.clone().into_iter(); + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/codemap_tests/unicode_2.stderr b/src/test/ui/codemap_tests/unicode_2.stderr index a776a4a1e..19aae1d3c 100644 --- a/src/test/ui/codemap_tests/unicode_2.stderr +++ b/src/test/ui/codemap_tests/unicode_2.stderr @@ -1,3 +1,9 @@ +error[E0425]: cannot find value `a̐é` in this scope + --> $DIR/unicode_2.rs:4:13 + | +LL | let _ = a̐é; + | ^^ not found in this scope + error: invalid width `7` for integer literal --> $DIR/unicode_2.rs:2:25 | @@ -14,12 +20,6 @@ LL | let _ = ("아あ", 1i42); | = help: valid widths are 8, 16, 32, 64 and 128 -error[E0425]: cannot find value `a̐é` in this scope - --> $DIR/unicode_2.rs:4:13 - | -LL | let _ = a̐é; - | ^^ not found in this scope - error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/coercion/coerce-block-tail-26978.rs b/src/test/ui/coercion/coerce-block-tail-26978.rs new file mode 100644 index 000000000..01c8ab5a8 --- /dev/null +++ b/src/test/ui/coercion/coerce-block-tail-26978.rs @@ -0,0 +1,11 @@ +// check-fail +fn f(_: &i32) {} + +fn main() { + let x = Box::new(1i32); + + f(&x); + f(&(x)); + f(&{x}); + //~^ ERROR mismatched types +} diff --git a/src/test/ui/coercion/coerce-block-tail-26978.stderr b/src/test/ui/coercion/coerce-block-tail-26978.stderr new file mode 100644 index 000000000..384debd48 --- /dev/null +++ b/src/test/ui/coercion/coerce-block-tail-26978.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/coerce-block-tail-26978.rs:9:9 + | +LL | f(&{x}); + | ^ expected `i32`, found struct `Box` + | + = note: expected type `i32` + found struct `Box<i32>` +help: consider unboxing the value + | +LL | f(&{*x}); + | + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/coercion/coerce-block-tail-57749.rs b/src/test/ui/coercion/coerce-block-tail-57749.rs new file mode 100644 index 000000000..79b5b3323 --- /dev/null +++ b/src/test/ui/coercion/coerce-block-tail-57749.rs @@ -0,0 +1,35 @@ +// check-fail +use std::ops::Deref; + +fn main() { + fn save(who: &str) { + println!("I'll save you, {}!", who); + } + + struct Madoka; + + impl Deref for Madoka { + type Target = str; + fn deref(&self) -> &Self::Target { + "Madoka" + } + } + + save(&{ Madoka }); + + fn reset(how: &u32) { + println!("Reset {} times", how); + } + + struct Homura; + + impl Deref for Homura { + type Target = u32; + fn deref(&self) -> &Self::Target { + &42 + } + } + + reset(&{ Homura }); + //~^ ERROR mismatched types +} diff --git a/src/test/ui/coercion/coerce-block-tail-57749.stderr b/src/test/ui/coercion/coerce-block-tail-57749.stderr new file mode 100644 index 000000000..d5660c81d --- /dev/null +++ b/src/test/ui/coercion/coerce-block-tail-57749.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/coerce-block-tail-57749.rs:33:14 + | +LL | reset(&{ Homura }); + | ^^^^^^ expected `u32`, found struct `Homura` + | +help: consider dereferencing the type + | +LL | reset(&{ *Homura }); + | + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/coercion/coerce-block-tail-83783.rs b/src/test/ui/coercion/coerce-block-tail-83783.rs new file mode 100644 index 000000000..18c8ae3bb --- /dev/null +++ b/src/test/ui/coercion/coerce-block-tail-83783.rs @@ -0,0 +1,13 @@ +// check-fail +// edition:2018 +fn _consume_reference<T: ?Sized>(_: &T) {} + +async fn _foo() { + _consume_reference::<i32>(&Box::new(7_i32)); + _consume_reference::<i32>(&async { Box::new(7_i32) }.await); + //~^ ERROR mismatched types + _consume_reference::<[i32]>(&vec![7_i32]); + _consume_reference::<[i32]>(&async { vec![7_i32] }.await); +} + +fn main() { } diff --git a/src/test/ui/coercion/coerce-block-tail-83783.stderr b/src/test/ui/coercion/coerce-block-tail-83783.stderr new file mode 100644 index 000000000..5f53606ce --- /dev/null +++ b/src/test/ui/coercion/coerce-block-tail-83783.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/coerce-block-tail-83783.rs:7:32 + | +LL | _consume_reference::<i32>(&async { Box::new(7_i32) }.await); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found struct `Box` + | + = note: expected type `i32` + found struct `Box<i32>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/coercion/coerce-block-tail-83850.rs b/src/test/ui/coercion/coerce-block-tail-83850.rs new file mode 100644 index 000000000..77fdf9998 --- /dev/null +++ b/src/test/ui/coercion/coerce-block-tail-83850.rs @@ -0,0 +1,7 @@ +// check-fail +fn f(_: &[i32]) {} + +fn main() { + f(&Box::new([1, 2])); + //~^ ERROR mismatched types +} diff --git a/src/test/ui/coercion/coerce-block-tail-83850.stderr b/src/test/ui/coercion/coerce-block-tail-83850.stderr new file mode 100644 index 000000000..bbf607543 --- /dev/null +++ b/src/test/ui/coercion/coerce-block-tail-83850.stderr @@ -0,0 +1,19 @@ +error[E0308]: mismatched types + --> $DIR/coerce-block-tail-83850.rs:5:7 + | +LL | f(&Box::new([1, 2])); + | - ^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found struct `Box` + | | + | arguments to this function are incorrect + | + = note: expected reference `&[i32]` + found reference `&Box<[{integer}; 2]>` +note: function defined here + --> $DIR/coerce-block-tail-83850.rs:2:4 + | +LL | fn f(_: &[i32]) {} + | ^ --------- + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/coercion/coerce-block-tail.rs b/src/test/ui/coercion/coerce-block-tail.rs new file mode 100644 index 000000000..dcbcd3762 --- /dev/null +++ b/src/test/ui/coercion/coerce-block-tail.rs @@ -0,0 +1,6 @@ +// check-fail +fn main() { + let _: &str = & { String::from("hahah")}; + let _: &i32 = & { Box::new(1i32) }; + //~^ ERROR mismatched types +} diff --git a/src/test/ui/coercion/coerce-block-tail.stderr b/src/test/ui/coercion/coerce-block-tail.stderr new file mode 100644 index 000000000..318cf7586 --- /dev/null +++ b/src/test/ui/coercion/coerce-block-tail.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/coerce-block-tail.rs:4:23 + | +LL | let _: &i32 = & { Box::new(1i32) }; + | ^^^^^^^^^^^^^^ expected `i32`, found struct `Box` + | + = note: expected type `i32` + found struct `Box<i32>` +help: consider unboxing the value + | +LL | let _: &i32 = & { *Box::new(1i32) }; + | + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs b/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs index c139e823c..d7b11317a 100644 --- a/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs +++ b/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs @@ -6,27 +6,27 @@ use std::fmt::Debug; pub fn main() { - let _ = box { [1, 2, 3] }: Box<[i32]>; //~ ERROR mismatched types - let _ = box if true { [1, 2, 3] } else { [1, 3, 4] }: Box<[i32]>; //~ ERROR mismatched types - let _ = box match true { true => [1, 2, 3], false => [1, 3, 4] }: Box<[i32]>; + let _ = type_ascribe!(box { [1, 2, 3] }, Box<[i32]>); //~ ERROR mismatched types + let _ = type_ascribe!(box if true { [1, 2, 3] } else { [1, 3, 4] }, Box<[i32]>); //~ ERROR mismatched types + let _ = type_ascribe!(box match true { true => [1, 2, 3], false => [1, 3, 4] }, Box<[i32]>); //~^ ERROR mismatched types - let _ = box { |x| (x as u8) }: Box<dyn Fn(i32) -> _>; //~ ERROR mismatched types - let _ = box if true { false } else { true }: Box<dyn Debug>; //~ ERROR mismatched types - let _ = box match true { true => 'a', false => 'b' }: Box<dyn Debug>; //~ ERROR mismatched types + let _ = type_ascribe!(box { |x| (x as u8) }, Box<dyn Fn(i32) -> _>); //~ ERROR mismatched types + let _ = type_ascribe!(box if true { false } else { true }, Box<dyn Debug>); //~ ERROR mismatched types + let _ = type_ascribe!(box match true { true => 'a', false => 'b' }, Box<dyn Debug>); //~ ERROR mismatched types - let _ = &{ [1, 2, 3] }: &[i32]; //~ ERROR mismatched types - let _ = &if true { [1, 2, 3] } else { [1, 3, 4] }: &[i32]; //~ ERROR mismatched types - let _ = &match true { true => [1, 2, 3], false => [1, 3, 4] }: &[i32]; + let _ = type_ascribe!(&{ [1, 2, 3] }, &[i32]); //~ ERROR mismatched types + let _ = type_ascribe!(&if true { [1, 2, 3] } else { [1, 3, 4] }, &[i32]); //~ ERROR mismatched types + let _ = type_ascribe!(&match true { true => [1, 2, 3], false => [1, 3, 4] }, &[i32]); //~^ ERROR mismatched types - let _ = &{ |x| (x as u8) }: &dyn Fn(i32) -> _; //~ ERROR mismatched types - let _ = &if true { false } else { true }: &dyn Debug; //~ ERROR mismatched types - let _ = &match true { true => 'a', false => 'b' }: &dyn Debug; //~ ERROR mismatched types + let _ = type_ascribe!(&{ |x| (x as u8) }, &dyn Fn(i32) -> _); //~ ERROR mismatched types + let _ = type_ascribe!(&if true { false } else { true }, &dyn Debug); //~ ERROR mismatched types + let _ = type_ascribe!(&match true { true => 'a', false => 'b' }, &dyn Debug); //~ ERROR mismatched types - let _ = Box::new([1, 2, 3]): Box<[i32]>; //~ ERROR mismatched types - let _ = Box::new(|x| (x as u8)): Box<dyn Fn(i32) -> _>; //~ ERROR mismatched types + let _ = type_ascribe!(Box::new([1, 2, 3]), Box<[i32]>); //~ ERROR mismatched types + let _ = type_ascribe!(Box::new(|x| (x as u8)), Box<dyn Fn(i32) -> _>); //~ ERROR mismatched types - let _ = vec![ + let _ = type_ascribe!(vec![ Box::new(|x| (x as u8)), box |x| (x as i16 as u8), - ]: Vec<Box<dyn Fn(i32) -> _>>; + ], Vec<Box<dyn Fn(i32) -> _>>); } diff --git a/src/test/ui/coercion/coerce-expect-unsized-ascribed.stderr b/src/test/ui/coercion/coerce-expect-unsized-ascribed.stderr index 9d614e610..44968244c 100644 --- a/src/test/ui/coercion/coerce-expect-unsized-ascribed.stderr +++ b/src/test/ui/coercion/coerce-expect-unsized-ascribed.stderr @@ -1,128 +1,128 @@ error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:9:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:9:27 | -LL | let _ = box { [1, 2, 3] }: Box<[i32]>; - | ^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]` +LL | let _ = type_ascribe!(box { [1, 2, 3] }, Box<[i32]>); + | ^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]` | = note: expected struct `Box<[i32]>` found struct `Box<[i32; 3]>` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:10:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:10:27 | -LL | let _ = box if true { [1, 2, 3] } else { [1, 3, 4] }: Box<[i32]>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]` +LL | let _ = type_ascribe!(box if true { [1, 2, 3] } else { [1, 3, 4] }, Box<[i32]>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]` | = note: expected struct `Box<[i32]>` found struct `Box<[i32; 3]>` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:11:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:11:27 | -LL | let _ = box match true { true => [1, 2, 3], false => [1, 3, 4] }: Box<[i32]>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]` +LL | let _ = type_ascribe!(box match true { true => [1, 2, 3], false => [1, 3, 4] }, Box<[i32]>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]` | = note: expected struct `Box<[i32]>` found struct `Box<[i32; 3]>` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:13:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:13:27 | -LL | let _ = box { |x| (x as u8) }: Box<dyn Fn(i32) -> _>; - | ^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Fn`, found closure +LL | let _ = type_ascribe!(box { |x| (x as u8) }, Box<dyn Fn(i32) -> _>); + | ^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Fn`, found closure | = note: expected struct `Box<dyn Fn(i32) -> u8>` - found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:13:19: 13:22]>` + found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:13:33: 13:36]>` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:14:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:14:27 | -LL | let _ = box if true { false } else { true }: Box<dyn Debug>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Debug`, found `bool` +LL | let _ = type_ascribe!(box if true { false } else { true }, Box<dyn Debug>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Debug`, found `bool` | = note: expected struct `Box<dyn Debug>` found struct `Box<bool>` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:15:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:15:27 | -LL | let _ = box match true { true => 'a', false => 'b' }: Box<dyn Debug>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Debug`, found `char` +LL | let _ = type_ascribe!(box match true { true => 'a', false => 'b' }, Box<dyn Debug>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Debug`, found `char` | = note: expected struct `Box<dyn Debug>` found struct `Box<char>` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:17:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:17:27 | -LL | let _ = &{ [1, 2, 3] }: &[i32]; - | ^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]` +LL | let _ = type_ascribe!(&{ [1, 2, 3] }, &[i32]); + | ^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]` | = note: expected reference `&[i32]` found reference `&[i32; 3]` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:18:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:18:27 | -LL | let _ = &if true { [1, 2, 3] } else { [1, 3, 4] }: &[i32]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]` +LL | let _ = type_ascribe!(&if true { [1, 2, 3] } else { [1, 3, 4] }, &[i32]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]` | = note: expected reference `&[i32]` found reference `&[i32; 3]` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:19:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:19:27 | -LL | let _ = &match true { true => [1, 2, 3], false => [1, 3, 4] }: &[i32]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]` +LL | let _ = type_ascribe!(&match true { true => [1, 2, 3], false => [1, 3, 4] }, &[i32]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]` | = note: expected reference `&[i32]` found reference `&[i32; 3]` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:21:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:21:27 | -LL | let _ = &{ |x| (x as u8) }: &dyn Fn(i32) -> _; - | ^^^^^^^^^^^^^^^^^^ expected trait object `dyn Fn`, found closure +LL | let _ = type_ascribe!(&{ |x| (x as u8) }, &dyn Fn(i32) -> _); + | ^^^^^^^^^^^^^^^^^^ expected trait object `dyn Fn`, found closure | = note: expected reference `&dyn Fn(i32) -> u8` - found reference `&[closure@$DIR/coerce-expect-unsized-ascribed.rs:21:16: 21:19]` + found reference `&[closure@$DIR/coerce-expect-unsized-ascribed.rs:21:30: 21:33]` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:22:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:22:27 | -LL | let _ = &if true { false } else { true }: &dyn Debug; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Debug`, found `bool` +LL | let _ = type_ascribe!(&if true { false } else { true }, &dyn Debug); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Debug`, found `bool` | = note: expected reference `&dyn Debug` found reference `&bool` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:23:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:23:27 | -LL | let _ = &match true { true => 'a', false => 'b' }: &dyn Debug; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Debug`, found `char` +LL | let _ = type_ascribe!(&match true { true => 'a', false => 'b' }, &dyn Debug); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Debug`, found `char` | = note: expected reference `&dyn Debug` found reference `&char` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:25:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:25:27 | -LL | let _ = Box::new([1, 2, 3]): Box<[i32]>; - | ^^^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]` +LL | let _ = type_ascribe!(Box::new([1, 2, 3]), Box<[i32]>); + | ^^^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]` | = note: expected struct `Box<[i32]>` found struct `Box<[i32; 3]>` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:26:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:26:27 | -LL | let _ = Box::new(|x| (x as u8)): Box<dyn Fn(i32) -> _>; - | ^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Fn`, found closure +LL | let _ = type_ascribe!(Box::new(|x| (x as u8)), Box<dyn Fn(i32) -> _>); + | ^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Fn`, found closure | = note: expected struct `Box<dyn Fn(i32) -> u8>` - found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:26:22: 26:25]>` + found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:26:36: 26:39]>` error: aborting due to 14 previous errors diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.stderr index c25c43692..4d7872598 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.stderr +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.stderr @@ -1,4 +1,4 @@ -error[E0119]: conflicting implementations of trait `go_trait::GoMut` for type `MyThingy` +error[E0119]: conflicting implementations of trait `GoMut` for type `MyThingy` --> $DIR/coherence-blanket-conflicts-with-specific-cross-crate.rs:15:1 | LL | impl GoMut for MyThingy { diff --git a/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.stderr b/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.stderr index 111019773..2463f38a9 100644 --- a/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.stderr +++ b/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.stderr @@ -1,4 +1,4 @@ -error[E0751]: found both positive and negative implementation of trait `std::marker::Send` for type `TestType<_>`: +error[E0751]: found both positive and negative implementation of trait `Send` for type `TestType<_>`: --> $DIR/coherence-conflicting-negative-trait-impl.rs:11:1 | LL | unsafe impl<T: MyTrait + 'static> Send for TestType<T> {} @@ -7,7 +7,7 @@ LL | LL | impl<T: MyTrait> !Send for TestType<T> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ negative implementation here -error[E0119]: conflicting implementations of trait `std::marker::Send` for type `TestType<_>` +error[E0119]: conflicting implementations of trait `Send` for type `TestType<_>` --> $DIR/coherence-conflicting-negative-trait-impl.rs:13:1 | LL | unsafe impl<T: MyTrait + 'static> Send for TestType<T> {} diff --git a/src/test/ui/coherence/coherence-impls-copy.stderr b/src/test/ui/coherence/coherence-impls-copy.stderr index 86356af25..d40ffc48a 100644 --- a/src/test/ui/coherence/coherence-impls-copy.stderr +++ b/src/test/ui/coherence/coherence-impls-copy.stderr @@ -9,7 +9,7 @@ LL | impl Copy for i32 {} | = note: define and implement a trait or new type instead -error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `&NotSync` +error[E0119]: conflicting implementations of trait `Copy` for type `&NotSync` --> $DIR/coherence-impls-copy.rs:28:1 | LL | impl Copy for &'static NotSync {} diff --git a/src/test/ui/coherence/coherence-overlap-issue-23516.stderr b/src/test/ui/coherence/coherence-overlap-issue-23516.stderr index 85eb189e1..cd3984267 100644 --- a/src/test/ui/coherence/coherence-overlap-issue-23516.stderr +++ b/src/test/ui/coherence/coherence-overlap-issue-23516.stderr @@ -1,10 +1,10 @@ -error[E0119]: conflicting implementations of trait `Sweet` for type `std::boxed::Box<_>` +error[E0119]: conflicting implementations of trait `Sweet` for type `Box<_>` --> $DIR/coherence-overlap-issue-23516.rs:8:1 | LL | impl<T:Sugar> Sweet for T { } | ------------------------- first implementation here LL | impl<U:Sugar> Sweet for Box<U> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `std::boxed::Box<_>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Box<_>` | = note: downstream crates may implement trait `Sugar` for type `std::boxed::Box<_>` diff --git a/src/test/ui/coherence/coherence-projection-conflict-ty-param.stderr b/src/test/ui/coherence/coherence-projection-conflict-ty-param.stderr index 6492747bb..94d242eaa 100644 --- a/src/test/ui/coherence/coherence-projection-conflict-ty-param.stderr +++ b/src/test/ui/coherence/coherence-projection-conflict-ty-param.stderr @@ -1,11 +1,11 @@ -error[E0119]: conflicting implementations of trait `Foo<_>` for type `std::option::Option<_>` +error[E0119]: conflicting implementations of trait `Foo<_>` for type `Option<_>` --> $DIR/coherence-projection-conflict-ty-param.rs:10:1 | LL | impl <P, T: Foo<P>> Foo<P> for Option<T> {} | ---------------------------------------- first implementation here LL | LL | impl<T, U> Foo<T> for Option<U> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `std::option::Option<_>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Option<_>` error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-wasm-bindgen.stderr b/src/test/ui/coherence/coherence-wasm-bindgen.stderr index cfcc21240..89615f0fb 100644 --- a/src/test/ui/coherence/coherence-wasm-bindgen.stderr +++ b/src/test/ui/coherence/coherence-wasm-bindgen.stderr @@ -1,11 +1,11 @@ -error: conflicting implementations of trait `IntoWasmAbi` for type `&dyn std::ops::Fn(&_) -> _` +error: conflicting implementations of trait `IntoWasmAbi` for type `&dyn Fn(&_) -> _` --> $DIR/coherence-wasm-bindgen.rs:28:1 | LL | impl<'a, 'b, A, R> IntoWasmAbi for &'a (dyn Fn(A) -> R + 'b) | ------------------------------------------------------------ first implementation here ... LL | impl<'a, 'b, A, R> IntoWasmAbi for &'a (dyn for<'x> Fn(&'x A) -> R + 'b) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&dyn std::ops::Fn(&_) -> _` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&dyn Fn(&_) -> _` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105> diff --git a/src/test/ui/coherence/coherence-with-closure.rs b/src/test/ui/coherence/coherence-with-closure.rs index 6e3281d85..5b6a62b24 100644 --- a/src/test/ui/coherence/coherence-with-closure.rs +++ b/src/test/ui/coherence/coherence-with-closure.rs @@ -8,7 +8,6 @@ fn defining_use() -> OpaqueClosure { struct Wrapper<T>(T); trait Trait {} impl Trait for Wrapper<OpaqueClosure> {} -//~^ ERROR cannot implement trait on type alias impl trait impl<T: Sync> Trait for Wrapper<T> {} //~^ ERROR conflicting implementations of trait `Trait` for type `Wrapper<OpaqueClosure>` diff --git a/src/test/ui/coherence/coherence-with-closure.stderr b/src/test/ui/coherence/coherence-with-closure.stderr index d2ca63fa1..431108e14 100644 --- a/src/test/ui/coherence/coherence-with-closure.stderr +++ b/src/test/ui/coherence/coherence-with-closure.stderr @@ -1,24 +1,11 @@ error[E0119]: conflicting implementations of trait `Trait` for type `Wrapper<OpaqueClosure>` - --> $DIR/coherence-with-closure.rs:12:1 + --> $DIR/coherence-with-closure.rs:11:1 | LL | impl Trait for Wrapper<OpaqueClosure> {} | ------------------------------------- first implementation here -LL | LL | impl<T: Sync> Trait for Wrapper<T> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Wrapper<OpaqueClosure>` -error: cannot implement trait on type alias impl trait - --> $DIR/coherence-with-closure.rs:10:24 - | -LL | impl Trait for Wrapper<OpaqueClosure> {} - | ^^^^^^^^^^^^^ - | -note: type alias impl trait defined here - --> $DIR/coherence-with-closure.rs:3:22 - | -LL | type OpaqueClosure = impl Sized; - | ^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-with-generator.rs b/src/test/ui/coherence/coherence-with-generator.rs index d34c391db..70665ba06 100644 --- a/src/test/ui/coherence/coherence-with-generator.rs +++ b/src/test/ui/coherence/coherence-with-generator.rs @@ -12,7 +12,6 @@ fn defining_use() -> OpaqueGenerator { struct Wrapper<T>(T); trait Trait {} impl Trait for Wrapper<OpaqueGenerator> {} -//~^ ERROR cannot implement trait on type alias impl trait impl<T: Sync> Trait for Wrapper<T> {} //~^ ERROR conflicting implementations of trait `Trait` for type `Wrapper<OpaqueGenerator>` diff --git a/src/test/ui/coherence/coherence-with-generator.stderr b/src/test/ui/coherence/coherence-with-generator.stderr index 804bc1c3a..6d3be2e16 100644 --- a/src/test/ui/coherence/coherence-with-generator.stderr +++ b/src/test/ui/coherence/coherence-with-generator.stderr @@ -1,24 +1,11 @@ error[E0119]: conflicting implementations of trait `Trait` for type `Wrapper<OpaqueGenerator>` - --> $DIR/coherence-with-generator.rs:16:1 + --> $DIR/coherence-with-generator.rs:15:1 | LL | impl Trait for Wrapper<OpaqueGenerator> {} | --------------------------------------- first implementation here -LL | LL | impl<T: Sync> Trait for Wrapper<T> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Wrapper<OpaqueGenerator>` -error: cannot implement trait on type alias impl trait - --> $DIR/coherence-with-generator.rs:14:24 - | -LL | impl Trait for Wrapper<OpaqueGenerator> {} - | ^^^^^^^^^^^^^^^ - | -note: type alias impl trait defined here - --> $DIR/coherence-with-generator.rs:3:24 - | -LL | type OpaqueGenerator = impl Sized; - | ^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.stderr b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.stderr index db7306501..93486fa5f 100644 --- a/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.stderr +++ b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.stderr @@ -1,11 +1,11 @@ -error[E0119]: conflicting implementations of trait `MyTrait` for type `lib::MyFundamentalStruct<(MyType,)>` +error[E0119]: conflicting implementations of trait `MyTrait` for type `MyFundamentalStruct<(MyType,)>` --> $DIR/coherence_copy_like_err_fundamental_struct_tuple.rs:16:1 | LL | impl<T: lib::MyCopy> MyTrait for T { } | ---------------------------------- first implementation here ... LL | impl MyTrait for lib::MyFundamentalStruct<(MyType,)> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `lib::MyFundamentalStruct<(MyType,)>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyFundamentalStruct<(MyType,)>` | = note: upstream crates may add a new impl of trait `lib::MyCopy` for type `lib::MyFundamentalStruct<(MyType,)>` in future versions diff --git a/src/test/ui/coherence/coherence_copy_like_err_struct.stderr b/src/test/ui/coherence/coherence_copy_like_err_struct.stderr index 3bc3dffda..7432733b9 100644 --- a/src/test/ui/coherence/coherence_copy_like_err_struct.stderr +++ b/src/test/ui/coherence/coherence_copy_like_err_struct.stderr @@ -1,11 +1,11 @@ -error[E0119]: conflicting implementations of trait `MyTrait` for type `lib::MyStruct<MyType>` +error[E0119]: conflicting implementations of trait `MyTrait` for type `MyStruct<MyType>` --> $DIR/coherence_copy_like_err_struct.rs:19:1 | LL | impl<T: lib::MyCopy> MyTrait for T { } | ---------------------------------- first implementation here ... LL | impl MyTrait for lib::MyStruct<MyType> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `lib::MyStruct<MyType>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyStruct<MyType>` | = note: upstream crates may add a new impl of trait `lib::MyCopy` for type `lib::MyStruct<MyType>` in future versions diff --git a/src/test/ui/coherence/inter-crate-ambiguity-causes-notes.stderr b/src/test/ui/coherence/inter-crate-ambiguity-causes-notes.stderr index 038a0199a..4ddd712b2 100644 --- a/src/test/ui/coherence/inter-crate-ambiguity-causes-notes.stderr +++ b/src/test/ui/coherence/inter-crate-ambiguity-causes-notes.stderr @@ -1,4 +1,4 @@ -error[E0119]: conflicting implementations of trait `std::convert::From<()>` for type `S` +error[E0119]: conflicting implementations of trait `From<()>` for type `S` --> $DIR/inter-crate-ambiguity-causes-notes.rs:9:1 | LL | impl From<()> for S { diff --git a/src/test/ui/coherence/issue-100191-2.rs b/src/test/ui/coherence/issue-100191-2.rs deleted file mode 100644 index 1c8316f87..000000000 --- a/src/test/ui/coherence/issue-100191-2.rs +++ /dev/null @@ -1,12 +0,0 @@ -//~ ERROR overflow evaluating the requirement `T: Trait<_>` - -#![feature(specialization, with_negative_coherence)] -#![allow(incomplete_features)] - -pub trait Trait<T> {} - -default impl<T, U> Trait<T> for U {} - -impl<T> Trait<<T as Iterator>::Item> for T {} - -fn main() {} diff --git a/src/test/ui/coherence/issue-100191.rs b/src/test/ui/coherence/issue-100191.rs deleted file mode 100644 index e8597fde5..000000000 --- a/src/test/ui/coherence/issue-100191.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![crate_type = "lib"] -#![feature(specialization, with_negative_coherence)] -#![allow(incomplete_features)] - -trait X {} -trait Y: X {} -trait Z { - type Assoc: Y; -} -struct A<T>(T); - -impl<T> Y for T where T: X {} -impl<T: X> Z for A<T> { - type Assoc = T; -} - -// this impl is invalid, but causes an ICE anyway -impl<T> From<<A<T> as Z>::Assoc> for T {} -//~^ ERROR type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`) - -fn main() {} diff --git a/src/test/ui/coherence/strict-coherence-needs-negative-coherence.rs b/src/test/ui/coherence/strict-coherence-needs-negative-coherence.rs new file mode 100644 index 000000000..221683dd5 --- /dev/null +++ b/src/test/ui/coherence/strict-coherence-needs-negative-coherence.rs @@ -0,0 +1,7 @@ +#![feature(rustc_attrs)] + +#[rustc_strict_coherence] +trait Foo {} +//~^ ERROR to use `strict_coherence` on this trait, the `with_negative_coherence` feature must be enabled + +fn main() {} diff --git a/src/test/ui/coherence/strict-coherence-needs-negative-coherence.stderr b/src/test/ui/coherence/strict-coherence-needs-negative-coherence.stderr new file mode 100644 index 000000000..b54729287 --- /dev/null +++ b/src/test/ui/coherence/strict-coherence-needs-negative-coherence.stderr @@ -0,0 +1,10 @@ +error: to use `strict_coherence` on this trait, the `with_negative_coherence` feature must be enabled + --> $DIR/strict-coherence-needs-negative-coherence.rs:4:1 + | +LL | #[rustc_strict_coherence] + | ------------------------- due to this attribute +LL | trait Foo {} + | ^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compiletest-self-test/compile-flags-last.rs b/src/test/ui/compiletest-self-test/compile-flags-last.rs new file mode 100644 index 000000000..232df10f1 --- /dev/null +++ b/src/test/ui/compiletest-self-test/compile-flags-last.rs @@ -0,0 +1,7 @@ +// Check that the arguments provided through `// compile-flags` are added last to the command line +// in UI tests. To ensure that we invoke rustc with a flag that expects an argument withut actually +// providing it. If the compile-flags are not last, the test will fail as rustc will interpret the +// next flag as the argument of this flag. +// +// compile-flags: --cap-lints +// error-pattern: Argument to option 'cap-lints' missing diff --git a/src/test/ui/compiletest-self-test/compile-flags-last.stderr b/src/test/ui/compiletest-self-test/compile-flags-last.stderr new file mode 100644 index 000000000..d8d40a7d9 --- /dev/null +++ b/src/test/ui/compiletest-self-test/compile-flags-last.stderr @@ -0,0 +1,2 @@ +error: Argument to option 'cap-lints' missing + diff --git a/src/test/ui/ui-testing-optout.rs b/src/test/ui/compiletest-self-test/ui-testing-optout.rs index 88e811583..88e811583 100644 --- a/src/test/ui/ui-testing-optout.rs +++ b/src/test/ui/compiletest-self-test/ui-testing-optout.rs diff --git a/src/test/ui/ui-testing-optout.stderr b/src/test/ui/compiletest-self-test/ui-testing-optout.stderr index 652c472c0..652c472c0 100644 --- a/src/test/ui/ui-testing-optout.stderr +++ b/src/test/ui/compiletest-self-test/ui-testing-optout.stderr diff --git a/src/test/ui/conditional-compilation/cfg-attr-multi-true.stderr b/src/test/ui/conditional-compilation/cfg-attr-multi-true.stderr index 5f278f94b..fbfcd4565 100644 --- a/src/test/ui/conditional-compilation/cfg-attr-multi-true.stderr +++ b/src/test/ui/conditional-compilation/cfg-attr-multi-true.stderr @@ -28,7 +28,7 @@ warning: unused `MustUseDeprecated` that must be used --> $DIR/cfg-attr-multi-true.rs:19:5 | LL | MustUseDeprecated::new(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here --> $DIR/cfg-attr-multi-true.rs:7:9 diff --git a/src/test/ui/conditional-compilation/cfg_accessible-not_sure.rs b/src/test/ui/conditional-compilation/cfg_accessible-not_sure.rs index d68acd245..99a7949db 100644 --- a/src/test/ui/conditional-compilation/cfg_accessible-not_sure.rs +++ b/src/test/ui/conditional-compilation/cfg_accessible-not_sure.rs @@ -46,7 +46,7 @@ const C: bool = true; trait Trait {} impl dyn Trait { fn existing() {} } -// FIXME: Should be a error for edition > 2015 +// FIXME: Should be an error for edition > 2015 #[cfg_accessible(Trait::existing)] //~ ERROR not sure const A: bool = true; #[cfg_accessible(Trait::unresolved)] //~ ERROR not sure diff --git a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr index f2e7777ce..a46bd5352 100644 --- a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr +++ b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr @@ -18,9 +18,7 @@ LL | LL | 1_u32 | ----- return type was inferred to be `u32` here | - = help: the following other types implement trait `Traitor<N, M>`: - <u32 as Traitor<N, 2>> - <u64 as Traitor<1, 2>> + = help: the trait `Traitor<N, 2>` is implemented for `u32` error[E0277]: the trait bound `u64: Traitor` is not satisfied --> $DIR/rp_impl_trait_fail.rs:21:13 @@ -31,9 +29,7 @@ LL | LL | 1_u64 | ----- return type was inferred to be `u64` here | - = help: the following other types implement trait `Traitor<N, M>`: - <u32 as Traitor<N, 2>> - <u64 as Traitor<1, 2>> + = help: the trait `Traitor<1, 2>` is implemented for `u64` error: aborting due to 3 previous errors diff --git a/src/test/ui/const-generics/defaults/self-referential.rs b/src/test/ui/const-generics/defaults/self-referential.rs new file mode 100644 index 000000000..14a870dc3 --- /dev/null +++ b/src/test/ui/const-generics/defaults/self-referential.rs @@ -0,0 +1,4 @@ +trait Foo<const M: u8, const M: u8 = M> {} +//~^ ERROR the name `M` is already used for a generic parameter in this item's generic parameters +impl Foo<2> for () {} +fn main() {} diff --git a/src/test/ui/const-generics/defaults/self-referential.stderr b/src/test/ui/const-generics/defaults/self-referential.stderr new file mode 100644 index 000000000..170c1f7f7 --- /dev/null +++ b/src/test/ui/const-generics/defaults/self-referential.stderr @@ -0,0 +1,11 @@ +error[E0403]: the name `M` is already used for a generic parameter in this item's generic parameters + --> $DIR/self-referential.rs:1:30 + | +LL | trait Foo<const M: u8, const M: u8 = M> {} + | - ^ already used + | | + | first use of `M` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0403`. diff --git a/src/test/ui/const-generics/generic_const_exprs/assoc_const_unification/const_equate_assoc_consts.rs b/src/test/ui/const-generics/generic_const_exprs/assoc_const_unification/const_equate_assoc_consts.rs new file mode 100644 index 000000000..e8f89cb1a --- /dev/null +++ b/src/test/ui/const-generics/generic_const_exprs/assoc_const_unification/const_equate_assoc_consts.rs @@ -0,0 +1,27 @@ +// check-pass +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +trait Trait { + const ASSOC: usize; +} +impl<T> Trait for T { + const ASSOC: usize = std::mem::size_of::<T>(); +} + +struct Foo<T: Trait>([u8; T::ASSOC]) +where + [(); T::ASSOC]:; + +fn bar<T: Trait>() +where + [(); T::ASSOC]:, +{ + let _: Foo<T> = Foo::<_>(make()); +} + +fn make() -> ! { + todo!() +} + +fn main() {} diff --git a/src/test/ui/const-generics/generic_const_exprs/assoc_const_unification/doesnt_unify_evaluatable.rs b/src/test/ui/const-generics/generic_const_exprs/assoc_const_unification/doesnt_unify_evaluatable.rs new file mode 100644 index 000000000..c8f7553da --- /dev/null +++ b/src/test/ui/const-generics/generic_const_exprs/assoc_const_unification/doesnt_unify_evaluatable.rs @@ -0,0 +1,15 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +trait Trait { + const ASSOC: usize; +} + +fn foo<T: Trait, U: Trait>() where [(); U::ASSOC]:, { + bar::<{ T::ASSOC }>(); + //~^ ERROR: unconstrained generic constant +} + +fn bar<const N: usize>() {} + +fn main() {} diff --git a/src/test/ui/const-generics/generic_const_exprs/assoc_const_unification/doesnt_unify_evaluatable.stderr b/src/test/ui/const-generics/generic_const_exprs/assoc_const_unification/doesnt_unify_evaluatable.stderr new file mode 100644 index 000000000..e4a0cabe5 --- /dev/null +++ b/src/test/ui/const-generics/generic_const_exprs/assoc_const_unification/doesnt_unify_evaluatable.stderr @@ -0,0 +1,10 @@ +error: unconstrained generic constant + --> $DIR/doesnt_unify_evaluatable.rs:9:11 + | +LL | bar::<{ T::ASSOC }>(); + | ^^^^^^^^^^^^ + | + = help: try adding a `where` bound using this expression: `where [(); { T::ASSOC }]:` + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/generic_const_exprs/assoc_const_unification/dropck_unifies_assoc_consts.rs b/src/test/ui/const-generics/generic_const_exprs/assoc_const_unification/dropck_unifies_assoc_consts.rs new file mode 100644 index 000000000..274caa1e9 --- /dev/null +++ b/src/test/ui/const-generics/generic_const_exprs/assoc_const_unification/dropck_unifies_assoc_consts.rs @@ -0,0 +1,20 @@ +// check-pass +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +trait Trait { + const ASSOC: usize; +} + +struct Foo<T: Trait>(T) +where + [(); T::ASSOC]:; + +impl<T: Trait> Drop for Foo<T> +where + [(); T::ASSOC]:, +{ + fn drop(&mut self) {} +} + +fn main() {} diff --git a/src/test/ui/const-generics/generic_const_exprs/assoc_const_unification/unifies_evaluatable.rs b/src/test/ui/const-generics/generic_const_exprs/assoc_const_unification/unifies_evaluatable.rs new file mode 100644 index 000000000..6597b9f2b --- /dev/null +++ b/src/test/ui/const-generics/generic_const_exprs/assoc_const_unification/unifies_evaluatable.rs @@ -0,0 +1,18 @@ +// check-pass + +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +trait Trait { + const ASSOC: usize; +} + +fn foo<T: Trait, U: Trait>() where [(); T::ASSOC]:, { + bar::<{ T::ASSOC }>(); +} + +fn bar<const N: usize>() -> [(); N] { + [(); N] +} + +fn main() {} diff --git a/src/test/ui/const-generics/generic_const_exprs/const_kind_expr/wf_obligation.rs b/src/test/ui/const-generics/generic_const_exprs/const_kind_expr/wf_obligation.rs new file mode 100644 index 000000000..6093fc70b --- /dev/null +++ b/src/test/ui/const-generics/generic_const_exprs/const_kind_expr/wf_obligation.rs @@ -0,0 +1,22 @@ +#![feature(generic_const_exprs, generic_arg_infer)] +#![allow(incomplete_features)] + +// minimized repro for #105205 +// +// the `foo::<_, L>` call results in a `WellFormed(_)` obligation and a +// `ConstEvaluatable(Unevaluated(_ + 1 + L))` obligation. Attempting to fulfill the latter +// unifies the `_` with `Expr(L - 1)` from the paramenv which turns the `WellFormed` +// obligation into `WellFormed(Expr(L - 1))` + +fn foo<const N: usize, const M: usize>(_: [(); N + 1 + M]) {} + +fn ice<const L: usize>() +where + [(); (L - 1) + 1 + L]:, +{ + foo::<_, L>([(); L + 1 + L]); + //~^ ERROR: mismatched types + //~^^ ERROR: unconstrained generic constant +} + +fn main() {} diff --git a/src/test/ui/const-generics/generic_const_exprs/const_kind_expr/wf_obligation.stderr b/src/test/ui/const-generics/generic_const_exprs/const_kind_expr/wf_obligation.stderr new file mode 100644 index 000000000..da5194696 --- /dev/null +++ b/src/test/ui/const-generics/generic_const_exprs/const_kind_expr/wf_obligation.stderr @@ -0,0 +1,20 @@ +error[E0308]: mismatched types + --> $DIR/wf_obligation.rs:17:17 + | +LL | foo::<_, L>([(); L + 1 + L]); + | ^^^^^^^^^^^^^^^ expected `N + 1 + M`, found `L + 1 + L` + | + = note: expected constant `N + 1 + M` + found constant `L + 1 + L` + +error: unconstrained generic constant + --> $DIR/wf_obligation.rs:17:22 + | +LL | foo::<_, L>([(); L + 1 + L]); + | ^^^^^^^^^ + | + = help: try adding a `where` bound using this expression: `where [(); L + 1 + L]:` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/const-generics/generic_const_exprs/issue-102768.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-102768.stderr index 9deb9b265..8278edabe 100644 --- a/src/test/ui/const-generics/generic_const_exprs/issue-102768.stderr +++ b/src/test/ui/const-generics/generic_const_exprs/issue-102768.stderr @@ -11,7 +11,7 @@ LL | type Y<'a>; | ^ -- help: add missing lifetime argument | -LL | fn f2<'a>(arg: Box<dyn X<Y<'a, 1> = &'a ()>>) {} +LL | fn f2<'a>(arg: Box<dyn X<Y<'_, 1> = &'a ()>>) {} | +++ error[E0107]: this associated type takes 0 generic arguments but 1 generic argument was supplied diff --git a/src/test/ui/const-generics/generic_const_exprs/issue-80742.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-80742.stderr index 1b502642e..bf1b411ee 100644 --- a/src/test/ui/const-generics/generic_const_exprs/issue-80742.stderr +++ b/src/test/ui/const-generics/generic_const_exprs/issue-80742.stderr @@ -2,15 +2,18 @@ error[E0080]: evaluation of `Inline::<dyn std::fmt::Debug>::{constant#0}` failed --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | intrinsics::size_of::<T>() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | size_of called on unsized type `dyn Debug` - | inside `std::mem::size_of::<dyn Debug>` at $SRC_DIR/core/src/mem/mod.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ size_of called on unsized type `dyn Debug` + | +note: inside `std::mem::size_of::<dyn Debug>` + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | - ::: $DIR/issue-80742.rs:22:10 +LL | intrinsics::size_of::<T>() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `Inline::<dyn Debug>::{constant#0}` + --> $DIR/issue-80742.rs:22:10 | LL | [u8; size_of::<T>() + 1]: , - | -------------- inside `Inline::<dyn Debug>::{constant#0}` at $DIR/issue-80742.rs:22:10 + | ^^^^^^^^^^^^^^ error[E0599]: the function or associated item `new` exists for struct `Inline<dyn Debug>`, but its trait bounds were not satisfied --> $DIR/issue-80742.rs:30:36 @@ -33,15 +36,18 @@ error[E0080]: evaluation of `Inline::<dyn std::fmt::Debug>::{constant#0}` failed --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | intrinsics::size_of::<T>() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | size_of called on unsized type `dyn Debug` - | inside `std::mem::size_of::<dyn Debug>` at $SRC_DIR/core/src/mem/mod.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ size_of called on unsized type `dyn Debug` + | +note: inside `std::mem::size_of::<dyn Debug>` + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | - ::: $DIR/issue-80742.rs:14:10 +LL | intrinsics::size_of::<T>() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `Inline::<dyn Debug>::{constant#0}` + --> $DIR/issue-80742.rs:14:10 | LL | [u8; size_of::<T>() + 1]: , - | -------------- inside `Inline::<dyn Debug>::{constant#0}` at $DIR/issue-80742.rs:14:10 + | ^^^^^^^^^^^^^^ error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time --> $DIR/issue-80742.rs:30:15 diff --git a/src/test/ui/const-generics/generic_const_exprs/issue-99705.rs b/src/test/ui/const-generics/generic_const_exprs/issue-99705.rs new file mode 100644 index 000000000..75b57b621 --- /dev/null +++ b/src/test/ui/const-generics/generic_const_exprs/issue-99705.rs @@ -0,0 +1,33 @@ +// check-pass +#![crate_type = "lib"] +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] +pub trait MyIterator { + type Output; +} + +pub trait Foo { + const ABC: usize; +} + +pub struct IteratorStruct<const N: usize>{ + +} + +pub struct Bar<const N: usize> { + pub data: [usize; N] +} + +impl<const N: usize> MyIterator for IteratorStruct<N> { + type Output = Bar<N>; +} + +pub fn test1<T: Foo>() -> impl MyIterator<Output = Bar<{T::ABC}>> where [(); T::ABC]: Sized { + IteratorStruct::<{T::ABC}>{} +} + +pub trait Baz<const N: usize>{} +impl<const N: usize> Baz<N> for Bar<N> {} +pub fn test2<T: Foo>() -> impl MyIterator<Output = impl Baz<{ T::ABC }>> where [(); T::ABC]: Sized { + IteratorStruct::<{T::ABC}>{} +} diff --git a/src/test/ui/const-generics/generic_const_exprs/normed_to_param_is_evaluatable.rs b/src/test/ui/const-generics/generic_const_exprs/normed_to_param_is_evaluatable.rs new file mode 100644 index 000000000..b37b354ae --- /dev/null +++ b/src/test/ui/const-generics/generic_const_exprs/normed_to_param_is_evaluatable.rs @@ -0,0 +1,12 @@ +// check-pass +#![feature(generic_const_exprs)] +#![allow(incomplete_features, unused_braces)] + +#[rustfmt::skip] +fn foo<const N: usize>() { + bar::<{{{{{{ N }}}}}}>(); +} + +fn bar<const N: usize>() {} + +fn main() {} diff --git a/src/test/ui/const-generics/conservative_is_privately_uninhabited_uses_correct_param_env-1.rs b/src/test/ui/const-generics/inhabited-assoc-ty-ice-1.rs index c9e26c302..b385406b0 100644 --- a/src/test/ui/const-generics/conservative_is_privately_uninhabited_uses_correct_param_env-1.rs +++ b/src/test/ui/const-generics/inhabited-assoc-ty-ice-1.rs @@ -2,7 +2,7 @@ #![feature(generic_const_exprs)] #![allow(incomplete_features)] -// This tests that the `conservative_is_privately_uninhabited` fn doesn't cause +// This tests that the inhabited check doesn't cause // ICEs by trying to evaluate `T::ASSOC` with an incorrect `ParamEnv`. trait Foo { diff --git a/src/test/ui/const-generics/conservative_is_privately_uninhabited_uses_correct_param_env-2.rs b/src/test/ui/const-generics/inhabited-assoc-ty-ice-2.rs index 3017920fc..216d29c7c 100644 --- a/src/test/ui/const-generics/conservative_is_privately_uninhabited_uses_correct_param_env-2.rs +++ b/src/test/ui/const-generics/inhabited-assoc-ty-ice-2.rs @@ -2,7 +2,7 @@ #![feature(generic_const_exprs)] #![allow(incomplete_features)] -// This tests that the `conservative_is_privately_uninhabited` fn doesn't cause +// This tests that the inhabited check doesn't cause // ICEs by trying to evaluate `T::ASSOC` with an incorrect `ParamEnv`. trait Foo { diff --git a/src/test/ui/const-generics/invariant.rs b/src/test/ui/const-generics/invariant.rs index ee191b65c..39d658be6 100644 --- a/src/test/ui/const-generics/invariant.rs +++ b/src/test/ui/const-generics/invariant.rs @@ -24,7 +24,8 @@ where fn covariant( v: &'static Foo<for<'a> fn(&'a ())> ) -> &'static Foo<fn(&'static ())> { - v //~ ERROR mismatched types + v + //~^ ERROR mismatched types } fn main() { diff --git a/src/test/ui/const-generics/issues/issue-100313.stderr b/src/test/ui/const-generics/issues/issue-100313.stderr index f3ce357c2..d4b486376 100644 --- a/src/test/ui/const-generics/issues/issue-100313.stderr +++ b/src/test/ui/const-generics/issues/issue-100313.stderr @@ -2,13 +2,18 @@ error[E0080]: evaluation of constant value failed --> $DIR/issue-100313.rs:10:13 | LL | *(B as *const bool as *mut bool) = false; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ writing to alloc7 which is read-only + | +note: inside `T::<&true>::set_false` + --> $DIR/issue-100313.rs:10:13 + | +LL | *(B as *const bool as *mut bool) = false; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | writing to alloc7 which is read-only - | inside `T::<&true>::set_false` at $DIR/issue-100313.rs:10:13 -... +note: inside `_` + --> $DIR/issue-100313.rs:18:5 + | LL | x.set_false(); - | ------------- inside `_` at $DIR/issue-100313.rs:18:5 + | ^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/const-generics/issues/issue-82956.stderr b/src/test/ui/const-generics/issues/issue-82956.stderr index c8b999da9..d2320293e 100644 --- a/src/test/ui/const-generics/issues/issue-82956.stderr +++ b/src/test/ui/const-generics/issues/issue-82956.stderr @@ -2,7 +2,7 @@ error[E0433]: failed to resolve: use of undeclared type `IntoIter` --> $DIR/issue-82956.rs:25:24 | LL | let mut iter = IntoIter::new(self); - | ^^^^^^^^ not found in this scope + | ^^^^^^^^ use of undeclared type `IntoIter` | help: consider importing one of these items | diff --git a/src/test/ui/const-generics/issues/issue-83765.stderr b/src/test/ui/const-generics/issues/issue-83765.stderr index 4becf3a36..d7b2b006c 100644 --- a/src/test/ui/const-generics/issues/issue-83765.stderr +++ b/src/test/ui/const-generics/issues/issue-83765.stderr @@ -1,15 +1,15 @@ -error[E0391]: cycle detected when resolving instance `<LazyUpdim<'_, T, { T::DIM }, DIM> as TensorDimension>::DIM` +error[E0391]: cycle detected when resolving instance `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>::DIM` --> $DIR/issue-83765.rs:5:5 | LL | const DIM: usize; | ^^^^^^^^^^^^^^^^ | -note: ...which requires computing candidate for `<LazyUpdim<'_, T, { T::DIM }, DIM> as TensorDimension>`... +note: ...which requires computing candidate for `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>`... --> $DIR/issue-83765.rs:4:1 | LL | trait TensorDimension { | ^^^^^^^^^^^^^^^^^^^^^ - = note: ...which again requires resolving instance `<LazyUpdim<'_, T, { T::DIM }, DIM> as TensorDimension>::DIM`, completing the cycle + = note: ...which again requires resolving instance `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>::DIM`, completing the cycle note: cycle used when computing candidate for `<LazyUpdim<'_, T, { T::DIM }, DIM> as TensorDimension>` --> $DIR/issue-83765.rs:4:1 | diff --git a/src/test/ui/const-generics/issues/issue-85031-2.rs b/src/test/ui/const-generics/issues/issue-85031-2.rs new file mode 100644 index 000000000..4908fb296 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-85031-2.rs @@ -0,0 +1,18 @@ +// check-pass +// known-bug + +// This should not compile, as the compiler should not know +// `A - 0` is satisfied `?x - 0` if `?x` is inferred to `A`. +#![allow(incomplete_features)] +#![feature(generic_const_exprs)] + +pub struct Ref<'a>(&'a i32); + +impl<'a> Ref<'a> { + pub fn foo<const A: usize>() -> [(); A - 0] { + //~^ WARN function cannot + Self::foo() + } +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-85031-2.stderr b/src/test/ui/const-generics/issues/issue-85031-2.stderr new file mode 100644 index 000000000..fc6905768 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-85031-2.stderr @@ -0,0 +1,14 @@ +warning: function cannot return without recursing + --> $DIR/issue-85031-2.rs:12:5 + | +LL | pub fn foo<const A: usize>() -> [(); A - 0] { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing +LL | +LL | Self::foo() + | ----------- recursive call site + | + = help: a `loop` may express intention better if this is on purpose + = note: `#[warn(unconditional_recursion)]` on by default + +warning: 1 warning emitted + diff --git a/src/test/ui/const-generics/min_const_generics/macro-fail.rs b/src/test/ui/const-generics/min_const_generics/macro-fail.rs index f83518fc9..7fb69032e 100644 --- a/src/test/ui/const-generics/min_const_generics/macro-fail.rs +++ b/src/test/ui/const-generics/min_const_generics/macro-fail.rs @@ -14,7 +14,6 @@ impl<const N: usize> Marker<N> for Example<N> {} fn make_marker() -> impl Marker<gimme_a_const!(marker)> { //~^ ERROR: type provided when a constant was expected Example::<gimme_a_const!(marker)> - //~^ ERROR: type provided when a constant was expected } fn from_marker(_: impl Marker<{ @@ -34,9 +33,7 @@ fn main() { }>; let _fail = Example::<external_macro!()>; - //~^ ERROR: type provided when a constant was expected let _fail = Example::<gimme_a_const!()>; - //~^ ERROR: type provided when a constant was expected - //~| ERROR unexpected end of macro invocation + //~^ ERROR unexpected end of macro invocation } diff --git a/src/test/ui/const-generics/min_const_generics/macro-fail.stderr b/src/test/ui/const-generics/min_const_generics/macro-fail.stderr index d5dd70d9b..9f73b91aa 100644 --- a/src/test/ui/const-generics/min_const_generics/macro-fail.stderr +++ b/src/test/ui/const-generics/min_const_generics/macro-fail.stderr @@ -1,5 +1,5 @@ error: expected type, found `{` - --> $DIR/macro-fail.rs:29:27 + --> $DIR/macro-fail.rs:28:27 | LL | fn make_marker() -> impl Marker<gimme_a_const!(marker)> { | ---------------------- @@ -13,7 +13,7 @@ LL | ($rusty: ident) => {{ let $rusty = 3; *&$rusty }} = note: this error originates in the macro `gimme_a_const` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected type, found `{` - --> $DIR/macro-fail.rs:29:27 + --> $DIR/macro-fail.rs:28:27 | LL | Example::<gimme_a_const!(marker)> | ---------------------- @@ -46,13 +46,19 @@ LL | let _fail = Example::<external_macro!()>; = note: this error originates in the macro `external_macro` (in Nightly builds, run with -Z macro-backtrace for more info) error: unexpected end of macro invocation - --> $DIR/macro-fail.rs:39:25 + --> $DIR/macro-fail.rs:37:25 | LL | macro_rules! gimme_a_const { | -------------------------- when calling this macro ... LL | let _fail = Example::<gimme_a_const!()>; | ^^^^^^^^^^^^^^^^ missing tokens in macro arguments + | +note: while trying to match meta-variable `$rusty:ident` + --> $DIR/macro-fail.rs:28:8 + | +LL | ($rusty: ident) => {{ let $rusty = 3; *&$rusty }} + | ^^^^^^^^^^^^^ error[E0747]: type provided when a constant was expected --> $DIR/macro-fail.rs:14:33 @@ -60,24 +66,6 @@ error[E0747]: type provided when a constant was expected LL | fn make_marker() -> impl Marker<gimme_a_const!(marker)> { | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0747]: type provided when a constant was expected - --> $DIR/macro-fail.rs:16:13 - | -LL | Example::<gimme_a_const!(marker)> - | ^^^^^^^^^^^^^^^^^^^^^^ - -error[E0747]: type provided when a constant was expected - --> $DIR/macro-fail.rs:36:25 - | -LL | let _fail = Example::<external_macro!()>; - | ^^^^^^^^^^^^^^^^^ - -error[E0747]: type provided when a constant was expected - --> $DIR/macro-fail.rs:39:25 - | -LL | let _fail = Example::<gimme_a_const!()>; - | ^^^^^^^^^^^^^^^^ - -error: aborting due to 8 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0747`. diff --git a/src/test/ui/const-generics/projection-as-arg-const.rs b/src/test/ui/const-generics/projection-as-arg-const.rs new file mode 100644 index 000000000..903548c75 --- /dev/null +++ b/src/test/ui/const-generics/projection-as-arg-const.rs @@ -0,0 +1,20 @@ +// This is currently not possible to use projections as const generics. +// More information about this available here: +// https://github.com/rust-lang/rust/pull/104443#discussion_r1029375633 + +pub trait Identity { + type Identity; +} + +impl<T> Identity for T { + type Identity = Self; +} + +pub fn foo<const X: <i32 as Identity>::Identity>() { +//~^ ERROR + assert!(X == 12); +} + +fn main() { + foo::<12>(); +} diff --git a/src/test/ui/const-generics/projection-as-arg-const.stderr b/src/test/ui/const-generics/projection-as-arg-const.stderr new file mode 100644 index 000000000..803ed9c95 --- /dev/null +++ b/src/test/ui/const-generics/projection-as-arg-const.stderr @@ -0,0 +1,11 @@ +error: `<i32 as Identity>::Identity` is forbidden as the type of a const generic parameter + --> $DIR/projection-as-arg-const.rs:13:21 + | +LL | pub fn foo<const X: <i32 as Identity>::Identity>() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: aborting due to previous error + diff --git a/src/test/ui/const-ptr/forbidden_slices.32bit.stderr b/src/test/ui/const-ptr/forbidden_slices.32bit.stderr index 8978ab436..563f3ffd6 100644 --- a/src/test/ui/const-ptr/forbidden_slices.32bit.stderr +++ b/src/test/ui/const-ptr/forbidden_slices.32bit.stderr @@ -2,43 +2,52 @@ error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | LL | &*ptr::slice_from_raw_parts(data, len) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance) - | inside `std::slice::from_raw_parts::<'_, u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance) + | +note: inside `std::slice::from_raw_parts::<'_, u32>` + --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | - ::: $DIR/forbidden_slices.rs:18:34 +LL | &*ptr::slice_from_raw_parts(data, len) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `S0` + --> $DIR/forbidden_slices.rs:18:34 | LL | pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) }; - | ------------------------------ inside `S0` at $DIR/forbidden_slices.rs:18:34 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | LL | &*ptr::slice_from_raw_parts(data, len) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance) - | inside `std::slice::from_raw_parts::<'_, ()>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance) + | +note: inside `std::slice::from_raw_parts::<'_, ()>` + --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | - ::: $DIR/forbidden_slices.rs:19:33 +LL | &*ptr::slice_from_raw_parts(data, len) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `S1` + --> $DIR/forbidden_slices.rs:19:33 | LL | pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) }; - | ------------------------------ inside `S1` at $DIR/forbidden_slices.rs:19:33 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | LL | &*ptr::slice_from_raw_parts(data, len) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | dereferencing pointer failed: ALLOC_ID has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds - | inside `std::slice::from_raw_parts::<'_, u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC_ID has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds + | +note: inside `std::slice::from_raw_parts::<'_, u32>` + --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | - ::: $DIR/forbidden_slices.rs:22:34 +LL | &*ptr::slice_from_raw_parts(data, len) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `S2` + --> $DIR/forbidden_slices.rs:22:34 | LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) }; - | ---------------------- inside `S2` at $DIR/forbidden_slices.rs:22:34 + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value --> $DIR/forbidden_slices.rs:25:1 @@ -89,72 +98,85 @@ error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | LL | &*ptr::slice_from_raw_parts(data, len) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | dereferencing pointer failed: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds - | inside `std::slice::from_raw_parts::<'_, u64>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds | - ::: $DIR/forbidden_slices.rs:43:5 +note: inside `std::slice::from_raw_parts::<'_, u64>` + --> $SRC_DIR/core/src/slice/raw.rs:LL:COL + | +LL | &*ptr::slice_from_raw_parts(data, len) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `S8` + --> $DIR/forbidden_slices.rs:43:5 | LL | from_raw_parts(ptr, 1) - | ---------------------- inside `S8` at $DIR/forbidden_slices.rs:43:5 + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance) - | inside `ptr::const_ptr::<impl *const u32>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance) | - ::: $SRC_DIR/core/src/slice/raw.rs:LL:COL +note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | -LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) } - | ------------------------------ inside `from_ptr_range::<'_, u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL +LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `from_ptr_range::<'_, u32>` + --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | - ::: $DIR/forbidden_slices.rs:46:34 +LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `R0` + --> $DIR/forbidden_slices.rs:46:34 | LL | pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; - | ---------------------------------------- inside `R0` at $DIR/forbidden_slices.rs:46:34 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | assert!(0 < pointee_size && pointee_size <= isize::MAX as usize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | the evaluated program panicked at 'assertion failed: 0 < pointee_size && pointee_size <= isize::MAX as usize', $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL - | inside `ptr::const_ptr::<impl *const ()>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: 0 < pointee_size && pointee_size <= isize::MAX as usize', $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - ::: $SRC_DIR/core/src/slice/raw.rs:LL:COL +note: inside `ptr::const_ptr::<impl *const ()>::sub_ptr` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | -LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) } - | ------------------------------ inside `from_ptr_range::<'_, ()>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL +LL | assert!(0 < pointee_size && pointee_size <= isize::MAX as usize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `from_ptr_range::<'_, ()>` + --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | - ::: $DIR/forbidden_slices.rs:47:33 +LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `R1` + --> $DIR/forbidden_slices.rs:47:33 | LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; - | ---------------------------------------- inside `R1` at $DIR/forbidden_slices.rs:47:33 - | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::offset(self, count) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC_ID has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds + | +note: inside `ptr::const_ptr::<impl *const u32>::offset` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | +LL | unsafe { intrinsics::offset(self, count) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | out-of-bounds pointer arithmetic: ALLOC_ID has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds - | inside `ptr::const_ptr::<impl *const u32>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -... -LL | unsafe { self.offset(count as isize) } - | --------------------------- inside `ptr::const_ptr::<impl *const u32>::add` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL +note: inside `ptr::const_ptr::<impl *const u32>::add` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - ::: $DIR/forbidden_slices.rs:50:25 +LL | unsafe { self.offset(count as isize) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `R2` + --> $DIR/forbidden_slices.rs:50:25 | LL | from_ptr_range(ptr..ptr.add(2)) - | ---------- inside `R2` at $DIR/forbidden_slices.rs:50:25 + | ^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value --> $DIR/forbidden_slices.rs:52:1 @@ -205,56 +227,67 @@ error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::offset(self, count) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds + | +note: inside `ptr::const_ptr::<impl *const u64>::offset` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | +LL | unsafe { intrinsics::offset(self, count) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | out-of-bounds pointer arithmetic: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds - | inside `ptr::const_ptr::<impl *const u64>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -... -LL | unsafe { self.offset(count as isize) } - | --------------------------- inside `ptr::const_ptr::<impl *const u64>::add` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL +note: inside `ptr::const_ptr::<impl *const u64>::add` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - ::: $DIR/forbidden_slices.rs:74:25 +LL | unsafe { self.offset(count as isize) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `R8` + --> $DIR/forbidden_slices.rs:74:25 | LL | from_ptr_range(ptr..ptr.add(1)) - | ---------- inside `R8` at $DIR/forbidden_slices.rs:74:25 + | ^^^^^^^^^^ error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | `ptr_offset_from_unsigned` called on pointers into different allocations - | inside `ptr::const_ptr::<impl *const u32>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on pointers into different allocations | - ::: $SRC_DIR/core/src/slice/raw.rs:LL:COL +note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | -LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) } - | ------------------------------ inside `from_ptr_range::<'_, u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL +LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `from_ptr_range::<'_, u32>` + --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | - ::: $DIR/forbidden_slices.rs:79:34 +LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `R9` + --> $DIR/forbidden_slices.rs:79:34 | LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) }; - | ----------------------------------------------- inside `R9` at $DIR/forbidden_slices.rs:79:34 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | `ptr_offset_from_unsigned` called on pointers into different allocations - | inside `ptr::const_ptr::<impl *const u32>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on pointers into different allocations | - ::: $SRC_DIR/core/src/slice/raw.rs:LL:COL +note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | -LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) } - | ------------------------------ inside `from_ptr_range::<'_, u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL +LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `from_ptr_range::<'_, u32>` + --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | - ::: $DIR/forbidden_slices.rs:80:35 +LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `R10` + --> $DIR/forbidden_slices.rs:80:35 | LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) }; - | ------------------------ inside `R10` at $DIR/forbidden_slices.rs:80:35 + | ^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 18 previous errors diff --git a/src/test/ui/const-ptr/forbidden_slices.64bit.stderr b/src/test/ui/const-ptr/forbidden_slices.64bit.stderr index db42b7c98..43529d57f 100644 --- a/src/test/ui/const-ptr/forbidden_slices.64bit.stderr +++ b/src/test/ui/const-ptr/forbidden_slices.64bit.stderr @@ -2,43 +2,52 @@ error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | LL | &*ptr::slice_from_raw_parts(data, len) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance) - | inside `std::slice::from_raw_parts::<'_, u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance) + | +note: inside `std::slice::from_raw_parts::<'_, u32>` + --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | - ::: $DIR/forbidden_slices.rs:18:34 +LL | &*ptr::slice_from_raw_parts(data, len) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `S0` + --> $DIR/forbidden_slices.rs:18:34 | LL | pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) }; - | ------------------------------ inside `S0` at $DIR/forbidden_slices.rs:18:34 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | LL | &*ptr::slice_from_raw_parts(data, len) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance) - | inside `std::slice::from_raw_parts::<'_, ()>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance) + | +note: inside `std::slice::from_raw_parts::<'_, ()>` + --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | - ::: $DIR/forbidden_slices.rs:19:33 +LL | &*ptr::slice_from_raw_parts(data, len) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `S1` + --> $DIR/forbidden_slices.rs:19:33 | LL | pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) }; - | ------------------------------ inside `S1` at $DIR/forbidden_slices.rs:19:33 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | LL | &*ptr::slice_from_raw_parts(data, len) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | dereferencing pointer failed: ALLOC_ID has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds - | inside `std::slice::from_raw_parts::<'_, u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC_ID has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds + | +note: inside `std::slice::from_raw_parts::<'_, u32>` + --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | - ::: $DIR/forbidden_slices.rs:22:34 +LL | &*ptr::slice_from_raw_parts(data, len) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `S2` + --> $DIR/forbidden_slices.rs:22:34 | LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) }; - | ---------------------- inside `S2` at $DIR/forbidden_slices.rs:22:34 + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value --> $DIR/forbidden_slices.rs:25:1 @@ -89,72 +98,85 @@ error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | LL | &*ptr::slice_from_raw_parts(data, len) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | dereferencing pointer failed: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds - | inside `std::slice::from_raw_parts::<'_, u64>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds | - ::: $DIR/forbidden_slices.rs:43:5 +note: inside `std::slice::from_raw_parts::<'_, u64>` + --> $SRC_DIR/core/src/slice/raw.rs:LL:COL + | +LL | &*ptr::slice_from_raw_parts(data, len) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `S8` + --> $DIR/forbidden_slices.rs:43:5 | LL | from_raw_parts(ptr, 1) - | ---------------------- inside `S8` at $DIR/forbidden_slices.rs:43:5 + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance) - | inside `ptr::const_ptr::<impl *const u32>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance) | - ::: $SRC_DIR/core/src/slice/raw.rs:LL:COL +note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | -LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) } - | ------------------------------ inside `from_ptr_range::<'_, u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL +LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `from_ptr_range::<'_, u32>` + --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | - ::: $DIR/forbidden_slices.rs:46:34 +LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `R0` + --> $DIR/forbidden_slices.rs:46:34 | LL | pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; - | ---------------------------------------- inside `R0` at $DIR/forbidden_slices.rs:46:34 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | assert!(0 < pointee_size && pointee_size <= isize::MAX as usize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | the evaluated program panicked at 'assertion failed: 0 < pointee_size && pointee_size <= isize::MAX as usize', $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL - | inside `ptr::const_ptr::<impl *const ()>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: 0 < pointee_size && pointee_size <= isize::MAX as usize', $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - ::: $SRC_DIR/core/src/slice/raw.rs:LL:COL +note: inside `ptr::const_ptr::<impl *const ()>::sub_ptr` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | -LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) } - | ------------------------------ inside `from_ptr_range::<'_, ()>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL +LL | assert!(0 < pointee_size && pointee_size <= isize::MAX as usize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `from_ptr_range::<'_, ()>` + --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | - ::: $DIR/forbidden_slices.rs:47:33 +LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `R1` + --> $DIR/forbidden_slices.rs:47:33 | LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; - | ---------------------------------------- inside `R1` at $DIR/forbidden_slices.rs:47:33 - | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::offset(self, count) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC_ID has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds + | +note: inside `ptr::const_ptr::<impl *const u32>::offset` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | +LL | unsafe { intrinsics::offset(self, count) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | out-of-bounds pointer arithmetic: ALLOC_ID has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds - | inside `ptr::const_ptr::<impl *const u32>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -... -LL | unsafe { self.offset(count as isize) } - | --------------------------- inside `ptr::const_ptr::<impl *const u32>::add` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL +note: inside `ptr::const_ptr::<impl *const u32>::add` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - ::: $DIR/forbidden_slices.rs:50:25 +LL | unsafe { self.offset(count as isize) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `R2` + --> $DIR/forbidden_slices.rs:50:25 | LL | from_ptr_range(ptr..ptr.add(2)) - | ---------- inside `R2` at $DIR/forbidden_slices.rs:50:25 + | ^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value --> $DIR/forbidden_slices.rs:52:1 @@ -205,56 +227,67 @@ error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::offset(self, count) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds + | +note: inside `ptr::const_ptr::<impl *const u64>::offset` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | +LL | unsafe { intrinsics::offset(self, count) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | out-of-bounds pointer arithmetic: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds - | inside `ptr::const_ptr::<impl *const u64>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -... -LL | unsafe { self.offset(count as isize) } - | --------------------------- inside `ptr::const_ptr::<impl *const u64>::add` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL +note: inside `ptr::const_ptr::<impl *const u64>::add` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - ::: $DIR/forbidden_slices.rs:74:25 +LL | unsafe { self.offset(count as isize) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `R8` + --> $DIR/forbidden_slices.rs:74:25 | LL | from_ptr_range(ptr..ptr.add(1)) - | ---------- inside `R8` at $DIR/forbidden_slices.rs:74:25 + | ^^^^^^^^^^ error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | `ptr_offset_from_unsigned` called on pointers into different allocations - | inside `ptr::const_ptr::<impl *const u32>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on pointers into different allocations | - ::: $SRC_DIR/core/src/slice/raw.rs:LL:COL +note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | -LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) } - | ------------------------------ inside `from_ptr_range::<'_, u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL +LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `from_ptr_range::<'_, u32>` + --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | - ::: $DIR/forbidden_slices.rs:79:34 +LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `R9` + --> $DIR/forbidden_slices.rs:79:34 | LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) }; - | ----------------------------------------------- inside `R9` at $DIR/forbidden_slices.rs:79:34 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | `ptr_offset_from_unsigned` called on pointers into different allocations - | inside `ptr::const_ptr::<impl *const u32>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on pointers into different allocations | - ::: $SRC_DIR/core/src/slice/raw.rs:LL:COL +note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | -LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) } - | ------------------------------ inside `from_ptr_range::<'_, u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL +LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `from_ptr_range::<'_, u32>` + --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | - ::: $DIR/forbidden_slices.rs:80:35 +LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `R10` + --> $DIR/forbidden_slices.rs:80:35 | LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) }; - | ------------------------ inside `R10` at $DIR/forbidden_slices.rs:80:35 + | ^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 18 previous errors diff --git a/src/test/ui/const-ptr/out_of_bounds_read.stderr b/src/test/ui/const-ptr/out_of_bounds_read.stderr index 52b173c4d..bca29b468 100644 --- a/src/test/ui/const-ptr/out_of_bounds_read.stderr +++ b/src/test/ui/const-ptr/out_of_bounds_read.stderr @@ -2,53 +2,62 @@ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | memory access failed: alloc5 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds - | inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: alloc5 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds + | +note: inside `std::ptr::read::<u32>` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | - ::: $DIR/out_of_bounds_read.rs:12:33 +LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `_READ` + --> $DIR/out_of_bounds_read.rs:12:33 | LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; - | ----------------------- inside `_READ` at $DIR/out_of_bounds_read.rs:12:33 + | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | memory access failed: alloc5 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds - | inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: alloc5 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds | - ::: $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 | -LL | unsafe { read(self) } - | ---------- inside `ptr::const_ptr::<impl *const u32>::read` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL +LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `ptr::const_ptr::<impl *const u32>::read` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - ::: $DIR/out_of_bounds_read.rs:13:39 +LL | unsafe { read(self) } + | ^^^^^^^^^^ +note: inside `_CONST_READ` + --> $DIR/out_of_bounds_read.rs:13:39 | LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; - | ------------------- inside `_CONST_READ` at $DIR/out_of_bounds_read.rs:13:39 + | ^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | memory access failed: alloc5 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds - | inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: alloc5 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds + | +note: inside `std::ptr::read::<u32>` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | - ::: $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL +LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `ptr::mut_ptr::<impl *mut u32>::read` + --> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL | LL | unsafe { read(self) } - | ---------- inside `ptr::mut_ptr::<impl *mut u32>::read` at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - | - ::: $DIR/out_of_bounds_read.rs:14:37 + | ^^^^^^^^^^ +note: inside `_MUT_READ` + --> $DIR/out_of_bounds_read.rs:14:37 | LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() }; - | --------------------------------- inside `_MUT_READ` at $DIR/out_of_bounds_read.rs:14:37 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/constructor-lifetime-args.stderr b/src/test/ui/constructor-lifetime-args.stderr index b97b6faa3..bc1141b16 100644 --- a/src/test/ui/constructor-lifetime-args.stderr +++ b/src/test/ui/constructor-lifetime-args.stderr @@ -13,8 +13,8 @@ LL | struct S<'a, 'b>(&'a u8, &'b u8); | ^ -- -- help: add missing lifetime argument | -LL | S::<'static, 'b>(&0, &0); - | ++++ +LL | S::<'static, 'static>(&0, &0); + | +++++++++ error[E0107]: this struct takes 2 lifetime arguments but 3 lifetime arguments were supplied --> $DIR/constructor-lifetime-args.rs:19:5 @@ -45,8 +45,8 @@ LL | enum E<'a, 'b> { | ^ -- -- help: add missing lifetime argument | -LL | E::V::<'static, 'b>(&0); - | ++++ +LL | E::V::<'static, 'static>(&0); + | +++++++++ error[E0107]: this enum takes 2 lifetime arguments but 3 lifetime arguments were supplied --> $DIR/constructor-lifetime-args.rs:24:8 diff --git a/src/test/ui/consts/const-err-late.rs b/src/test/ui/consts/const-err-late.rs index a20ae7025..d2476e493 100644 --- a/src/test/ui/consts/const-err-late.rs +++ b/src/test/ui/consts/const-err-late.rs @@ -16,7 +16,5 @@ impl<T> S<T> { } fn main() { - black_box((S::<i32>::FOO, S::<u32>::FOO)); - //~^ ERROR erroneous constant - //~| ERROR erroneous constant + black_box((S::<i32>::FOO, S::<u32>::FOO)); //~ constant } diff --git a/src/test/ui/consts/const-err-late.stderr b/src/test/ui/consts/const-err-late.stderr index 3a8b10317..c5c668189 100644 --- a/src/test/ui/consts/const-err-late.stderr +++ b/src/test/ui/consts/const-err-late.stderr @@ -4,11 +4,17 @@ error[E0080]: evaluation of `S::<i32>::FOO` failed LL | const FOO: u8 = [5u8][1]; | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 -error[E0080]: erroneous constant used +note: erroneous constant used --> $DIR/const-err-late.rs:19:16 | LL | black_box((S::<i32>::FOO, S::<u32>::FOO)); - | ^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^ + +note: erroneous constant used + --> $DIR/const-err-late.rs:19:16 + | +LL | black_box((S::<i32>::FOO, S::<u32>::FOO)); + | ^^^^^^^^^^^^^ error[E0080]: evaluation of `S::<u32>::FOO` failed --> $DIR/const-err-late.rs:13:21 @@ -16,12 +22,30 @@ error[E0080]: evaluation of `S::<u32>::FOO` failed LL | const FOO: u8 = [5u8][1]; | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 -error[E0080]: erroneous constant used +note: erroneous constant used + --> $DIR/const-err-late.rs:19:31 + | +LL | black_box((S::<i32>::FOO, S::<u32>::FOO)); + | ^^^^^^^^^^^^^ + +note: erroneous constant used + --> $DIR/const-err-late.rs:19:31 + | +LL | black_box((S::<i32>::FOO, S::<u32>::FOO)); + | ^^^^^^^^^^^^^ + +note: erroneous constant used + --> $DIR/const-err-late.rs:19:16 + | +LL | black_box((S::<i32>::FOO, S::<u32>::FOO)); + | ^^^^^^^^^^^^^ + +note: erroneous constant used --> $DIR/const-err-late.rs:19:31 | LL | black_box((S::<i32>::FOO, S::<u32>::FOO)); - | ^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-err-multi.rs b/src/test/ui/consts/const-err-multi.rs index fb26e8aac..b265bc4c4 100644 --- a/src/test/ui/consts/const-err-multi.rs +++ b/src/test/ui/consts/const-err-multi.rs @@ -1,11 +1,11 @@ pub const A: i8 = -i8::MIN; //~^ ERROR constant pub const B: i8 = A; -//~^ ERROR constant +//~^ constant pub const C: u8 = A as u8; -//~^ ERROR constant +//~^ constant pub const D: i8 = 50 - A; -//~^ ERROR constant +//~^ constant fn main() { let _ = (A, B, C, D); diff --git a/src/test/ui/consts/const-err-multi.stderr b/src/test/ui/consts/const-err-multi.stderr index fca9e2270..28af8e5eb 100644 --- a/src/test/ui/consts/const-err-multi.stderr +++ b/src/test/ui/consts/const-err-multi.stderr @@ -4,24 +4,24 @@ error[E0080]: evaluation of constant value failed LL | pub const A: i8 = -i8::MIN; | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/const-err-multi.rs:3:19 | LL | pub const B: i8 = A; - | ^ referenced constant has errors + | ^ -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/const-err-multi.rs:5:19 | LL | pub const C: u8 = A as u8; - | ^ referenced constant has errors + | ^ -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/const-err-multi.rs:7:24 | LL | pub const D: i8 = 50 - A; - | ^ referenced constant has errors + | ^ -error: aborting due to 4 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/const-eval-intrinsic-promotion.stderr b/src/test/ui/consts/const-eval/const-eval-intrinsic-promotion.stderr index 78143042e..ed6a6ee6e 100644 --- a/src/test/ui/consts/const-eval/const-eval-intrinsic-promotion.stderr +++ b/src/test/ui/consts/const-eval/const-eval-intrinsic-promotion.stderr @@ -4,7 +4,7 @@ error[E0716]: temporary value dropped while borrowed LL | let x: &'static usize = | -------------- type annotation requires that borrow lasts for `'static` LL | &std::intrinsics::size_of::<i32>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use LL | } | - temporary value is freed at the end of this statement diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr index c685922c4..f19917001 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr @@ -12,15 +12,10 @@ LL | = [0; (i8::MAX + 1u8) as usize]; | = help: the trait `~const Add<u8>` is not implemented for `i8` = help: the following other types implement trait `Add<Rhs>`: - <&'a f32 as Add<f32>> - <&'a f64 as Add<f64>> - <&'a i128 as Add<i128>> - <&'a i16 as Add<i16>> - <&'a i32 as Add<i32>> - <&'a i64 as Add<i64>> <&'a i8 as Add<i8>> - <&'a isize as Add<isize>> - and 48 others + <&i8 as Add<&i8>> + <i8 as Add<&i8>> + <i8 as Add> error: aborting due to 2 previous errors diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr index b39607924..1f8e40231 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr @@ -12,15 +12,10 @@ LL | : [u32; (i8::MAX as i8 + 1u8) as usize] | = help: the trait `~const Add<u8>` is not implemented for `i8` = help: the following other types implement trait `Add<Rhs>`: - <&'a f32 as Add<f32>> - <&'a f64 as Add<f64>> - <&'a i128 as Add<i128>> - <&'a i16 as Add<i16>> - <&'a i32 as Add<i32>> - <&'a i64 as Add<i64>> <&'a i8 as Add<i8>> - <&'a isize as Add<isize>> - and 48 others + <&i8 as Add<&i8>> + <i8 as Add<&i8>> + <i8 as Add> error[E0604]: only `u8` can be cast as `char`, not `i8` --> $DIR/const-eval-overflow-4b.rs:22:13 diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr index 3784a3861..0734f479f 100644 --- a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr +++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr @@ -2,25 +2,35 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_fn_ptr_fail2.rs:9:5 | LL | x(y) + | ^^^^ calling non-const function `double` + | +note: inside `bar` + --> $DIR/const_fn_ptr_fail2.rs:9:5 + | +LL | x(y) | ^^^^ - | | - | calling non-const function `double` - | inside `bar` at $DIR/const_fn_ptr_fail2.rs:9:5 -... +note: inside `Y` + --> $DIR/const_fn_ptr_fail2.rs:14:18 + | LL | const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday - | --------- inside `Y` at $DIR/const_fn_ptr_fail2.rs:14:18 + | ^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $DIR/const_fn_ptr_fail2.rs:9:5 | LL | x(y) + | ^^^^ calling non-const function `double` + | +note: inside `bar` + --> $DIR/const_fn_ptr_fail2.rs:9:5 + | +LL | x(y) | ^^^^ - | | - | calling non-const function `double` - | inside `bar` at $DIR/const_fn_ptr_fail2.rs:9:5 -... +note: inside `Z` + --> $DIR/const_fn_ptr_fail2.rs:15:18 + | LL | const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday - | -------------- inside `Z` at $DIR/const_fn_ptr_fail2.rs:15:18 + | ^^^^^^^^^^^^^^ warning: skipping const checks | diff --git a/src/test/ui/consts/const-eval/const_panic_track_caller.stderr b/src/test/ui/consts/const-eval/const_panic_track_caller.stderr index 5c3b412d3..846458176 100644 --- a/src/test/ui/consts/const-eval/const_panic_track_caller.stderr +++ b/src/test/ui/consts/const-eval/const_panic_track_caller.stderr @@ -2,13 +2,18 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic_track_caller.rs:15:5 | LL | b() + | ^^^ the evaluated program panicked at 'hey', $DIR/const_panic_track_caller.rs:15:5 + | +note: inside `c` + --> $DIR/const_panic_track_caller.rs:15:5 + | +LL | b() | ^^^ - | | - | the evaluated program panicked at 'hey', $DIR/const_panic_track_caller.rs:15:5 - | inside `c` at $DIR/const_panic_track_caller.rs:15:5 -... +note: inside `X` + --> $DIR/const_panic_track_caller.rs:21:16 + | LL | const X: u32 = c(); - | --- inside `X` at $DIR/const_panic_track_caller.rs:21:16 + | ^^^ error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr index 69e3ca716..2e697b219 100644 --- a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr +++ b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr @@ -10,7 +10,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/dont_promote_unstable_const_fn.rs:17:28 | LL | let _: &'static u32 = &foo(); - | ------------ ^^^^^ creates a temporary which is freed while still in use + | ------------ ^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | } @@ -20,7 +20,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/dont_promote_unstable_const_fn.rs:21:28 | LL | let _: &'static u32 = &meh(); - | ------------ ^^^^^ creates a temporary which is freed while still in use + | ------------ ^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -31,7 +31,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/dont_promote_unstable_const_fn.rs:22:26 | LL | let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis(); - | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | diff --git a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.stderr b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.stderr index 129f06151..aa742d784 100644 --- a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.stderr +++ b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/dont_promote_unstable_const_fn_cross_crate.rs:8:28 | LL | let _: &'static u32 = &foo(); - | ------------ ^^^^^ creates a temporary which is freed while still in use + | ------------ ^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | let _x: &'static u32 = &foo(); @@ -13,7 +13,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/dont_promote_unstable_const_fn_cross_crate.rs:9:29 | LL | let _x: &'static u32 = &foo(); - | ------------ ^^^^^ creates a temporary which is freed while still in use + | ------------ ^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | } diff --git a/src/test/ui/consts/const-eval/erroneous-const.rs b/src/test/ui/consts/const-eval/erroneous-const.rs index cf11531ba..e0fd057a2 100644 --- a/src/test/ui/consts/const-eval/erroneous-const.rs +++ b/src/test/ui/consts/const-eval/erroneous-const.rs @@ -10,7 +10,7 @@ const fn no_codegen<T>() { if false { // This bad constant is only used in dead code in a no-codegen function... and yet we still // must make sure that the build fails. - let _ = PrintName::<T>::VOID; //~ERROR could not evaluate static initializer + let _ = PrintName::<T>::VOID; //~ constant } } diff --git a/src/test/ui/consts/const-eval/erroneous-const.stderr b/src/test/ui/consts/const-eval/erroneous-const.stderr index 33579135d..03030392a 100644 --- a/src/test/ui/consts/const-eval/erroneous-const.stderr +++ b/src/test/ui/consts/const-eval/erroneous-const.stderr @@ -4,18 +4,12 @@ error[E0080]: evaluation of `PrintName::<i32>::VOID` failed LL | const VOID: () = [()][2]; | ^^^^^^^ index out of bounds: the length is 1 but the index is 2 -error[E0080]: could not evaluate static initializer +note: erroneous constant used --> $DIR/erroneous-const.rs:13:17 | LL | let _ = PrintName::<T>::VOID; | ^^^^^^^^^^^^^^^^^^^^ - | | - | referenced constant has errors - | inside `no_codegen::<i32>` at $DIR/erroneous-const.rs:13:17 -... -LL | pub static FOO: () = no_codegen::<i32>(); - | ------------------- inside `FOO` at $DIR/erroneous-const.rs:17:22 -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/erroneous-const2.rs b/src/test/ui/consts/const-eval/erroneous-const2.rs index 2fbf7be88..15c0f9107 100644 --- a/src/test/ui/consts/const-eval/erroneous-const2.rs +++ b/src/test/ui/consts/const-eval/erroneous-const2.rs @@ -10,7 +10,7 @@ pub static FOO: () = { if false { // This bad constant is only used in dead code in a static initializer... and yet we still // must make sure that the build fails. - let _ = PrintName::<i32>::VOID; //~ERROR could not evaluate static initializer + let _ = PrintName::<i32>::VOID; //~ constant } }; diff --git a/src/test/ui/consts/const-eval/erroneous-const2.stderr b/src/test/ui/consts/const-eval/erroneous-const2.stderr index 630b1cf16..8626f4d78 100644 --- a/src/test/ui/consts/const-eval/erroneous-const2.stderr +++ b/src/test/ui/consts/const-eval/erroneous-const2.stderr @@ -4,12 +4,12 @@ error[E0080]: evaluation of `PrintName::<i32>::VOID` failed LL | const VOID: () = [()][2]; | ^^^^^^^ index out of bounds: the length is 1 but the index is 2 -error[E0080]: could not evaluate static initializer +note: erroneous constant used --> $DIR/erroneous-const2.rs:13:17 | LL | let _ = PrintName::<i32>::VOID; - | ^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/format.rs b/src/test/ui/consts/const-eval/format.rs index 3eef0d6c3..0d8b7c12d 100644 --- a/src/test/ui/consts/const-eval/format.rs +++ b/src/test/ui/consts/const-eval/format.rs @@ -1,8 +1,6 @@ const fn failure() { panic!("{:?}", 0); //~^ ERROR cannot call non-const formatting macro in constant functions - //~| ERROR erroneous constant used - //~| ERROR erroneous constant used } const fn print() { @@ -10,8 +8,6 @@ const fn print() { //~^ ERROR cannot call non-const formatting macro in constant functions //~| ERROR `Arguments::<'a>::new_v1` is not yet stable as a const fn //~| ERROR cannot call non-const fn `_print` in constant functions - //~| ERROR erroneous constant used - //~| ERROR erroneous constant used } fn main() {} diff --git a/src/test/ui/consts/const-eval/format.stderr b/src/test/ui/consts/const-eval/format.stderr index 64c769648..4bf39db58 100644 --- a/src/test/ui/consts/const-eval/format.stderr +++ b/src/test/ui/consts/const-eval/format.stderr @@ -8,7 +8,7 @@ LL | panic!("{:?}", 0); = note: this error originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const formatting macro in constant functions - --> $DIR/format.rs:9:22 + --> $DIR/format.rs:7:22 | LL | println!("{:?}", 0); | ^ @@ -17,7 +17,7 @@ LL | println!("{:?}", 0); = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: `Arguments::<'a>::new_v1` is not yet stable as a const fn - --> $DIR/format.rs:9:5 + --> $DIR/format.rs:7:5 | LL | println!("{:?}", 0); | ^^^^^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | println!("{:?}", 0); = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const fn `_print` in constant functions - --> $DIR/format.rs:9:5 + --> $DIR/format.rs:7:5 | LL | println!("{:?}", 0); | ^^^^^^^^^^^^^^^^^^^ @@ -34,35 +34,62 @@ LL | println!("{:?}", 0); = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: erroneous constant used +note: erroneous constant used --> $DIR/format.rs:2:12 | LL | panic!("{:?}", 0); - | ^^^^^^ referenced constant has errors + | ^^^^^^ -error[E0080]: erroneous constant used +note: erroneous constant used + --> $DIR/format.rs:2:12 + | +LL | panic!("{:?}", 0); + | ^^^^^^ + +note: erroneous constant used --> $DIR/format.rs:2:20 | LL | panic!("{:?}", 0); - | ^ referenced constant has errors + | ^ | - = note: this error originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this note originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) + +note: erroneous constant used + --> $DIR/format.rs:2:20 + | +LL | panic!("{:?}", 0); + | ^ + | + = note: this note originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: erroneous constant used - --> $DIR/format.rs:9:14 +note: erroneous constant used + --> $DIR/format.rs:7:14 | LL | println!("{:?}", 0); - | ^^^^^^ referenced constant has errors + | ^^^^^^ -error[E0080]: erroneous constant used - --> $DIR/format.rs:9:22 +note: erroneous constant used + --> $DIR/format.rs:7:14 | LL | println!("{:?}", 0); - | ^ referenced constant has errors + | ^^^^^^ + +note: erroneous constant used + --> $DIR/format.rs:7:22 | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +LL | println!("{:?}", 0); + | ^ + | + = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +note: erroneous constant used + --> $DIR/format.rs:7:22 + | +LL | println!("{:?}", 0); + | ^ + | + = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 8 previous errors +error: aborting due to 4 previous errors -Some errors have detailed explanations: E0015, E0080. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr index 2628a7845..8f3b3d5f7 100644 --- a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr +++ b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr @@ -1,14 +1,19 @@ error[E0080]: evaluation of constant value failed --> $DIR/alloc_intrinsic_errors.rs:9:17 | -LL | const FOO: i32 = foo(); - | ----- inside `FOO` at $DIR/alloc_intrinsic_errors.rs:6:18 -... +LL | let _ = intrinsics::const_allocate(4, 3) as *mut i32; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ align has to be a power of 2, `3` is not a power of 2 + | +note: inside `foo` + --> $DIR/alloc_intrinsic_errors.rs:9:17 + | LL | let _ = intrinsics::const_allocate(4, 3) as *mut i32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | align has to be a power of 2, `3` is not a power of 2 - | inside `foo` at $DIR/alloc_intrinsic_errors.rs:9:17 +note: inside `FOO` + --> $DIR/alloc_intrinsic_errors.rs:6:18 + | +LL | const FOO: i32 = foo(); + | ^^^^^ error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/issue-104390.rs b/src/test/ui/consts/const-eval/issue-104390.rs new file mode 100644 index 000000000..602d81824 --- /dev/null +++ b/src/test/ui/consts/const-eval/issue-104390.rs @@ -0,0 +1,10 @@ +fn f1() -> impl Sized { & 2E } //~ ERROR expected at least one digit in exponent +fn f2() -> impl Sized { && 2E } //~ ERROR expected at least one digit in exponent +fn f3() -> impl Sized { &'a 2E } //~ ERROR expected at least one digit in exponent +//~^ ERROR borrow expressions cannot be annotated with lifetimes +fn f4() -> impl Sized { &'static 2E } //~ ERROR expected at least one digit in exponent +//~^ ERROR borrow expressions cannot be annotated with lifetimes +fn f5() -> impl Sized { *& 2E } //~ ERROR expected at least one digit in exponent +fn f6() -> impl Sized { &'_ 2E } //~ ERROR expected at least one digit in exponent +//~^ ERROR borrow expressions cannot be annotated with lifetimes +fn main() {} diff --git a/src/test/ui/consts/const-eval/issue-104390.stderr b/src/test/ui/consts/const-eval/issue-104390.stderr new file mode 100644 index 000000000..865b9996e --- /dev/null +++ b/src/test/ui/consts/const-eval/issue-104390.stderr @@ -0,0 +1,65 @@ +error: expected at least one digit in exponent + --> $DIR/issue-104390.rs:1:27 + | +LL | fn f1() -> impl Sized { & 2E } + | ^^ + +error: expected at least one digit in exponent + --> $DIR/issue-104390.rs:2:28 + | +LL | fn f2() -> impl Sized { && 2E } + | ^^ + +error: expected at least one digit in exponent + --> $DIR/issue-104390.rs:3:29 + | +LL | fn f3() -> impl Sized { &'a 2E } + | ^^ + +error: expected at least one digit in exponent + --> $DIR/issue-104390.rs:5:34 + | +LL | fn f4() -> impl Sized { &'static 2E } + | ^^ + +error: expected at least one digit in exponent + --> $DIR/issue-104390.rs:7:28 + | +LL | fn f5() -> impl Sized { *& 2E } + | ^^ + +error: expected at least one digit in exponent + --> $DIR/issue-104390.rs:8:29 + | +LL | fn f6() -> impl Sized { &'_ 2E } + | ^^ + +error: borrow expressions cannot be annotated with lifetimes + --> $DIR/issue-104390.rs:3:25 + | +LL | fn f3() -> impl Sized { &'a 2E } + | ^--^^^ + | | + | annotated with lifetime here + | help: remove the lifetime annotation + +error: borrow expressions cannot be annotated with lifetimes + --> $DIR/issue-104390.rs:5:25 + | +LL | fn f4() -> impl Sized { &'static 2E } + | ^-------^^^ + | | + | annotated with lifetime here + | help: remove the lifetime annotation + +error: borrow expressions cannot be annotated with lifetimes + --> $DIR/issue-104390.rs:8:25 + | +LL | fn f6() -> impl Sized { &'_ 2E } + | ^--^^^ + | | + | annotated with lifetime here + | help: remove the lifetime annotation + +error: aborting due to 9 previous errors + diff --git a/src/test/ui/consts/const-eval/issue-44578.rs b/src/test/ui/consts/const-eval/issue-44578.rs index 2dbe1c2bd..e4dcc6230 100644 --- a/src/test/ui/consts/const-eval/issue-44578.rs +++ b/src/test/ui/consts/const-eval/issue-44578.rs @@ -23,6 +23,5 @@ impl Foo for u16 { fn main() { println!("{}", <Bar<u16, u8> as Foo>::AMT); - //~^ ERROR evaluation of constant value failed - //~| ERROR erroneous constant used + //~^ constant } diff --git a/src/test/ui/consts/const-eval/issue-44578.stderr b/src/test/ui/consts/const-eval/issue-44578.stderr index 963381b58..0cbf54480 100644 --- a/src/test/ui/consts/const-eval/issue-44578.stderr +++ b/src/test/ui/consts/const-eval/issue-44578.stderr @@ -4,20 +4,36 @@ error[E0080]: evaluation of `<Bar<u16, u8> as Foo>::AMT` failed LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1 -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/issue-44578.rs:25:20 | LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: erroneous constant used +note: erroneous constant used --> $DIR/issue-44578.rs:25:20 | LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 3 previous errors +note: erroneous constant used + --> $DIR/issue-44578.rs:25:20 + | +LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +note: erroneous constant used + --> $DIR/issue-44578.rs:25:20 + | +LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/issue-50814-2.rs b/src/test/ui/consts/const-eval/issue-50814-2.rs index 49d1d8ff0..53eb7b149 100644 --- a/src/test/ui/consts/const-eval/issue-50814-2.rs +++ b/src/test/ui/consts/const-eval/issue-50814-2.rs @@ -15,7 +15,7 @@ impl<T: C> Foo<T> for A<T> { } fn foo<T: C>() -> &'static usize { - &<A<T> as Foo<T>>::BAR //~ ERROR E0080 + &<A<T> as Foo<T>>::BAR //~ constant } impl C for () { diff --git a/src/test/ui/consts/const-eval/issue-50814-2.stderr b/src/test/ui/consts/const-eval/issue-50814-2.stderr index 6604f2b9f..956f7aec9 100644 --- a/src/test/ui/consts/const-eval/issue-50814-2.stderr +++ b/src/test/ui/consts/const-eval/issue-50814-2.stderr @@ -4,11 +4,11 @@ error[E0080]: evaluation of `<A<()> as Foo<()>>::BAR` failed LL | const BAR: usize = [5, 6, 7][T::BOO]; | ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42 -error[E0080]: evaluation of `foo::<()>` failed +note: erroneous constant used --> $DIR/issue-50814-2.rs:18:6 | LL | &<A<T> as Foo<T>>::BAR - | ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^^^^^^^ note: the above error was encountered while instantiating `fn foo::<()>` --> $DIR/issue-50814-2.rs:30:22 @@ -16,6 +16,6 @@ note: the above error was encountered while instantiating `fn foo::<()>` LL | println!("{:x}", foo::<()>() as *const usize as usize); | ^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/issue-50814.rs b/src/test/ui/consts/const-eval/issue-50814.rs index 5a587701f..374ed1d93 100644 --- a/src/test/ui/consts/const-eval/issue-50814.rs +++ b/src/test/ui/consts/const-eval/issue-50814.rs @@ -9,16 +9,16 @@ impl Unsigned for U8 { const MAX: u8 = 0xff; } -struct Sum<A,B>(A,B); +struct Sum<A, B>(A, B); -impl<A: Unsigned, B: Unsigned> Unsigned for Sum<A,B> { +impl<A: Unsigned, B: Unsigned> Unsigned for Sum<A, B> { const MAX: u8 = A::MAX + B::MAX; //~^ ERROR evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed } fn foo<T>(_: T) -> &'static u8 { - &Sum::<U8,U8>::MAX - //~^ ERROR E0080 + &Sum::<U8, U8>::MAX + //~^ constant } fn main() { diff --git a/src/test/ui/consts/const-eval/issue-50814.stderr b/src/test/ui/consts/const-eval/issue-50814.stderr index 46dd2b89f..05b6271f4 100644 --- a/src/test/ui/consts/const-eval/issue-50814.stderr +++ b/src/test/ui/consts/const-eval/issue-50814.stderr @@ -4,11 +4,11 @@ error[E0080]: evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed LL | const MAX: u8 = A::MAX + B::MAX; | ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow -error[E0080]: evaluation of `foo::<i32>` failed +note: erroneous constant used --> $DIR/issue-50814.rs:20:6 | -LL | &Sum::<U8,U8>::MAX - | ^^^^^^^^^^^^^^^^^ referenced constant has errors +LL | &Sum::<U8, U8>::MAX + | ^^^^^^^^^^^^^^^^^^ note: the above error was encountered while instantiating `fn foo::<i32>` --> $DIR/issue-50814.rs:25:5 @@ -16,6 +16,6 @@ note: the above error was encountered while instantiating `fn foo::<i32>` LL | foo(0); | ^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.rs b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs index d2a840932..28edf5144 100644 --- a/src/test/ui/consts/const-eval/panic-assoc-never-type.rs +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs @@ -11,6 +11,5 @@ impl PrintName { } fn main() { - let _ = PrintName::VOID; - //~^ ERROR erroneous constant used [E0080] + let _ = PrintName::VOID; //~ constant } diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr index 4204d302b..7c36a3a42 100644 --- a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr @@ -6,12 +6,18 @@ LL | const VOID: ! = panic!(); | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: erroneous constant used +note: erroneous constant used --> $DIR/panic-assoc-never-type.rs:14:13 | LL | let _ = PrintName::VOID; - | ^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +note: erroneous constant used + --> $DIR/panic-assoc-never-type.rs:14:13 + | +LL | let _ = PrintName::VOID; + | ^^^^^^^^^^^^^^^ + +error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr b/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr index 596fa090d..2d4e7c83d 100644 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr +++ b/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promoted_const_fn_fail.rs:17:27 | LL | let x: &'static u8 = &(bar() + 1); - | ----------- ^^^^^^^^^^^ creates a temporary which is freed while still in use + | ----------- ^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... diff --git a/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.stderr b/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.stderr index 63dc43a41..9ebae3a18 100644 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.stderr +++ b/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promoted_const_fn_fail_deny_const_err.rs:18:27 | LL | let x: &'static u8 = &(bar() + 1); - | ----------- ^^^^^^^^^^^ creates a temporary which is freed while still in use + | ----------- ^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... diff --git a/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr b/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr index 8ac60da38..01fcf2ec2 100644 --- a/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr +++ b/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promoted_raw_ptr_ops.rs:2:29 | LL | let x: &'static bool = &(42 as *const i32 == 43 as *const i32); - | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -13,7 +13,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promoted_raw_ptr_ops.rs:4:30 | LL | let y: &'static usize = &(&1 as *const i32 as usize + 1); - | -------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | -------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -24,7 +24,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promoted_raw_ptr_ops.rs:6:28 | LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -35,7 +35,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promoted_raw_ptr_ops.rs:8:29 | LL | let a: &'static bool = &(main as fn() == main as fn()); - | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | diff --git a/src/test/ui/consts/const-eval/transmute-const-promotion.stderr b/src/test/ui/consts/const-eval/transmute-const-promotion.stderr index 15b9b56ea..434a957f6 100644 --- a/src/test/ui/consts/const-eval/transmute-const-promotion.stderr +++ b/src/test/ui/consts/const-eval/transmute-const-promotion.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/transmute-const-promotion.rs:4:37 | LL | let x: &'static u32 = unsafe { &mem::transmute(3.0f32) }; - | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | diff --git a/src/test/ui/consts/const-eval/ub-nonnull.32bit.stderr b/src/test/ui/consts/const-eval/ub-nonnull.32bit.stderr index dbd05b8f4..b24e0cc37 100644 --- a/src/test/ui/consts/const-eval/ub-nonnull.32bit.stderr +++ b/src/test/ui/consts/const-eval/ub-nonnull.32bit.stderr @@ -65,6 +65,17 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; 14 00 00 00 │ .... } -error: aborting due to 7 previous errors +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-nonnull.rs:50:1 + | +LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 8, align: 4) { + 00 00 00 00 ╾─alloc26─╼ │ ....╾──╼ + } + +error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/ub-nonnull.64bit.stderr b/src/test/ui/consts/const-eval/ub-nonnull.64bit.stderr index 5a1ac09bd..92b8d017c 100644 --- a/src/test/ui/consts/const-eval/ub-nonnull.64bit.stderr +++ b/src/test/ui/consts/const-eval/ub-nonnull.64bit.stderr @@ -65,6 +65,17 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; 14 00 00 00 │ .... } -error: aborting due to 7 previous errors +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-nonnull.rs:50:1 + | +LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 16, align: 8) { + 00 00 00 00 00 00 00 00 ╾───────alloc26───────╼ │ ........╾──────╼ + } + +error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/ub-nonnull.rs b/src/test/ui/consts/const-eval/ub-nonnull.rs index d22a99cd0..490925822 100644 --- a/src/test/ui/consts/const-eval/ub-nonnull.rs +++ b/src/test/ui/consts/const-eval/ub-nonnull.rs @@ -1,5 +1,5 @@ // stderr-per-bitwidth -#![feature(rustc_attrs)] +#![feature(rustc_attrs, ptr_metadata)] #![allow(invalid_value)] // make sure we cannot allow away the errors tested here use std::mem; @@ -47,4 +47,11 @@ struct RestrictedRange2(u32); const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; //~^ ERROR it is undefined behavior to use this value +const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { +//~^ ERROR it is undefined behavior to use this value + let x: &dyn Send = &42; + let meta = std::ptr::metadata(x); + mem::transmute((0_usize, meta)) +}; + fn main() {} diff --git a/src/test/ui/consts/const-eval/ub-ref-ptr.32bit.stderr b/src/test/ui/consts/const-eval/ub-ref-ptr.32bit.stderr index 6f5c028cb..e5b5c7a84 100644 --- a/src/test/ui/consts/const-eval/ub-ref-ptr.32bit.stderr +++ b/src/test/ui/consts/const-eval/ub-ref-ptr.32bit.stderr @@ -60,14 +60,14 @@ LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/ub-ref-ptr.rs:34:38 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:38:86 + --> $DIR/ub-ref-ptr.rs:37:86 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes @@ -75,14 +75,14 @@ LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[us = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:38:85 +note: erroneous constant used + --> $DIR/ub-ref-ptr.rs:37:85 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:42:1 + --> $DIR/ub-ref-ptr.rs:40:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (address 0x539 is unallocated) @@ -93,7 +93,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:45:1 + --> $DIR/ub-ref-ptr.rs:43:1 | LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (address 0x539 is unallocated) @@ -104,13 +104,13 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:48:41 + --> $DIR/ub-ref-ptr.rs:46:41 | LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:52:1 + --> $DIR/ub-ref-ptr.rs:50:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer @@ -121,13 +121,13 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:54:38 + --> $DIR/ub-ref-ptr.rs:52:38 | LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:57:1 + --> $DIR/ub-ref-ptr.rs:55:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer @@ -138,7 +138,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:59:1 + --> $DIR/ub-ref-ptr.rs:57:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered alloc41, but expected a function pointer @@ -148,6 +148,6 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; ╾─alloc41─╼ │ ╾──╼ } -error: aborting due to 16 previous errors +error: aborting due to 14 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/ub-ref-ptr.64bit.stderr b/src/test/ui/consts/const-eval/ub-ref-ptr.64bit.stderr index 5ffb710d4..607366cab 100644 --- a/src/test/ui/consts/const-eval/ub-ref-ptr.64bit.stderr +++ b/src/test/ui/consts/const-eval/ub-ref-ptr.64bit.stderr @@ -60,14 +60,14 @@ LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/ub-ref-ptr.rs:34:38 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:38:86 + --> $DIR/ub-ref-ptr.rs:37:86 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes @@ -75,14 +75,14 @@ LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[us = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:38:85 +note: erroneous constant used + --> $DIR/ub-ref-ptr.rs:37:85 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:42:1 + --> $DIR/ub-ref-ptr.rs:40:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (address 0x539 is unallocated) @@ -93,7 +93,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:45:1 + --> $DIR/ub-ref-ptr.rs:43:1 | LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (address 0x539 is unallocated) @@ -104,13 +104,13 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:48:41 + --> $DIR/ub-ref-ptr.rs:46:41 | LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:52:1 + --> $DIR/ub-ref-ptr.rs:50:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer @@ -121,13 +121,13 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:54:38 + --> $DIR/ub-ref-ptr.rs:52:38 | LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:57:1 + --> $DIR/ub-ref-ptr.rs:55:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer @@ -138,7 +138,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:59:1 + --> $DIR/ub-ref-ptr.rs:57:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered alloc41, but expected a function pointer @@ -148,6 +148,6 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; ╾───────alloc41───────╼ │ ╾──────╼ } -error: aborting due to 16 previous errors +error: aborting due to 14 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/ub-ref-ptr.rs b/src/test/ui/consts/const-eval/ub-ref-ptr.rs index 92049d4c1..a1c812390 100644 --- a/src/test/ui/consts/const-eval/ub-ref-ptr.rs +++ b/src/test/ui/consts/const-eval/ub-ref-ptr.rs @@ -33,11 +33,9 @@ const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; //~^ ERROR evaluation of constant value failed -//~| ERROR evaluation of constant value failed const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; //~^ ERROR evaluation of constant value failed -//~| ERROR evaluation of constant value failed const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; //~^ ERROR it is undefined behavior to use this value diff --git a/src/test/ui/consts/const-eval/ub-wide-ptr.32bit.stderr b/src/test/ui/consts/const-eval/ub-wide-ptr.32bit.stderr index c8b46608d..9994c2e5a 100644 --- a/src/test/ui/consts/const-eval/ub-wide-ptr.32bit.stderr +++ b/src/test/ui/consts/const-eval/ub-wide-ptr.32bit.stderr @@ -139,11 +139,11 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; ╾─allocN─╼ │ ╾──╼ } -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/ub-wide-ptr.rs:83:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-wide-ptr.rs:90:1 @@ -156,11 +156,11 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 ╾allocN─╼ │ ╾──╼ } -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/ub-wide-ptr.rs:90:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-wide-ptr.rs:94:1 @@ -173,11 +173,11 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran ╾allocN─╼ │ ╾──╼ } -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/ub-wide-ptr.rs:94:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $DIR/ub-wide-ptr.rs:102:1 @@ -292,6 +292,6 @@ error[E0080]: could not evaluate static initializer LL | mem::transmute::<_, &dyn Trait>((&92u8, &3u64)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable -error: aborting due to 32 previous errors +error: aborting due to 29 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/ub-wide-ptr.64bit.stderr b/src/test/ui/consts/const-eval/ub-wide-ptr.64bit.stderr index 70574d2dc..06a377d9f 100644 --- a/src/test/ui/consts/const-eval/ub-wide-ptr.64bit.stderr +++ b/src/test/ui/consts/const-eval/ub-wide-ptr.64bit.stderr @@ -139,11 +139,11 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; ╾───────allocN───────╼ │ ╾──────╼ } -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/ub-wide-ptr.rs:83:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-wide-ptr.rs:90:1 @@ -156,11 +156,11 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 ╾──────allocN───────╼ │ ╾──────╼ } -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/ub-wide-ptr.rs:90:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-wide-ptr.rs:94:1 @@ -173,11 +173,11 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran ╾──────allocN───────╼ │ ╾──────╼ } -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/ub-wide-ptr.rs:94:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $DIR/ub-wide-ptr.rs:102:1 @@ -292,6 +292,6 @@ error[E0080]: could not evaluate static initializer LL | mem::transmute::<_, &dyn Trait>((&92u8, &3u64)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable -error: aborting due to 32 previous errors +error: aborting due to 29 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/ub-wide-ptr.rs b/src/test/ui/consts/const-eval/ub-wide-ptr.rs index 65f6f0235..2894ef831 100644 --- a/src/test/ui/consts/const-eval/ub-wide-ptr.rs +++ b/src/test/ui/consts/const-eval/ub-wide-ptr.rs @@ -82,18 +82,18 @@ const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) }; // bad data *inside* the slice const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; //~^ ERROR it is undefined behavior to use this value -//~| ERROR evaluation of constant value failed +//~| constant // good MySliceBool const MYSLICE_GOOD: &MySliceBool = &MySlice(true, [false]); // bad: sized field is not okay const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); //~^ ERROR it is undefined behavior to use this value -//~| ERROR evaluation of constant value failed +//~| constant // bad: unsized part is not okay const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); //~^ ERROR it is undefined behavior to use this value -//~| ERROR evaluation of constant value failed +//~| constant // # raw slice const RAW_SLICE_VALID: *const [u8] = unsafe { mem::transmute((&42u8, 1usize)) }; // ok diff --git a/src/test/ui/consts/const-eval/union-const-eval-field.rs b/src/test/ui/consts/const-eval/union-const-eval-field.rs index d88bf2a84..a94fcbbfa 100644 --- a/src/test/ui/consts/const-eval/union-const-eval-field.rs +++ b/src/test/ui/consts/const-eval/union-const-eval-field.rs @@ -29,7 +29,6 @@ const fn read_field3() -> Field3 { //~^ ERROR evaluation of constant value failed //~| uninitialized FIELD3 - //~^ ERROR erroneous constant used [E0080] } fn main() { diff --git a/src/test/ui/consts/const-eval/union-const-eval-field.stderr b/src/test/ui/consts/const-eval/union-const-eval-field.stderr index 00964489e..9899c56c0 100644 --- a/src/test/ui/consts/const-eval/union-const-eval-field.stderr +++ b/src/test/ui/consts/const-eval/union-const-eval-field.stderr @@ -4,12 +4,18 @@ error[E0080]: evaluation of constant value failed LL | const FIELD3: Field3 = unsafe { UNION.field3 }; | ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory -error[E0080]: erroneous constant used +note: erroneous constant used --> $DIR/union-const-eval-field.rs:31:5 | LL | FIELD3 - | ^^^^^^ referenced constant has errors + | ^^^^^^ -error: aborting due to 2 previous errors +note: erroneous constant used + --> $DIR/union-const-eval-field.rs:31:5 + | +LL | FIELD3 + | ^^^^^^ + +error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/union_promotion.stderr b/src/test/ui/consts/const-eval/union_promotion.stderr index 70808c520..42f17de20 100644 --- a/src/test/ui/consts/const-eval/union_promotion.stderr +++ b/src/test/ui/consts/const-eval/union_promotion.stderr @@ -7,7 +7,7 @@ LL | let x: &'static bool = &unsafe { | | type annotation requires that borrow lasts for `'static` LL | | Foo { a: &1 }.b == Foo { a: &2 }.b LL | | }; - | |_____^ creates a temporary which is freed while still in use + | |_____^ creates a temporary value which is freed while still in use LL | } | - temporary value is freed at the end of this statement diff --git a/src/test/ui/consts/const-eval/unwind-abort.stderr b/src/test/ui/consts/const-eval/unwind-abort.stderr index 99178ae8c..759ce15ab 100644 --- a/src/test/ui/consts/const-eval/unwind-abort.stderr +++ b/src/test/ui/consts/const-eval/unwind-abort.stderr @@ -2,14 +2,18 @@ error[E0080]: evaluation of constant value failed --> $DIR/unwind-abort.rs:4:5 | LL | panic!() + | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/unwind-abort.rs:4:5 + | +note: inside `foo` + --> $DIR/unwind-abort.rs:4:5 + | +LL | panic!() | ^^^^^^^^ - | | - | the evaluated program panicked at 'explicit panic', $DIR/unwind-abort.rs:4:5 - | inside `foo` at $SRC_DIR/std/src/panic.rs:LL:COL -... -LL | const _: () = foo(); - | ----- inside `_` at $DIR/unwind-abort.rs:7:15 +note: inside `_` + --> $DIR/unwind-abort.rs:7:15 | +LL | const _: () = foo(); + | ^^^^^ = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr index 63639729a..9710bf476 100644 --- a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr +++ b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr @@ -14,13 +14,18 @@ error[E0080]: evaluation of constant value failed --> $DIR/validate_uninhabited_zsts.rs:4:14 | LL | unsafe { std::mem::transmute(()) } + | ^^^^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type + | +note: inside `foo` + --> $DIR/validate_uninhabited_zsts.rs:4:14 + | +LL | unsafe { std::mem::transmute(()) } | ^^^^^^^^^^^^^^^^^^^^^^^ - | | - | transmuting to uninhabited type - | inside `foo` at $DIR/validate_uninhabited_zsts.rs:4:14 -... +note: inside `FOO` + --> $DIR/validate_uninhabited_zsts.rs:19:33 + | LL | const FOO: [empty::Empty; 3] = [foo(); 3]; - | ----- inside `FOO` at $DIR/validate_uninhabited_zsts.rs:19:33 + | ^^^^^ error[E0080]: it is undefined behavior to use this value --> $DIR/validate_uninhabited_zsts.rs:21:1 @@ -40,6 +45,11 @@ LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | +note: in this struct field + --> $DIR/validate_uninhabited_zsts.rs:16:22 + | +LL | pub struct Empty(Void); + | ^^^^ note: enums with no inhabited variants have no valid value --> $DIR/validate_uninhabited_zsts.rs:13:5 | diff --git a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr index 63639729a..9710bf476 100644 --- a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr +++ b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr @@ -14,13 +14,18 @@ error[E0080]: evaluation of constant value failed --> $DIR/validate_uninhabited_zsts.rs:4:14 | LL | unsafe { std::mem::transmute(()) } + | ^^^^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type + | +note: inside `foo` + --> $DIR/validate_uninhabited_zsts.rs:4:14 + | +LL | unsafe { std::mem::transmute(()) } | ^^^^^^^^^^^^^^^^^^^^^^^ - | | - | transmuting to uninhabited type - | inside `foo` at $DIR/validate_uninhabited_zsts.rs:4:14 -... +note: inside `FOO` + --> $DIR/validate_uninhabited_zsts.rs:19:33 + | LL | const FOO: [empty::Empty; 3] = [foo(); 3]; - | ----- inside `FOO` at $DIR/validate_uninhabited_zsts.rs:19:33 + | ^^^^^ error[E0080]: it is undefined behavior to use this value --> $DIR/validate_uninhabited_zsts.rs:21:1 @@ -40,6 +45,11 @@ LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | +note: in this struct field + --> $DIR/validate_uninhabited_zsts.rs:16:22 + | +LL | pub struct Empty(Void); + | ^^^^ note: enums with no inhabited variants have no valid value --> $DIR/validate_uninhabited_zsts.rs:13:5 | diff --git a/src/test/ui/consts/const-float-bits-reject-conv.rs b/src/test/ui/consts/const-float-bits-reject-conv.rs index 5bf54fdbb..c77e99abb 100644 --- a/src/test/ui/consts/const-float-bits-reject-conv.rs +++ b/src/test/ui/consts/const-float-bits-reject-conv.rs @@ -1,4 +1,5 @@ // compile-flags: -Zmir-opt-level=0 +// error-pattern: cannot use f32::to_bits on a NaN #![feature(const_float_bits_conv)] #![feature(const_float_classify)] @@ -25,22 +26,21 @@ fn f32() { // 0xA is 0b1010; 0x5 is 0b0101 -- so these two together clobbers all the mantissa bits // ...actually, let's just check that these break. :D const MASKED_NAN1: u32 = f32::NAN.to_bits() ^ 0x002A_AAAA; + //~^ inside const MASKED_NAN2: u32 = f32::NAN.to_bits() ^ 0x0055_5555; + //~^ inside + + // The rest of the code is dead because the constants already fail to evaluate. const_assert!(f32::from_bits(MASKED_NAN1).is_nan()); - //~^ ERROR evaluation of constant value failed const_assert!(f32::from_bits(MASKED_NAN1).is_nan()); - //~^ ERROR evaluation of constant value failed // LLVM does not guarantee that loads and stores of NaNs preserve their exact bit pattern. // In practice, this seems to only cause a problem on x86, since the most widely used calling // convention mandates that floating point values are returned on the x87 FPU stack. See #73328. - if !cfg!(target_arch = "x86") { - const_assert!(f32::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); - //~^ ERROR evaluation of constant value failed - const_assert!(f32::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); - //~^ ERROR evaluation of constant value failed - } + // However, during CTFE we still preserve bit patterns (though that is not a guarantee). + const_assert!(f32::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); + const_assert!(f32::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); } fn f64() { @@ -48,20 +48,18 @@ fn f64() { // 0xA is 0b1010; 0x5 is 0b0101 -- so these two together clobbers all the mantissa bits // ...actually, let's just check that these break. :D const MASKED_NAN1: u64 = f64::NAN.to_bits() ^ 0x000A_AAAA_AAAA_AAAA; + //~^ inside const MASKED_NAN2: u64 = f64::NAN.to_bits() ^ 0x0005_5555_5555_5555; + //~^ inside + + // The rest of the code is dead because the constants already fail to evaluate. const_assert!(f64::from_bits(MASKED_NAN1).is_nan()); - //~^ ERROR evaluation of constant value failed const_assert!(f64::from_bits(MASKED_NAN1).is_nan()); - //~^ ERROR evaluation of constant value failed // See comment above. - if !cfg!(target_arch = "x86") { - const_assert!(f64::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); - //~^ ERROR evaluation of constant value failed - const_assert!(f64::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); - //~^ ERROR evaluation of constant value failed - } + const_assert!(f64::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); + const_assert!(f64::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); } fn main() { diff --git a/src/test/ui/consts/const-float-bits-reject-conv.stderr b/src/test/ui/consts/const-float-bits-reject-conv.stderr index b3575f641..195a087ff 100644 --- a/src/test/ui/consts/const-float-bits-reject-conv.stderr +++ b/src/test/ui/consts/const-float-bits-reject-conv.stderr @@ -2,126 +2,142 @@ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/num/f32.rs:LL:COL | LL | panic!("const-eval error: cannot use f32::to_bits on a NaN") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'const-eval error: cannot use f32::to_bits on a NaN', $SRC_DIR/core/src/num/f32.rs:LL:COL + | +note: inside `core::f32::<impl f32>::to_bits::ct_f32_to_u32` + --> $SRC_DIR/core/src/num/f32.rs:LL:COL + | +LL | panic!("const-eval error: cannot use f32::to_bits on a NaN") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | the evaluated program panicked at 'const-eval error: cannot use f32::to_bits on a NaN', $SRC_DIR/core/src/num/f32.rs:LL:COL - | inside `core::f32::<impl f32>::to_bits::ct_f32_to_u32` at $SRC_DIR/core/src/panic.rs:LL:COL -... -LL | unsafe { intrinsics::const_eval_select((self,), ct_f32_to_u32, rt_f32_to_u32) } - | -------------------------------------------------------------------- inside `core::f32::<impl f32>::to_bits` at $SRC_DIR/core/src/num/f32.rs:LL:COL +note: inside `core::f32::<impl f32>::to_bits` + --> $SRC_DIR/core/src/num/f32.rs:LL:COL | - ::: $DIR/const-float-bits-reject-conv.rs:27:30 +LL | unsafe { intrinsics::const_eval_select((self,), ct_f32_to_u32, rt_f32_to_u32) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `f32::MASKED_NAN1` + --> $DIR/const-float-bits-reject-conv.rs:28:30 | LL | const MASKED_NAN1: u32 = f32::NAN.to_bits() ^ 0x002A_AAAA; - | ------------------ inside `f32::MASKED_NAN1` at $DIR/const-float-bits-reject-conv.rs:27:30 - | + | ^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/num/f32.rs:LL:COL | LL | panic!("const-eval error: cannot use f32::to_bits on a NaN") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'const-eval error: cannot use f32::to_bits on a NaN', $SRC_DIR/core/src/num/f32.rs:LL:COL + | +note: inside `core::f32::<impl f32>::to_bits::ct_f32_to_u32` + --> $SRC_DIR/core/src/num/f32.rs:LL:COL + | +LL | panic!("const-eval error: cannot use f32::to_bits on a NaN") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | the evaluated program panicked at 'const-eval error: cannot use f32::to_bits on a NaN', $SRC_DIR/core/src/num/f32.rs:LL:COL - | inside `core::f32::<impl f32>::to_bits::ct_f32_to_u32` at $SRC_DIR/core/src/panic.rs:LL:COL -... -LL | unsafe { intrinsics::const_eval_select((self,), ct_f32_to_u32, rt_f32_to_u32) } - | -------------------------------------------------------------------- inside `core::f32::<impl f32>::to_bits` at $SRC_DIR/core/src/num/f32.rs:LL:COL +note: inside `core::f32::<impl f32>::to_bits` + --> $SRC_DIR/core/src/num/f32.rs:LL:COL | - ::: $DIR/const-float-bits-reject-conv.rs:28:30 +LL | unsafe { intrinsics::const_eval_select((self,), ct_f32_to_u32, rt_f32_to_u32) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `f32::MASKED_NAN2` + --> $DIR/const-float-bits-reject-conv.rs:30:30 | LL | const MASKED_NAN2: u32 = f32::NAN.to_bits() ^ 0x0055_5555; - | ------------------ inside `f32::MASKED_NAN2` at $DIR/const-float-bits-reject-conv.rs:28:30 - | + | ^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: evaluation of constant value failed - --> $DIR/const-float-bits-reject-conv.rs:30:34 +note: erroneous constant used + --> $DIR/const-float-bits-reject-conv.rs:35:34 | LL | const_assert!(f32::from_bits(MASKED_NAN1).is_nan()); - | ^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^ -error[E0080]: evaluation of constant value failed - --> $DIR/const-float-bits-reject-conv.rs:32:34 +note: erroneous constant used + --> $DIR/const-float-bits-reject-conv.rs:36:34 | LL | const_assert!(f32::from_bits(MASKED_NAN1).is_nan()); - | ^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^ -error[E0080]: evaluation of constant value failed - --> $DIR/const-float-bits-reject-conv.rs:39:38 +note: erroneous constant used + --> $DIR/const-float-bits-reject-conv.rs:42:34 | -LL | const_assert!(f32::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); - | ^^^^^^^^^^^ referenced constant has errors +LL | const_assert!(f32::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); + | ^^^^^^^^^^^ -error[E0080]: evaluation of constant value failed - --> $DIR/const-float-bits-reject-conv.rs:41:38 +note: erroneous constant used + --> $DIR/const-float-bits-reject-conv.rs:43:34 | -LL | const_assert!(f32::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); - | ^^^^^^^^^^^ referenced constant has errors +LL | const_assert!(f32::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); + | ^^^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/num/f64.rs:LL:COL | LL | panic!("const-eval error: cannot use f64::to_bits on a NaN") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'const-eval error: cannot use f64::to_bits on a NaN', $SRC_DIR/core/src/num/f64.rs:LL:COL + | +note: inside `core::f64::<impl f64>::to_bits::ct_f64_to_u64` + --> $SRC_DIR/core/src/num/f64.rs:LL:COL + | +LL | panic!("const-eval error: cannot use f64::to_bits on a NaN") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | the evaluated program panicked at 'const-eval error: cannot use f64::to_bits on a NaN', $SRC_DIR/core/src/num/f64.rs:LL:COL - | inside `core::f64::<impl f64>::to_bits::ct_f64_to_u64` at $SRC_DIR/core/src/panic.rs:LL:COL -... -LL | unsafe { intrinsics::const_eval_select((self,), ct_f64_to_u64, rt_f64_to_u64) } - | -------------------------------------------------------------------- inside `core::f64::<impl f64>::to_bits` at $SRC_DIR/core/src/num/f64.rs:LL:COL +note: inside `core::f64::<impl f64>::to_bits` + --> $SRC_DIR/core/src/num/f64.rs:LL:COL | - ::: $DIR/const-float-bits-reject-conv.rs:50:30 +LL | unsafe { intrinsics::const_eval_select((self,), ct_f64_to_u64, rt_f64_to_u64) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `f64::MASKED_NAN1` + --> $DIR/const-float-bits-reject-conv.rs:50:30 | LL | const MASKED_NAN1: u64 = f64::NAN.to_bits() ^ 0x000A_AAAA_AAAA_AAAA; - | ------------------ inside `f64::MASKED_NAN1` at $DIR/const-float-bits-reject-conv.rs:50:30 - | + | ^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/num/f64.rs:LL:COL | LL | panic!("const-eval error: cannot use f64::to_bits on a NaN") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'const-eval error: cannot use f64::to_bits on a NaN', $SRC_DIR/core/src/num/f64.rs:LL:COL + | +note: inside `core::f64::<impl f64>::to_bits::ct_f64_to_u64` + --> $SRC_DIR/core/src/num/f64.rs:LL:COL + | +LL | panic!("const-eval error: cannot use f64::to_bits on a NaN") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | the evaluated program panicked at 'const-eval error: cannot use f64::to_bits on a NaN', $SRC_DIR/core/src/num/f64.rs:LL:COL - | inside `core::f64::<impl f64>::to_bits::ct_f64_to_u64` at $SRC_DIR/core/src/panic.rs:LL:COL -... -LL | unsafe { intrinsics::const_eval_select((self,), ct_f64_to_u64, rt_f64_to_u64) } - | -------------------------------------------------------------------- inside `core::f64::<impl f64>::to_bits` at $SRC_DIR/core/src/num/f64.rs:LL:COL +note: inside `core::f64::<impl f64>::to_bits` + --> $SRC_DIR/core/src/num/f64.rs:LL:COL | - ::: $DIR/const-float-bits-reject-conv.rs:51:30 +LL | unsafe { intrinsics::const_eval_select((self,), ct_f64_to_u64, rt_f64_to_u64) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `f64::MASKED_NAN2` + --> $DIR/const-float-bits-reject-conv.rs:52:30 | LL | const MASKED_NAN2: u64 = f64::NAN.to_bits() ^ 0x0005_5555_5555_5555; - | ------------------ inside `f64::MASKED_NAN2` at $DIR/const-float-bits-reject-conv.rs:51:30 - | + | ^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: evaluation of constant value failed - --> $DIR/const-float-bits-reject-conv.rs:53:34 +note: erroneous constant used + --> $DIR/const-float-bits-reject-conv.rs:57:34 | LL | const_assert!(f64::from_bits(MASKED_NAN1).is_nan()); - | ^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^ -error[E0080]: evaluation of constant value failed - --> $DIR/const-float-bits-reject-conv.rs:55:34 +note: erroneous constant used + --> $DIR/const-float-bits-reject-conv.rs:58:34 | LL | const_assert!(f64::from_bits(MASKED_NAN1).is_nan()); - | ^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^ -error[E0080]: evaluation of constant value failed - --> $DIR/const-float-bits-reject-conv.rs:60:38 +note: erroneous constant used + --> $DIR/const-float-bits-reject-conv.rs:61:34 | -LL | const_assert!(f64::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); - | ^^^^^^^^^^^ referenced constant has errors +LL | const_assert!(f64::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); + | ^^^^^^^^^^^ -error[E0080]: evaluation of constant value failed - --> $DIR/const-float-bits-reject-conv.rs:62:38 +note: erroneous constant used + --> $DIR/const-float-bits-reject-conv.rs:62:34 | -LL | const_assert!(f64::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); - | ^^^^^^^^^^^ referenced constant has errors +LL | const_assert!(f64::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); + | ^^^^^^^^^^^ -error: aborting due to 12 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-int-conversion.stderr b/src/test/ui/consts/const-int-conversion.stderr index 61162a792..5dd757e3f 100644 --- a/src/test/ui/consts/const-int-conversion.stderr +++ b/src/test/ui/consts/const-int-conversion.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-conversion.rs:2:28 | LL | let x: &'static i32 = &(5_i32.reverse_bits()); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -13,7 +13,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-conversion.rs:4:28 | LL | let y: &'static i32 = &(i32::from_be_bytes([0x12, 0x34, 0x56, 0x78])); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -24,7 +24,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-conversion.rs:6:28 | LL | let z: &'static i32 = &(i32::from_le_bytes([0x12, 0x34, 0x56, 0x78])); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -35,7 +35,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-conversion.rs:8:28 | LL | let a: &'static i32 = &(i32::from_be(i32::from_ne_bytes([0x80, 0, 0, 0]))); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -46,7 +46,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-conversion.rs:10:29 | LL | let b: &'static [u8] = &(0x12_34_56_78_i32.to_be_bytes()); - | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -57,7 +57,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-conversion.rs:12:29 | LL | let c: &'static [u8] = &(0x12_34_56_78_i32.to_le_bytes()); - | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -68,7 +68,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-conversion.rs:14:29 | LL | let d: &'static [u8] = &(i32::MIN.to_be().to_ne_bytes()); - | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | diff --git a/src/test/ui/consts/const-int-overflowing.stderr b/src/test/ui/consts/const-int-overflowing.stderr index 56c7f7f09..7d3689e6e 100644 --- a/src/test/ui/consts/const-int-overflowing.stderr +++ b/src/test/ui/consts/const-int-overflowing.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-overflowing.rs:2:36 | LL | let x: &'static (i32, bool) = &(5_i32.overflowing_add(3)); - | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -13,7 +13,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-overflowing.rs:4:36 | LL | let y: &'static (i32, bool) = &(5_i32.overflowing_sub(3)); - | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -24,7 +24,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-overflowing.rs:6:36 | LL | let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); - | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | diff --git a/src/test/ui/consts/const-int-rotate.stderr b/src/test/ui/consts/const-int-rotate.stderr index ed265804b..039da1c31 100644 --- a/src/test/ui/consts/const-int-rotate.stderr +++ b/src/test/ui/consts/const-int-rotate.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-rotate.rs:2:28 | LL | let x: &'static i32 = &(5_i32.rotate_left(3)); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -13,7 +13,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-rotate.rs:4:28 | LL | let y: &'static i32 = &(5_i32.rotate_right(3)); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | diff --git a/src/test/ui/consts/const-int-sign.stderr b/src/test/ui/consts/const-int-sign.stderr index 5f8fd4141..fc23d9d2b 100644 --- a/src/test/ui/consts/const-int-sign.stderr +++ b/src/test/ui/consts/const-int-sign.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-sign.rs:2:29 | LL | let x: &'static bool = &(5_i32.is_negative()); - | ------------- ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------- ^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -13,7 +13,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-sign.rs:4:29 | LL | let y: &'static bool = &(5_i32.is_positive()); - | ------------- ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------- ^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | diff --git a/src/test/ui/consts/const-int-wrapping.stderr b/src/test/ui/consts/const-int-wrapping.stderr index 5174b7265..1342fadc4 100644 --- a/src/test/ui/consts/const-int-wrapping.stderr +++ b/src/test/ui/consts/const-int-wrapping.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-wrapping.rs:2:28 | LL | let x: &'static i32 = &(5_i32.wrapping_add(3)); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -13,7 +13,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-wrapping.rs:4:28 | LL | let y: &'static i32 = &(5_i32.wrapping_sub(3)); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -24,7 +24,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-wrapping.rs:6:28 | LL | let z: &'static i32 = &(5_i32.wrapping_mul(3)); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -35,7 +35,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-wrapping.rs:8:28 | LL | let a: &'static i32 = &(5_i32.wrapping_shl(3)); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -46,7 +46,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-wrapping.rs:10:28 | LL | let b: &'static i32 = &(5_i32.wrapping_shr(3)); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | diff --git a/src/test/ui/consts/const-integer-bool-ops.rs b/src/test/ui/consts/const-integer-bool-ops.rs index 6924956bd..4110ae3e4 100644 --- a/src/test/ui/consts/const-integer-bool-ops.rs +++ b/src/test/ui/consts/const-integer-bool-ops.rs @@ -6,7 +6,7 @@ const X: usize = 42 && 39; //~| ERROR mismatched types //~| expected `usize`, found `bool` const ARR: [i32; X] = [99; 34]; -//~^ ERROR evaluation of constant value failed +//~^ constant const X1: usize = 42 || 39; //~^ ERROR mismatched types @@ -16,7 +16,7 @@ const X1: usize = 42 || 39; //~| ERROR mismatched types //~| expected `usize`, found `bool` const ARR1: [i32; X1] = [99; 47]; -//~^ ERROR evaluation of constant value failed +//~^ constant const X2: usize = -42 || -39; //~^ ERROR mismatched types @@ -26,7 +26,7 @@ const X2: usize = -42 || -39; //~| ERROR mismatched types //~| expected `usize`, found `bool` const ARR2: [i32; X2] = [99; 18446744073709551607]; -//~^ ERROR evaluation of constant value failed +//~^ constant const X3: usize = -42 && -39; //~^ ERROR mismatched types @@ -36,43 +36,43 @@ const X3: usize = -42 && -39; //~| ERROR mismatched types //~| expected `usize`, found `bool` const ARR3: [i32; X3] = [99; 6]; -//~^ ERROR evaluation of constant value failed +//~^ constant const Y: usize = 42.0 == 42.0; //~^ ERROR mismatched types //~| expected `usize`, found `bool` const ARRR: [i32; Y] = [99; 1]; -//~^ ERROR evaluation of constant value failed +//~^ constant const Y1: usize = 42.0 >= 42.0; //~^ ERROR mismatched types //~| expected `usize`, found `bool` const ARRR1: [i32; Y1] = [99; 1]; -//~^ ERROR evaluation of constant value failed +//~^ constant const Y2: usize = 42.0 <= 42.0; //~^ ERROR mismatched types //~| expected `usize`, found `bool` const ARRR2: [i32; Y2] = [99; 1]; -//~^ ERROR evaluation of constant value failed +//~^ constant const Y3: usize = 42.0 > 42.0; //~^ ERROR mismatched types //~| expected `usize`, found `bool` const ARRR3: [i32; Y3] = [99; 0]; -//~^ ERROR evaluation of constant value failed +//~^ constant const Y4: usize = 42.0 < 42.0; //~^ ERROR mismatched types //~| expected `usize`, found `bool` const ARRR4: [i32; Y4] = [99; 0]; -//~^ ERROR evaluation of constant value failed +//~^ constant const Y5: usize = 42.0 != 42.0; //~^ ERROR mismatched types //~| expected `usize`, found `bool` const ARRR5: [i32; Y5] = [99; 0]; -//~^ ERROR evaluation of constant value failed +//~^ constant fn main() { let _ = ARR; diff --git a/src/test/ui/consts/const-integer-bool-ops.stderr b/src/test/ui/consts/const-integer-bool-ops.stderr index 9001fefd1..b5c3b22fd 100644 --- a/src/test/ui/consts/const-integer-bool-ops.stderr +++ b/src/test/ui/consts/const-integer-bool-ops.stderr @@ -16,11 +16,11 @@ error[E0308]: mismatched types LL | const X: usize = 42 && 39; | ^^^^^^^^ expected `usize`, found `bool` -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/const-integer-bool-ops.rs:8:18 | LL | const ARR: [i32; X] = [99; 34]; - | ^ referenced constant has errors + | ^ error[E0308]: mismatched types --> $DIR/const-integer-bool-ops.rs:11:19 @@ -40,11 +40,11 @@ error[E0308]: mismatched types LL | const X1: usize = 42 || 39; | ^^^^^^^^ expected `usize`, found `bool` -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/const-integer-bool-ops.rs:18:19 | LL | const ARR1: [i32; X1] = [99; 47]; - | ^^ referenced constant has errors + | ^^ error[E0308]: mismatched types --> $DIR/const-integer-bool-ops.rs:21:19 @@ -64,11 +64,11 @@ error[E0308]: mismatched types LL | const X2: usize = -42 || -39; | ^^^^^^^^^^ expected `usize`, found `bool` -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/const-integer-bool-ops.rs:28:19 | LL | const ARR2: [i32; X2] = [99; 18446744073709551607]; - | ^^ referenced constant has errors + | ^^ error[E0308]: mismatched types --> $DIR/const-integer-bool-ops.rs:31:19 @@ -88,11 +88,11 @@ error[E0308]: mismatched types LL | const X3: usize = -42 && -39; | ^^^^^^^^^^ expected `usize`, found `bool` -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/const-integer-bool-ops.rs:38:19 | LL | const ARR3: [i32; X3] = [99; 6]; - | ^^ referenced constant has errors + | ^^ error[E0308]: mismatched types --> $DIR/const-integer-bool-ops.rs:41:18 @@ -100,11 +100,11 @@ error[E0308]: mismatched types LL | const Y: usize = 42.0 == 42.0; | ^^^^^^^^^^^^ expected `usize`, found `bool` -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/const-integer-bool-ops.rs:44:19 | LL | const ARRR: [i32; Y] = [99; 1]; - | ^ referenced constant has errors + | ^ error[E0308]: mismatched types --> $DIR/const-integer-bool-ops.rs:47:19 @@ -112,11 +112,11 @@ error[E0308]: mismatched types LL | const Y1: usize = 42.0 >= 42.0; | ^^^^^^^^^^^^ expected `usize`, found `bool` -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/const-integer-bool-ops.rs:50:20 | LL | const ARRR1: [i32; Y1] = [99; 1]; - | ^^ referenced constant has errors + | ^^ error[E0308]: mismatched types --> $DIR/const-integer-bool-ops.rs:53:19 @@ -124,11 +124,11 @@ error[E0308]: mismatched types LL | const Y2: usize = 42.0 <= 42.0; | ^^^^^^^^^^^^ expected `usize`, found `bool` -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/const-integer-bool-ops.rs:56:20 | LL | const ARRR2: [i32; Y2] = [99; 1]; - | ^^ referenced constant has errors + | ^^ error[E0308]: mismatched types --> $DIR/const-integer-bool-ops.rs:59:19 @@ -136,11 +136,11 @@ error[E0308]: mismatched types LL | const Y3: usize = 42.0 > 42.0; | ^^^^^^^^^^^ expected `usize`, found `bool` -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/const-integer-bool-ops.rs:62:20 | LL | const ARRR3: [i32; Y3] = [99; 0]; - | ^^ referenced constant has errors + | ^^ error[E0308]: mismatched types --> $DIR/const-integer-bool-ops.rs:65:19 @@ -148,11 +148,11 @@ error[E0308]: mismatched types LL | const Y4: usize = 42.0 < 42.0; | ^^^^^^^^^^^ expected `usize`, found `bool` -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/const-integer-bool-ops.rs:68:20 | LL | const ARRR4: [i32; Y4] = [99; 0]; - | ^^ referenced constant has errors + | ^^ error[E0308]: mismatched types --> $DIR/const-integer-bool-ops.rs:71:19 @@ -160,13 +160,12 @@ error[E0308]: mismatched types LL | const Y5: usize = 42.0 != 42.0; | ^^^^^^^^^^^^ expected `usize`, found `bool` -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/const-integer-bool-ops.rs:74:20 | LL | const ARRR5: [i32; Y5] = [99; 0]; - | ^^ referenced constant has errors + | ^^ -error: aborting due to 28 previous errors +error: aborting due to 18 previous errors -Some errors have detailed explanations: E0080, E0308. -For more information about an error, try `rustc --explain E0080`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/consts/const-len-underflow-separate-spans.rs b/src/test/ui/consts/const-len-underflow-separate-spans.rs index 478761aef..4544c8876 100644 --- a/src/test/ui/consts/const-len-underflow-separate-spans.rs +++ b/src/test/ui/consts/const-len-underflow-separate-spans.rs @@ -9,5 +9,5 @@ const LEN: usize = ONE - TWO; fn main() { let a: [i8; LEN] = unimplemented!(); -//~^ ERROR E0080 +//~^ constant } diff --git a/src/test/ui/consts/const-len-underflow-separate-spans.stderr b/src/test/ui/consts/const-len-underflow-separate-spans.stderr index 1416e695e..269553631 100644 --- a/src/test/ui/consts/const-len-underflow-separate-spans.stderr +++ b/src/test/ui/consts/const-len-underflow-separate-spans.stderr @@ -4,12 +4,12 @@ error[E0080]: evaluation of constant value failed LL | const LEN: usize = ONE - TWO; | ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/const-len-underflow-separate-spans.rs:11:17 | LL | let a: [i8; LEN] = unimplemented!(); - | ^^^ referenced constant has errors + | ^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-mut-refs/issue-76510.32bit.stderr b/src/test/ui/consts/const-mut-refs/issue-76510.32bit.stderr index 0f420ae1b..109d15a8e 100644 --- a/src/test/ui/consts/const-mut-refs/issue-76510.32bit.stderr +++ b/src/test/ui/consts/const-mut-refs/issue-76510.32bit.stderr @@ -19,13 +19,13 @@ error[E0596]: cannot borrow data in a `&` reference as mutable LL | const S: &'static mut str = &mut " hello "; | ^^^^^^^^^^^^^^ cannot borrow as mutable -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/issue-76510.rs:11:70 | LL | let s = transmute::<(*const u8, usize), &ManuallyDrop<str>>((S.as_ptr(), 3)); - | ^ referenced constant has errors + | ^ -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0080, E0596, E0658, E0764. -For more information about an error, try `rustc --explain E0080`. +Some errors have detailed explanations: E0596, E0658, E0764. +For more information about an error, try `rustc --explain E0596`. diff --git a/src/test/ui/consts/const-mut-refs/issue-76510.64bit.stderr b/src/test/ui/consts/const-mut-refs/issue-76510.64bit.stderr index 0f420ae1b..109d15a8e 100644 --- a/src/test/ui/consts/const-mut-refs/issue-76510.64bit.stderr +++ b/src/test/ui/consts/const-mut-refs/issue-76510.64bit.stderr @@ -19,13 +19,13 @@ error[E0596]: cannot borrow data in a `&` reference as mutable LL | const S: &'static mut str = &mut " hello "; | ^^^^^^^^^^^^^^ cannot borrow as mutable -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/issue-76510.rs:11:70 | LL | let s = transmute::<(*const u8, usize), &ManuallyDrop<str>>((S.as_ptr(), 3)); - | ^ referenced constant has errors + | ^ -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0080, E0596, E0658, E0764. -For more information about an error, try `rustc --explain E0080`. +Some errors have detailed explanations: E0596, E0658, E0764. +For more information about an error, try `rustc --explain E0596`. diff --git a/src/test/ui/consts/const-mut-refs/issue-76510.rs b/src/test/ui/consts/const-mut-refs/issue-76510.rs index 08cf64ee3..b853e2737 100644 --- a/src/test/ui/consts/const-mut-refs/issue-76510.rs +++ b/src/test/ui/consts/const-mut-refs/issue-76510.rs @@ -9,7 +9,7 @@ const S: &'static mut str = &mut " hello "; const fn trigger() -> [(); unsafe { let s = transmute::<(*const u8, usize), &ManuallyDrop<str>>((S.as_ptr(), 3)); - //~^ ERROR evaluation of constant value failed + //~^ constant 0 }] { [(); 0] diff --git a/src/test/ui/consts/const-mut-refs/mut_ref_in_final.stderr b/src/test/ui/consts/const-mut-refs/mut_ref_in_final.stderr index 3a9ce79f1..78c58b5ab 100644 --- a/src/test/ui/consts/const-mut-refs/mut_ref_in_final.stderr +++ b/src/test/ui/consts/const-mut-refs/mut_ref_in_final.stderr @@ -11,7 +11,7 @@ LL | const B3: Option<&mut i32> = Some(&mut 42); | ----------^^- | | | | | | | temporary value is freed at the end of this statement - | | creates a temporary which is freed while still in use + | | creates a temporary value which is freed while still in use | using this value as a constant requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed @@ -21,7 +21,7 @@ LL | const B4: Option<&mut i32> = helper(&mut 42); | ------------^^- | | | | | | | temporary value is freed at the end of this statement - | | creates a temporary which is freed while still in use + | | creates a temporary value which is freed while still in use | using this value as a constant requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed @@ -31,7 +31,7 @@ LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- | | | | | | | temporary value is freed at the end of this statement - | | creates a temporary which is freed while still in use + | | creates a temporary value which is freed while still in use | using this value as a constant requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed @@ -41,7 +41,7 @@ LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- | | | | | | | temporary value is freed at the end of this statement - | | creates a temporary which is freed while still in use + | | creates a temporary value which is freed while still in use | using this value as a static requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed @@ -51,7 +51,7 @@ LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- | | | | | | | temporary value is freed at the end of this statement - | | creates a temporary which is freed while still in use + | | creates a temporary value which is freed while still in use | using this value as a static requires that borrow lasts for `'static` error: aborting due to 6 previous errors diff --git a/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr b/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr index 234e55e3a..6e110dbdd 100644 --- a/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr +++ b/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr @@ -2,13 +2,18 @@ error[E0080]: evaluation of constant value failed --> $DIR/mut_ref_in_final_dynamic_check.rs:13:10 | LL | Some(&mut *(42 as *mut i32)) + | ^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: 0x2a[noalloc] is a dangling pointer (it has no provenance) + | +note: inside `helper` + --> $DIR/mut_ref_in_final_dynamic_check.rs:13:10 + | +LL | Some(&mut *(42 as *mut i32)) | ^^^^^^^^^^^^^^^^^^^^^^ - | | - | dereferencing pointer failed: 0x2a[noalloc] is a dangling pointer (it has no provenance) - | inside `helper` at $DIR/mut_ref_in_final_dynamic_check.rs:13:10 -... +note: inside `A` + --> $DIR/mut_ref_in_final_dynamic_check.rs:18:29 + | LL | const A: Option<&mut i32> = helper(); - | -------- inside `A` at $DIR/mut_ref_in_final_dynamic_check.rs:18:29 + | ^^^^^^^^ error: encountered dangling pointer in final constant --> $DIR/mut_ref_in_final_dynamic_check.rs:25:1 diff --git a/src/test/ui/consts/const-ptr-nonnull.stderr b/src/test/ui/consts/const-ptr-nonnull.stderr index 26946fb99..dbcb0c860 100644 --- a/src/test/ui/consts/const-ptr-nonnull.stderr +++ b/src/test/ui/consts/const-ptr-nonnull.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-ptr-nonnull.rs:4:37 | LL | let x: &'static NonNull<u32> = &(NonNull::dangling()); - | --------------------- ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | --------------------- ^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -13,7 +13,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-ptr-nonnull.rs:9:37 | LL | let x: &'static NonNull<u32> = &(non_null.cast()); - | --------------------- ^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | --------------------- ^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | diff --git a/src/test/ui/consts/const-ptr-unique.stderr b/src/test/ui/consts/const-ptr-unique.stderr index 3644cf4ce..83448c3e8 100644 --- a/src/test/ui/consts/const-ptr-unique.stderr +++ b/src/test/ui/consts/const-ptr-unique.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/const-ptr-unique.rs:8:33 | LL | let x: &'static *mut u32 = &(unique.as_ptr()); - | ----------------- ^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ----------------- ^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | diff --git a/src/test/ui/consts/const-tup-index-span.rs b/src/test/ui/consts/const-tup-index-span.rs index 763263c6a..778a21224 100644 --- a/src/test/ui/consts/const-tup-index-span.rs +++ b/src/test/ui/consts/const-tup-index-span.rs @@ -4,7 +4,7 @@ const TUP: (usize,) = 5usize << 64; //~^ ERROR mismatched types //~| expected tuple, found `usize` const ARR: [i32; TUP.0] = []; -//~^ ERROR evaluation of constant value failed +//~^ constant fn main() { } diff --git a/src/test/ui/consts/const-tup-index-span.stderr b/src/test/ui/consts/const-tup-index-span.stderr index b178e05e2..ad8468056 100644 --- a/src/test/ui/consts/const-tup-index-span.stderr +++ b/src/test/ui/consts/const-tup-index-span.stderr @@ -11,13 +11,12 @@ help: use a trailing comma to create a tuple with one element LL | const TUP: (usize,) = (5usize << 64,); | + ++ -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/const-tup-index-span.rs:6:18 | LL | const ARR: [i32; TUP.0] = []; - | ^^^ referenced constant has errors + | ^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0080, E0308. -For more information about an error, try `rustc --explain E0080`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/consts/const_in_pattern/accept_structural.rs b/src/test/ui/consts/const_in_pattern/accept_structural.rs index 5093fe539..1f56f581c 100644 --- a/src/test/ui/consts/const_in_pattern/accept_structural.rs +++ b/src/test/ui/consts/const_in_pattern/accept_structural.rs @@ -45,7 +45,7 @@ fn main() { const TUPLE: (OND, OND) = (None, None); match (None, None) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), }; - const TYPE_ASCRIPTION: OND = None: OND; + const TYPE_ASCRIPTION: OND = type_ascribe!(None, OND); match None { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), }; const ARRAY: [OND; 2] = [None, None]; diff --git a/src/test/ui/consts/const_in_pattern/reject_non_structural.rs b/src/test/ui/consts/const_in_pattern/reject_non_structural.rs index 7a8169bec..75fde0d92 100644 --- a/src/test/ui/consts/const_in_pattern/reject_non_structural.rs +++ b/src/test/ui/consts/const_in_pattern/reject_non_structural.rs @@ -53,7 +53,7 @@ fn main() { match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), }; //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` - const TYPE_ASCRIPTION: OND = Some(NoDerive): OND; + const TYPE_ASCRIPTION: OND = type_ascribe!(Some(NoDerive), OND); match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), }; //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` diff --git a/src/test/ui/consts/const_unsafe_unreachable_ub.stderr b/src/test/ui/consts/const_unsafe_unreachable_ub.stderr index f6de3699f..cbc7cac93 100644 --- a/src/test/ui/consts/const_unsafe_unreachable_ub.stderr +++ b/src/test/ui/consts/const_unsafe_unreachable_ub.stderr @@ -2,18 +2,23 @@ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/hint.rs:LL:COL | LL | intrinsics::unreachable() - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | entering unreachable code - | inside `unreachable_unchecked` at $SRC_DIR/core/src/hint.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^ entering unreachable code + | +note: inside `unreachable_unchecked` + --> $SRC_DIR/core/src/hint.rs:LL:COL | - ::: $DIR/const_unsafe_unreachable_ub.rs:6:18 +LL | intrinsics::unreachable() + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `foo` + --> $DIR/const_unsafe_unreachable_ub.rs:6:18 | LL | false => std::hint::unreachable_unchecked(), - | ---------------------------------- inside `foo` at $DIR/const_unsafe_unreachable_ub.rs:6:18 -... + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `BAR` + --> $DIR/const_unsafe_unreachable_ub.rs:10:28 + | LL | const BAR: bool = unsafe { foo(false) }; - | ---------- inside `BAR` at $DIR/const_unsafe_unreachable_ub.rs:10:28 + | ^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/consts/control-flow/interior-mutability.stderr b/src/test/ui/consts/control-flow/interior-mutability.stderr index 4f9c7d34c..db2ffb91b 100644 --- a/src/test/ui/consts/control-flow/interior-mutability.stderr +++ b/src/test/ui/consts/control-flow/interior-mutability.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/interior-mutability.rs:40:26 | LL | let x: &'static _ = &X; - | ---------- ^ creates a temporary which is freed while still in use + | ---------- ^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -13,7 +13,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/interior-mutability.rs:41:26 | LL | let y: &'static _ = &Y; - | ---------- ^ creates a temporary which is freed while still in use + | ---------- ^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | let z: &'static _ = &Z; @@ -24,7 +24,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/interior-mutability.rs:42:26 | LL | let z: &'static _ = &Z; - | ---------- ^ creates a temporary which is freed while still in use + | ---------- ^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | } diff --git a/src/test/ui/consts/extra-const-ub/detect-extra-ub.rs b/src/test/ui/consts/extra-const-ub/detect-extra-ub.rs index 159cdf257..9c239c8a1 100644 --- a/src/test/ui/consts/extra-const-ub/detect-extra-ub.rs +++ b/src/test/ui/consts/extra-const-ub/detect-extra-ub.rs @@ -29,7 +29,7 @@ const UNALIGNED_PTR: () = unsafe { }; const UNALIGNED_READ: () = { - INNER; //[with_flag]~ERROR evaluation of constant value failed + INNER; //[with_flag]~ constant // There is an error here but its span is in the standard library so we cannot match it... // so we have this in a *nested* const, such that the *outer* const fails to use it. const INNER: () = unsafe { diff --git a/src/test/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr b/src/test/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr index 3e1195822..2603a7358 100644 --- a/src/test/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr +++ b/src/test/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr @@ -32,27 +32,30 @@ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | accessing memory with alignment 1, but alignment 4 is required - | inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ accessing memory with alignment 1, but alignment 4 is required | - ::: $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 | -LL | unsafe { read(self) } - | ---------- inside `ptr::const_ptr::<impl *const u32>::read` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL +LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `ptr::const_ptr::<impl *const u32>::read` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - ::: $DIR/detect-extra-ub.rs:38:9 +LL | unsafe { read(self) } + | ^^^^^^^^^^ +note: inside `INNER` + --> $DIR/detect-extra-ub.rs:38:9 | LL | ptr.read(); - | ---------- inside `INNER` at $DIR/detect-extra-ub.rs:38:9 + | ^^^^^^^^^^ -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/detect-extra-ub.rs:32:5 | LL | INNER; - | ^^^^^ referenced constant has errors + | ^^^^^ -error: aborting due to 6 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/fn_trait_refs.rs b/src/test/ui/consts/fn_trait_refs.rs new file mode 100644 index 000000000..b50749297 --- /dev/null +++ b/src/test/ui/consts/fn_trait_refs.rs @@ -0,0 +1,77 @@ +// check-pass + +#![feature(const_fn_trait_ref_impls)] +#![feature(fn_traits)] +#![feature(unboxed_closures)] +#![feature(const_trait_impl)] +#![feature(const_mut_refs)] +#![feature(const_cmp)] +#![feature(const_refs_to_cell)] + +use std::marker::Destruct; + +const fn tester_fn<T>(f: T) -> T::Output +where + T: ~const Fn<()> + ~const Destruct, +{ + f() +} + +const fn tester_fn_mut<T>(mut f: T) -> T::Output +where + T: ~const FnMut<()> + ~const Destruct, +{ + f() +} + +const fn tester_fn_once<T>(f: T) -> T::Output +where + T: ~const FnOnce<()>, +{ + f() +} + +const fn test_fn<T>(mut f: T) -> (T::Output, T::Output, T::Output) +where + T: ~const Fn<()> + ~const Destruct, +{ + ( + // impl<A: Tuple, F: ~const Fn + ?Sized> const Fn<A> for &F + tester_fn(&f), + // impl<A: Tuple, F: ~const Fn + ?Sized> const FnMut<A> for &F + tester_fn_mut(&f), + // impl<A: Tuple, F: ~const Fn + ?Sized> const FnOnce<A> for &F + tester_fn_once(&f), + ) +} + +const fn test_fn_mut<T>(mut f: T) -> (T::Output, T::Output) +where + T: ~const FnMut<()> + ~const Destruct, +{ + ( + // impl<A: Tuple, F: ~const FnMut + ?Sized> const FnMut<A> for &mut F + tester_fn_mut(&mut f), + // impl<A: Tuple, F: ~const FnMut + ?Sized> const FnOnce<A> for &mut F + tester_fn_once(&mut f), + ) +} +const fn test(i: i32) -> i32 { + i + 1 +} + +fn main() { + const fn one() -> i32 { + 1 + }; + const fn two() -> i32 { + 2 + }; + const _: () = { + let test_one = test_fn(one); + assert!(test_one == (1, 1, 1)); + + let test_two = test_fn_mut(two); + assert!(test_two == (2, 2)); + }; +} diff --git a/src/test/ui/consts/invalid-const-in-body.rs b/src/test/ui/consts/invalid-const-in-body.rs new file mode 100644 index 000000000..f0fa3bb7b --- /dev/null +++ b/src/test/ui/consts/invalid-const-in-body.rs @@ -0,0 +1,6 @@ +fn f() -> impl Sized { + 2.0E + //~^ ERROR expected at least one digit in exponent +} + +fn main() {} diff --git a/src/test/ui/consts/invalid-const-in-body.stderr b/src/test/ui/consts/invalid-const-in-body.stderr new file mode 100644 index 000000000..3be658359 --- /dev/null +++ b/src/test/ui/consts/invalid-const-in-body.stderr @@ -0,0 +1,8 @@ +error: expected at least one digit in exponent + --> $DIR/invalid-const-in-body.rs:2:5 + | +LL | 2.0E + | ^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/consts/invalid-inline-const-in-match-arm.rs b/src/test/ui/consts/invalid-inline-const-in-match-arm.rs new file mode 100644 index 000000000..4d2d8fb13 --- /dev/null +++ b/src/test/ui/consts/invalid-inline-const-in-match-arm.rs @@ -0,0 +1,9 @@ +#![allow(incomplete_features)] +#![feature(inline_const_pat)] + +fn main() { + match () { + const { (|| {})() } => {} + //~^ ERROR cannot call non-const closure in constants + } +} diff --git a/src/test/ui/consts/invalid-inline-const-in-match-arm.stderr b/src/test/ui/consts/invalid-inline-const-in-match-arm.stderr new file mode 100644 index 000000000..ab594c921 --- /dev/null +++ b/src/test/ui/consts/invalid-inline-const-in-match-arm.stderr @@ -0,0 +1,12 @@ +error[E0015]: cannot call non-const closure in constants + --> $DIR/invalid-inline-const-in-match-arm.rs:6:17 + | +LL | const { (|| {})() } => {} + | ^^^^^^^^^ + | + = note: closures need an RFC before allowed to be called in constants + = note: calls in constants are limited to constant functions, tuple structs and tuple variants + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0015`. diff --git a/src/test/ui/consts/invalid-union.32bit.stderr b/src/test/ui/consts/invalid-union.32bit.stderr index bad07989e..4758ea4ae 100644 --- a/src/test/ui/consts/invalid-union.32bit.stderr +++ b/src/test/ui/consts/invalid-union.32bit.stderr @@ -9,12 +9,24 @@ LL | fn main() { ╾─alloc7──╼ │ ╾──╼ } -error[E0080]: erroneous constant used - --> $DIR/invalid-union.rs:42:25 +note: erroneous constant used + --> $DIR/invalid-union.rs:43:25 | LL | let _: &'static _ = &C; - | ^^ referenced constant has errors + | ^^ -error: aborting due to 2 previous errors +note: erroneous constant used + --> $DIR/invalid-union.rs:43:25 + | +LL | let _: &'static _ = &C; + | ^^ + +note: erroneous constant used + --> $DIR/invalid-union.rs:43:25 + | +LL | let _: &'static _ = &C; + | ^^ + +error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/invalid-union.64bit.stderr b/src/test/ui/consts/invalid-union.64bit.stderr index a209f0038..22b85d20c 100644 --- a/src/test/ui/consts/invalid-union.64bit.stderr +++ b/src/test/ui/consts/invalid-union.64bit.stderr @@ -9,12 +9,24 @@ LL | fn main() { ╾───────alloc7────────╼ │ ╾──────╼ } -error[E0080]: erroneous constant used - --> $DIR/invalid-union.rs:42:25 +note: erroneous constant used + --> $DIR/invalid-union.rs:43:25 | LL | let _: &'static _ = &C; - | ^^ referenced constant has errors + | ^^ -error: aborting due to 2 previous errors +note: erroneous constant used + --> $DIR/invalid-union.rs:43:25 + | +LL | let _: &'static _ = &C; + | ^^ + +note: erroneous constant used + --> $DIR/invalid-union.rs:43:25 + | +LL | let _: &'static _ = &C; + | ^^ + +error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/invalid-union.rs b/src/test/ui/consts/invalid-union.rs index 435d26d6e..28706b4a9 100644 --- a/src/test/ui/consts/invalid-union.rs +++ b/src/test/ui/consts/invalid-union.rs @@ -39,5 +39,6 @@ const C: S = { }; fn main() { //~ ERROR it is undefined behavior to use this value - let _: &'static _ = &C; //~ ERROR erroneous constant used + // FIXME the span here is wrong, sould be pointing at the line below, not above. + let _: &'static _ = &C; } diff --git a/src/test/ui/consts/issue-102117.rs b/src/test/ui/consts/issue-102117.rs index b77342c41..3ed90aed2 100644 --- a/src/test/ui/consts/issue-102117.rs +++ b/src/test/ui/consts/issue-102117.rs @@ -14,11 +14,11 @@ pub struct VTable { impl VTable { pub fn new<T>() -> &'static Self { const { - //~^ ERROR the parameter type `T` may not live long enough - //~| ERROR the parameter type `T` may not live long enough &VTable { layout: Layout::new::<T>(), type_id: TypeId::of::<T>(), + //~^ ERROR the parameter type `T` may not live long enough + //~| ERROR the parameter type `T` may not live long enough drop_in_place: unsafe { transmute::<unsafe fn(*mut T), unsafe fn(*mut ())>(drop_in_place::<T>) }, diff --git a/src/test/ui/consts/issue-102117.stderr b/src/test/ui/consts/issue-102117.stderr index eb4b329bd..f42bcf90f 100644 --- a/src/test/ui/consts/issue-102117.stderr +++ b/src/test/ui/consts/issue-102117.stderr @@ -1,14 +1,8 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/issue-102117.rs:16:9 + --> $DIR/issue-102117.rs:19:26 | -LL | / const { -LL | | -LL | | -LL | | &VTable { -... | -LL | | } -LL | | } - | |_________^ ...so that the type `T` will meet its required lifetime bounds +LL | type_id: TypeId::of::<T>(), + | ^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound... | @@ -16,16 +10,10 @@ LL | pub fn new<T: 'static>() -> &'static Self { | +++++++++ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/issue-102117.rs:16:9 + --> $DIR/issue-102117.rs:19:26 | -LL | / const { -LL | | -LL | | -LL | | &VTable { -... | -LL | | } -LL | | } - | |_________^ ...so that the type `T` will meet its required lifetime bounds +LL | type_id: TypeId::of::<T>(), + | ^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound... | diff --git a/src/test/ui/consts/issue-103790.rs b/src/test/ui/consts/issue-103790.rs new file mode 100644 index 000000000..ea3cac605 --- /dev/null +++ b/src/test/ui/consts/issue-103790.rs @@ -0,0 +1,10 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +struct S<const S: (), const S: S = { S }>; +//~^ ERROR the name `S` is already used for a generic parameter in this item's generic parameters +//~| ERROR missing generics for struct `S` +//~| ERROR cycle detected when computing type of `S::S` +//~| ERROR cycle detected when computing type of `S` + +fn main() {} diff --git a/src/test/ui/consts/issue-103790.stderr b/src/test/ui/consts/issue-103790.stderr new file mode 100644 index 000000000..41b0816dc --- /dev/null +++ b/src/test/ui/consts/issue-103790.stderr @@ -0,0 +1,65 @@ +error[E0403]: the name `S` is already used for a generic parameter in this item's generic parameters + --> $DIR/issue-103790.rs:4:29 + | +LL | struct S<const S: (), const S: S = { S }>; + | - ^ already used + | | + | first use of `S` + +error[E0107]: missing generics for struct `S` + --> $DIR/issue-103790.rs:4:32 + | +LL | struct S<const S: (), const S: S = { S }>; + | ^ expected at least 1 generic argument + | +note: struct defined here, with at least 1 generic parameter: `S` + --> $DIR/issue-103790.rs:4:8 + | +LL | struct S<const S: (), const S: S = { S }>; + | ^ ----------- +help: add missing generic argument + | +LL | struct S<const S: (), const S: S<S> = { S }>; + | ~~~~ + +error[E0391]: cycle detected when computing type of `S::S` + --> $DIR/issue-103790.rs:4:32 + | +LL | struct S<const S: (), const S: S = { S }>; + | ^ + | + = note: ...which immediately requires computing type of `S::S` again +note: cycle used when computing type of `S` + --> $DIR/issue-103790.rs:4:1 + | +LL | struct S<const S: (), const S: S = { S }>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0391]: cycle detected when computing type of `S` + --> $DIR/issue-103790.rs:4:1 + | +LL | struct S<const S: (), const S: S = { S }>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...which requires computing type of `S::S`... + --> $DIR/issue-103790.rs:4:32 + | +LL | struct S<const S: (), const S: S = { S }>; + | ^ + = note: ...which again requires computing type of `S`, completing the cycle +note: cycle used when collecting item types in top-level module + --> $DIR/issue-103790.rs:1:1 + | +LL | / #![feature(generic_const_exprs)] +LL | | #![allow(incomplete_features)] +LL | | +LL | | struct S<const S: (), const S: S = { S }>; +... | +LL | | +LL | | fn main() {} + | |____________^ + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0107, E0391, E0403. +For more information about an error, try `rustc --explain E0107`. diff --git a/src/test/ui/consts/issue-104609.rs b/src/test/ui/consts/issue-104609.rs new file mode 100644 index 000000000..01fd1c48c --- /dev/null +++ b/src/test/ui/consts/issue-104609.rs @@ -0,0 +1,10 @@ +fn foo() { + oops; + //~^ ERROR: cannot find value `oops` in this scope +} + +unsafe fn bar() { + std::mem::transmute::<_, *mut _>(1_u8); +} + +fn main() {} diff --git a/src/test/ui/consts/issue-104609.stderr b/src/test/ui/consts/issue-104609.stderr new file mode 100644 index 000000000..00360c44d --- /dev/null +++ b/src/test/ui/consts/issue-104609.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find value `oops` in this scope + --> $DIR/issue-104609.rs:2:5 + | +LL | oops; + | ^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/consts/issue-104768.rs b/src/test/ui/consts/issue-104768.rs new file mode 100644 index 000000000..3192daafa --- /dev/null +++ b/src/test/ui/consts/issue-104768.rs @@ -0,0 +1,4 @@ +const A: &_ = 0_u32; +//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for constants + +fn main() {} diff --git a/src/test/ui/consts/issue-104768.stderr b/src/test/ui/consts/issue-104768.stderr new file mode 100644 index 000000000..55b2b6f04 --- /dev/null +++ b/src/test/ui/consts/issue-104768.stderr @@ -0,0 +1,12 @@ +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants + --> $DIR/issue-104768.rs:1:10 + | +LL | const A: &_ = 0_u32; + | ^^ + | | + | not allowed in type signatures + | help: replace with the correct type: `u32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0121`. diff --git a/src/test/ui/consts/issue-36163.stderr b/src/test/ui/consts/issue-36163.stderr index 9ac6c984c..7137c0538 100644 --- a/src/test/ui/consts/issue-36163.stderr +++ b/src/test/ui/consts/issue-36163.stderr @@ -5,10 +5,10 @@ LL | B = A, | ^ | note: ...which requires const-evaluating + checking `A`... - --> $DIR/issue-36163.rs:1:1 + --> $DIR/issue-36163.rs:1:18 | LL | const A: isize = Foo::B as isize; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ = note: ...which again requires const-evaluating + checking `Foo::B::{constant#0}`, completing the cycle note: cycle used when simplifying constant for the type system `Foo::B::{constant#0}` --> $DIR/issue-36163.rs:4:9 diff --git a/src/test/ui/consts/issue-54224.stderr b/src/test/ui/consts/issue-54224.stderr index 8dcb4daca..55fe55759 100644 --- a/src/test/ui/consts/issue-54224.stderr +++ b/src/test/ui/consts/issue-54224.stderr @@ -5,7 +5,7 @@ LL | const FOO: Option<&[[u8; 3]]> = Some(&[*b"foo"]); | ------^^^^^^^^^- | | | | | | | temporary value is freed at the end of this statement - | | creates a temporary which is freed while still in use + | | creates a temporary value which is freed while still in use | using this value as a constant requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed @@ -15,7 +15,7 @@ LL | pub const Z: Cow<'static, [ [u8; 3] ]> = Cow::Borrowed(&[*b"ABC"]); | ---------------^^^^^^^^^- | | | | | | | temporary value is freed at the end of this statement - | | creates a temporary which is freed while still in use + | | creates a temporary value which is freed while still in use | using this value as a constant requires that borrow lasts for `'static` error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-54954.rs b/src/test/ui/consts/issue-54954.rs index d4e1df227..520bf508f 100644 --- a/src/test/ui/issues/issue-54954.rs +++ b/src/test/ui/consts/issue-54954.rs @@ -9,8 +9,8 @@ trait Tt { } fn f(z: [f32; ARR_LEN]) -> [f32; ARR_LEN] { - //~^ ERROR evaluation of constant value failed - //~| ERROR evaluation of constant value failed + //~^ constant + //~| constant z } diff --git a/src/test/ui/issues/issue-54954.stderr b/src/test/ui/consts/issue-54954.stderr index 668985c2b..850558287 100644 --- a/src/test/ui/issues/issue-54954.stderr +++ b/src/test/ui/consts/issue-54954.stderr @@ -16,19 +16,19 @@ LL | | core::mem::size_of::<T>() LL | | } | |_____- `Tt::const_val` defined here -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/issue-54954.rs:11:15 | LL | fn f(z: [f32; ARR_LEN]) -> [f32; ARR_LEN] { - | ^^^^^^^ referenced constant has errors + | ^^^^^^^ -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/issue-54954.rs:11:34 | LL | fn f(z: [f32; ARR_LEN]) -> [f32; ARR_LEN] { - | ^^^^^^^ referenced constant has errors + | ^^^^^^^ -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0080, E0379, E0790. -For more information about an error, try `rustc --explain E0080`. +Some errors have detailed explanations: E0379, E0790. +For more information about an error, try `rustc --explain E0379`. diff --git a/src/test/ui/consts/issue-56164.rs b/src/test/ui/consts/issue-56164.rs index df3e3bf90..22c257d0b 100644 --- a/src/test/ui/consts/issue-56164.rs +++ b/src/test/ui/consts/issue-56164.rs @@ -1,6 +1,5 @@ const fn foo() { (||{})() } //~^ ERROR cannot call non-const closure -//~| ERROR erroneous constant used const fn bad(input: fn()) { input() diff --git a/src/test/ui/consts/issue-56164.stderr b/src/test/ui/consts/issue-56164.stderr index c5b2c57fb..2579b3e78 100644 --- a/src/test/ui/consts/issue-56164.stderr +++ b/src/test/ui/consts/issue-56164.stderr @@ -8,18 +8,23 @@ LL | const fn foo() { (||{})() } = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: function pointer calls are not allowed in constant functions - --> $DIR/issue-56164.rs:6:5 + --> $DIR/issue-56164.rs:5:5 | LL | input() | ^^^^^^^ -error[E0080]: erroneous constant used +note: erroneous constant used --> $DIR/issue-56164.rs:1:18 | LL | const fn foo() { (||{})() } - | ^^^^^^ referenced constant has errors + | ^^^^^^ -error: aborting due to 3 previous errors +note: erroneous constant used + --> $DIR/issue-56164.rs:1:18 + | +LL | const fn foo() { (||{})() } + | ^^^^^^ + +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0015, E0080. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/src/test/ui/consts/issue-66693.rs b/src/test/ui/consts/issue-66693.rs index 1ff250be1..df45d01ec 100644 --- a/src/test/ui/consts/issue-66693.rs +++ b/src/test/ui/consts/issue-66693.rs @@ -10,7 +10,6 @@ static _FOO: () = panic!(true); const fn _foo() { panic!(&1); //~^ ERROR: argument to `panic!()` in a const context must have type `&str` - //~| ERROR: erroneous constant used } // ensure that conforming panics don't cause an error diff --git a/src/test/ui/consts/issue-66693.stderr b/src/test/ui/consts/issue-66693.stderr index 911374f50..e9a3fced6 100644 --- a/src/test/ui/consts/issue-66693.stderr +++ b/src/test/ui/consts/issue-66693.stderr @@ -22,12 +22,17 @@ LL | panic!(&1); | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: erroneous constant used +note: erroneous constant used --> $DIR/issue-66693.rs:11:12 | LL | panic!(&1); - | ^^ referenced constant has errors + | ^^ -error: aborting due to 4 previous errors +note: erroneous constant used + --> $DIR/issue-66693.rs:11:12 + | +LL | panic!(&1); + | ^^ + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/issue-miri-1910.stderr b/src/test/ui/consts/issue-miri-1910.stderr index 3872e3d4f..1f82e1777 100644 --- a/src/test/ui/consts/issue-miri-1910.stderr +++ b/src/test/ui/consts/issue-miri-1910.stderr @@ -2,23 +2,25 @@ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | unable to copy parts of a pointer from memory at ALLOC - | inside `std::ptr::read::<u8>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to copy parts of a pointer from memory at ALLOC | - ::: $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported +note: inside `std::ptr::read::<u8>` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | -LL | unsafe { read(self) } - | ---------- inside `ptr::const_ptr::<impl *const u8>::read` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL +LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `ptr::const_ptr::<impl *const u8>::read` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - ::: $DIR/issue-miri-1910.rs:8:5 +LL | unsafe { read(self) } + | ^^^^^^^^^^ +note: inside `C` + --> $DIR/issue-miri-1910.rs:8:5 | LL | (&foo as *const _ as *const u8).add(one_and_a_half_pointers).read(); - | ------------------------------------------------------------------- inside `C` at $DIR/issue-miri-1910.rs:8:5 - | - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/consts/min_const_fn/promotion.stderr b/src/test/ui/consts/min_const_fn/promotion.stderr index 550423c2d..0b8dc0ce0 100644 --- a/src/test/ui/consts/min_const_fn/promotion.stderr +++ b/src/test/ui/consts/min_const_fn/promotion.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promotion.rs:11:27 | LL | let x: &'static () = &foo1(); - | ----------- ^^^^^^ creates a temporary which is freed while still in use + | ----------- ^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -13,7 +13,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promotion.rs:12:28 | LL | let y: &'static i32 = &foo2(42); - | ------------ ^^^^^^^^ creates a temporary which is freed while still in use + | ------------ ^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -24,7 +24,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promotion.rs:13:28 | LL | let z: &'static i32 = &foo3(); - | ------------ ^^^^^^ creates a temporary which is freed while still in use + | ------------ ^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -35,7 +35,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promotion.rs:14:34 | LL | let a: &'static Cell<i32> = &foo4(); - | ------------------ ^^^^^^ creates a temporary which is freed while still in use + | ------------------ ^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -46,7 +46,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promotion.rs:15:42 | LL | let a: &'static Option<Cell<i32>> = &foo5(); - | -------------------------- ^^^^^^ creates a temporary which is freed while still in use + | -------------------------- ^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | let a: &'static Option<Cell<i32>> = &foo6(); @@ -57,7 +57,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promotion.rs:16:42 | LL | let a: &'static Option<Cell<i32>> = &foo6(); - | -------------------------- ^^^^^^ creates a temporary which is freed while still in use + | -------------------------- ^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | } diff --git a/src/test/ui/consts/miri_unleashed/abi-mismatch.stderr b/src/test/ui/consts/miri_unleashed/abi-mismatch.stderr index 840d698eb..cf3fd88d0 100644 --- a/src/test/ui/consts/miri_unleashed/abi-mismatch.stderr +++ b/src/test/ui/consts/miri_unleashed/abi-mismatch.stderr @@ -2,13 +2,18 @@ error[E0080]: could not evaluate static initializer --> $DIR/abi-mismatch.rs:9:5 | LL | my_fn(); + | ^^^^^^^ calling a function with calling convention C using calling convention Rust + | +note: inside `call_rust_fn` + --> $DIR/abi-mismatch.rs:9:5 + | +LL | my_fn(); | ^^^^^^^ - | | - | calling a function with calling convention C using calling convention Rust - | inside `call_rust_fn` at $DIR/abi-mismatch.rs:9:5 -... +note: inside `VAL` + --> $DIR/abi-mismatch.rs:15:18 + | LL | static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) }); - | --------------------------------------------------------------------- inside `VAL` at $DIR/abi-mismatch.rs:15:18 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: skipping const checks | diff --git a/src/test/ui/consts/miri_unleashed/assoc_const.rs b/src/test/ui/consts/miri_unleashed/assoc_const.rs index 76ed667a5..7bb0c1b77 100644 --- a/src/test/ui/consts/miri_unleashed/assoc_const.rs +++ b/src/test/ui/consts/miri_unleashed/assoc_const.rs @@ -26,5 +26,5 @@ fn main() { // this is fine, but would have been forbidden by the static checks on `F` let x = <() as Bar<u32, ()>>::F; // this test only causes errors due to the line below, so post-monomorphization - let y = <String as Bar<Vec<u32>, String>>::F; //~ ERROR erroneous constant + let y = <String as Bar<Vec<u32>, String>>::F; //~ constant } diff --git a/src/test/ui/consts/miri_unleashed/assoc_const.stderr b/src/test/ui/consts/miri_unleashed/assoc_const.stderr index 519bd0748..b26f121db 100644 --- a/src/test/ui/consts/miri_unleashed/assoc_const.stderr +++ b/src/test/ui/consts/miri_unleashed/assoc_const.stderr @@ -2,22 +2,41 @@ error[E0080]: evaluation of `<std::string::String as Bar<std::vec::Vec<u32>, std --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | LL | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling non-const function `<Vec<u32> as Drop>::drop` + | +note: inside `std::ptr::drop_in_place::<Vec<u32>> - shim(Some(Vec<u32>))` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | +LL | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | calling non-const function `<Vec<u32> as Drop>::drop` - | inside `std::ptr::drop_in_place::<Vec<u32>> - shim(Some(Vec<u32>))` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - | inside `std::ptr::drop_in_place::<(Vec<u32>, u32)> - shim(Some((Vec<u32>, u32)))` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL +note: inside `std::ptr::drop_in_place::<(Vec<u32>, u32)> - shim(Some((Vec<u32>, u32)))` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | - ::: $DIR/assoc_const.rs:12:31 +LL | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `<String as Bar<Vec<u32>, String>>::F` + --> $DIR/assoc_const.rs:12:31 | LL | const F: u32 = (U::X, 42).1; - | - inside `<String as Bar<Vec<u32>, String>>::F` at $DIR/assoc_const.rs:12:31 + | ^ + +note: erroneous constant used + --> $DIR/assoc_const.rs:29:13 + | +LL | let y = <String as Bar<Vec<u32>, String>>::F; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: erroneous constant used + --> $DIR/assoc_const.rs:29:13 + | +LL | let y = <String as Bar<Vec<u32>, String>>::F; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: erroneous constant used +note: erroneous constant used --> $DIR/assoc_const.rs:29:13 | LL | let y = <String as Bar<Vec<u32>, String>>::F; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: skipping const checks | @@ -27,6 +46,6 @@ help: skipping check that does not even have a feature gate LL | const F: u32 = (U::X, 42).1; | ^^^^^^^^^^ -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/miri_unleashed/assoc_const_2.rs b/src/test/ui/consts/miri_unleashed/assoc_const_2.rs index 8377141ea..aad5b3460 100644 --- a/src/test/ui/consts/miri_unleashed/assoc_const_2.rs +++ b/src/test/ui/consts/miri_unleashed/assoc_const_2.rs @@ -24,5 +24,5 @@ impl Bar<String> for String {} fn main() { let x = <() as Bar<()>>::F; // this test only causes errors due to the line below, so post-monomorphization - let y = <String as Bar<String>>::F; //~ ERROR erroneous constant + let y = <String as Bar<String>>::F; //~ constant } diff --git a/src/test/ui/consts/miri_unleashed/assoc_const_2.stderr b/src/test/ui/consts/miri_unleashed/assoc_const_2.stderr index 2bf753c2b..fc4b18056 100644 --- a/src/test/ui/consts/miri_unleashed/assoc_const_2.stderr +++ b/src/test/ui/consts/miri_unleashed/assoc_const_2.stderr @@ -4,12 +4,24 @@ error[E0080]: evaluation of `<std::string::String as Bar<std::string::String>>:: LL | const F: u32 = 100 / U::X; | ^^^^^^^^^^ attempt to divide `100_u32` by zero -error[E0080]: erroneous constant used +note: erroneous constant used --> $DIR/assoc_const_2.rs:27:13 | LL | let y = <String as Bar<String>>::F; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +note: erroneous constant used + --> $DIR/assoc_const_2.rs:27:13 + | +LL | let y = <String as Bar<String>>::F; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: erroneous constant used + --> $DIR/assoc_const_2.rs:27:13 + | +LL | let y = <String as Bar<String>>::F; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/miri_unleashed/drop.stderr b/src/test/ui/consts/miri_unleashed/drop.stderr index a3a502723..e2e2f16d5 100644 --- a/src/test/ui/consts/miri_unleashed/drop.stderr +++ b/src/test/ui/consts/miri_unleashed/drop.stderr @@ -2,15 +2,18 @@ error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | LL | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | calling non-const function `<Vec<i32> as Drop>::drop` - | inside `std::ptr::drop_in_place::<Vec<i32>> - shim(Some(Vec<i32>))` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling non-const function `<Vec<i32> as Drop>::drop` + | +note: inside `std::ptr::drop_in_place::<Vec<i32>> - shim(Some(Vec<i32>))` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | - ::: $DIR/drop.rs:17:1 +LL | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `TEST_BAD` + --> $DIR/drop.rs:17:1 | LL | }; - | - inside `TEST_BAD` at $DIR/drop.rs:17:1 + | ^ warning: skipping const checks | diff --git a/src/test/ui/consts/miri_unleashed/tls.stderr b/src/test/ui/consts/miri_unleashed/tls.stderr index 436c51123..7aaeadd04 100644 --- a/src/test/ui/consts/miri_unleashed/tls.stderr +++ b/src/test/ui/consts/miri_unleashed/tls.stderr @@ -2,13 +2,13 @@ error[E0080]: could not evaluate static initializer --> $DIR/tls.rs:11:25 | LL | unsafe { let _val = A; } - | ^ cannot access thread local static (DefId(0:6 ~ tls[78b0]::A)) + | ^ cannot access thread local static (DefId(0:4 ~ tls[78b0]::A)) error[E0080]: could not evaluate static initializer --> $DIR/tls.rs:18:26 | LL | unsafe { let _val = &A; } - | ^ cannot access thread local static (DefId(0:6 ~ tls[78b0]::A)) + | ^ cannot access thread local static (DefId(0:4 ~ tls[78b0]::A)) warning: skipping const checks | diff --git a/src/test/ui/consts/missing_span_in_backtrace.rs b/src/test/ui/consts/missing_span_in_backtrace.rs new file mode 100644 index 000000000..c4930b73a --- /dev/null +++ b/src/test/ui/consts/missing_span_in_backtrace.rs @@ -0,0 +1,27 @@ +// compile-flags: -Z simulate-remapped-rust-src-base=/rustc/FAKE_PREFIX -Z translate-remapped-path-to-local-path=no -Z ui-testing=no +// normalize-stderr-test "alloc[0-9]+" -> "ALLOC_ID" + +#![feature(const_swap)] +#![feature(const_mut_refs)] +use std::{ + mem::{self, MaybeUninit}, + ptr, +}; + +const X: () = { + let mut ptr1 = &1; + let mut ptr2 = &2; + + // Swap them, bytewise. + unsafe { + ptr::swap_nonoverlapping( + &mut ptr1 as *mut _ as *mut MaybeUninit<u8>, + &mut ptr2 as *mut _ as *mut MaybeUninit<u8>, + mem::size_of::<&i32>(), + ); + } +}; + +fn main() { + X +} diff --git a/src/test/ui/consts/missing_span_in_backtrace.stderr b/src/test/ui/consts/missing_span_in_backtrace.stderr new file mode 100644 index 000000000..e6d3d5199 --- /dev/null +++ b/src/test/ui/consts/missing_span_in_backtrace.stderr @@ -0,0 +1,28 @@ +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | + = note: unable to copy parts of a pointer from memory at ALLOC_ID + | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported +note: inside `std::ptr::read::<MaybeUninit<MaybeUninit<u8>>>` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL +note: inside `mem::swap_simple::<MaybeUninit<MaybeUninit<u8>>>` + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL +note: inside `ptr::swap_nonoverlapping_simple_untyped::<MaybeUninit<u8>>` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL +note: inside `swap_nonoverlapping::<MaybeUninit<u8>>` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL +note: inside `X` + --> $DIR/missing_span_in_backtrace.rs:17:9 + | +17 | / ptr::swap_nonoverlapping( +18 | | &mut ptr1 as *mut _ as *mut MaybeUninit<u8>, +19 | | &mut ptr2 as *mut _ as *mut MaybeUninit<u8>, +20 | | mem::size_of::<&i32>(), +21 | | ); + | |_________^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/offset_from_ub.stderr b/src/test/ui/consts/offset_from_ub.stderr index 62a087d94..9578d90ea 100644 --- a/src/test/ui/consts/offset_from_ub.stderr +++ b/src/test/ui/consts/offset_from_ub.stderr @@ -8,15 +8,18 @@ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::ptr_offset_from(self, origin) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | `ptr_offset_from` called on pointers into different allocations - | inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on pointers into different allocations + | +note: inside `ptr::const_ptr::<impl *const u8>::offset_from` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - ::: $DIR/offset_from_ub.rs:24:14 +LL | unsafe { intrinsics::ptr_offset_from(self, origin) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `NOT_PTR` + --> $DIR/offset_from_ub.rs:24:14 | LL | unsafe { (42 as *const u8).offset_from(&5u8) as usize } - | ----------------------------------- inside `NOT_PTR` at $DIR/offset_from_ub.rs:24:14 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:31:14 @@ -88,29 +91,35 @@ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::ptr_offset_from(self, origin) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance) - | inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance) | - ::: $DIR/offset_from_ub.rs:115:14 +note: inside `ptr::const_ptr::<impl *const u8>::offset_from` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | +LL | unsafe { intrinsics::ptr_offset_from(self, origin) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `OFFSET_VERY_FAR1` + --> $DIR/offset_from_ub.rs:115:14 | LL | unsafe { ptr2.offset_from(ptr1) } - | ---------------------- inside `OFFSET_VERY_FAR1` at $DIR/offset_from_ub.rs:115:14 + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::ptr_offset_from(self, origin) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance) - | inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance) | - ::: $DIR/offset_from_ub.rs:121:14 +note: inside `ptr::const_ptr::<impl *const u8>::offset_from` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | +LL | unsafe { intrinsics::ptr_offset_from(self, origin) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `OFFSET_VERY_FAR2` + --> $DIR/offset_from_ub.rs:121:14 | LL | unsafe { ptr1.offset_from(ptr2.wrapping_offset(1)) } - | ----------------------------------------- inside `OFFSET_VERY_FAR2` at $DIR/offset_from_ub.rs:121:14 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 15 previous errors diff --git a/src/test/ui/consts/offset_ub.stderr b/src/test/ui/consts/offset_ub.stderr index 5a792bba5..7938f70a2 100644 --- a/src/test/ui/consts/offset_ub.stderr +++ b/src/test/ui/consts/offset_ub.stderr @@ -2,169 +2,205 @@ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::offset(self, count) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | overflowing in-bounds pointer arithmetic - | inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing in-bounds pointer arithmetic + | +note: inside `ptr::const_ptr::<impl *const u8>::offset` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - ::: $DIR/offset_ub.rs:7:46 +LL | unsafe { intrinsics::offset(self, count) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `BEFORE_START` + --> $DIR/offset_ub.rs:7:46 | LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) }; - | ------------------------------ inside `BEFORE_START` at $DIR/offset_ub.rs:7:46 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::offset(self, count) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | out-of-bounds pointer arithmetic: allocN has size 1, so pointer to 2 bytes starting at offset 0 is out-of-bounds - | inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: allocN has size 1, so pointer to 2 bytes starting at offset 0 is out-of-bounds | - ::: $DIR/offset_ub.rs:8:43 +note: inside `ptr::const_ptr::<impl *const u8>::offset` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | +LL | unsafe { intrinsics::offset(self, count) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `AFTER_END` + --> $DIR/offset_ub.rs:8:43 | LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) }; - | ----------------------------- inside `AFTER_END` at $DIR/offset_ub.rs:8:43 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::offset(self, count) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | out-of-bounds pointer arithmetic: allocN has size 100, so pointer to 101 bytes starting at offset 0 is out-of-bounds - | inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: allocN has size 100, so pointer to 101 bytes starting at offset 0 is out-of-bounds | - ::: $DIR/offset_ub.rs:9:45 +note: inside `ptr::const_ptr::<impl *const u8>::offset` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | +LL | unsafe { intrinsics::offset(self, count) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `AFTER_ARRAY` + --> $DIR/offset_ub.rs:9:45 | LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) }; - | ------------------------------- inside `AFTER_ARRAY` at $DIR/offset_ub.rs:9:45 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::offset(self, count) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | overflowing in-bounds pointer arithmetic - | inside `ptr::const_ptr::<impl *const u16>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing in-bounds pointer arithmetic + | +note: inside `ptr::const_ptr::<impl *const u16>::offset` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - ::: $DIR/offset_ub.rs:11:43 +LL | unsafe { intrinsics::offset(self, count) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `OVERFLOW` + --> $DIR/offset_ub.rs:11:43 | LL | pub const OVERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MAX) }; - | ------------------------------------- inside `OVERFLOW` at $DIR/offset_ub.rs:11:43 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::offset(self, count) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | overflowing in-bounds pointer arithmetic - | inside `ptr::const_ptr::<impl *const u16>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing in-bounds pointer arithmetic | - ::: $DIR/offset_ub.rs:12:44 +note: inside `ptr::const_ptr::<impl *const u16>::offset` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | +LL | unsafe { intrinsics::offset(self, count) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `UNDERFLOW` + --> $DIR/offset_ub.rs:12:44 | LL | pub const UNDERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MIN) }; - | ------------------------------------- inside `UNDERFLOW` at $DIR/offset_ub.rs:12:44 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::offset(self, count) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | overflowing in-bounds pointer arithmetic - | inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing in-bounds pointer arithmetic | - ::: $DIR/offset_ub.rs:13:56 +note: inside `ptr::const_ptr::<impl *const u8>::offset` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | +LL | unsafe { intrinsics::offset(self, count) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `OVERFLOW_ADDRESS_SPACE` + --> $DIR/offset_ub.rs:13:56 | LL | pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) }; - | ----------------------------------- inside `OVERFLOW_ADDRESS_SPACE` at $DIR/offset_ub.rs:13:56 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::offset(self, count) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | overflowing in-bounds pointer arithmetic - | inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing in-bounds pointer arithmetic + | +note: inside `ptr::const_ptr::<impl *const u8>::offset` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - ::: $DIR/offset_ub.rs:14:57 +LL | unsafe { intrinsics::offset(self, count) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `UNDERFLOW_ADDRESS_SPACE` + --> $DIR/offset_ub.rs:14:57 | LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) }; - | --------------------------- inside `UNDERFLOW_ADDRESS_SPACE` at $DIR/offset_ub.rs:14:57 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::offset(self, count) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | out-of-bounds pointer arithmetic: allocN has size 1, so pointer to 2 bytes starting at offset -4 is out-of-bounds - | inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: allocN has size 1, so pointer to 2 bytes starting at offset -4 is out-of-bounds | - ::: $DIR/offset_ub.rs:15:49 +note: inside `ptr::const_ptr::<impl *const u8>::offset` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | +LL | unsafe { intrinsics::offset(self, count) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `NEGATIVE_OFFSET` + --> $DIR/offset_ub.rs:15:49 | LL | pub const NEGATIVE_OFFSET: *const u8 = unsafe { [0u8; 1].as_ptr().wrapping_offset(-2).offset(-2) }; - | ------------------------------------------------ inside `NEGATIVE_OFFSET` at $DIR/offset_ub.rs:15:49 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::offset(self, count) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | out-of-bounds pointer arithmetic: allocN has size 0, so pointer to 1 byte starting at offset 0 is out-of-bounds - | inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: allocN has size 0, so pointer to 1 byte starting at offset 0 is out-of-bounds | - ::: $DIR/offset_ub.rs:17:50 +note: inside `ptr::const_ptr::<impl *const u8>::offset` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | +LL | unsafe { intrinsics::offset(self, count) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `ZERO_SIZED_ALLOC` + --> $DIR/offset_ub.rs:17:50 | LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) }; - | --------------------------- inside `ZERO_SIZED_ALLOC` at $DIR/offset_ub.rs:17:50 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL | LL | unsafe { intrinsics::offset(self, count) as *mut T } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | out-of-bounds pointer arithmetic: 0x1[noalloc] is a dangling pointer (it has no provenance) - | inside `ptr::mut_ptr::<impl *mut u8>::offset` at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: 0x1[noalloc] is a dangling pointer (it has no provenance) + | +note: inside `ptr::mut_ptr::<impl *mut u8>::offset` + --> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL | - ::: $DIR/offset_ub.rs:18:42 +LL | unsafe { intrinsics::offset(self, count) as *mut T } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `DANGLING` + --> $DIR/offset_ub.rs:18:42 | LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_ptr().offset(4) }; - | ------------------------------------------------- inside `DANGLING` at $DIR/offset_ub.rs:18:42 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::offset(self, count) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | out-of-bounds pointer arithmetic: null pointer is a dangling pointer (it has no provenance) - | inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: null pointer is a dangling pointer (it has no provenance) | - ::: $DIR/offset_ub.rs:21:50 +note: inside `ptr::const_ptr::<impl *const u8>::offset` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | +LL | unsafe { intrinsics::offset(self, count) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `NULL_OFFSET_ZERO` + --> $DIR/offset_ub.rs:21:50 | LL | pub const NULL_OFFSET_ZERO: *const u8 = unsafe { ptr::null::<u8>().offset(0) }; - | --------------------------- inside `NULL_OFFSET_ZERO` at $DIR/offset_ub.rs:21:50 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::offset(self, count) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | out-of-bounds pointer arithmetic: 0x7f..f[noalloc] is a dangling pointer (it has no provenance) - | inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: 0x7f..f[noalloc] is a dangling pointer (it has no provenance) | - ::: $DIR/offset_ub.rs:24:47 +note: inside `ptr::const_ptr::<impl *const u8>::offset` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | +LL | unsafe { intrinsics::offset(self, count) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `UNDERFLOW_ABS` + --> $DIR/offset_ub.rs:24:47 | LL | pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).offset(isize::MIN) }; - | -------------------------------------------- inside `UNDERFLOW_ABS` at $DIR/offset_ub.rs:24:47 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 12 previous errors diff --git a/src/test/ui/consts/promote-not.stderr b/src/test/ui/consts/promote-not.stderr index 0d0b0f9c6..b93358e8d 100644 --- a/src/test/ui/consts/promote-not.stderr +++ b/src/test/ui/consts/promote-not.stderr @@ -5,14 +5,14 @@ LL | static mut TEST1: Option<&mut [i32]> = Some(&mut [1, 2, 3]); | ----------^^^^^^^^^- | | | | | | | temporary value is freed at the end of this statement - | | creates a temporary which is freed while still in use + | | creates a temporary value which is freed while still in use | using this value as a static requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed --> $DIR/promote-not.rs:11:18 | LL | let x = &mut [1,2,3]; - | ^^^^^^^ creates a temporary which is freed while still in use + | ^^^^^^^ creates a temporary value which is freed while still in use LL | x | - using this value as a static requires that borrow lasts for `'static` LL | }; @@ -22,7 +22,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promote-not.rs:20:32 | LL | let _x: &'static () = &foo(); - | ----------- ^^^^^ creates a temporary which is freed while still in use + | ----------- ^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | } @@ -32,7 +32,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promote-not.rs:28:29 | LL | let _x: &'static i32 = &unsafe { U { x: 0 }.x }; - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | } @@ -42,7 +42,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promote-not.rs:33:29 | LL | let _x: &'static i32 = &unsafe { U { x: 0 }.x }; - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | }; @@ -52,7 +52,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promote-not.rs:39:29 | LL | let _val: &'static _ = &(Cell::new(1), 2).1; - | ---------- ^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ---------- ^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | }; @@ -62,7 +62,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promote-not.rs:46:29 | LL | let _val: &'static _ = &(Cell::new(1), 2).0; - | ---------- ^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ---------- ^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -73,7 +73,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promote-not.rs:47:29 | LL | let _val: &'static _ = &(Cell::new(1), 2).1; - | ---------- ^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ---------- ^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -84,7 +84,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promote-not.rs:50:29 | LL | let _val: &'static _ = &(1/0); - | ---------- ^^^^^ creates a temporary which is freed while still in use + | ---------- ^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -95,7 +95,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promote-not.rs:51:29 | LL | let _val: &'static _ = &(1/(1-1)); - | ---------- ^^^^^^^^^ creates a temporary which is freed while still in use + | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -106,7 +106,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promote-not.rs:52:29 | LL | let _val: &'static _ = &(1%0); - | ---------- ^^^^^ creates a temporary which is freed while still in use + | ---------- ^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -117,7 +117,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promote-not.rs:53:29 | LL | let _val: &'static _ = &(1%(1-1)); - | ---------- ^^^^^^^^^ creates a temporary which is freed while still in use + | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -128,7 +128,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promote-not.rs:54:29 | LL | let _val: &'static _ = &([1,2,3][4]+1); - | ---------- ^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ---------- ^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -139,7 +139,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promote-not.rs:57:29 | LL | let _val: &'static _ = &TEST_DROP; - | ---------- ^^^^^^^^^ creates a temporary which is freed while still in use + | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -150,7 +150,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promote-not.rs:59:29 | LL | let _val: &'static _ = &&TEST_DROP; - | ---------- ^^^^^^^^^^ creates a temporary which is freed while still in use + | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -161,7 +161,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promote-not.rs:59:30 | LL | let _val: &'static _ = &&TEST_DROP; - | ---------- ^^^^^^^^^ creates a temporary which is freed while still in use + | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -172,7 +172,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promote-not.rs:62:29 | LL | let _val: &'static _ = &(&TEST_DROP,); - | ---------- ^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -183,7 +183,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promote-not.rs:62:31 | LL | let _val: &'static _ = &(&TEST_DROP,); - | ---------- ^^^^^^^^^ creates a temporary which is freed while still in use + | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -194,7 +194,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promote-not.rs:65:29 | LL | let _val: &'static _ = &[&TEST_DROP; 1]; - | ---------- ^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ---------- ^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -207,7 +207,7 @@ error[E0716]: temporary value dropped while borrowed LL | let _val: &'static _ = &[&TEST_DROP; 1]; | ---------- ^^^^^^^^^ - temporary value is freed at the end of this statement | | | - | | creates a temporary which is freed while still in use + | | creates a temporary value which is freed while still in use | type annotation requires that borrow lasts for `'static` error: aborting due to 20 previous errors diff --git a/src/test/ui/consts/promote_const_let.stderr b/src/test/ui/consts/promote_const_let.stderr index c47d297c9..975a235a6 100644 --- a/src/test/ui/consts/promote_const_let.stderr +++ b/src/test/ui/consts/promote_const_let.stderr @@ -19,7 +19,7 @@ LL | let x: &'static u32 = &{ LL | | let y = 42; LL | | y LL | | }; - | |_____^ creates a temporary which is freed while still in use + | |_____^ creates a temporary value which is freed while still in use LL | } | - temporary value is freed at the end of this statement diff --git a/src/test/ui/consts/promoted-const-drop.stderr b/src/test/ui/consts/promoted-const-drop.stderr index 184ba0ea3..480283417 100644 --- a/src/test/ui/consts/promoted-const-drop.stderr +++ b/src/test/ui/consts/promoted-const-drop.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promoted-const-drop.rs:13:26 | LL | let _: &'static A = &A(); - | ---------- ^^^ creates a temporary which is freed while still in use + | ---------- ^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | let _: &'static [A] = &[C]; @@ -13,7 +13,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/promoted-const-drop.rs:14:28 | LL | let _: &'static [A] = &[C]; - | ------------ ^^^ creates a temporary which is freed while still in use + | ------------ ^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | } diff --git a/src/test/ui/consts/ptr_comparisons.stderr b/src/test/ui/consts/ptr_comparisons.stderr index b71964b92..274753ef1 100644 --- a/src/test/ui/consts/ptr_comparisons.stderr +++ b/src/test/ui/consts/ptr_comparisons.stderr @@ -2,15 +2,18 @@ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | LL | unsafe { intrinsics::offset(self, count) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | out-of-bounds pointer arithmetic: alloc3 has size $WORD, so pointer to $TWO_WORDS bytes starting at offset 0 is out-of-bounds - | inside `ptr::const_ptr::<impl *const usize>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: alloc3 has size $WORD, so pointer to $TWO_WORDS bytes starting at offset 0 is out-of-bounds + | +note: inside `ptr::const_ptr::<impl *const usize>::offset` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - ::: $DIR/ptr_comparisons.rs:50:34 +LL | unsafe { intrinsics::offset(self, count) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `_` + --> $DIR/ptr_comparisons.rs:50:34 | LL | const _: *const usize = unsafe { (FOO as *const usize).offset(2) }; - | ------------------------------- inside `_` at $DIR/ptr_comparisons.rs:50:34 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $DIR/ptr_comparisons.rs:53:33 diff --git a/src/test/ui/consts/qualif-union.stderr b/src/test/ui/consts/qualif-union.stderr index 8ec68ada0..d847cf88f 100644 --- a/src/test/ui/consts/qualif-union.stderr +++ b/src/test/ui/consts/qualif-union.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/qualif-union.rs:28:26 | LL | let _: &'static _ = &C1; - | ---------- ^^ creates a temporary which is freed while still in use + | ---------- ^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -13,7 +13,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/qualif-union.rs:29:26 | LL | let _: &'static _ = &C2; - | ---------- ^^ creates a temporary which is freed while still in use + | ---------- ^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -24,7 +24,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/qualif-union.rs:30:26 | LL | let _: &'static _ = &C3; - | ---------- ^^ creates a temporary which is freed while still in use + | ---------- ^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` ... @@ -35,7 +35,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/qualif-union.rs:31:26 | LL | let _: &'static _ = &C4; - | ---------- ^^ creates a temporary which is freed while still in use + | ---------- ^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | let _: &'static _ = &C5; @@ -46,7 +46,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/qualif-union.rs:32:26 | LL | let _: &'static _ = &C5; - | ---------- ^^ creates a temporary which is freed while still in use + | ---------- ^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | } diff --git a/src/test/ui/consts/recursive.stderr b/src/test/ui/consts/recursive.stderr index 14fa3da7a..60ce64d2a 100644 --- a/src/test/ui/consts/recursive.stderr +++ b/src/test/ui/consts/recursive.stderr @@ -13,14 +13,23 @@ error[E0080]: evaluation of constant value failed --> $DIR/recursive.rs:4:5 | LL | f(x); + | ^^^^ reached the configured maximum number of stack frames + | +note: inside `f::<i32>` + --> $DIR/recursive.rs:4:5 + | +LL | f(x); | ^^^^ - | | - | reached the configured maximum number of stack frames - | inside `f::<i32>` at $DIR/recursive.rs:4:5 - | [... 126 additional calls inside `f::<i32>` at $DIR/recursive.rs:4:5 ...] -... +note: [... 126 additional calls inside `f::<i32>` ...] + --> $DIR/recursive.rs:4:5 + | +LL | f(x); + | ^^^^ +note: inside `X` + --> $DIR/recursive.rs:8:15 + | LL | const X: () = f(1); - | ---- inside `X` at $DIR/recursive.rs:8:15 + | ^^^^ error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/consts/uninhabited-const-issue-61744.rs b/src/test/ui/consts/uninhabited-const-issue-61744.rs index a07c39882..ca6449cce 100644 --- a/src/test/ui/consts/uninhabited-const-issue-61744.rs +++ b/src/test/ui/consts/uninhabited-const-issue-61744.rs @@ -15,5 +15,5 @@ trait Const { impl<T> Const for T {} pub fn main() -> () { - dbg!(i32::CONSTANT); //~ ERROR erroneous constant used + dbg!(i32::CONSTANT); //~ constant } diff --git a/src/test/ui/consts/uninhabited-const-issue-61744.stderr b/src/test/ui/consts/uninhabited-const-issue-61744.stderr index 9c7cc8861..3a94e1931 100644 --- a/src/test/ui/consts/uninhabited-const-issue-61744.stderr +++ b/src/test/ui/consts/uninhabited-const-issue-61744.stderr @@ -2,150 +2,667 @@ error[E0080]: evaluation of `<i32 as Const>::CONSTANT` failed --> $DIR/uninhabited-const-issue-61744.rs:4:5 | LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ reached the configured maximum number of stack frames + | +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ - | | - | reached the configured maximum number of stack frames - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `fake_type::<i32>` at $DIR/uninhabited-const-issue-61744.rs:4:5 -... -LL | fake_type() - | ----------- - | | - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 -... +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<!>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `hint_unreachable` + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ +note: inside `fake_type::<i32>` + --> $DIR/uninhabited-const-issue-61744.rs:4:5 + | +LL | hint_unreachable() + | ^^^^^^^^^^^^^^^^^^ +note: inside `<i32 as Const>::CONSTANT` + --> $DIR/uninhabited-const-issue-61744.rs:12:36 + | LL | const CONSTANT: i32 = unsafe { fake_type() }; - | ----------- inside `<i32 as Const>::CONSTANT` at $DIR/uninhabited-const-issue-61744.rs:12:36 + | ^^^^^^^^^^^ + +note: erroneous constant used + --> $DIR/uninhabited-const-issue-61744.rs:18:10 + | +LL | dbg!(i32::CONSTANT); + | ^^^^^^^^^^^^^ + +note: erroneous constant used + --> $DIR/uninhabited-const-issue-61744.rs:18:10 + | +LL | dbg!(i32::CONSTANT); + | ^^^^^^^^^^^^^ -error[E0080]: erroneous constant used +note: erroneous constant used --> $DIR/uninhabited-const-issue-61744.rs:18:10 | LL | dbg!(i32::CONSTANT); - | ^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/deref-patterns/basic.rs b/src/test/ui/deref-patterns/basic.rs new file mode 100644 index 000000000..249716040 --- /dev/null +++ b/src/test/ui/deref-patterns/basic.rs @@ -0,0 +1,17 @@ +// run-pass +// check-run-results +#![feature(string_deref_patterns)] + +fn main() { + test(Some(String::from("42"))); + test(Some(String::new())); + test(None); +} + +fn test(o: Option<String>) { + match o { + Some("42") => println!("the answer"), + Some(_) => println!("something else?"), + None => println!("nil"), + } +} diff --git a/src/test/ui/deref-patterns/basic.run.stdout b/src/test/ui/deref-patterns/basic.run.stdout new file mode 100644 index 000000000..e50df0582 --- /dev/null +++ b/src/test/ui/deref-patterns/basic.run.stdout @@ -0,0 +1,3 @@ +the answer +something else? +nil diff --git a/src/test/ui/deref-patterns/default-infer.rs b/src/test/ui/deref-patterns/default-infer.rs new file mode 100644 index 000000000..050b84730 --- /dev/null +++ b/src/test/ui/deref-patterns/default-infer.rs @@ -0,0 +1,9 @@ +// check-pass +#![feature(string_deref_patterns)] + +fn main() { + match <_ as Default>::default() { + "" => (), + _ => unreachable!(), + } +} diff --git a/src/test/ui/deref-patterns/gate.rs b/src/test/ui/deref-patterns/gate.rs new file mode 100644 index 000000000..ff50e30de --- /dev/null +++ b/src/test/ui/deref-patterns/gate.rs @@ -0,0 +1,7 @@ +// gate-test-string_deref_patterns +fn main() { + match String::new() { + "" | _ => {} + //~^ mismatched types + } +} diff --git a/src/test/ui/deref-patterns/gate.stderr b/src/test/ui/deref-patterns/gate.stderr new file mode 100644 index 000000000..993468b5e --- /dev/null +++ b/src/test/ui/deref-patterns/gate.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/gate.rs:4:9 + | +LL | match String::new() { + | ------------- this expression has type `String` +LL | "" | _ => {} + | ^^ expected struct `String`, found `&str` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/deref-patterns/refs.rs b/src/test/ui/deref-patterns/refs.rs new file mode 100644 index 000000000..97e260d27 --- /dev/null +++ b/src/test/ui/deref-patterns/refs.rs @@ -0,0 +1,18 @@ +// check-pass +#![feature(string_deref_patterns)] + +fn foo(s: &String) -> i32 { + match *s { + "a" => 42, + _ => -1, + } +} + +fn bar(s: Option<&&&&String>) -> i32 { + match s { + Some(&&&&"&&&&") => 1, + _ => -1, + } +} + +fn main() {} diff --git a/src/test/ui/derived-errors/issue-31997-1.stderr b/src/test/ui/derived-errors/issue-31997-1.stderr index 6d177666e..2f4aabf84 100644 --- a/src/test/ui/derived-errors/issue-31997-1.stderr +++ b/src/test/ui/derived-errors/issue-31997-1.stderr @@ -2,7 +2,7 @@ error[E0433]: failed to resolve: use of undeclared type `HashMap` --> $DIR/issue-31997-1.rs:20:19 | LL | let mut map = HashMap::new(); - | ^^^^^^^ not found in this scope + | ^^^^^^^ use of undeclared type `HashMap` | help: consider importing this struct | diff --git a/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.rs b/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.rs index 15d068175..6ab1fb7b0 100644 --- a/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.rs +++ b/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.rs @@ -3,7 +3,7 @@ #[derive(Debug)] pub struct Whatever { pub field0: (), - field1: (), //~ ERROR fields `field1`, `field2`, `field3` and `field4` are never read + field1: (), //~ ERROR fields `field1`, `field2`, `field3`, and `field4` are never read field2: (), field3: (), field4: (), diff --git a/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.stderr b/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.stderr index 512b870fa..7f4f78ceb 100644 --- a/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.stderr +++ b/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.stderr @@ -1,4 +1,4 @@ -error: fields `field1`, `field2`, `field3` and `field4` are never read +error: fields `field1`, `field2`, `field3`, and `field4` are never read --> $DIR/clone-debug-dead-code-in-the-same-struct.rs:6:5 | LL | pub struct Whatever { diff --git a/src/test/ui/deriving/deriving-all-codegen.stdout b/src/test/ui/deriving/deriving-all-codegen.stdout index 92fce6888..a63cbd4ca 100644 --- a/src/test/ui/deriving/deriving-all-codegen.stdout +++ b/src/test/ui/deriving/deriving-all-codegen.stdout @@ -463,16 +463,14 @@ struct PackedNonCopy(u8); impl ::core::clone::Clone for PackedNonCopy { #[inline] fn clone(&self) -> PackedNonCopy { - let Self(ref __self_0_0) = *self; - PackedNonCopy(::core::clone::Clone::clone(__self_0_0)) + PackedNonCopy(::core::clone::Clone::clone(&self.0)) } } #[automatically_derived] impl ::core::fmt::Debug for PackedNonCopy { fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - let Self(ref __self_0_0) = *self; ::core::fmt::Formatter::debug_tuple_field1_finish(f, "PackedNonCopy", - &__self_0_0) + &&self.0) } } #[automatically_derived] @@ -485,8 +483,7 @@ impl ::core::default::Default for PackedNonCopy { #[automatically_derived] impl ::core::hash::Hash for PackedNonCopy { fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { - let Self(ref __self_0_0) = *self; - ::core::hash::Hash::hash(__self_0_0, state) + ::core::hash::Hash::hash(&self.0, state) } } #[automatically_derived] @@ -494,11 +491,7 @@ impl ::core::marker::StructuralPartialEq for PackedNonCopy { } #[automatically_derived] impl ::core::cmp::PartialEq for PackedNonCopy { #[inline] - fn eq(&self, other: &PackedNonCopy) -> bool { - let Self(ref __self_0_0) = *self; - let Self(ref __self_1_0) = *other; - *__self_0_0 == *__self_1_0 - } + fn eq(&self, other: &PackedNonCopy) -> bool { self.0 == other.0 } } #[automatically_derived] impl ::core::marker::StructuralEq for PackedNonCopy { } @@ -516,18 +509,14 @@ impl ::core::cmp::PartialOrd for PackedNonCopy { #[inline] fn partial_cmp(&self, other: &PackedNonCopy) -> ::core::option::Option<::core::cmp::Ordering> { - let Self(ref __self_0_0) = *self; - let Self(ref __self_1_0) = *other; - ::core::cmp::PartialOrd::partial_cmp(__self_0_0, __self_1_0) + ::core::cmp::PartialOrd::partial_cmp(&self.0, &other.0) } } #[automatically_derived] impl ::core::cmp::Ord for PackedNonCopy { #[inline] fn cmp(&self, other: &PackedNonCopy) -> ::core::cmp::Ordering { - let Self(ref __self_0_0) = *self; - let Self(ref __self_1_0) = *other; - ::core::cmp::Ord::cmp(__self_0_0, __self_1_0) + ::core::cmp::Ord::cmp(&self.0, &other.0) } } diff --git a/src/test/ui/deriving/issue-105101.rs b/src/test/ui/deriving/issue-105101.rs new file mode 100644 index 000000000..1a377feb9 --- /dev/null +++ b/src/test/ui/deriving/issue-105101.rs @@ -0,0 +1,9 @@ +// compile-flags: --crate-type=lib + +#[derive(Default)] //~ ERROR multiple declared defaults +enum E { + #[default] + A, + #[default] + A, //~ ERROR defined multiple times +} diff --git a/src/test/ui/deriving/issue-105101.stderr b/src/test/ui/deriving/issue-105101.stderr new file mode 100644 index 000000000..0f6f67043 --- /dev/null +++ b/src/test/ui/deriving/issue-105101.stderr @@ -0,0 +1,29 @@ +error: multiple declared defaults + --> $DIR/issue-105101.rs:3:10 + | +LL | #[derive(Default)] + | ^^^^^^^ +... +LL | A, + | - first default +LL | #[default] +LL | A, + | - additional default + | + = note: only one variant can be default + = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0428]: the name `A` is defined multiple times + --> $DIR/issue-105101.rs:8:5 + | +LL | A, + | - previous definition of the type `A` here +LL | #[default] +LL | A, + | ^ `A` redefined here + | + = note: `A` must be defined only once in the type namespace of this enum + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0428`. diff --git a/src/test/ui/diagnostic-width/long-E0308.rs b/src/test/ui/diagnostic-width/long-E0308.rs new file mode 100644 index 000000000..3fd7a7110 --- /dev/null +++ b/src/test/ui/diagnostic-width/long-E0308.rs @@ -0,0 +1,86 @@ +// compile-flags: --diagnostic-width=60 +// normalize-stderr-test: "long-type-\d+" -> "long-type-hash" + +struct Atype<T, K>(T, K); +struct Btype<T, K>(T, K); +struct Ctype<T, K>(T, K); + +fn main() { + let x: Atype< + Btype< + Ctype< + Atype< + Btype< + Ctype< + Atype< + Btype< + Ctype<i32, i32>, + i32 + >, + i32 + >, + i32 + >, + i32 + >, + i32 + >, + i32 + >, + i32 + >, + i32 + > = Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok( + Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok( + Ok("") + )))))))))))))))))))))))))))))) + )))))))))))))))))))))))))))))); + //~^^^^^ ERROR E0308 + + let _ = Some(Ok(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some( + Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some( + Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some( + Some(Some(Some(Some(Some(Some(Some(Some(Some(""))))))))) + ))))))))))))))))) + )))))))))))))))))) + ))))))))))))))))) == Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok( + Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok( + Ok(Ok(Ok(Ok(Ok(Ok(Ok(""))))))) + )))))))))))))))))))))))))))))) + )))))))))))))))))))))))); + //~^^^^^ ERROR E0308 + + let x: Atype< + Btype< + Ctype< + Atype< + Btype< + Ctype< + Atype< + Btype< + Ctype<i32, i32>, + i32 + >, + i32 + >, + i32 + >, + i32 + >, + i32 + >, + i32 + >, + i32 + >, + i32 + > = (); + //~^ ERROR E0308 + + let _: () = Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok( + Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok( + Ok(Ok(Ok(Ok(Ok(Ok(Ok(""))))))) + )))))))))))))))))))))))))))))) + )))))))))))))))))))))))); + //~^^^^^ ERROR E0308 +} diff --git a/src/test/ui/diagnostic-width/long-E0308.stderr b/src/test/ui/diagnostic-width/long-E0308.stderr new file mode 100644 index 000000000..487ab23a1 --- /dev/null +++ b/src/test/ui/diagnostic-width/long-E0308.stderr @@ -0,0 +1,80 @@ +error[E0308]: mismatched types + --> $DIR/long-E0308.rs:33:9 + | +LL | let x: Atype< + | _____________- +LL | | Btype< +LL | | Ctype< +LL | | Atype< +... | +LL | | i32 +LL | | > = Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok... + | | _____-___^ + | ||_____| + | | expected due to this +LL | | Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok... +LL | | Ok("") +LL | | )))))))))))))))))))))))))))))) +LL | | )))))))))))))))))))))))))))))); + | |__________________________________^ expected struct `Atype`, found enum `Result` + | + = note: expected struct `Atype<Btype<..., ...>, ...>` + the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt' + found enum `Result<Result<..., ...>, ...>` + the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt' + +error[E0308]: mismatched types + --> $DIR/long-E0308.rs:46:26 + | +LL | ))))))))))))))))) == Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(O... + | __________________________^ +LL | | Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(... +LL | | Ok(Ok(Ok(Ok(Ok(Ok(Ok(""))))))) +LL | | )))))))))))))))))))))))))))))) +LL | | )))))))))))))))))))))))); + | |____________________________^ expected enum `Option`, found enum `Result` + | + = note: expected enum `Option<Result<..., ...>>` + the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt' + found enum `Result<Result<..., ...>, ...>` + the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt' + +error[E0308]: mismatched types + --> $DIR/long-E0308.rs:77:9 + | +LL | let x: Atype< + | ____________- +LL | | Btype< +LL | | Ctype< +LL | | Atype< +... | +LL | | i32 +LL | | > = (); + | | - ^^ expected struct `Atype`, found `()` + | |_____| + | expected due to this + | + = note: expected struct `Atype<Btype<..., ...>, ...>` + the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt' + found unit type `()` + +error[E0308]: mismatched types + --> $DIR/long-E0308.rs:80:17 + | +LL | let _: () = Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(O... + | ____________--___^ + | | | + | | expected due to this +LL | | Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(... +LL | | Ok(Ok(Ok(Ok(Ok(Ok(Ok(""))))))) +LL | | )))))))))))))))))))))))))))))) +LL | | )))))))))))))))))))))))); + | |____________________________^ expected `()`, found enum `Result` + | + = note: expected unit type `()` + found enum `Result<Result<..., ...>, ...>` + the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt' + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/did_you_mean/issue-103909.rs b/src/test/ui/did_you_mean/issue-103909.rs new file mode 100644 index 000000000..20b67cd10 --- /dev/null +++ b/src/test/ui/did_you_mean/issue-103909.rs @@ -0,0 +1,9 @@ +#![allow(unused_variables)] +use std::fs::File; + +fn main() { + if Err(err) = File::open("hello.txt") { + //~^ ERROR: cannot find value `err` in this scope + //~| ERROR: mismatched types + } +} diff --git a/src/test/ui/did_you_mean/issue-103909.stderr b/src/test/ui/did_you_mean/issue-103909.stderr new file mode 100644 index 000000000..864101747 --- /dev/null +++ b/src/test/ui/did_you_mean/issue-103909.stderr @@ -0,0 +1,26 @@ +error[E0425]: cannot find value `err` in this scope + --> $DIR/issue-103909.rs:5:12 + | +LL | if Err(err) = File::open("hello.txt") { + | ^^^ not found in this scope + | +help: you might have meant to use pattern matching + | +LL | if let Err(err) = File::open("hello.txt") { + | +++ + +error[E0308]: mismatched types + --> $DIR/issue-103909.rs:5:8 + | +LL | if Err(err) = File::open("hello.txt") { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()` + | +help: consider adding `let` + | +LL | if let Err(err) = File::open("hello.txt") { + | +++ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0308, E0425. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr b/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr index d27b05fe7..7229b9ac9 100644 --- a/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr +++ b/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr @@ -12,10 +12,6 @@ LL | Foo::<i32>::bar(&1i8); <i8 as Foo<u32>> <i8 as Foo<u64>> <i8 as Foo<u8>> - <u8 as Foo<bool>> - <u8 as Foo<u16>> - <u8 as Foo<u32>> - <u8 as Foo<u64>> error[E0277]: the trait bound `u8: Foo<i32>` is not satisfied --> $DIR/issue-39802-show-5-trait-impls.rs:25:21 @@ -26,11 +22,6 @@ LL | Foo::<i32>::bar(&1u8); | required by a bound introduced by this call | = help: the following other types implement trait `Foo<B>`: - <i8 as Foo<bool>> - <i8 as Foo<u16>> - <i8 as Foo<u32>> - <i8 as Foo<u64>> - <i8 as Foo<u8>> <u8 as Foo<bool>> <u8 as Foo<u16>> <u8 as Foo<u32>> diff --git a/src/test/ui/drop/drop_order.rs b/src/test/ui/drop/drop_order.rs index 42385216a..5ce1fd54a 100644 --- a/src/test/ui/drop/drop_order.rs +++ b/src/test/ui/drop/drop_order.rs @@ -43,7 +43,7 @@ impl DropOrderCollector { } if { - if self.option_loud_drop(7).is_some() && self.option_loud_drop(6).is_some() { + if self.option_loud_drop(6).is_some() && self.option_loud_drop(7).is_some() { self.loud_drop(8); true } else { @@ -118,17 +118,85 @@ impl DropOrderCollector { } } + fn and_chain(&self) { + // issue-103107 + if self.option_loud_drop(1).is_some() // 1 + && self.option_loud_drop(2).is_some() // 2 + && self.option_loud_drop(3).is_some() // 3 + && self.option_loud_drop(4).is_some() // 4 + && self.option_loud_drop(5).is_some() // 5 + { + self.print(6); // 6 + } + + let _ = self.option_loud_drop(7).is_some() // 1 + && self.option_loud_drop(8).is_some() // 2 + && self.option_loud_drop(9).is_some(); // 3 + self.print(10); // 4 + + // Test associativity + if self.option_loud_drop(11).is_some() // 1 + && (self.option_loud_drop(12).is_some() // 2 + && self.option_loud_drop(13).is_some() // 3 + && self.option_loud_drop(14).is_some()) // 4 + && self.option_loud_drop(15).is_some() // 5 + { + self.print(16); // 6 + } + } + + fn or_chain(&self) { + // issue-103107 + if self.option_loud_drop(1).is_none() // 1 + || self.option_loud_drop(2).is_none() // 2 + || self.option_loud_drop(3).is_none() // 3 + || self.option_loud_drop(4).is_none() // 4 + || self.option_loud_drop(5).is_some() // 5 + { + self.print(6); // 6 + } + + let _ = self.option_loud_drop(7).is_none() // 1 + || self.option_loud_drop(8).is_none() // 2 + || self.option_loud_drop(9).is_none(); // 3 + self.print(10); // 4 + + // Test associativity + if self.option_loud_drop(11).is_none() // 1 + || (self.option_loud_drop(12).is_none() // 2 + || self.option_loud_drop(13).is_none() // 3 + || self.option_loud_drop(14).is_none()) // 4 + || self.option_loud_drop(15).is_some() // 5 + { + self.print(16); // 6 + } + } + + fn mixed_and_or_chain(&self) { + // issue-103107 + if self.option_loud_drop(1).is_none() // 1 + || self.option_loud_drop(2).is_none() // 2 + || self.option_loud_drop(3).is_some() // 3 + && self.option_loud_drop(4).is_some() // 4 + && self.option_loud_drop(5).is_none() // 5 + || self.option_loud_drop(6).is_none() // 6 + || self.option_loud_drop(7).is_some() // 7 + { + self.print(8); // 8 + } + } + fn let_chain(&self) { // take the "then" branch - if self.option_loud_drop(2).is_some() // 2 - && self.option_loud_drop(1).is_some() // 1 + if self.option_loud_drop(1).is_some() // 1 + && self.option_loud_drop(2).is_some() // 2 && let Some(_d) = self.option_loud_drop(4) { // 4 self.print(3); // 3 } // take the "else" branch - if self.option_loud_drop(6).is_some() // 2 - && self.option_loud_drop(5).is_some() // 1 + if self.option_loud_drop(5).is_some() // 1 + && self.option_loud_drop(6).is_some() // 2 && let None = self.option_loud_drop(8) { // 4 unreachable!(); } else { @@ -152,8 +220,8 @@ impl DropOrderCollector { } // let exprs last - if self.option_loud_drop(20).is_some() // 2 - && self.option_loud_drop(19).is_some() // 1 + if self.option_loud_drop(19).is_some() // 1 + && self.option_loud_drop(20).is_some() // 2 && let Some(_d) = self.option_loud_drop(23) // 5 && let Some(_e) = self.option_loud_drop(22) { // 4 self.print(21); // 3 @@ -187,6 +255,21 @@ fn main() { collector.if_(); collector.assert_sorted(); + println!("-- and chain --"); + let collector = DropOrderCollector::default(); + collector.and_chain(); + collector.assert_sorted(); + + println!("-- or chain --"); + let collector = DropOrderCollector::default(); + collector.or_chain(); + collector.assert_sorted(); + + println!("-- mixed and/or chain --"); + let collector = DropOrderCollector::default(); + collector.mixed_and_or_chain(); + collector.assert_sorted(); + println!("-- if let --"); let collector = DropOrderCollector::default(); collector.if_let(); diff --git a/src/test/ui/drop/issue-103107.rs b/src/test/ui/drop/issue-103107.rs new file mode 100644 index 000000000..5f4475956 --- /dev/null +++ b/src/test/ui/drop/issue-103107.rs @@ -0,0 +1,37 @@ +// check-pass +// compile-flags: -Z validate-mir + +struct Foo<'a>(&'a mut u32); + +impl<'a> Drop for Foo<'a> { + fn drop(&mut self) { + *self.0 = 0; + } +} + +fn and() { + let mut foo = 0; + // This used to compile also before the fix + if true && *Foo(&mut foo).0 == 0 && ({ foo = 0; true}) {} + + // This used to fail before the fix + if *Foo(&mut foo).0 == 0 && ({ foo = 0; true}) {} + + println!("{foo}"); +} + +fn or() { + let mut foo = 0; + // This used to compile also before the fix + if false || *Foo(&mut foo).0 == 1 || ({ foo = 0; true}) {} + + // This used to fail before the fix + if *Foo(&mut foo).0 == 1 || ({ foo = 0; true}) {} + + println!("{foo}"); +} + +fn main() { + and(); + or(); +} diff --git a/src/test/ui/drop/repeat-drop-2.stderr b/src/test/ui/drop/repeat-drop-2.stderr index 7357551c4..f030228f7 100644 --- a/src/test/ui/drop/repeat-drop-2.stderr +++ b/src/test/ui/drop/repeat-drop-2.stderr @@ -7,6 +7,11 @@ LL | let _bar = foo; | --- value moved here LL | let _baz = [foo; 0]; | ^^^ value used here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | let _bar = foo.clone(); + | ++++++++ error[E0493]: destructor of `String` cannot be evaluated at compile-time --> $DIR/repeat-drop-2.rs:7:25 diff --git a/src/test/ui/issues/issue-54943-1.rs b/src/test/ui/dropck/issue-54943-1.rs index ec682d960..ec682d960 100644 --- a/src/test/ui/issues/issue-54943-1.rs +++ b/src/test/ui/dropck/issue-54943-1.rs diff --git a/src/test/ui/issues/issue-54943-2.rs b/src/test/ui/dropck/issue-54943-2.rs index d400ae58d..d400ae58d 100644 --- a/src/test/ui/issues/issue-54943-2.rs +++ b/src/test/ui/dropck/issue-54943-2.rs diff --git a/src/test/ui/duplicate/duplicate-type-parameter.stderr b/src/test/ui/duplicate/duplicate-type-parameter.stderr index 6754574f0..628f898d5 100644 --- a/src/test/ui/duplicate/duplicate-type-parameter.stderr +++ b/src/test/ui/duplicate/duplicate-type-parameter.stderr @@ -55,10 +55,10 @@ LL | impl<T,T> Qux<T,T> for Option<T> {} | first use of `T` error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates - --> $DIR/duplicate-type-parameter.rs:24:6 + --> $DIR/duplicate-type-parameter.rs:24:8 | LL | impl<T,T> Qux<T,T> for Option<T> {} - | ^ unconstrained type parameter + | ^ unconstrained type parameter error: aborting due to 8 previous errors diff --git a/src/test/ui/dyn-star/align.normal.stderr b/src/test/ui/dyn-star/align.normal.stderr new file mode 100644 index 000000000..983d7bf6e --- /dev/null +++ b/src/test/ui/dyn-star/align.normal.stderr @@ -0,0 +1,11 @@ +warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/align.rs:4:12 + | +LL | #![feature(dyn_star)] + | ^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/src/test/ui/dyn-star/align.over_aligned.stderr b/src/test/ui/dyn-star/align.over_aligned.stderr new file mode 100644 index 000000000..6b6fc55d8 --- /dev/null +++ b/src/test/ui/dyn-star/align.over_aligned.stderr @@ -0,0 +1,20 @@ +warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/align.rs:4:12 + | +LL | #![feature(dyn_star)] + | ^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0277]: `AlignedUsize` needs to be a pointer-sized type + --> $DIR/align.rs:15:13 + | +LL | let x = AlignedUsize(12) as dyn* Debug; + | ^^^^^^^^^^^^^^^^ `AlignedUsize` needs to be a pointer-sized type + | + = help: the trait `PointerSized` is not implemented for `AlignedUsize` + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/dyn-star/align.rs b/src/test/ui/dyn-star/align.rs new file mode 100644 index 000000000..fb41a05a0 --- /dev/null +++ b/src/test/ui/dyn-star/align.rs @@ -0,0 +1,17 @@ +// revisions: normal over_aligned +//[normal] check-pass + +#![feature(dyn_star)] +//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + +use std::fmt::Debug; + +#[cfg_attr(over_aligned, repr(C, align(1024)))] +#[cfg_attr(not(over_aligned), repr(C))] +#[derive(Debug)] +struct AlignedUsize(usize); + +fn main() { + let x = AlignedUsize(12) as dyn* Debug; + //[over_aligned]~^ ERROR `AlignedUsize` needs to be a pointer-sized type +} diff --git a/src/test/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs b/src/test/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs new file mode 100644 index 000000000..e19e36cc7 --- /dev/null +++ b/src/test/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs @@ -0,0 +1,15 @@ +#![feature(dyn_star)] +#![allow(incomplete_features)] + +use std::fmt::Debug; + +fn dyn_debug(_: (dyn* Debug + '_)) { + +} + +fn polymorphic<T: Debug + ?Sized>(t: &T) { + dyn_debug(t); + //~^ ERROR `&T` needs to be a pointer-sized type +} + +fn main() {} diff --git a/src/test/ui/dyn-star/check-size-at-cast-polymorphic-bad.stderr b/src/test/ui/dyn-star/check-size-at-cast-polymorphic-bad.stderr new file mode 100644 index 000000000..53ccbe43d --- /dev/null +++ b/src/test/ui/dyn-star/check-size-at-cast-polymorphic-bad.stderr @@ -0,0 +1,15 @@ +error[E0277]: `&T` needs to be a pointer-sized type + --> $DIR/check-size-at-cast-polymorphic-bad.rs:11:15 + | +LL | dyn_debug(t); + | ^ `&T` needs to be a pointer-sized type + | + = help: the trait `PointerSized` is not implemented for `&T` +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | fn polymorphic<T: Debug + ?Sized>(t: &T) where &T: PointerSized { + | ++++++++++++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/dyn-star/check-size-at-cast-polymorphic.rs b/src/test/ui/dyn-star/check-size-at-cast-polymorphic.rs new file mode 100644 index 000000000..5c0a3d256 --- /dev/null +++ b/src/test/ui/dyn-star/check-size-at-cast-polymorphic.rs @@ -0,0 +1,16 @@ +// check-pass + +#![feature(dyn_star)] +#![allow(incomplete_features)] + +use std::fmt::Debug; + +fn dyn_debug(_: (dyn* Debug + '_)) { + +} + +fn polymorphic<T: Debug>(t: &T) { + dyn_debug(t); +} + +fn main() {} diff --git a/src/test/ui/dyn-star/check-size-at-cast.rs b/src/test/ui/dyn-star/check-size-at-cast.rs new file mode 100644 index 000000000..1f22f7983 --- /dev/null +++ b/src/test/ui/dyn-star/check-size-at-cast.rs @@ -0,0 +1,10 @@ +#![feature(dyn_star)] +#![allow(incomplete_features)] + +use std::fmt::Debug; + +fn main() { + let i = [1, 2, 3, 4] as dyn* Debug; + //~^ ERROR `[i32; 4]` needs to be a pointer-sized type + dbg!(i); +} diff --git a/src/test/ui/dyn-star/check-size-at-cast.stderr b/src/test/ui/dyn-star/check-size-at-cast.stderr new file mode 100644 index 000000000..af2a1ccf7 --- /dev/null +++ b/src/test/ui/dyn-star/check-size-at-cast.stderr @@ -0,0 +1,11 @@ +error[E0277]: `[i32; 4]` needs to be a pointer-sized type + --> $DIR/check-size-at-cast.rs:7:13 + | +LL | let i = [1, 2, 3, 4] as dyn* Debug; + | ^^^^^^^^^^^^ `[i32; 4]` needs to be a pointer-sized type + | + = help: the trait `PointerSized` is not implemented for `[i32; 4]` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/dyn-star/dispatch-on-pin-mut.rs b/src/test/ui/dyn-star/dispatch-on-pin-mut.rs new file mode 100644 index 000000000..5774c8b2a --- /dev/null +++ b/src/test/ui/dyn-star/dispatch-on-pin-mut.rs @@ -0,0 +1,52 @@ +// run-pass +// edition:2021 +// check-run-results + +#![feature(dyn_star)] +//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + +use std::future::Future; + +async fn foo(f: dyn* Future<Output = i32>) { + println!("value: {}", f.await); +} + +async fn async_main() { + foo(Box::pin(async { 1 })).await +} + +// ------------------------------------------------------------------------- // +// Implementation Details Below... + +use std::pin::Pin; +use std::task::*; + +pub fn noop_waker() -> Waker { + let raw = RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE); + + // SAFETY: the contracts for RawWaker and RawWakerVTable are upheld + unsafe { Waker::from_raw(raw) } +} + +const NOOP_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(noop_clone, noop, noop, noop); + +unsafe fn noop_clone(_p: *const ()) -> RawWaker { + RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE) +} + +unsafe fn noop(_p: *const ()) {} + +fn main() { + let mut fut = async_main(); + + // Poll loop, just to test the future... + let waker = noop_waker(); + let ctx = &mut Context::from_waker(&waker); + + loop { + match unsafe { Pin::new_unchecked(&mut fut).poll(ctx) } { + Poll::Pending => {} + Poll::Ready(()) => break, + } + } +} diff --git a/src/test/ui/dyn-star/dispatch-on-pin-mut.run.stdout b/src/test/ui/dyn-star/dispatch-on-pin-mut.run.stdout new file mode 100644 index 000000000..96c5ca698 --- /dev/null +++ b/src/test/ui/dyn-star/dispatch-on-pin-mut.run.stdout @@ -0,0 +1 @@ +value: 1 diff --git a/src/test/ui/dyn-star/dispatch-on-pin-mut.stderr b/src/test/ui/dyn-star/dispatch-on-pin-mut.stderr new file mode 100644 index 000000000..fdf74aa7e --- /dev/null +++ b/src/test/ui/dyn-star/dispatch-on-pin-mut.stderr @@ -0,0 +1,11 @@ +warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/dispatch-on-pin-mut.rs:5:12 + | +LL | #![feature(dyn_star)] + | ^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/src/test/ui/dyn-star/dont-unsize-coerce-dyn-star.rs b/src/test/ui/dyn-star/dont-unsize-coerce-dyn-star.rs new file mode 100644 index 000000000..c12b16f16 --- /dev/null +++ b/src/test/ui/dyn-star/dont-unsize-coerce-dyn-star.rs @@ -0,0 +1,27 @@ +// run-pass +// check-run-results + +#![feature(dyn_star)] +//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + +trait AddOne { + fn add1(&mut self) -> usize; +} + +impl AddOne for usize { + fn add1(&mut self) -> usize { + *self += 1; + *self + } +} + +fn add_one(i: &mut (dyn* AddOne + '_)) -> usize { + i.add1() +} + +fn main() { + let mut x = 42usize as dyn* AddOne; + + println!("{}", add_one(&mut x)); + println!("{}", add_one(&mut x)); +} diff --git a/src/test/ui/dyn-star/dont-unsize-coerce-dyn-star.run.stdout b/src/test/ui/dyn-star/dont-unsize-coerce-dyn-star.run.stdout new file mode 100644 index 000000000..b4db3ed70 --- /dev/null +++ b/src/test/ui/dyn-star/dont-unsize-coerce-dyn-star.run.stdout @@ -0,0 +1,2 @@ +43 +44 diff --git a/src/test/ui/dyn-star/dont-unsize-coerce-dyn-star.stderr b/src/test/ui/dyn-star/dont-unsize-coerce-dyn-star.stderr new file mode 100644 index 000000000..933c13383 --- /dev/null +++ b/src/test/ui/dyn-star/dont-unsize-coerce-dyn-star.stderr @@ -0,0 +1,11 @@ +warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/dont-unsize-coerce-dyn-star.rs:4:12 + | +LL | #![feature(dyn_star)] + | ^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/src/test/ui/dyn-star/dyn-async-trait.rs b/src/test/ui/dyn-star/dyn-async-trait.rs new file mode 100644 index 000000000..9b27133b4 --- /dev/null +++ b/src/test/ui/dyn-star/dyn-async-trait.rs @@ -0,0 +1,36 @@ +// check-pass +// edition: 2021 + +// This test case is meant to demonstrate how close we can get to async +// functions in dyn traits with the current level of dyn* support. + +#![feature(dyn_star)] +#![allow(incomplete_features)] + +use std::future::Future; + +trait DynAsyncCounter { + fn increment<'a>(&'a mut self) -> dyn* Future<Output = usize> + 'a; +} + +struct MyCounter { + count: usize, +} + +impl DynAsyncCounter for MyCounter { + fn increment<'a>(&'a mut self) -> dyn* Future<Output = usize> + 'a { + Box::pin(async { + self.count += 1; + self.count + }) + } +} + +async fn do_counter(counter: &mut dyn DynAsyncCounter) -> usize { + counter.increment().await +} + +fn main() { + let mut counter = MyCounter { count: 0 }; + let _ = do_counter(&mut counter); +} diff --git a/src/test/ui/dyn-star/issue-102430.rs b/src/test/ui/dyn-star/issue-102430.rs new file mode 100644 index 000000000..244ecda66 --- /dev/null +++ b/src/test/ui/dyn-star/issue-102430.rs @@ -0,0 +1,32 @@ +// check-pass + +#![feature(dyn_star)] +#![allow(incomplete_features)] + +trait AddOne { + fn add1(&mut self) -> usize; +} + +impl AddOne for usize { + fn add1(&mut self) -> usize { + *self += 1; + *self + } +} + +impl AddOne for &mut usize { + fn add1(&mut self) -> usize { + (*self).add1() + } +} + +fn add_one(mut i: dyn* AddOne + '_) -> usize { + i.add1() +} + +fn main() { + let mut x = 42usize; + let y = &mut x as (dyn* AddOne + '_); + + println!("{}", add_one(y)); +} diff --git a/src/test/ui/dyn-star/no-unsize-coerce-dyn-trait.rs b/src/test/ui/dyn-star/no-unsize-coerce-dyn-trait.rs new file mode 100644 index 000000000..a4eb669e3 --- /dev/null +++ b/src/test/ui/dyn-star/no-unsize-coerce-dyn-trait.rs @@ -0,0 +1,13 @@ +#![feature(dyn_star, trait_upcasting)] +//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + +trait A: B {} +trait B {} +impl A for usize {} +impl B for usize {} + +fn main() { + let x: Box<dyn* A> = Box::new(1usize as dyn* A); + let y: Box<dyn* B> = x; + //~^ ERROR mismatched types +} diff --git a/src/test/ui/dyn-star/no-unsize-coerce-dyn-trait.stderr b/src/test/ui/dyn-star/no-unsize-coerce-dyn-trait.stderr new file mode 100644 index 000000000..2fc751b3b --- /dev/null +++ b/src/test/ui/dyn-star/no-unsize-coerce-dyn-trait.stderr @@ -0,0 +1,23 @@ +warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/no-unsize-coerce-dyn-trait.rs:1:12 + | +LL | #![feature(dyn_star, trait_upcasting)] + | ^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0308]: mismatched types + --> $DIR/no-unsize-coerce-dyn-trait.rs:11:26 + | +LL | let y: Box<dyn* B> = x; + | ----------- ^ expected trait `B`, found trait `A` + | | + | expected due to this + | + = note: expected struct `Box<dyn* B>` + found struct `Box<dyn* A>` + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/dyn-star/return.rs b/src/test/ui/dyn-star/return.rs new file mode 100644 index 000000000..fa3d8d7d5 --- /dev/null +++ b/src/test/ui/dyn-star/return.rs @@ -0,0 +1,10 @@ +// check-pass + +#![feature(dyn_star)] +//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + +fn _foo() -> dyn* Unpin { + 4usize +} + +fn main() {} diff --git a/src/test/ui/dyn-star/return.stderr b/src/test/ui/dyn-star/return.stderr new file mode 100644 index 000000000..e000351a6 --- /dev/null +++ b/src/test/ui/dyn-star/return.stderr @@ -0,0 +1,11 @@ +warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/return.rs:3:12 + | +LL | #![feature(dyn_star)] + | ^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/src/test/ui/dyn-star/unsize-into-ref-dyn-star.rs b/src/test/ui/dyn-star/unsize-into-ref-dyn-star.rs new file mode 100644 index 000000000..1e8cafe15 --- /dev/null +++ b/src/test/ui/dyn-star/unsize-into-ref-dyn-star.rs @@ -0,0 +1,9 @@ +#![feature(dyn_star)] +#![allow(incomplete_features)] + +use std::fmt::Debug; + +fn main() { + let i = 42 as &dyn* Debug; + //~^ ERROR non-primitive cast: `i32` as `&dyn* Debug` +} diff --git a/src/test/ui/dyn-star/unsize-into-ref-dyn-star.stderr b/src/test/ui/dyn-star/unsize-into-ref-dyn-star.stderr new file mode 100644 index 000000000..f6444a60a --- /dev/null +++ b/src/test/ui/dyn-star/unsize-into-ref-dyn-star.stderr @@ -0,0 +1,9 @@ +error[E0605]: non-primitive cast: `i32` as `&dyn* Debug` + --> $DIR/unsize-into-ref-dyn-star.rs:7:13 + | +LL | let i = 42 as &dyn* Debug; + | ^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0605`. diff --git a/src/test/ui/dyn-star/upcast.rs b/src/test/ui/dyn-star/upcast.rs index cee76ada7..c667ac143 100644 --- a/src/test/ui/dyn-star/upcast.rs +++ b/src/test/ui/dyn-star/upcast.rs @@ -1,7 +1,6 @@ -// run-pass +// known-bug: #104800 #![feature(dyn_star, trait_upcasting)] -#![allow(incomplete_features)] trait Foo: Bar { fn hello(&self); diff --git a/src/test/ui/dyn-star/upcast.stderr b/src/test/ui/dyn-star/upcast.stderr new file mode 100644 index 000000000..6a95f7754 --- /dev/null +++ b/src/test/ui/dyn-star/upcast.stderr @@ -0,0 +1,20 @@ +warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/upcast.rs:3:12 + | +LL | #![feature(dyn_star, trait_upcasting)] + | ^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0277]: `dyn* Foo` needs to be a pointer-sized type + --> $DIR/upcast.rs:30:23 + | +LL | let w: dyn* Bar = w; + | ^ `dyn* Foo` needs to be a pointer-sized type + | + = help: the trait `PointerSized` is not implemented for `dyn* Foo` + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr b/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr index 3435fdfd7..39944622d 100644 --- a/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr @@ -3,12 +3,24 @@ error: no rules expected the token `r#async` | LL | r#async = consumes_async!(r#async); | ^^^^^^^ no rules expected this token in macro call + | +note: while trying to match `async` + --> $DIR/auxiliary/edition-kw-macro-2015.rs:17:6 + | +LL | (async) => (1) + | ^^^^^ error: no rules expected the token `async` --> $DIR/edition-keywords-2015-2015-parsing.rs:17:35 | LL | r#async = consumes_async_raw!(async); | ^^^^^ no rules expected this token in macro call + | +note: while trying to match `r#async` + --> $DIR/auxiliary/edition-kw-macro-2015.rs:22:6 + | +LL | (r#async) => (1) + | ^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr b/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr index 6e86d746f..fa83908e6 100644 --- a/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr @@ -3,12 +3,24 @@ error: no rules expected the token `r#async` | LL | r#async = consumes_async!(r#async); | ^^^^^^^ no rules expected this token in macro call + | +note: while trying to match `async` + --> $DIR/auxiliary/edition-kw-macro-2018.rs:17:6 + | +LL | (async) => (1) + | ^^^^^ error: no rules expected the token `async` --> $DIR/edition-keywords-2015-2018-parsing.rs:17:35 | LL | r#async = consumes_async_raw!(async); | ^^^^^ no rules expected this token in macro call + | +note: while trying to match `r#async` + --> $DIR/auxiliary/edition-kw-macro-2018.rs:22:6 + | +LL | (r#async) => (1) + | ^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr b/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr index e1eea725b..1a4a94e97 100644 --- a/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr @@ -25,12 +25,24 @@ error: no rules expected the token `r#async` | LL | r#async = consumes_async!(r#async); | ^^^^^^^ no rules expected this token in macro call + | +note: while trying to match `async` + --> $DIR/auxiliary/edition-kw-macro-2015.rs:17:6 + | +LL | (async) => (1) + | ^^^^^ error: no rules expected the token `async` --> $DIR/edition-keywords-2018-2015-parsing.rs:21:35 | LL | r#async = consumes_async_raw!(async); | ^^^^^ no rules expected this token in macro call + | +note: while trying to match `r#async` + --> $DIR/auxiliary/edition-kw-macro-2015.rs:22:6 + | +LL | (r#async) => (1) + | ^^^^^^^ error: macro expansion ends with an incomplete expression: expected one of `move`, `|`, or `||` --> $DIR/auxiliary/edition-kw-macro-2015.rs:27:23 diff --git a/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr b/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr index 0af4da09c..19eb7ac98 100644 --- a/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr @@ -25,12 +25,24 @@ error: no rules expected the token `r#async` | LL | r#async = consumes_async!(r#async); | ^^^^^^^ no rules expected this token in macro call + | +note: while trying to match `async` + --> $DIR/auxiliary/edition-kw-macro-2018.rs:17:6 + | +LL | (async) => (1) + | ^^^^^ error: no rules expected the token `async` --> $DIR/edition-keywords-2018-2018-parsing.rs:21:35 | LL | r#async = consumes_async_raw!(async); | ^^^^^ no rules expected this token in macro call + | +note: while trying to match `r#async` + --> $DIR/auxiliary/edition-kw-macro-2018.rs:22:6 + | +LL | (r#async) => (1) + | ^^^^^^^ error: macro expansion ends with an incomplete expression: expected one of `move`, `|`, or `||` --> $DIR/auxiliary/edition-kw-macro-2018.rs:27:23 diff --git a/src/test/ui/empty/empty-comment.stderr b/src/test/ui/empty/empty-comment.stderr index f583dbbdc..7cc8d8fe9 100644 --- a/src/test/ui/empty/empty-comment.stderr +++ b/src/test/ui/empty/empty-comment.stderr @@ -6,6 +6,12 @@ LL | macro_rules! one_arg_macro { ... LL | one_arg_macro!(/**/); | ^^^^^^^^^^^^^^^^^^^^ missing tokens in macro arguments + | +note: while trying to match meta-variable `$fmt:expr` + --> $DIR/empty-comment.rs:6:6 + | +LL | ($fmt:expr) => (print!(concat!($fmt, "\n"))); + | ^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/empty/empty-struct-braces-expr.rs b/src/test/ui/empty/empty-struct-braces-expr.rs index f4144277f..2aab3e777 100644 --- a/src/test/ui/empty/empty-struct-braces-expr.rs +++ b/src/test/ui/empty/empty-struct-braces-expr.rs @@ -17,7 +17,7 @@ fn main() { //~^ ERROR expected function, tuple struct or tuple variant, found struct `Empty1` let e3 = E::Empty3; //~ ERROR expected value, found struct variant `E::Empty3` let e3 = E::Empty3(); - //~^ ERROR expected function, tuple struct or tuple variant, found struct variant `E::Empty3` + //~^ ERROR expected value, found struct variant `E::Empty3` let xe1 = XEmpty1; //~ ERROR expected value, found struct `XEmpty1` let xe1 = XEmpty1(); diff --git a/src/test/ui/empty/empty-struct-braces-expr.stderr b/src/test/ui/empty/empty-struct-braces-expr.stderr index 5b0ca613f..e1a7a02a5 100644 --- a/src/test/ui/empty/empty-struct-braces-expr.stderr +++ b/src/test/ui/empty/empty-struct-braces-expr.stderr @@ -21,24 +21,6 @@ help: a unit struct with a similar name exists LL | let e1 = XEmpty2; | ~~~~~~~ -error[E0423]: expected value, found struct variant `E::Empty3` - --> $DIR/empty-struct-braces-expr.rs:18:14 - | -LL | Empty3 {} - | --------- `E::Empty3` defined here -... -LL | let e3 = E::Empty3; - | ^^^^^^^^^ help: use struct literal syntax instead: `E::Empty3 {}` - -error[E0423]: expected function, tuple struct or tuple variant, found struct variant `E::Empty3` - --> $DIR/empty-struct-braces-expr.rs:19:14 - | -LL | Empty3 {} - | --------- `E::Empty3` defined here -... -LL | let e3 = E::Empty3(); - | ^^^^^^^^^^^ help: use struct literal syntax instead: `E::Empty3 {}` - error[E0423]: expected value, found struct `XEmpty1` --> $DIR/empty-struct-braces-expr.rs:22:15 | @@ -84,6 +66,18 @@ help: a unit struct with a similar name exists LL | let e1 = XEmpty2(); | ~~~~~~~ +error[E0533]: expected value, found struct variant `E::Empty3` + --> $DIR/empty-struct-braces-expr.rs:18:14 + | +LL | let e3 = E::Empty3; + | ^^^^^^^^^ not a value + +error[E0533]: expected value, found struct variant `E::Empty3` + --> $DIR/empty-struct-braces-expr.rs:19:14 + | +LL | let e3 = E::Empty3(); + | ^^^^^^^^^ not a value + error[E0423]: expected function, tuple struct or tuple variant, found struct `XEmpty1` --> $DIR/empty-struct-braces-expr.rs:23:15 | @@ -132,5 +126,5 @@ LL | XE::Empty1 {}; error: aborting due to 9 previous errors -Some errors have detailed explanations: E0423, E0599. +Some errors have detailed explanations: E0423, E0533, E0599. For more information about an error, try `rustc --explain E0423`. diff --git a/src/test/ui/empty/empty-struct-braces-pat-1.stderr b/src/test/ui/empty/empty-struct-braces-pat-1.stderr index 0215a9e59..14e09fc27 100644 --- a/src/test/ui/empty/empty-struct-braces-pat-1.stderr +++ b/src/test/ui/empty/empty-struct-braces-pat-1.stderr @@ -1,34 +1,15 @@ -error[E0532]: expected unit struct, unit variant or constant, found struct variant `E::Empty3` +error[E0533]: expected unit struct, unit variant or constant, found struct variant `E::Empty3` --> $DIR/empty-struct-braces-pat-1.rs:24:9 | -LL | Empty3 {} - | --------- `E::Empty3` defined here -... LL | E::Empty3 => () - | ^^^^^^^^^ help: use struct pattern syntax instead: `E::Empty3 {}` + | ^^^^^^^^^ not a unit struct, unit variant or constant -error[E0532]: expected unit struct, unit variant or constant, found struct variant `XE::XEmpty3` +error[E0533]: expected unit struct, unit variant or constant, found struct variant `XE::XEmpty3` --> $DIR/empty-struct-braces-pat-1.rs:31:9 | LL | XE::XEmpty3 => () - | ^^^^^^^^^^^ - | - ::: $DIR/auxiliary/empty-struct.rs:6:5 - | -LL | XEmpty3 {}, - | ------- `XE::XEmpty3` defined here -LL | XEmpty4, - | ------- similarly named unit variant `XEmpty4` defined here - | -help: use struct pattern syntax instead - | -LL | XE::XEmpty3 { /* fields */ } => () - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -help: a unit variant with a similar name exists - | -LL | XE::XEmpty4 => () - | ~~~~~~~ + | ^^^^^^^^^^^ not a unit struct, unit variant or constant error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0532`. +For more information about this error, try `rustc --explain E0533`. diff --git a/src/test/ui/empty/empty-struct-braces-pat-3.stderr b/src/test/ui/empty/empty-struct-braces-pat-3.stderr index 615e7fb4a..00c8b12e6 100644 --- a/src/test/ui/empty/empty-struct-braces-pat-3.stderr +++ b/src/test/ui/empty/empty-struct-braces-pat-3.stderr @@ -1,67 +1,27 @@ -error[E0532]: expected tuple struct or tuple variant, found struct variant `E::Empty3` +error[E0164]: expected tuple struct or tuple variant, found struct variant `E::Empty3` --> $DIR/empty-struct-braces-pat-3.rs:17:9 | -LL | Empty3 {} - | --------- `E::Empty3` defined here -... LL | E::Empty3() => () - | ^^^^^^^^^^^ help: use struct pattern syntax instead: `E::Empty3 {}` + | ^^^^^^^^^^^ not a tuple struct or tuple variant -error[E0532]: expected tuple struct or tuple variant, found struct variant `XE::XEmpty3` +error[E0164]: expected tuple struct or tuple variant, found struct variant `XE::XEmpty3` --> $DIR/empty-struct-braces-pat-3.rs:21:9 | LL | XE::XEmpty3() => () - | ^^^^^^^^^^^^^ - | - ::: $DIR/auxiliary/empty-struct.rs:6:5 - | -LL | XEmpty3 {}, - | ------- `XE::XEmpty3` defined here -LL | XEmpty4, -LL | XEmpty5(), - | ------- similarly named tuple variant `XEmpty5` defined here - | -help: use struct pattern syntax instead - | -LL | XE::XEmpty3 { /* fields */ } => () - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -help: a tuple variant with a similar name exists - | -LL | XE::XEmpty5() => () - | ~~~~~~~ + | ^^^^^^^^^^^^^ not a tuple struct or tuple variant -error[E0532]: expected tuple struct or tuple variant, found struct variant `E::Empty3` +error[E0164]: expected tuple struct or tuple variant, found struct variant `E::Empty3` --> $DIR/empty-struct-braces-pat-3.rs:25:9 | -LL | Empty3 {} - | --------- `E::Empty3` defined here -... LL | E::Empty3(..) => () - | ^^^^^^^^^^^^^ help: use struct pattern syntax instead: `E::Empty3 {}` + | ^^^^^^^^^^^^^ not a tuple struct or tuple variant -error[E0532]: expected tuple struct or tuple variant, found struct variant `XE::XEmpty3` +error[E0164]: expected tuple struct or tuple variant, found struct variant `XE::XEmpty3` --> $DIR/empty-struct-braces-pat-3.rs:29:9 | LL | XE::XEmpty3(..) => () - | ^^^^^^^^^^^^^^^ - | - ::: $DIR/auxiliary/empty-struct.rs:6:5 - | -LL | XEmpty3 {}, - | ------- `XE::XEmpty3` defined here -LL | XEmpty4, -LL | XEmpty5(), - | ------- similarly named tuple variant `XEmpty5` defined here - | -help: use struct pattern syntax instead - | -LL | XE::XEmpty3 { /* fields */ } => () - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -help: a tuple variant with a similar name exists - | -LL | XE::XEmpty5(..) => () - | ~~~~~~~ + | ^^^^^^^^^^^^^^^ not a tuple struct or tuple variant error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0532`. +For more information about this error, try `rustc --explain E0164`. diff --git a/src/test/ui/enum-discriminant/get_discr.rs b/src/test/ui/enum-discriminant/get_discr.rs new file mode 100644 index 000000000..71eea4e0f --- /dev/null +++ b/src/test/ui/enum-discriminant/get_discr.rs @@ -0,0 +1,114 @@ +// run-pass + +// Now that there are several variations on the code generated in +// `codegen_get_discr`, let's make sure the various cases yield the correct +// result. + +// To get the discriminant of an E<X1> value, there are no shortcuts - we must +// do the full algorithm. +#[repr(u8)] +pub enum X1 { + _1 = 1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, + _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, + _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, + _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, + _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80, + _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94, _95, _96, + _97, _98, _99, _100, _101, _102, _103, _104, _105, _106, _107, _108, _109, _110, _111, _112, + _113, _114, _115, _116, _117, _118, _119, _120, _121, _122, _123, _124, _125, _126, _127, _128, + _129, _130, _131, _132, _133, _134, _135, _136, _137, _138, _139, _140, _141, _142, _143, _144, + _145, _146, _147, _148, _149, _150, _151, _152, _153, _154, _155, _156, _157, _158, _159, _160, + _161, _162, _163, _164, _165, _166, _167, _168, _169, _170, _171, _172, _173, _174, _175, _176, + _177, _178, _179, _180, _181, _182, _183, _184, _185, _186, _187, _188, _189, _190, _191, _192, + _193, _194, _195, _196, _197, _198, _199, _200, _201, _202, _203, _204, _205, _206, _207, _208, + _209, _210, _211, _212, _213, _214, _215, _216, _217, _218, _219, _220, _221, _222, _223, _224, + _225, _226, _227, _228, _229, _230, _231, _232, _233, _234, _235, _236, _237, _238, _239, _240, + _241, _242, _243, _244, _245, _246, _247, _248, _249, _250, _251, _252, _253, _254, +} + +#[repr(i8)] +pub enum X2 { + _1 = -1, _2 = 0, _3 = 1, +} + +#[repr(i8)] +pub enum X3 { + _1 = -128, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, + _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, + _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, + _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, + _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80, + _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94, _95, _96, + _97, _98, _99, _100, _101, _102, _103, _104, _105, _106, _107, _108, _109, _110, _111, _112, + _113, _114, _115, _116, _117, _118, _119, _120, _121, _122, _123, _124, _125, _126, _127, _128, + _129, _130, _131, _132, _133, _134, _135, _136, _137, _138, _139, _140, _141, _142, _143, _144, + _145, _146, _147, _148, _149, _150, _151, _152, _153, _154, _155, _156, _157, _158, _159, _160, + _161, _162, _163, _164, _165, _166, _167, _168, _169, _170, _171, _172, _173, _174, _175, _176, + _177, _178, _179, _180, _181, _182, _183, _184, _185, _186, _187, _188, _189, _190, _191, _192, + _193, _194, _195, _196, _197, _198, _199, _200, _201, _202, _203, _204, _205, _206, _207, _208, + _209, _210, _211, _212, _213, _214, _215, _216, _217, _218, _219, _220, _221, _222, _223, _224, + _225, _226, _227, _228, _229, _230, _231, _232, _233, _234, _235, _236, _237, _238, _239, _240, + _241, _242, _243, _244, _245, _246, _247, _248, _249, _250, _251, _252, _253, _254, +} + +#[repr(i8)] +pub enum X4 { + _1 = -126, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, + _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, + _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, + _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, + _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80, + _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94, _95, _96, + _97, _98, _99, _100, _101, _102, _103, _104, _105, _106, _107, _108, _109, _110, _111, _112, + _113, _114, _115, _116, _117, _118, _119, _120, _121, _122, _123, _124, _125, _126, _127, _128, + _129, _130, _131, _132, _133, _134, _135, _136, _137, _138, _139, _140, _141, _142, _143, _144, + _145, _146, _147, _148, _149, _150, _151, _152, _153, _154, _155, _156, _157, _158, _159, _160, + _161, _162, _163, _164, _165, _166, _167, _168, _169, _170, _171, _172, _173, _174, _175, _176, + _177, _178, _179, _180, _181, _182, _183, _184, _185, _186, _187, _188, _189, _190, _191, _192, + _193, _194, _195, _196, _197, _198, _199, _200, _201, _202, _203, _204, _205, _206, _207, _208, + _209, _210, _211, _212, _213, _214, _215, _216, _217, _218, _219, _220, _221, _222, _223, _224, + _225, _226, _227, _228, _229, _230, _231, _232, _233, _234, _235, _236, _237, _238, _239, _240, + _241, _242, _243, _244, _245, _246, _247, _248, _249, _250, _251, _252, _253, _254, +} + +pub enum E<X> { + A(X), + B, + C, +} + +pub fn match_e<X>(e: E<X>) -> u8 { + use E::*; + match e { + A(_) => 0, + B => 1, + C => 2, + } +} + +fn main() { + assert_eq!(match_e(E::A(X1::_1)), 0); + assert_eq!(match_e(E::A(X1::_2)), 0); + assert_eq!(match_e(E::A(X1::_254)), 0); + assert_eq!(match_e(E::<X1>::B), 1); + assert_eq!(match_e(E::<X1>::C), 2); + assert_eq!(match_e(E::A(X2::_1)), 0); + assert_eq!(match_e(E::A(X2::_2)), 0); + assert_eq!(match_e(E::A(X2::_3)), 0); + assert_eq!(match_e(E::<X2>::B), 1); + assert_eq!(match_e(E::<X2>::C), 2); + assert_eq!(match_e(E::A(X3::_1)), 0); + assert_eq!(match_e(E::A(X3::_2)), 0); + assert_eq!(match_e(E::A(X3::_254)), 0); + assert_eq!(match_e(E::<X3>::B), 1); + assert_eq!(match_e(E::<X3>::C), 2); + assert_eq!(match_e(E::A(X4::_1)), 0); + assert_eq!(match_e(E::A(X4::_2)), 0); + assert_eq!(match_e(E::A(X4::_254)), 0); + assert_eq!(match_e(E::<X4>::B), 1); + assert_eq!(match_e(E::<X4>::C), 2); + assert_eq!(match_e(E::A(false)), 0); + assert_eq!(match_e(E::A(true)), 0); + assert_eq!(match_e(E::<bool>::B), 1); + assert_eq!(match_e(E::<bool>::C), 2); +} diff --git a/src/test/ui/enum-discriminant/issue-104519.rs b/src/test/ui/enum-discriminant/issue-104519.rs new file mode 100644 index 000000000..c4630f76b --- /dev/null +++ b/src/test/ui/enum-discriminant/issue-104519.rs @@ -0,0 +1,36 @@ +// run-pass +#![allow(dead_code)] + +enum OpenResult { + Ok(()), + Err(()), + TransportErr(TransportErr), +} + +#[repr(i32)] +enum TransportErr { + UnknownMethod = -2, +} + +#[inline(never)] +fn some_match(result: OpenResult) -> u8 { + match result { + OpenResult::Ok(()) => 0, + _ => 1, + } +} + +fn main() { + let result = OpenResult::Ok(()); + assert_eq!(some_match(result), 0); + + let result = OpenResult::Ok(()); + match result { + OpenResult::Ok(()) => (), + _ => unreachable!("message a"), + } + match result { + OpenResult::Ok(()) => (), + _ => unreachable!("message b"), + } +} diff --git a/src/test/ui/issues/issue-46519.rs b/src/test/ui/enum-discriminant/issue-46519.rs index 0567923b7..0567923b7 100644 --- a/src/test/ui/issues/issue-46519.rs +++ b/src/test/ui/enum-discriminant/issue-46519.rs diff --git a/src/test/ui/enum/issue-67945-2.rs b/src/test/ui/enum/issue-67945-2.rs index e5044468d..2eb123b73 100644 --- a/src/test/ui/enum/issue-67945-2.rs +++ b/src/test/ui/enum/issue-67945-2.rs @@ -1,7 +1,7 @@ #![feature(type_ascription)] enum Bug<S> { //~ ERROR parameter `S` is never used - Var = 0: S, + Var = type_ascribe!(0, S), //~^ ERROR generic parameters may not be used } diff --git a/src/test/ui/enum/issue-67945-2.stderr b/src/test/ui/enum/issue-67945-2.stderr index 4f5e236a3..63d3521af 100644 --- a/src/test/ui/enum/issue-67945-2.stderr +++ b/src/test/ui/enum/issue-67945-2.stderr @@ -1,8 +1,8 @@ error: generic parameters may not be used in const operations - --> $DIR/issue-67945-2.rs:4:14 + --> $DIR/issue-67945-2.rs:4:28 | -LL | Var = 0: S, - | ^ cannot perform const operation using `S` +LL | Var = type_ascribe!(0, S), + | ^ cannot perform const operation using `S` | = note: type parameters may not be used in const expressions = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions diff --git a/src/test/ui/error-codes/E0045.stderr b/src/test/ui/error-codes/E0045.stderr index d163128bc..fcc613b11 100644 --- a/src/test/ui/error-codes/E0045.stderr +++ b/src/test/ui/error-codes/E0045.stderr @@ -1,8 +1,8 @@ -error[E0045]: C-variadic function must have C or cdecl calling convention +error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl` --> $DIR/E0045.rs:1:17 | LL | extern "Rust" { fn foo(x: u8, ...); } - | ^^^^^^^^^^^^^^^^^^^ C-variadics require C or cdecl calling convention + | ^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0059.stderr b/src/test/ui/error-codes/E0059.stderr index a1b8aeaed..f331d0142 100644 --- a/src/test/ui/error-codes/E0059.stderr +++ b/src/test/ui/error-codes/E0059.stderr @@ -1,8 +1,14 @@ -error[E0059]: cannot use call notation; the first type parameter for the function trait is neither a tuple nor unit - --> $DIR/E0059.rs:3:41 +error[E0059]: type parameter to bare `Fn` trait must be a tuple + --> $DIR/E0059.rs:3:11 | LL | fn foo<F: Fn<i32>>(f: F) -> F::Output { f(3) } - | ^^^^ + | ^^^^^^^ the trait `Tuple` is not implemented for `i32` + | +note: required by a bound in `Fn` + --> $SRC_DIR/core/src/ops/function.rs:LL:COL + | +LL | pub trait Fn<Args: Tuple>: FnMut<Args> { + | ^^^^^ required by this bound in `Fn` error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0081.stderr b/src/test/ui/error-codes/E0081.stderr index 64562fefc..d4b21f689 100644 --- a/src/test/ui/error-codes/E0081.stderr +++ b/src/test/ui/error-codes/E0081.stderr @@ -32,7 +32,7 @@ LL | First = -1, | -- `-1` assigned here LL | LL | Second = -2, - | ----------- discriminant for `Last` incremented from this startpoint (`Second` + 1 variant later => `Last` = -1) + | ------ discriminant for `Last` incremented from this startpoint (`Second` + 1 variant later => `Last` = -1) LL | LL | Last, | ---- `-1` assigned here @@ -53,7 +53,7 @@ LL | V4 = 0, | - `0` assigned here LL | LL | V5 = -2, - | ------- discriminant for `V7` incremented from this startpoint (`V5` + 2 variants later => `V7` = 0) + | -- discriminant for `V7` incremented from this startpoint (`V5` + 2 variants later => `V7` = 0) ... LL | V7, | -- `0` assigned here @@ -68,7 +68,7 @@ LL | V5 = -2, | -- `-2` assigned here ... LL | V8 = -3, - | ------- discriminant for `V9` incremented from this startpoint (`V8` + 1 variant later => `V9` = -2) + | -- discriminant for `V9` incremented from this startpoint (`V8` + 1 variant later => `V9` = -2) LL | LL | V9, | -- `-2` assigned here diff --git a/src/test/ui/error-codes/E0164.stderr b/src/test/ui/error-codes/E0164.stderr index 0db89dfec..5a80d6ec3 100644 --- a/src/test/ui/error-codes/E0164.stderr +++ b/src/test/ui/error-codes/E0164.stderr @@ -2,7 +2,7 @@ error[E0164]: expected tuple struct or tuple variant, found associated constant --> $DIR/E0164.rs:9:9 | LL | Foo::B(i) => i, - | ^^^^^^^^^ not a tuple variant or struct + | ^^^^^^^^^ not a tuple struct or tuple variant error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0268.stderr b/src/test/ui/error-codes/E0268.stderr index c926f9e48..6422e8a94 100644 --- a/src/test/ui/error-codes/E0268.stderr +++ b/src/test/ui/error-codes/E0268.stderr @@ -1,8 +1,8 @@ -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/E0268.rs:2:5 | LL | break; - | ^^^^^ cannot `break` outside of a loop + | ^^^^^ cannot `break` outside of a loop or labeled block error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0275.rs b/src/test/ui/error-codes/E0275.rs index 28a9676f0..95d7f85f1 100644 --- a/src/test/ui/error-codes/E0275.rs +++ b/src/test/ui/error-codes/E0275.rs @@ -1,3 +1,4 @@ +// normalize-stderr-test: "long-type-\d+" -> "long-type-hash" trait Foo {} struct Bar<T>(T); diff --git a/src/test/ui/error-codes/E0275.stderr b/src/test/ui/error-codes/E0275.stderr index 87cfaa489..451a683ac 100644 --- a/src/test/ui/error-codes/E0275.stderr +++ b/src/test/ui/error-codes/E0275.stderr @@ -1,15 +1,16 @@ -error[E0275]: overflow evaluating the requirement `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Foo` - --> $DIR/E0275.rs:5:33 +error[E0275]: overflow evaluating the requirement `Bar<Bar<Bar<Bar<Bar<Bar<Bar<...>>>>>>>: Foo` + --> $DIR/E0275.rs:6:33 | LL | impl<T> Foo for T where Bar<T>: Foo {} | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`E0275`) -note: required for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Foo` - --> $DIR/E0275.rs:5:9 +note: required for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<...>>>>>>>>>>>>>>>>>>>>>` to implement `Foo` + --> $DIR/E0275.rs:6:9 | LL | impl<T> Foo for T where Bar<T>: Foo {} | ^^^ ^ + = note: the full type name has been written to '$TEST_BUILD_DIR/error-codes/E0275/E0275.long-type-hash.txt' = note: 127 redundant requirements hidden = note: required for `Bar<T>` to implement `Foo` diff --git a/src/test/ui/error-codes/E0282.rs b/src/test/ui/error-codes/E0282.rs index 9bd16abb7..f1f93b3ae 100644 --- a/src/test/ui/error-codes/E0282.rs +++ b/src/test/ui/error-codes/E0282.rs @@ -1,3 +1,4 @@ fn main() { - let x = "hello".chars().rev().collect(); //~ ERROR E0282 + let x = "hello".chars().rev().collect(); + //~^ ERROR E0282 } diff --git a/src/test/ui/error-codes/E0401.rs b/src/test/ui/error-codes/E0401.rs index c30e5f471..8f8d6b87e 100644 --- a/src/test/ui/error-codes/E0401.rs +++ b/src/test/ui/error-codes/E0401.rs @@ -8,7 +8,9 @@ fn foo<T>(x: T) { W: Fn()> (y: T) { //~ ERROR E0401 } - bfnr(x); //~ ERROR type annotations needed + bfnr(x); + //~^ ERROR type annotations needed + //~| ERROR type annotations needed } diff --git a/src/test/ui/error-codes/E0401.stderr b/src/test/ui/error-codes/E0401.stderr index b0e2ef5b6..9687eca61 100644 --- a/src/test/ui/error-codes/E0401.stderr +++ b/src/test/ui/error-codes/E0401.stderr @@ -21,7 +21,7 @@ LL | (y: T) { | ^ use of generic parameter from outer function error[E0401]: can't use generic parameters from outer function - --> $DIR/E0401.rs:22:25 + --> $DIR/E0401.rs:24:25 | LL | impl<T> Iterator for A<T> { | ---- `Self` type implicitly declared here, by this `impl` @@ -43,7 +43,28 @@ help: consider specifying the generic arguments LL | bfnr::<U, V, W>(x); | +++++++++++ -error: aborting due to 4 previous errors +error[E0283]: type annotations needed + --> $DIR/E0401.rs:11:5 + | +LL | bfnr(x); + | ^^^^ cannot infer type of the type parameter `W` declared on the function `bfnr` + | + = note: multiple `impl`s satisfying `_: Fn<()>` found in the following crates: `alloc`, `core`: + - impl<A, F> Fn<A> for &F + where A: Tuple, F: Fn<A>, F: ?Sized; + - impl<Args, F, A> Fn<Args> for Box<F, A> + where Args: Tuple, F: Fn<Args>, A: Allocator, F: ?Sized; +note: required by a bound in `bfnr` + --> $DIR/E0401.rs:4:30 + | +LL | fn bfnr<U, V: Baz<U>, W: Fn()>(y: T) { + | ^^^^ required by this bound in `bfnr` +help: consider specifying the type arguments in the function call + | +LL | bfnr::<U, V, W>(x); + | +++++++++++ + +error: aborting due to 5 previous errors -Some errors have detailed explanations: E0282, E0401. +Some errors have detailed explanations: E0282, E0283, E0401. For more information about an error, try `rustc --explain E0282`. diff --git a/src/test/ui/error-codes/E0767.rs b/src/test/ui/error-codes/E0767.rs index 6c6cb746e..14215d36a 100644 --- a/src/test/ui/error-codes/E0767.rs +++ b/src/test/ui/error-codes/E0767.rs @@ -1,6 +1,7 @@ -fn main () { +fn main() { 'a: loop { || { + //~^ ERROR mismatched types loop { break 'a; } //~ ERROR E0767 } } diff --git a/src/test/ui/error-codes/E0767.stderr b/src/test/ui/error-codes/E0767.stderr index 242982330..ee8524730 100644 --- a/src/test/ui/error-codes/E0767.stderr +++ b/src/test/ui/error-codes/E0767.stderr @@ -1,14 +1,27 @@ error[E0767]: use of unreachable label `'a` - --> $DIR/E0767.rs:4:26 + --> $DIR/E0767.rs:5:26 | LL | 'a: loop { | -- unreachable label defined here -LL | || { +... LL | loop { break 'a; } | ^^ unreachable label `'a` | = note: labels are unreachable through functions, closures, async blocks and modules -error: aborting due to previous error +error[E0308]: mismatched types + --> $DIR/E0767.rs:3:9 + | +LL | / || { +LL | | +LL | | loop { break 'a; } +LL | | } + | |_________^ expected `()`, found closure + | + = note: expected unit type `()` + found closure `[closure@$DIR/E0767.rs:3:9: 3:11]` + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0767`. +Some errors have detailed explanations: E0308, E0767. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/error-codes/E0778.rs b/src/test/ui/error-codes/E0778.rs index 60e5c2598..74653886d 100644 --- a/src/test/ui/error-codes/E0778.rs +++ b/src/test/ui/error-codes/E0778.rs @@ -1,8 +1,4 @@ -#![feature(isa_attribute)] - #[instruction_set()] //~ ERROR -fn no_isa_defined() { -} +fn no_isa_defined() {} -fn main() { -} +fn main() {} diff --git a/src/test/ui/error-codes/E0778.stderr b/src/test/ui/error-codes/E0778.stderr index 6ecae7924..42647e5c6 100644 --- a/src/test/ui/error-codes/E0778.stderr +++ b/src/test/ui/error-codes/E0778.stderr @@ -1,5 +1,5 @@ error[E0778]: `#[instruction_set]` requires an argument - --> $DIR/E0778.rs:3:1 + --> $DIR/E0778.rs:1:1 | LL | #[instruction_set()] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/error-codes/E0779.rs b/src/test/ui/error-codes/E0779.rs index 1b4dbce20..c32dae12c 100644 --- a/src/test/ui/error-codes/E0779.rs +++ b/src/test/ui/error-codes/E0779.rs @@ -1,6 +1,2 @@ -#![feature(isa_attribute)] - #[instruction_set(arm::magic)] //~ ERROR -fn main() { - -} +fn main() {} diff --git a/src/test/ui/error-codes/E0779.stderr b/src/test/ui/error-codes/E0779.stderr index da787260d..7c6a119a0 100644 --- a/src/test/ui/error-codes/E0779.stderr +++ b/src/test/ui/error-codes/E0779.stderr @@ -1,5 +1,5 @@ error[E0779]: invalid instruction set specified - --> $DIR/E0779.rs:3:1 + --> $DIR/E0779.rs:1:1 | LL | #[instruction_set(arm::magic)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/error-codes/e0119/conflict-with-std.stderr b/src/test/ui/error-codes/e0119/conflict-with-std.stderr index 3ff96a6a4..ef888a1c2 100644 --- a/src/test/ui/error-codes/e0119/conflict-with-std.stderr +++ b/src/test/ui/error-codes/e0119/conflict-with-std.stderr @@ -1,4 +1,4 @@ -error[E0119]: conflicting implementations of trait `std::convert::AsRef<Q>` for type `std::boxed::Box<Q>` +error[E0119]: conflicting implementations of trait `AsRef<Q>` for type `Box<Q>` --> $DIR/conflict-with-std.rs:5:1 | LL | impl AsRef<Q> for Box<Q> { @@ -8,7 +8,7 @@ LL | impl AsRef<Q> for Box<Q> { - impl<T, A> AsRef<T> for Box<T, A> where A: Allocator, T: ?Sized; -error[E0119]: conflicting implementations of trait `std::convert::From<S>` for type `S` +error[E0119]: conflicting implementations of trait `From<S>` for type `S` --> $DIR/conflict-with-std.rs:12:1 | LL | impl From<S> for S { @@ -17,7 +17,7 @@ LL | impl From<S> for S { = note: conflicting implementation in crate `core`: - impl<T> From<T> for T; -error[E0119]: conflicting implementations of trait `std::convert::TryFrom<X>` for type `X` +error[E0119]: conflicting implementations of trait `TryFrom<X>` for type `X` --> $DIR/conflict-with-std.rs:19:1 | LL | impl TryFrom<X> for X { diff --git a/src/test/ui/error-codes/e0119/issue-23563.stderr b/src/test/ui/error-codes/e0119/issue-23563.stderr index f149cef58..1b2d64282 100644 --- a/src/test/ui/error-codes/e0119/issue-23563.stderr +++ b/src/test/ui/error-codes/e0119/issue-23563.stderr @@ -1,4 +1,4 @@ -error[E0119]: conflicting implementations of trait `a::LolFrom<&[_]>` for type `LocalType<_>` +error[E0119]: conflicting implementations of trait `LolFrom<&[_]>` for type `LocalType<_>` --> $DIR/issue-23563.rs:13:1 | LL | impl<'a, T> LolFrom<&'a [T]> for LocalType<T> { diff --git a/src/test/ui/error-codes/e0119/issue-27403.stderr b/src/test/ui/error-codes/e0119/issue-27403.stderr index c11a50487..9b3345c23 100644 --- a/src/test/ui/error-codes/e0119/issue-27403.stderr +++ b/src/test/ui/error-codes/e0119/issue-27403.stderr @@ -1,4 +1,4 @@ -error[E0119]: conflicting implementations of trait `std::convert::Into<_>` for type `GenX<_>` +error[E0119]: conflicting implementations of trait `Into<_>` for type `GenX<_>` --> $DIR/issue-27403.rs:5:1 | LL | impl<S> Into<S> for GenX<S> { diff --git a/src/test/ui/error-codes/e0119/so-37347311.stderr b/src/test/ui/error-codes/e0119/so-37347311.stderr index f1c2b0d29..99367e808 100644 --- a/src/test/ui/error-codes/e0119/so-37347311.stderr +++ b/src/test/ui/error-codes/e0119/so-37347311.stderr @@ -1,4 +1,4 @@ -error[E0119]: conflicting implementations of trait `std::convert::From<MyError<_>>` for type `MyError<_>` +error[E0119]: conflicting implementations of trait `From<MyError<_>>` for type `MyError<_>` --> $DIR/so-37347311.rs:11:1 | LL | impl<S: Storage> From<S::Error> for MyError<S> { diff --git a/src/test/ui/errors/issue-104621-extern-bad-file.rs b/src/test/ui/errors/issue-104621-extern-bad-file.rs new file mode 100644 index 000000000..3f13d6052 --- /dev/null +++ b/src/test/ui/errors/issue-104621-extern-bad-file.rs @@ -0,0 +1,8 @@ +// compile-flags: --extern foo={{src-base}}/errors/issue-104621-extern-bad-file.rs +// only-linux + +extern crate foo; +//~^ ERROR extern location for foo is of an unknown type +//~| ERROR file name should be lib*.rlib or lib*.so +//~| ERROR can't find crate for `foo` [E0463] +fn main() {} diff --git a/src/test/ui/errors/issue-104621-extern-bad-file.stderr b/src/test/ui/errors/issue-104621-extern-bad-file.stderr new file mode 100644 index 000000000..b8500ad0e --- /dev/null +++ b/src/test/ui/errors/issue-104621-extern-bad-file.stderr @@ -0,0 +1,21 @@ +error: extern location for foo is of an unknown type: $DIR/issue-104621-extern-bad-file.rs + --> $DIR/issue-104621-extern-bad-file.rs:4:1 + | +LL | extern crate foo; + | ^^^^^^^^^^^^^^^^^ + +error: file name should be lib*.rlib or lib*.so + --> $DIR/issue-104621-extern-bad-file.rs:4:1 + | +LL | extern crate foo; + | ^^^^^^^^^^^^^^^^^ + +error[E0463]: can't find crate for `foo` + --> $DIR/issue-104621-extern-bad-file.rs:4:1 + | +LL | extern crate foo; + | ^^^^^^^^^^^^^^^^^ can't find crate + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0463`. diff --git a/src/test/ui/errors/issue-104621-extern-not-file.rs b/src/test/ui/errors/issue-104621-extern-not-file.rs new file mode 100644 index 000000000..899e45a30 --- /dev/null +++ b/src/test/ui/errors/issue-104621-extern-not-file.rs @@ -0,0 +1,4 @@ +// compile-flags: --extern foo=. + +extern crate foo; //~ ERROR extern location for foo is not a file: . +fn main() {} diff --git a/src/test/ui/errors/issue-104621-extern-not-file.stderr b/src/test/ui/errors/issue-104621-extern-not-file.stderr new file mode 100644 index 000000000..5aaf97413 --- /dev/null +++ b/src/test/ui/errors/issue-104621-extern-not-file.stderr @@ -0,0 +1,8 @@ +error: extern location for foo is not a file: . + --> $DIR/issue-104621-extern-not-file.rs:3:1 + | +LL | extern crate foo; + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/fail-simple.stderr b/src/test/ui/fail-simple.stderr index 26ed918e9..af8f54291 100644 --- a/src/test/ui/fail-simple.stderr +++ b/src/test/ui/fail-simple.stderr @@ -3,6 +3,8 @@ error: no rules expected the token `@` | LL | panic!(@); | ^ no rules expected this token in macro call + | + = note: while trying to match end of macro error: aborting due to previous error diff --git a/src/test/ui/feature-gates/feature-gate-abi-efiapi.rs b/src/test/ui/feature-gates/feature-gate-abi-efiapi.rs new file mode 100644 index 000000000..0c0d736ac --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-abi-efiapi.rs @@ -0,0 +1,33 @@ +// needs-llvm-components: x86 +// compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=rlib +#![no_core] +#![feature(no_core, lang_items)] +#[lang="sized"] +trait Sized { } + +// Functions +extern "efiapi" fn f1() {} //~ ERROR efiapi ABI is experimental + +// Methods in trait defintion +trait Tr { + extern "efiapi" fn f2(); //~ ERROR efiapi ABI is experimental + extern "efiapi" fn f3() {} //~ ERROR efiapi ABI is experimental +} + +struct S; + +// Methods in trait impl +impl Tr for S { + extern "efiapi" fn f2() {} //~ ERROR efiapi ABI is experimental +} + +// Methods in inherent impl +impl S { + extern "efiapi" fn f4() {} //~ ERROR efiapi ABI is experimental +} + +// Function pointer types +type A = extern "efiapi" fn(); //~ ERROR efiapi ABI is experimental + +// Foreign modules +extern "efiapi" {} //~ ERROR efiapi ABI is experimental diff --git a/src/test/ui/feature-gates/feature-gate-abi-efiapi.stderr b/src/test/ui/feature-gates/feature-gate-abi-efiapi.stderr new file mode 100644 index 000000000..5b01dcc6d --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-abi-efiapi.stderr @@ -0,0 +1,66 @@ +error[E0658]: efiapi ABI is experimental and subject to change + --> $DIR/feature-gate-abi-efiapi.rs:9:8 + | +LL | extern "efiapi" fn f1() {} + | ^^^^^^^^ + | + = note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information + = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable + +error[E0658]: efiapi ABI is experimental and subject to change + --> $DIR/feature-gate-abi-efiapi.rs:13:12 + | +LL | extern "efiapi" fn f2(); + | ^^^^^^^^ + | + = note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information + = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable + +error[E0658]: efiapi ABI is experimental and subject to change + --> $DIR/feature-gate-abi-efiapi.rs:14:12 + | +LL | extern "efiapi" fn f3() {} + | ^^^^^^^^ + | + = note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information + = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable + +error[E0658]: efiapi ABI is experimental and subject to change + --> $DIR/feature-gate-abi-efiapi.rs:21:12 + | +LL | extern "efiapi" fn f2() {} + | ^^^^^^^^ + | + = note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information + = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable + +error[E0658]: efiapi ABI is experimental and subject to change + --> $DIR/feature-gate-abi-efiapi.rs:26:12 + | +LL | extern "efiapi" fn f4() {} + | ^^^^^^^^ + | + = note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information + = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable + +error[E0658]: efiapi ABI is experimental and subject to change + --> $DIR/feature-gate-abi-efiapi.rs:30:17 + | +LL | type A = extern "efiapi" fn(); + | ^^^^^^^^ + | + = note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information + = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable + +error[E0658]: efiapi ABI is experimental and subject to change + --> $DIR/feature-gate-abi-efiapi.rs:33:8 + | +LL | extern "efiapi" {} + | ^^^^^^^^ + | + = note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information + = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gates/feature-gate-abi.rs b/src/test/ui/feature-gates/feature-gate-abi.rs index 855263595..712655f97 100644 --- a/src/test/ui/feature-gates/feature-gate-abi.rs +++ b/src/test/ui/feature-gates/feature-gate-abi.rs @@ -1,6 +1,5 @@ // gate-test-intrinsics // gate-test-platform_intrinsics -// gate-test-abi_efiapi // compile-flags: --crate-type=rlib #![feature(no_core, lang_items)] @@ -9,13 +8,15 @@ #[lang="sized"] trait Sized { } +#[lang="tuple_trait"] +trait Tuple { } + // Functions extern "rust-intrinsic" fn f1() {} //~ ERROR intrinsics are subject to change //~^ ERROR intrinsic must be in extern "platform-intrinsic" fn f2() {} //~ ERROR platform intrinsics are experimental //~^ ERROR intrinsic must be in extern "rust-call" fn f4(_: ()) {} //~ ERROR rust-call ABI is subject to change -extern "efiapi" fn f10() {} //~ ERROR efiapi ABI is experimental and subject to change // Methods in trait definition trait Tr { @@ -24,10 +25,8 @@ trait Tr { extern "platform-intrinsic" fn m2(); //~ ERROR platform intrinsics are experimental //~^ ERROR intrinsic must be in extern "rust-call" fn m4(_: ()); //~ ERROR rust-call ABI is subject to change - extern "efiapi" fn m10(); //~ ERROR efiapi ABI is experimental and subject to change extern "rust-call" fn dm4(_: ()) {} //~ ERROR rust-call ABI is subject to change - extern "efiapi" fn dm10() {} //~ ERROR efiapi ABI is experimental and subject to change } struct S; @@ -39,7 +38,6 @@ impl Tr for S { extern "platform-intrinsic" fn m2() {} //~ ERROR platform intrinsics are experimental //~^ ERROR intrinsic must be in extern "rust-call" fn m4(_: ()) {} //~ ERROR rust-call ABI is subject to change - extern "efiapi" fn m10() {} //~ ERROR efiapi ABI is experimental and subject to change } // Methods in inherent impl @@ -49,17 +47,14 @@ impl S { extern "platform-intrinsic" fn im2() {} //~ ERROR platform intrinsics are experimental //~^ ERROR intrinsic must be in extern "rust-call" fn im4(_: ()) {} //~ ERROR rust-call ABI is subject to change - extern "efiapi" fn im10() {} //~ ERROR efiapi ABI is experimental and subject to change } // Function pointer types type A1 = extern "rust-intrinsic" fn(); //~ ERROR intrinsics are subject to change type A2 = extern "platform-intrinsic" fn(); //~ ERROR platform intrinsics are experimental type A4 = extern "rust-call" fn(_: ()); //~ ERROR rust-call ABI is subject to change -type A10 = extern "efiapi" fn(); //~ ERROR efiapi ABI is experimental and subject to change // Foreign modules extern "rust-intrinsic" {} //~ ERROR intrinsics are subject to change extern "platform-intrinsic" {} //~ ERROR platform intrinsics are experimental extern "rust-call" {} //~ ERROR rust-call ABI is subject to change -extern "efiapi" {} //~ ERROR efiapi ABI is experimental and subject to change diff --git a/src/test/ui/feature-gates/feature-gate-abi.stderr b/src/test/ui/feature-gates/feature-gate-abi.stderr index bcca39c8f..e9791b951 100644 --- a/src/test/ui/feature-gates/feature-gate-abi.stderr +++ b/src/test/ui/feature-gates/feature-gate-abi.stderr @@ -1,5 +1,5 @@ error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:13:8 + --> $DIR/feature-gate-abi.rs:15:8 | LL | extern "rust-intrinsic" fn f1() {} | ^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | extern "rust-intrinsic" fn f1() {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:15:8 + --> $DIR/feature-gate-abi.rs:17:8 | LL | extern "platform-intrinsic" fn f2() {} | ^^^^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | extern "platform-intrinsic" fn f2() {} = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:17:8 + --> $DIR/feature-gate-abi.rs:19:8 | LL | extern "rust-call" fn f4(_: ()) {} | ^^^^^^^^^^^ @@ -24,17 +24,8 @@ LL | extern "rust-call" fn f4(_: ()) {} = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable -error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:18:8 - | -LL | extern "efiapi" fn f10() {} - | ^^^^^^^^ - | - = note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information - = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable - error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:22:12 + --> $DIR/feature-gate-abi.rs:23:12 | LL | extern "rust-intrinsic" fn m1(); | ^^^^^^^^^^^^^^^^ @@ -42,7 +33,7 @@ LL | extern "rust-intrinsic" fn m1(); = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:24:12 + --> $DIR/feature-gate-abi.rs:25:12 | LL | extern "platform-intrinsic" fn m2(); | ^^^^^^^^^^^^^^^^^^^^ @@ -51,7 +42,7 @@ LL | extern "platform-intrinsic" fn m2(); = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:26:12 + --> $DIR/feature-gate-abi.rs:27:12 | LL | extern "rust-call" fn m4(_: ()); | ^^^^^^^^^^^ @@ -59,15 +50,6 @@ LL | extern "rust-call" fn m4(_: ()); = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable -error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:27:12 - | -LL | extern "efiapi" fn m10(); - | ^^^^^^^^ - | - = note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information - = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable - error[E0658]: rust-call ABI is subject to change --> $DIR/feature-gate-abi.rs:29:12 | @@ -77,17 +59,8 @@ LL | extern "rust-call" fn dm4(_: ()) {} = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable -error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:30:12 - | -LL | extern "efiapi" fn dm10() {} - | ^^^^^^^^ - | - = note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information - = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable - error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:37:12 + --> $DIR/feature-gate-abi.rs:36:12 | LL | extern "rust-intrinsic" fn m1() {} | ^^^^^^^^^^^^^^^^ @@ -95,7 +68,7 @@ LL | extern "rust-intrinsic" fn m1() {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:39:12 + --> $DIR/feature-gate-abi.rs:38:12 | LL | extern "platform-intrinsic" fn m2() {} | ^^^^^^^^^^^^^^^^^^^^ @@ -104,7 +77,7 @@ LL | extern "platform-intrinsic" fn m2() {} = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:41:12 + --> $DIR/feature-gate-abi.rs:40:12 | LL | extern "rust-call" fn m4(_: ()) {} | ^^^^^^^^^^^ @@ -112,17 +85,8 @@ LL | extern "rust-call" fn m4(_: ()) {} = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable -error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:42:12 - | -LL | extern "efiapi" fn m10() {} - | ^^^^^^^^ - | - = note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information - = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable - error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:47:12 + --> $DIR/feature-gate-abi.rs:45:12 | LL | extern "rust-intrinsic" fn im1() {} | ^^^^^^^^^^^^^^^^ @@ -130,7 +94,7 @@ LL | extern "rust-intrinsic" fn im1() {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:49:12 + --> $DIR/feature-gate-abi.rs:47:12 | LL | extern "platform-intrinsic" fn im2() {} | ^^^^^^^^^^^^^^^^^^^^ @@ -139,7 +103,7 @@ LL | extern "platform-intrinsic" fn im2() {} = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:51:12 + --> $DIR/feature-gate-abi.rs:49:12 | LL | extern "rust-call" fn im4(_: ()) {} | ^^^^^^^^^^^ @@ -147,17 +111,8 @@ LL | extern "rust-call" fn im4(_: ()) {} = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable -error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:52:12 - | -LL | extern "efiapi" fn im10() {} - | ^^^^^^^^ - | - = note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information - = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable - error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:56:18 + --> $DIR/feature-gate-abi.rs:53:18 | LL | type A1 = extern "rust-intrinsic" fn(); | ^^^^^^^^^^^^^^^^ @@ -165,7 +120,7 @@ LL | type A1 = extern "rust-intrinsic" fn(); = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:57:18 + --> $DIR/feature-gate-abi.rs:54:18 | LL | type A2 = extern "platform-intrinsic" fn(); | ^^^^^^^^^^^^^^^^^^^^ @@ -174,7 +129,7 @@ LL | type A2 = extern "platform-intrinsic" fn(); = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:58:18 + --> $DIR/feature-gate-abi.rs:55:18 | LL | type A4 = extern "rust-call" fn(_: ()); | ^^^^^^^^^^^ @@ -182,17 +137,8 @@ LL | type A4 = extern "rust-call" fn(_: ()); = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable -error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:59:19 - | -LL | type A10 = extern "efiapi" fn(); - | ^^^^^^^^ - | - = note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information - = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable - error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:62:8 + --> $DIR/feature-gate-abi.rs:58:8 | LL | extern "rust-intrinsic" {} | ^^^^^^^^^^^^^^^^ @@ -200,7 +146,7 @@ LL | extern "rust-intrinsic" {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:63:8 + --> $DIR/feature-gate-abi.rs:59:8 | LL | extern "platform-intrinsic" {} | ^^^^^^^^^^^^^^^^^^^^ @@ -209,7 +155,7 @@ LL | extern "platform-intrinsic" {} = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:64:8 + --> $DIR/feature-gate-abi.rs:60:8 | LL | extern "rust-call" {} | ^^^^^^^^^^^ @@ -217,63 +163,54 @@ LL | extern "rust-call" {} = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable -error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:65:8 - | -LL | extern "efiapi" {} - | ^^^^^^^^ - | - = note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information - = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable - error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:22:32 + --> $DIR/feature-gate-abi.rs:23:32 | LL | extern "rust-intrinsic" fn m1(); | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:24:36 + --> $DIR/feature-gate-abi.rs:25:36 | LL | extern "platform-intrinsic" fn m2(); | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:13:33 + --> $DIR/feature-gate-abi.rs:15:33 | LL | extern "rust-intrinsic" fn f1() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:15:37 + --> $DIR/feature-gate-abi.rs:17:37 | LL | extern "platform-intrinsic" fn f2() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:37:37 + --> $DIR/feature-gate-abi.rs:36:37 | LL | extern "rust-intrinsic" fn m1() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:39:41 + --> $DIR/feature-gate-abi.rs:38:41 | LL | extern "platform-intrinsic" fn m2() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:47:38 + --> $DIR/feature-gate-abi.rs:45:38 | LL | extern "rust-intrinsic" fn im1() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:49:42 + --> $DIR/feature-gate-abi.rs:47:42 | LL | extern "platform-intrinsic" fn im2() {} | ^^ -error: aborting due to 34 previous errors +error: aborting due to 27 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gates/feature-gate-alloc-error-handler.rs b/src/test/ui/feature-gates/feature-gate-alloc-error-handler.rs index ad8909618..78d189d20 100644 --- a/src/test/ui/feature-gates/feature-gate-alloc-error-handler.rs +++ b/src/test/ui/feature-gates/feature-gate-alloc-error-handler.rs @@ -5,10 +5,12 @@ use core::alloc::Layout; -#[alloc_error_handler] //~ ERROR the `#[alloc_error_handler]` attribute is an experimental feature +#[alloc_error_handler] //~ ERROR use of unstable library feature 'alloc_error_handler' fn oom(info: Layout) -> ! { loop {} } #[panic_handler] -fn panic(_: &core::panic::PanicInfo) -> ! { loop {} } +fn panic(_: &core::panic::PanicInfo) -> ! { + loop {} +} diff --git a/src/test/ui/feature-gates/feature-gate-alloc-error-handler.stderr b/src/test/ui/feature-gates/feature-gate-alloc-error-handler.stderr index 03f31e53f..f414eb463 100644 --- a/src/test/ui/feature-gates/feature-gate-alloc-error-handler.stderr +++ b/src/test/ui/feature-gates/feature-gate-alloc-error-handler.stderr @@ -1,8 +1,8 @@ -error[E0658]: the `#[alloc_error_handler]` attribute is an experimental feature - --> $DIR/feature-gate-alloc-error-handler.rs:8:1 +error[E0658]: use of unstable library feature 'alloc_error_handler' + --> $DIR/feature-gate-alloc-error-handler.rs:8:3 | LL | #[alloc_error_handler] - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ | = note: see issue #51540 <https://github.com/rust-lang/rust/issues/51540> for more information = help: add `#![feature(alloc_error_handler)]` to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-custom_mir.rs b/src/test/ui/feature-gates/feature-gate-custom_mir.rs new file mode 100644 index 000000000..0126dde2f --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-custom_mir.rs @@ -0,0 +1,12 @@ +#![feature(core_intrinsics)] + +extern crate core; + +#[custom_mir(dialect = "built")] //~ ERROR the `#[custom_mir]` attribute is just used for the Rust test suite +pub fn foo(_x: i32) -> i32 { + 0 +} + +fn main() { + assert_eq!(2, foo(2)); +} diff --git a/src/test/ui/feature-gates/feature-gate-custom_mir.stderr b/src/test/ui/feature-gates/feature-gate-custom_mir.stderr new file mode 100644 index 000000000..3c149d30d --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-custom_mir.stderr @@ -0,0 +1,11 @@ +error[E0658]: the `#[custom_mir]` attribute is just used for the Rust test suite + --> $DIR/feature-gate-custom_mir.rs:5:1 + | +LL | #[custom_mir(dialect = "built")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(custom_mir)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs b/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs new file mode 100644 index 000000000..0db8088f7 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs @@ -0,0 +1,6 @@ +fn f() -> impl Fn() -> impl Sized { || () } +//~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return +fn g() -> &'static dyn Fn() -> impl Sized { &|| () } +//~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr b/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr new file mode 100644 index 000000000..760dcb615 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr @@ -0,0 +1,21 @@ +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return + --> $DIR/feature-gate-impl_trait_in_fn_trait_return.rs:1:24 + | +LL | fn f() -> impl Fn() -> impl Sized { || () } + | ^^^^^^^^^^ + | + = note: see issue #99697 <https://github.com/rust-lang/rust/issues/99697> for more information + = help: add `#![feature(impl_trait_in_fn_trait_return)]` to the crate attributes to enable + +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return + --> $DIR/feature-gate-impl_trait_in_fn_trait_return.rs:3:32 + | +LL | fn g() -> &'static dyn Fn() -> impl Sized { &|| () } + | ^^^^^^^^^^ + | + = note: see issue #99697 <https://github.com/rust-lang/rust/issues/99697> for more information + = help: add `#![feature(impl_trait_in_fn_trait_return)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0562`. diff --git a/src/test/ui/feature-gates/feature-gate-isa_attribute.rs b/src/test/ui/feature-gates/feature-gate-isa_attribute.rs deleted file mode 100644 index cb02a0955..000000000 --- a/src/test/ui/feature-gates/feature-gate-isa_attribute.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[instruction_set] -//~^ ERROR the `#[instruction_set]` attribute is an experimental feature [E0658] -//~| ERROR malformed `instruction_set` attribute input -//~| ERROR must specify an instruction set [E0778] -fn main() { -} diff --git a/src/test/ui/feature-gates/feature-gate-isa_attribute.stderr b/src/test/ui/feature-gates/feature-gate-isa_attribute.stderr deleted file mode 100644 index 2a95a80ca..000000000 --- a/src/test/ui/feature-gates/feature-gate-isa_attribute.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error: malformed `instruction_set` attribute input - --> $DIR/feature-gate-isa_attribute.rs:1:1 - | -LL | #[instruction_set] - | ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[instruction_set(set)]` - -error[E0658]: the `#[instruction_set]` attribute is an experimental feature - --> $DIR/feature-gate-isa_attribute.rs:1:1 - | -LL | #[instruction_set] - | ^^^^^^^^^^^^^^^^^^ - | - = note: see issue #74727 <https://github.com/rust-lang/rust/issues/74727> for more information - = help: add `#![feature(isa_attribute)]` to the crate attributes to enable - -error[E0778]: must specify an instruction set - --> $DIR/feature-gate-isa_attribute.rs:1:1 - | -LL | #[instruction_set] - | ^^^^^^^^^^^^^^^^^^ - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0658, E0778. -For more information about an error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gates/feature-gate-linkage.rs b/src/test/ui/feature-gates/feature-gate-linkage.rs index 15b8d442a..505f31ec6 100644 --- a/src/test/ui/feature-gates/feature-gate-linkage.rs +++ b/src/test/ui/feature-gates/feature-gate-linkage.rs @@ -1,5 +1,5 @@ extern "C" { - #[linkage = "extern_weak"] static foo: isize; + #[linkage = "extern_weak"] static foo: *mut isize; //~^ ERROR: the `linkage` attribute is experimental and not portable } diff --git a/src/test/ui/feature-gates/feature-gate-linkage.stderr b/src/test/ui/feature-gates/feature-gate-linkage.stderr index 3e5b79bfd..a1c73e555 100644 --- a/src/test/ui/feature-gates/feature-gate-linkage.stderr +++ b/src/test/ui/feature-gates/feature-gate-linkage.stderr @@ -1,7 +1,7 @@ error[E0658]: the `linkage` attribute is experimental and not portable across platforms --> $DIR/feature-gate-linkage.rs:2:5 | -LL | #[linkage = "extern_weak"] static foo: isize; +LL | #[linkage = "extern_weak"] static foo: *mut isize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #29603 <https://github.com/rust-lang/rust/issues/29603> for more information diff --git a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_verbatim.rs b/src/test/ui/feature-gates/feature-gate-native_link_modifiers_verbatim.rs deleted file mode 100644 index 7b09195dc..000000000 --- a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_verbatim.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[link(name = "foo", modifiers = "+verbatim")] -//~^ ERROR: linking modifier `verbatim` is unstable -extern "C" {} - -fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_verbatim.stderr b/src/test/ui/feature-gates/feature-gate-native_link_modifiers_verbatim.stderr deleted file mode 100644 index 3bfbeb8db..000000000 --- a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_verbatim.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: linking modifier `verbatim` is unstable - --> $DIR/feature-gate-native_link_modifiers_verbatim.rs:1:34 - | -LL | #[link(name = "foo", modifiers = "+verbatim")] - | ^^^^^^^^^^^ - | - = note: see issue #81490 <https://github.com/rust-lang/rust/issues/81490> for more information - = help: add `#![feature(native_link_modifiers_verbatim)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr b/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr index 5a645cf4e..787670404 100644 --- a/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr +++ b/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr @@ -110,19 +110,19 @@ error: attribute should be applied to an `extern crate` item --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:25:1 | LL | #![no_link] - | ^^^^^^^^^^^ + | ^^^^^^^^^^^ not an `extern crate` item error: attribute should be applied to a free function, impl method or static --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:27:1 | LL | #![export_name = "2200"] - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ not a free function, impl method or static error[E0518]: attribute should be applied to function or closure --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:29:1 | LL | #![inline] - | ^^^^^^^^^^ + | ^^^^^^^^^^ not a function or closure error: `macro_export` attribute cannot be used at crate level --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:12:1 diff --git a/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs b/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs index 8db12e55d..1fa315f3d 100644 --- a/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs +++ b/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs @@ -1,6 +1,6 @@ //~ NOTE not a function //~| NOTE not a foreign function or static -//~| NOTE not a function or static +//~| NOTE cannot be applied to crates //~| NOTE not an `extern` block // This test enumerates as many compiler-builtin ungated attributes as // possible (that is, all the mutually compatible ones), and checks diff --git a/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr b/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr index 310d1f720..300392679 100644 --- a/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr +++ b/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr @@ -403,7 +403,7 @@ warning: attribute should be applied to a function definition --> $DIR/issue-43106-gating-of-builtin-attrs.rs:62:1 | LL | #![cold] - | ^^^^^^^^ + | ^^^^^^^^ cannot be applied to crates | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! @@ -411,7 +411,7 @@ warning: attribute should be applied to an `extern` block with non-Rust ABI --> $DIR/issue-43106-gating-of-builtin-attrs.rs:64:1 | LL | #![link()] - | ^^^^^^^^^^ + | ^^^^^^^^^^ not an `extern` block | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! @@ -419,7 +419,7 @@ warning: attribute should be applied to a foreign function or static --> $DIR/issue-43106-gating-of-builtin-attrs.rs:66:1 | LL | #![link_name = "1900"] - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ not a foreign function or static | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! @@ -427,7 +427,7 @@ warning: attribute should be applied to a function or static --> $DIR/issue-43106-gating-of-builtin-attrs.rs:69:1 | LL | #![link_section = "1800"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^ not a function or static | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! diff --git a/src/test/ui/fmt/format-raw-string-error.rs b/src/test/ui/fmt/format-raw-string-error.rs new file mode 100644 index 000000000..9f0bc01a7 --- /dev/null +++ b/src/test/ui/fmt/format-raw-string-error.rs @@ -0,0 +1,3 @@ +fn main() { + println!(r#"\'\'\'\'\'\'\'\'\'\'\'\'\'\'}"#); //~ ERROR invalid format string: unmatched `}` found +} diff --git a/src/test/ui/fmt/format-raw-string-error.stderr b/src/test/ui/fmt/format-raw-string-error.stderr new file mode 100644 index 000000000..8d61950d8 --- /dev/null +++ b/src/test/ui/fmt/format-raw-string-error.stderr @@ -0,0 +1,10 @@ +error: invalid format string: unmatched `}` found + --> $DIR/format-raw-string-error.rs:2:45 + | +LL | println!(r#"\'\'\'\'\'\'\'\'\'\'\'\'\'\'}"#); + | ^ unmatched `}` in format string + | + = note: if you intended to print `}`, you can escape it using `}}` + +error: aborting due to previous error + diff --git a/src/test/ui/fmt/issue-104142.rs b/src/test/ui/fmt/issue-104142.rs new file mode 100644 index 000000000..8d7283a71 --- /dev/null +++ b/src/test/ui/fmt/issue-104142.rs @@ -0,0 +1,6 @@ +fn main() { + println!( + r#" + \"\'}、"# //~ ERROR invalid format string: unmatched `}` found + ); +} diff --git a/src/test/ui/fmt/issue-104142.stderr b/src/test/ui/fmt/issue-104142.stderr new file mode 100644 index 000000000..d41644faa --- /dev/null +++ b/src/test/ui/fmt/issue-104142.stderr @@ -0,0 +1,10 @@ +error: invalid format string: unmatched `}` found + --> $DIR/issue-104142.rs:4:9 + | +LL | \"\'}、"# + | ^ unmatched `}` in format string + | + = note: if you intended to print `}`, you can escape it using `}}` + +error: aborting due to previous error + diff --git a/src/test/ui/fmt/unicode-escape-spans.rs b/src/test/ui/fmt/unicode-escape-spans.rs new file mode 100644 index 000000000..753d91ce5 --- /dev/null +++ b/src/test/ui/fmt/unicode-escape-spans.rs @@ -0,0 +1,19 @@ +fn main() { + // 1 byte in UTF-8 + format!("\u{000041}{a}"); //~ ERROR cannot find value + format!("\u{0041}{a}"); //~ ERROR cannot find value + format!("\u{41}{a}"); //~ ERROR cannot find value + format!("\u{0}{a}"); //~ ERROR cannot find value + + // 2 bytes + format!("\u{0df}{a}"); //~ ERROR cannot find value + format!("\u{df}{a}"); //~ ERROR cannot find value + + // 3 bytes + format!("\u{00211d}{a}"); //~ ERROR cannot find value + format!("\u{211d}{a}"); //~ ERROR cannot find value + + // 4 bytes + format!("\u{1f4a3}{a}"); //~ ERROR cannot find value + format!("\u{10ffff}{a}"); //~ ERROR cannot find value +} diff --git a/src/test/ui/fmt/unicode-escape-spans.stderr b/src/test/ui/fmt/unicode-escape-spans.stderr new file mode 100644 index 000000000..1d8473f01 --- /dev/null +++ b/src/test/ui/fmt/unicode-escape-spans.stderr @@ -0,0 +1,63 @@ +error[E0425]: cannot find value `a` in this scope + --> $DIR/unicode-escape-spans.rs:3:25 + | +LL | format!("\u{000041}{a}"); + | ^ not found in this scope + +error[E0425]: cannot find value `a` in this scope + --> $DIR/unicode-escape-spans.rs:4:23 + | +LL | format!("\u{0041}{a}"); + | ^ not found in this scope + +error[E0425]: cannot find value `a` in this scope + --> $DIR/unicode-escape-spans.rs:5:21 + | +LL | format!("\u{41}{a}"); + | ^ not found in this scope + +error[E0425]: cannot find value `a` in this scope + --> $DIR/unicode-escape-spans.rs:6:20 + | +LL | format!("\u{0}{a}"); + | ^ not found in this scope + +error[E0425]: cannot find value `a` in this scope + --> $DIR/unicode-escape-spans.rs:9:22 + | +LL | format!("\u{0df}{a}"); + | ^ not found in this scope + +error[E0425]: cannot find value `a` in this scope + --> $DIR/unicode-escape-spans.rs:10:21 + | +LL | format!("\u{df}{a}"); + | ^ not found in this scope + +error[E0425]: cannot find value `a` in this scope + --> $DIR/unicode-escape-spans.rs:13:25 + | +LL | format!("\u{00211d}{a}"); + | ^ not found in this scope + +error[E0425]: cannot find value `a` in this scope + --> $DIR/unicode-escape-spans.rs:14:23 + | +LL | format!("\u{211d}{a}"); + | ^ not found in this scope + +error[E0425]: cannot find value `a` in this scope + --> $DIR/unicode-escape-spans.rs:17:24 + | +LL | format!("\u{1f4a3}{a}"); + | ^ not found in this scope + +error[E0425]: cannot find value `a` in this scope + --> $DIR/unicode-escape-spans.rs:18:25 + | +LL | format!("\u{10ffff}{a}"); + | ^ not found in this scope + +error: aborting due to 10 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/fn/signature-error-reporting-under-verbose.rs b/src/test/ui/fn/signature-error-reporting-under-verbose.rs new file mode 100644 index 000000000..d7a8c95e8 --- /dev/null +++ b/src/test/ui/fn/signature-error-reporting-under-verbose.rs @@ -0,0 +1,15 @@ +// compile-flags: -Zverbose + +fn foo(_: i32, _: i32) {} + +fn needs_ptr(_: fn(i32, u32)) {} +//~^ NOTE function defined here +//~| NOTE + +fn main() { + needs_ptr(foo); + //~^ ERROR mismatched types + //~| NOTE expected `u32`, found `i32` + //~| NOTE expected fn pointer `fn(i32, u32)` + //~| NOTE arguments to this function are incorrect +} diff --git a/src/test/ui/fn/signature-error-reporting-under-verbose.stderr b/src/test/ui/fn/signature-error-reporting-under-verbose.stderr new file mode 100644 index 000000000..6260fc8dc --- /dev/null +++ b/src/test/ui/fn/signature-error-reporting-under-verbose.stderr @@ -0,0 +1,19 @@ +error[E0308]: mismatched types + --> $DIR/signature-error-reporting-under-verbose.rs:10:15 + | +LL | needs_ptr(foo); + | --------- ^^^ expected `u32`, found `i32` + | | + | arguments to this function are incorrect + | + = note: expected fn pointer `fn(i32, u32)` + found fn item `fn(i32, i32) {foo}` +note: function defined here + --> $DIR/signature-error-reporting-under-verbose.rs:5:4 + | +LL | fn needs_ptr(_: fn(i32, u32)) {} + | ^^^^^^^^^ --------------- + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/for-loop-while/break-outside-loop.stderr b/src/test/ui/for-loop-while/break-outside-loop.stderr index 287bf9af6..9092f34df 100644 --- a/src/test/ui/for-loop-while/break-outside-loop.stderr +++ b/src/test/ui/for-loop-while/break-outside-loop.stderr @@ -9,11 +9,11 @@ LL | break 'lab; | = note: labels are unreachable through functions, closures, async blocks and modules -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/break-outside-loop.rs:10:15 | LL | let pth = break; - | ^^^^^ cannot `break` outside of a loop + | ^^^^^ cannot `break` outside of a loop or labeled block error[E0268]: `continue` outside of a loop --> $DIR/break-outside-loop.rs:11:17 @@ -38,11 +38,11 @@ LL | if cond() { break } LL | if cond() { continue } | ^^^^^^^^ cannot `continue` inside of a closure -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/break-outside-loop.rs:24:25 | LL | let unconstrained = break; - | ^^^^^ cannot `break` outside of a loop + | ^^^^^ cannot `break` outside of a loop or labeled block error[E0267]: `break` inside of a closure --> $DIR/break-outside-loop.rs:30:13 diff --git a/src/test/ui/function-pointer/unsized-ret.rs b/src/test/ui/function-pointer/unsized-ret.rs index 60af5769d..79009c5cb 100644 --- a/src/test/ui/function-pointer/unsized-ret.rs +++ b/src/test/ui/function-pointer/unsized-ret.rs @@ -1,7 +1,8 @@ #![feature(fn_traits)] #![feature(unboxed_closures)] +#![feature(tuple_trait)] -fn foo<F: Fn<T>, T>(f: Option<F>, t: T) { +fn foo<F: Fn<T>, T:std::marker::Tuple>(f: Option<F>, t: T) { let y = (f.unwrap()).call(t); } diff --git a/src/test/ui/function-pointer/unsized-ret.stderr b/src/test/ui/function-pointer/unsized-ret.stderr index bec3e2aa3..40bf7a389 100644 --- a/src/test/ui/function-pointer/unsized-ret.stderr +++ b/src/test/ui/function-pointer/unsized-ret.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/unsized-ret.rs:9:27 + --> $DIR/unsized-ret.rs:10:27 | LL | foo::<fn() -> str, _>(None, ()); | --------------------- ^^^^ doesn't have a size known at compile-time @@ -9,13 +9,13 @@ LL | foo::<fn() -> str, _>(None, ()); = help: within `fn() -> str`, the trait `Sized` is not implemented for `str` = note: required because it appears within the type `fn() -> str` note: required by a bound in `foo` - --> $DIR/unsized-ret.rs:4:11 + --> $DIR/unsized-ret.rs:5:11 | -LL | fn foo<F: Fn<T>, T>(f: Option<F>, t: T) { +LL | fn foo<F: Fn<T>, T:std::marker::Tuple>(f: Option<F>, t: T) { | ^^^^^ required by this bound in `foo` error[E0277]: the size for values of type `(dyn std::fmt::Display + 'a)` cannot be known at compilation time - --> $DIR/unsized-ret.rs:12:66 + --> $DIR/unsized-ret.rs:13:66 | LL | foo::<for<'a> fn(&'a ()) -> (dyn std::fmt::Display + 'a), _>(None, (&(),)); | ------------------------------------------------------------ ^^^^ doesn't have a size known at compile-time @@ -25,9 +25,9 @@ LL | foo::<for<'a> fn(&'a ()) -> (dyn std::fmt::Display + 'a), _>(None, (&() = help: within `for<'a> fn(&'a ()) -> (dyn std::fmt::Display + 'a)`, the trait `for<'a> Sized` is not implemented for `(dyn std::fmt::Display + 'a)` = note: required because it appears within the type `for<'a> fn(&'a ()) -> (dyn std::fmt::Display + 'a)` note: required by a bound in `foo` - --> $DIR/unsized-ret.rs:4:11 + --> $DIR/unsized-ret.rs:5:11 | -LL | fn foo<F: Fn<T>, T>(f: Option<F>, t: T) { +LL | fn foo<F: Fn<T>, T:std::marker::Tuple>(f: Option<F>, t: T) { | ^^^^^ required by this bound in `foo` error: aborting due to 2 previous errors diff --git a/src/test/ui/generator/auto-trait-regions.stderr b/src/test/ui/generator/auto-trait-regions.stderr index 23324af61..0b1f34aeb 100644 --- a/src/test/ui/generator/auto-trait-regions.stderr +++ b/src/test/ui/generator/auto-trait-regions.stderr @@ -4,7 +4,7 @@ error[E0716]: temporary value dropped while borrowed LL | let a = A(&mut true, &mut true, No); | ^^^^ - temporary value is freed at the end of this statement | | - | creates a temporary which is freed while still in use + | creates a temporary value which is freed while still in use ... LL | assert_foo(a); | - borrow later used here @@ -17,7 +17,7 @@ error[E0716]: temporary value dropped while borrowed LL | let a = A(&mut true, &mut true, No); | ^^^^ - temporary value is freed at the end of this statement | | - | creates a temporary which is freed while still in use + | creates a temporary value which is freed while still in use ... LL | assert_foo(a); | - borrow later used here diff --git a/src/test/ui/generator/clone-impl-async.rs b/src/test/ui/generator/clone-impl-async.rs index 83c51526b..9e9b59d36 100644 --- a/src/test/ui/generator/clone-impl-async.rs +++ b/src/test/ui/generator/clone-impl-async.rs @@ -15,42 +15,42 @@ fn main() { drop(non_clone); }; check_copy(&inner_non_clone); - //~^ ERROR the trait bound `impl Future<Output = ()>: Copy` is not satisfied + //~^ ERROR : Copy` is not satisfied check_clone(&inner_non_clone); - //~^ ERROR the trait bound `impl Future<Output = ()>: Clone` is not satisfied + //~^ ERROR : Clone` is not satisfied let non_clone = NonClone; let outer_non_clone = async move { drop(non_clone); }; check_copy(&outer_non_clone); - //~^ ERROR the trait bound `impl Future<Output = ()>: Copy` is not satisfied + //~^ ERROR : Copy` is not satisfied check_clone(&outer_non_clone); - //~^ ERROR the trait bound `impl Future<Output = ()>: Clone` is not satisfied + //~^ ERROR : Clone` is not satisfied let maybe_copy_clone = async move {}; check_copy(&maybe_copy_clone); - //~^ ERROR the trait bound `impl Future<Output = ()>: Copy` is not satisfied + //~^ ERROR : Copy` is not satisfied check_clone(&maybe_copy_clone); - //~^ ERROR the trait bound `impl Future<Output = ()>: Clone` is not satisfied + //~^ ERROR : Clone` is not satisfied let inner_non_clone_fn = the_inner_non_clone_fn(); check_copy(&inner_non_clone_fn); - //~^ ERROR the trait bound `impl Future<Output = ()>: Copy` is not satisfied + //~^ ERROR : Copy` is not satisfied check_clone(&inner_non_clone_fn); - //~^ ERROR the trait bound `impl Future<Output = ()>: Clone` is not satisfied + //~^ ERROR : Clone` is not satisfied let outer_non_clone_fn = the_outer_non_clone_fn(NonClone); check_copy(&outer_non_clone_fn); - //~^ ERROR the trait bound `impl Future<Output = ()>: Copy` is not satisfied + //~^ ERROR : Copy` is not satisfied check_clone(&outer_non_clone_fn); - //~^ ERROR the trait bound `impl Future<Output = ()>: Clone` is not satisfied + //~^ ERROR : Clone` is not satisfied let maybe_copy_clone_fn = the_maybe_copy_clone_fn(); check_copy(&maybe_copy_clone_fn); - //~^ ERROR the trait bound `impl Future<Output = ()>: Copy` is not satisfied + //~^ ERROR : Copy` is not satisfied check_clone(&maybe_copy_clone_fn); - //~^ ERROR the trait bound `impl Future<Output = ()>: Clone` is not satisfied + //~^ ERROR : Clone` is not satisfied } async fn the_inner_non_clone_fn() { @@ -64,8 +64,7 @@ async fn the_outer_non_clone_fn(non_clone: NonClone) { drop(non_clone); } -async fn the_maybe_copy_clone_fn() { -} +async fn the_maybe_copy_clone_fn() {} fn check_copy<T: Copy>(_x: &T) {} fn check_clone<T: Clone>(_x: &T) {} diff --git a/src/test/ui/generator/clone-impl-async.stderr b/src/test/ui/generator/clone-impl-async.stderr index cbb58d2af..985472887 100644 --- a/src/test/ui/generator/clone-impl-async.stderr +++ b/src/test/ui/generator/clone-impl-async.stderr @@ -1,83 +1,83 @@ -error[E0277]: the trait bound `impl Future<Output = ()>: Copy` is not satisfied +error[E0277]: the trait bound `[async block@$DIR/clone-impl-async.rs:12:27: 16:6]: Copy` is not satisfied --> $DIR/clone-impl-async.rs:17:16 | LL | check_copy(&inner_non_clone); - | ---------- ^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `impl Future<Output = ()>` + | ---------- ^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `[async block@$DIR/clone-impl-async.rs:12:27: 16:6]` | | | required by a bound introduced by this call | note: required by a bound in `check_copy` - --> $DIR/clone-impl-async.rs:70:18 + --> $DIR/clone-impl-async.rs:69:18 | LL | fn check_copy<T: Copy>(_x: &T) {} | ^^^^ required by this bound in `check_copy` -error[E0277]: the trait bound `impl Future<Output = ()>: Clone` is not satisfied +error[E0277]: the trait bound `[async block@$DIR/clone-impl-async.rs:12:27: 16:6]: Clone` is not satisfied --> $DIR/clone-impl-async.rs:19:17 | LL | check_clone(&inner_non_clone); - | ----------- ^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `impl Future<Output = ()>` + | ----------- ^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `[async block@$DIR/clone-impl-async.rs:12:27: 16:6]` | | | required by a bound introduced by this call | note: required by a bound in `check_clone` - --> $DIR/clone-impl-async.rs:71:19 + --> $DIR/clone-impl-async.rs:70:19 | LL | fn check_clone<T: Clone>(_x: &T) {} | ^^^^^ required by this bound in `check_clone` -error[E0277]: the trait bound `impl Future<Output = ()>: Copy` is not satisfied +error[E0277]: the trait bound `[async block@$DIR/clone-impl-async.rs:23:27: 25:6]: Copy` is not satisfied --> $DIR/clone-impl-async.rs:26:16 | LL | check_copy(&outer_non_clone); - | ---------- ^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `impl Future<Output = ()>` + | ---------- ^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `[async block@$DIR/clone-impl-async.rs:23:27: 25:6]` | | | required by a bound introduced by this call | note: required by a bound in `check_copy` - --> $DIR/clone-impl-async.rs:70:18 + --> $DIR/clone-impl-async.rs:69:18 | LL | fn check_copy<T: Copy>(_x: &T) {} | ^^^^ required by this bound in `check_copy` -error[E0277]: the trait bound `impl Future<Output = ()>: Clone` is not satisfied +error[E0277]: the trait bound `[async block@$DIR/clone-impl-async.rs:23:27: 25:6]: Clone` is not satisfied --> $DIR/clone-impl-async.rs:28:17 | LL | check_clone(&outer_non_clone); - | ----------- ^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `impl Future<Output = ()>` + | ----------- ^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `[async block@$DIR/clone-impl-async.rs:23:27: 25:6]` | | | required by a bound introduced by this call | note: required by a bound in `check_clone` - --> $DIR/clone-impl-async.rs:71:19 + --> $DIR/clone-impl-async.rs:70:19 | LL | fn check_clone<T: Clone>(_x: &T) {} | ^^^^^ required by this bound in `check_clone` -error[E0277]: the trait bound `impl Future<Output = ()>: Copy` is not satisfied +error[E0277]: the trait bound `[async block@$DIR/clone-impl-async.rs:31:28: 31:41]: Copy` is not satisfied --> $DIR/clone-impl-async.rs:32:16 | LL | check_copy(&maybe_copy_clone); - | ---------- ^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `impl Future<Output = ()>` + | ---------- ^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `[async block@$DIR/clone-impl-async.rs:31:28: 31:41]` | | | required by a bound introduced by this call | note: required by a bound in `check_copy` - --> $DIR/clone-impl-async.rs:70:18 + --> $DIR/clone-impl-async.rs:69:18 | LL | fn check_copy<T: Copy>(_x: &T) {} | ^^^^ required by this bound in `check_copy` -error[E0277]: the trait bound `impl Future<Output = ()>: Clone` is not satisfied +error[E0277]: the trait bound `[async block@$DIR/clone-impl-async.rs:31:28: 31:41]: Clone` is not satisfied --> $DIR/clone-impl-async.rs:34:17 | LL | check_clone(&maybe_copy_clone); - | ----------- ^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `impl Future<Output = ()>` + | ----------- ^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `[async block@$DIR/clone-impl-async.rs:31:28: 31:41]` | | | required by a bound introduced by this call | note: required by a bound in `check_clone` - --> $DIR/clone-impl-async.rs:71:19 + --> $DIR/clone-impl-async.rs:70:19 | LL | fn check_clone<T: Clone>(_x: &T) {} | ^^^^^ required by this bound in `check_clone` @@ -91,7 +91,7 @@ LL | check_copy(&inner_non_clone_fn); | required by a bound introduced by this call | note: required by a bound in `check_copy` - --> $DIR/clone-impl-async.rs:70:18 + --> $DIR/clone-impl-async.rs:69:18 | LL | fn check_copy<T: Copy>(_x: &T) {} | ^^^^ required by this bound in `check_copy` @@ -105,7 +105,7 @@ LL | check_clone(&inner_non_clone_fn); | required by a bound introduced by this call | note: required by a bound in `check_clone` - --> $DIR/clone-impl-async.rs:71:19 + --> $DIR/clone-impl-async.rs:70:19 | LL | fn check_clone<T: Clone>(_x: &T) {} | ^^^^^ required by this bound in `check_clone` @@ -119,7 +119,7 @@ LL | check_copy(&outer_non_clone_fn); | required by a bound introduced by this call | note: required by a bound in `check_copy` - --> $DIR/clone-impl-async.rs:70:18 + --> $DIR/clone-impl-async.rs:69:18 | LL | fn check_copy<T: Copy>(_x: &T) {} | ^^^^ required by this bound in `check_copy` @@ -133,7 +133,7 @@ LL | check_clone(&outer_non_clone_fn); | required by a bound introduced by this call | note: required by a bound in `check_clone` - --> $DIR/clone-impl-async.rs:71:19 + --> $DIR/clone-impl-async.rs:70:19 | LL | fn check_clone<T: Clone>(_x: &T) {} | ^^^^^ required by this bound in `check_clone` @@ -147,7 +147,7 @@ LL | check_copy(&maybe_copy_clone_fn); | required by a bound introduced by this call | note: required by a bound in `check_copy` - --> $DIR/clone-impl-async.rs:70:18 + --> $DIR/clone-impl-async.rs:69:18 | LL | fn check_copy<T: Copy>(_x: &T) {} | ^^^^ required by this bound in `check_copy` @@ -161,7 +161,7 @@ LL | check_clone(&maybe_copy_clone_fn); | required by a bound introduced by this call | note: required by a bound in `check_clone` - --> $DIR/clone-impl-async.rs:71:19 + --> $DIR/clone-impl-async.rs:70:19 | LL | fn check_clone<T: Clone>(_x: &T) {} | ^^^^^ required by this bound in `check_clone` diff --git a/src/test/ui/generator/issue-52398.stderr b/src/test/ui/generator/issue-52398.stderr index 30a6732f7..539343275 100644 --- a/src/test/ui/generator/issue-52398.stderr +++ b/src/test/ui/generator/issue-52398.stderr @@ -4,7 +4,7 @@ warning: unused generator that must be used LL | / move || { LL | | A.test(yield); LL | | }; - | |______^ + | |_____^ | = note: generators are lazy and do nothing unless resumed = note: `#[warn(unused_must_use)]` on by default @@ -16,7 +16,7 @@ LL | / static move || { LL | | yield *y.borrow(); LL | | return "Done"; LL | | }; - | |______^ + | |_____^ | = note: generators are lazy and do nothing unless resumed diff --git a/src/test/ui/generator/issue-57084.stderr b/src/test/ui/generator/issue-57084.stderr index 29aca9440..8f1fc5e80 100644 --- a/src/test/ui/generator/issue-57084.stderr +++ b/src/test/ui/generator/issue-57084.stderr @@ -7,7 +7,7 @@ LL | | loop { LL | | yield LL | | } LL | | }; - | |______^ + | |_____^ | = note: generators are lazy and do nothing unless resumed = note: `#[warn(unused_must_use)]` on by default diff --git a/src/test/ui/generator/match-bindings.stderr b/src/test/ui/generator/match-bindings.stderr index b911b6661..3dd2d5954 100644 --- a/src/test/ui/generator/match-bindings.stderr +++ b/src/test/ui/generator/match-bindings.stderr @@ -8,7 +8,7 @@ LL | | match Enum::A(String::new()) { ... | LL | | } LL | | }; - | |______^ + | |_____^ | = note: generators are lazy and do nothing unless resumed = note: `#[warn(unused_must_use)]` on by default diff --git a/src/test/ui/generator/print/generator-print-verbose-1.stderr b/src/test/ui/generator/print/generator-print-verbose-1.stderr index 2e0207804..ed0628bbb 100644 --- a/src/test/ui/generator/print/generator-print-verbose-1.stderr +++ b/src/test/ui/generator/print/generator-print-verbose-1.stderr @@ -9,7 +9,7 @@ note: generator is not `Send` as this value is used across a yield --> $DIR/generator-print-verbose-1.rs:35:9 | LL | let _non_send_gen = make_non_send_generator(); - | ------------- has type `Opaque(DefId(0:44 ~ generator_print_verbose_1[749a]::make_non_send_generator::{opaque#0}), [])` which is not `Send` + | ------------- has type `Opaque(DefId(0:34 ~ generator_print_verbose_1[749a]::make_non_send_generator::{opaque#0}), [])` which is not `Send` LL | yield; | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later LL | }; @@ -35,17 +35,17 @@ note: required because it's used within this generator | LL | || { | ^^ -note: required because it appears within the type `Opaque(DefId(0:45 ~ generator_print_verbose_1[749a]::make_gen2::{opaque#0}), [std::sync::Arc<std::cell::RefCell<i32>>])` +note: required because it appears within the type `Opaque(DefId(0:35 ~ generator_print_verbose_1[749a]::make_gen2::{opaque#0}), [std::sync::Arc<std::cell::RefCell<i32>>])` --> $DIR/generator-print-verbose-1.rs:41:30 | LL | pub fn make_gen2<T>(t: T) -> impl Generator<Return = T> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required because it appears within the type `Opaque(DefId(0:46 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])` +note: required because it appears within the type `Opaque(DefId(0:36 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])` --> $DIR/generator-print-verbose-1.rs:47:34 | LL | fn make_non_send_generator2() -> impl Generator<Return = Arc<RefCell<i32>>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `Opaque(DefId(0:46 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])`, `()` + = note: required because it captures the following types: `Opaque(DefId(0:36 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])`, `()` note: required because it's used within this generator --> $DIR/generator-print-verbose-1.rs:52:20 | diff --git a/src/test/ui/generator/reborrow-mut-upvar.stderr b/src/test/ui/generator/reborrow-mut-upvar.stderr index e83dbf833..2e1fec35e 100644 --- a/src/test/ui/generator/reborrow-mut-upvar.stderr +++ b/src/test/ui/generator/reborrow-mut-upvar.stderr @@ -8,7 +8,7 @@ LL | | yield; ... | LL | | *bar = 2; LL | | }; - | |______^ + | |_____^ | = note: generators are lazy and do nothing unless resumed = note: `#[warn(unused_must_use)]` on by default diff --git a/src/test/ui/generator/too-live-local-in-immovable-gen.stderr b/src/test/ui/generator/too-live-local-in-immovable-gen.stderr index 5cb43067f..e262f213f 100644 --- a/src/test/ui/generator/too-live-local-in-immovable-gen.stderr +++ b/src/test/ui/generator/too-live-local-in-immovable-gen.stderr @@ -8,7 +8,7 @@ LL | | // and it should also find out that `a` is not live. ... | LL | | let _ = &a; LL | | }; - | |__________^ + | |_________^ | = note: generators are lazy and do nothing unless resumed = note: `#[warn(unused_must_use)]` on by default diff --git a/src/test/ui/generator/unresolved-ct-var.rs b/src/test/ui/generator/unresolved-ct-var.rs new file mode 100644 index 000000000..0a1570fc2 --- /dev/null +++ b/src/test/ui/generator/unresolved-ct-var.rs @@ -0,0 +1,14 @@ +// incremental +// edition:2021 + +fn main() { + let _ = async { + let s = std::array::from_fn(|_| ()).await; + //~^ ERROR `[(); _]` is not a future + //~| ERROR type inside `async` block must be known in this context + //~| ERROR type inside `async` block must be known in this context + //~| ERROR type inside `async` block must be known in this context + //~| ERROR type inside `async` block must be known in this context + //~| ERROR type inside `async` block must be known in this context + }; +} diff --git a/src/test/ui/generator/unresolved-ct-var.stderr b/src/test/ui/generator/unresolved-ct-var.stderr new file mode 100644 index 000000000..fdf00dfad --- /dev/null +++ b/src/test/ui/generator/unresolved-ct-var.stderr @@ -0,0 +1,78 @@ +error[E0277]: `[(); _]` is not a future + --> $DIR/unresolved-ct-var.rs:6:44 + | +LL | let s = std::array::from_fn(|_| ()).await; + | ---------------------------^^^^^^ + | | | + | | `[(); _]` is not a future + | | help: remove the `.await` + | this call returns `[(); _]` + | + = help: the trait `Future` is not implemented for `[(); _]` + = note: [(); _] must be a future or must implement `IntoFuture` to be awaited + = note: required for `[(); _]` to implement `IntoFuture` + +error[E0698]: type inside `async` block must be known in this context + --> $DIR/unresolved-ct-var.rs:6:17 + | +LL | let s = std::array::from_fn(|_| ()).await; + | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` + | +note: the type is part of the `async` block because of this `await` + --> $DIR/unresolved-ct-var.rs:6:44 + | +LL | let s = std::array::from_fn(|_| ()).await; + | ^^^^^^ + +error[E0698]: type inside `async` block must be known in this context + --> $DIR/unresolved-ct-var.rs:6:17 + | +LL | let s = std::array::from_fn(|_| ()).await; + | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` + | +note: the type is part of the `async` block because of this `await` + --> $DIR/unresolved-ct-var.rs:6:44 + | +LL | let s = std::array::from_fn(|_| ()).await; + | ^^^^^^ + +error[E0698]: type inside `async` block must be known in this context + --> $DIR/unresolved-ct-var.rs:6:17 + | +LL | let s = std::array::from_fn(|_| ()).await; + | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` + | +note: the type is part of the `async` block because of this `await` + --> $DIR/unresolved-ct-var.rs:6:44 + | +LL | let s = std::array::from_fn(|_| ()).await; + | ^^^^^^ + +error[E0698]: type inside `async` block must be known in this context + --> $DIR/unresolved-ct-var.rs:6:17 + | +LL | let s = std::array::from_fn(|_| ()).await; + | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` + | +note: the type is part of the `async` block because of this `await` + --> $DIR/unresolved-ct-var.rs:6:44 + | +LL | let s = std::array::from_fn(|_| ()).await; + | ^^^^^^ + +error[E0698]: type inside `async` block must be known in this context + --> $DIR/unresolved-ct-var.rs:6:17 + | +LL | let s = std::array::from_fn(|_| ()).await; + | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` + | +note: the type is part of the `async` block because of this `await` + --> $DIR/unresolved-ct-var.rs:6:44 + | +LL | let s = std::array::from_fn(|_| ()).await; + | ^^^^^^ + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0277, E0698. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/generator/yield-in-args-rev.stderr b/src/test/ui/generator/yield-in-args-rev.stderr index c9e1ab722..a87248f66 100644 --- a/src/test/ui/generator/yield-in-args-rev.stderr +++ b/src/test/ui/generator/yield-in-args-rev.stderr @@ -5,7 +5,7 @@ LL | / || { LL | | let b = true; LL | | foo(yield, &b); LL | | }; - | |______^ + | |_____^ | = note: generators are lazy and do nothing unless resumed = note: `#[warn(unused_must_use)]` on by default diff --git a/src/test/ui/generator/yield-in-box.stderr b/src/test/ui/generator/yield-in-box.stderr index 8587e1dc6..9d03ee008 100644 --- a/src/test/ui/generator/yield-in-box.stderr +++ b/src/test/ui/generator/yield-in-box.stderr @@ -8,7 +8,7 @@ LL | | let _t = box (&x, yield 0, &y); ... | LL | | } LL | | }; - | |______^ + | |_____^ | = note: generators are lazy and do nothing unless resumed = note: `#[warn(unused_must_use)]` on by default diff --git a/src/test/ui/generator/yield-in-initializer.stderr b/src/test/ui/generator/yield-in-initializer.stderr index 07de24662..ed14a2e32 100644 --- a/src/test/ui/generator/yield-in-initializer.stderr +++ b/src/test/ui/generator/yield-in-initializer.stderr @@ -8,7 +8,7 @@ LL | | // See https://github.com/rust-lang/rust/issues/52792 ... | LL | | } LL | | }; - | |______^ + | |_____^ | = note: generators are lazy and do nothing unless resumed = note: `#[warn(unused_must_use)]` on by default diff --git a/src/test/ui/generator/yield-subtype.stderr b/src/test/ui/generator/yield-subtype.stderr index fe10477bf..97862e91c 100644 --- a/src/test/ui/generator/yield-subtype.stderr +++ b/src/test/ui/generator/yield-subtype.stderr @@ -5,7 +5,7 @@ LL | / || { LL | | yield a; LL | | yield b; LL | | }; - | |______^ + | |_____^ | = note: generators are lazy and do nothing unless resumed = note: `#[warn(unused_must_use)]` on by default diff --git a/src/test/ui/generic-associated-types/bugs/hrtb-implied-1.stderr b/src/test/ui/generic-associated-types/bugs/hrtb-implied-1.stderr index 414999881..1c9abc4e8 100644 --- a/src/test/ui/generic-associated-types/bugs/hrtb-implied-1.stderr +++ b/src/test/ui/generic-associated-types/bugs/hrtb-implied-1.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/hrtb-implied-1.rs:31:22 | LL | let slice = &mut (); - | ^^ creates a temporary which is freed while still in use + | ^^ creates a temporary value which is freed while still in use ... LL | print_items::<WindowsMut<'_>>(windows); | -------------------------------------- argument requires that borrow lasts for `'static` diff --git a/src/test/ui/generic-associated-types/bugs/issue-100013.rs b/src/test/ui/generic-associated-types/bugs/issue-100013.rs new file mode 100644 index 000000000..fc4e47a3b --- /dev/null +++ b/src/test/ui/generic-associated-types/bugs/issue-100013.rs @@ -0,0 +1,39 @@ +// check-fail +// known-bug +// edition: 2021 + +// We really should accept this, but we need implied bounds between the regions +// in a generator interior. + +pub trait FutureIterator { + type Future<'s, 'cx>: Send + where + 's: 'cx; +} + +fn call<I: FutureIterator>() -> impl Send { + async { // a generator checked for autotrait impl `Send` + //~^ lifetime bound not satisfied + let x = None::<I::Future<'_, '_>>; // a type referencing GAT + async {}.await; // a yield point + } +} + +fn call2<'a, 'b, I: FutureIterator>() -> impl Send { + async { // a generator checked for autotrait impl `Send` + //~^ lifetime bound not satisfied + let x = None::<I::Future<'a, 'b>>; // a type referencing GAT + //~^ lifetime may not live long enough + async {}.await; // a yield point + } +} + +fn call3<'a: 'b, 'b, I: FutureIterator>() -> impl Send { + async { // a generator checked for autotrait impl `Send` + //~^ lifetime bound not satisfied + let x = None::<I::Future<'a, 'b>>; // a type referencing GAT + async {}.await; // a yield point + } +} + +fn main() {} diff --git a/src/test/ui/generic-associated-types/bugs/issue-100013.stderr b/src/test/ui/generic-associated-types/bugs/issue-100013.stderr new file mode 100644 index 000000000..72ae288dc --- /dev/null +++ b/src/test/ui/generic-associated-types/bugs/issue-100013.stderr @@ -0,0 +1,82 @@ +error: lifetime bound not satisfied + --> $DIR/issue-100013.rs:15:5 + | +LL | / async { // a generator checked for autotrait impl `Send` +LL | | +LL | | let x = None::<I::Future<'_, '_>>; // a type referencing GAT +LL | | async {}.await; // a yield point +LL | | } + | |_____^ + | +note: the lifetime defined here... + --> $DIR/issue-100013.rs:17:38 + | +LL | let x = None::<I::Future<'_, '_>>; // a type referencing GAT + | ^^ +note: ...must outlive the lifetime defined here + --> $DIR/issue-100013.rs:17:34 + | +LL | let x = None::<I::Future<'_, '_>>; // a type referencing GAT + | ^^ + = note: this is a known limitation that will be removed in the future (see issue #100013 <https://github.com/rust-lang/rust/issues/100013> for more information) + +error: lifetime bound not satisfied + --> $DIR/issue-100013.rs:23:5 + | +LL | / async { // a generator checked for autotrait impl `Send` +LL | | +LL | | let x = None::<I::Future<'a, 'b>>; // a type referencing GAT +LL | | +LL | | async {}.await; // a yield point +LL | | } + | |_____^ + | +note: the lifetime defined here... + --> $DIR/issue-100013.rs:22:14 + | +LL | fn call2<'a, 'b, I: FutureIterator>() -> impl Send { + | ^^ +note: ...must outlive the lifetime defined here + --> $DIR/issue-100013.rs:22:10 + | +LL | fn call2<'a, 'b, I: FutureIterator>() -> impl Send { + | ^^ + = note: this is a known limitation that will be removed in the future (see issue #100013 <https://github.com/rust-lang/rust/issues/100013> for more information) + +error: lifetime may not live long enough + --> $DIR/issue-100013.rs:25:17 + | +LL | fn call2<'a, 'b, I: FutureIterator>() -> impl Send { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +... +LL | let x = None::<I::Future<'a, 'b>>; // a type referencing GAT + | ^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` + +error: lifetime bound not satisfied + --> $DIR/issue-100013.rs:32:5 + | +LL | / async { // a generator checked for autotrait impl `Send` +LL | | +LL | | let x = None::<I::Future<'a, 'b>>; // a type referencing GAT +LL | | async {}.await; // a yield point +LL | | } + | |_____^ + | +note: the lifetime defined here... + --> $DIR/issue-100013.rs:31:18 + | +LL | fn call3<'a: 'b, 'b, I: FutureIterator>() -> impl Send { + | ^^ +note: ...must outlive the lifetime defined here + --> $DIR/issue-100013.rs:31:10 + | +LL | fn call3<'a: 'b, 'b, I: FutureIterator>() -> impl Send { + | ^^ + = note: this is a known limitation that will be removed in the future (see issue #100013 <https://github.com/rust-lang/rust/issues/100013> for more information) + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/generic-associated-types/bugs/issue-80626.rs b/src/test/ui/generic-associated-types/bugs/issue-80626.rs index f6aa6b36e..d6e18010f 100644 --- a/src/test/ui/generic-associated-types/bugs/issue-80626.rs +++ b/src/test/ui/generic-associated-types/bugs/issue-80626.rs @@ -1,7 +1,4 @@ -// check-fail -// known-bug: #80626 - -// This should pass, but it requires `Sized` to be coinductive. +// check-pass trait Allocator { type Allocated<T>; @@ -9,7 +6,7 @@ trait Allocator { enum LinkedList<A: Allocator> { Head, - Next(A::Allocated<Self>) + Next(A::Allocated<Self>), } fn main() {} diff --git a/src/test/ui/generic-associated-types/bugs/issue-80626.stderr b/src/test/ui/generic-associated-types/bugs/issue-80626.stderr deleted file mode 100644 index 9a0f332ed..000000000 --- a/src/test/ui/generic-associated-types/bugs/issue-80626.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0275]: overflow evaluating the requirement `LinkedList<A>: Sized` - --> $DIR/issue-80626.rs:12:10 - | -LL | Next(A::Allocated<Self>) - | ^^^^^^^^^^^^^^^^^^ - | -note: required by a bound in `Allocator::Allocated` - --> $DIR/issue-80626.rs:7:20 - | -LL | type Allocated<T>; - | ^ required by this bound in `Allocator::Allocated` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/generic-associated-types/elided-in-expr-position.stderr b/src/test/ui/generic-associated-types/elided-in-expr-position.stderr index 20f35c3c1..a9996123f 100644 --- a/src/test/ui/generic-associated-types/elided-in-expr-position.stderr +++ b/src/test/ui/generic-associated-types/elided-in-expr-position.stderr @@ -11,7 +11,7 @@ LL | type Assoc<'a> where Self: 'a; | ^^^^^ -- help: add missing lifetime argument | -LL | fn g(&self) -> Self::Assoc<'a>; +LL | fn g(&self) -> Self::Assoc<'_>; | ~~~~~~~~~ error[E0107]: missing generics for associated type `Trait::Assoc` @@ -27,7 +27,7 @@ LL | type Assoc<'a> where Self: 'a; | ^^^^^ -- help: add missing lifetime argument | -LL | fn g(&self) -> Self::Assoc<'a> { +LL | fn g(&self) -> Self::Assoc<'_> { | ~~~~~~~~~ error: aborting due to 2 previous errors diff --git a/src/test/ui/generic-associated-types/gat-trait-path-parenthesised-args.stderr b/src/test/ui/generic-associated-types/gat-trait-path-parenthesised-args.stderr index e55a21e19..165779796 100644 --- a/src/test/ui/generic-associated-types/gat-trait-path-parenthesised-args.stderr +++ b/src/test/ui/generic-associated-types/gat-trait-path-parenthesised-args.stderr @@ -36,7 +36,7 @@ LL | type Y<'a>; | ^ -- help: add missing lifetime argument | -LL | fn foo<'a>(arg: Box<dyn X<Y('a, 'a) = &'a ()>>) {} +LL | fn foo<'a>(arg: Box<dyn X<Y('_, 'a) = &'a ()>>) {} | +++ error[E0107]: this associated type takes 0 generic arguments but 1 generic argument was supplied @@ -66,7 +66,7 @@ LL | type Y<'a>; | ^ -- help: add missing lifetime argument | -LL | fn bar<'a>(arg: Box<dyn X<Y('a) = ()>>) {} +LL | fn bar<'a>(arg: Box<dyn X<Y('_) = ()>>) {} | ++ error: aborting due to 6 previous errors diff --git a/src/test/ui/generic-associated-types/issue-81862.stderr b/src/test/ui/generic-associated-types/issue-81862.stderr index ba7980846..9e21c567c 100644 --- a/src/test/ui/generic-associated-types/issue-81862.stderr +++ b/src/test/ui/generic-associated-types/issue-81862.stderr @@ -11,7 +11,7 @@ LL | type Item<'a>; | ^^^^ -- help: add missing lifetime argument | -LL | fn next(&mut self) -> Option<Self::Item<'a>>; +LL | fn next(&mut self) -> Option<Self::Item<'_>>; | ~~~~~~~~ error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/issue-87750.rs b/src/test/ui/generic-associated-types/issue-87750.rs index 0a11a0f3a..b35657989 100644 --- a/src/test/ui/generic-associated-types/issue-87750.rs +++ b/src/test/ui/generic-associated-types/issue-87750.rs @@ -1,3 +1,5 @@ +// check-pass + trait PointerFamily { type Pointer<T>; } @@ -10,11 +12,13 @@ impl PointerFamily for RcFamily { } #[allow(dead_code)] -enum Node<T, P: PointerFamily> where P::Pointer<Node<T, P>>: Sized { +enum Node<T, P: PointerFamily> +where + P::Pointer<Node<T, P>>: Sized, +{ Cons(P::Pointer<Node<T, P>>), } fn main() { let _list: <RcFamily as PointerFamily>::Pointer<Node<i32, RcFamily>>; - //~^ ERROR overflow evaluating the requirement `Node<i32, RcFamily>: Sized` } diff --git a/src/test/ui/generic-associated-types/issue-87750.stderr b/src/test/ui/generic-associated-types/issue-87750.stderr deleted file mode 100644 index b358ca273..000000000 --- a/src/test/ui/generic-associated-types/issue-87750.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0275]: overflow evaluating the requirement `Node<i32, RcFamily>: Sized` - --> $DIR/issue-87750.rs:18:16 - | -LL | let _list: <RcFamily as PointerFamily>::Pointer<Node<i32, RcFamily>>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/generic-associated-types/issue-91139.rs b/src/test/ui/generic-associated-types/issue-91139.rs index 5fc6071c9..e321da53d 100644 --- a/src/test/ui/generic-associated-types/issue-91139.rs +++ b/src/test/ui/generic-associated-types/issue-91139.rs @@ -21,6 +21,7 @@ fn foo<T>() { //~| ERROR `T` does not live long enough //~| ERROR `T` does not live long enough //~| ERROR `T` may not live long enough + //~| ERROR `T` may not live long enough // // FIXME: This error is bogus, but it arises because we try to validate // that `<() as Foo<T>>::Type<'a>` is valid, which requires proving diff --git a/src/test/ui/generic-associated-types/issue-91139.stderr b/src/test/ui/generic-associated-types/issue-91139.stderr index 8bbe98fa1..5485570ce 100644 --- a/src/test/ui/generic-associated-types/issue-91139.stderr +++ b/src/test/ui/generic-associated-types/issue-91139.stderr @@ -22,6 +22,17 @@ error: `T` does not live long enough LL | let _: for<'a> fn(<() as Foo<T>>::Type<'a>, &'a T) = |_, _| (); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/issue-91139.rs:14:58 + | +LL | let _: for<'a> fn(<() as Foo<T>>::Type<'a>, &'a T) = |_, _| (); + | ^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn foo<T: 'static>() { + | +++++++++ + error: `T` does not live long enough --> $DIR/issue-91139.rs:14:58 | @@ -57,6 +68,6 @@ error: `T` does not live long enough LL | let _: for<'a> fn(<() as Foo<T>>::Type<'a>, &'a T) = |_, _| (); | ^^^^^^^^^ -error: aborting due to 9 previous errors +error: aborting due to 10 previous errors For more information about this error, try `rustc --explain E0310`. diff --git a/src/test/ui/generic-associated-types/missing_lifetime_args.stderr b/src/test/ui/generic-associated-types/missing_lifetime_args.stderr index 0ad1f1f8c..752587c25 100644 --- a/src/test/ui/generic-associated-types/missing_lifetime_args.stderr +++ b/src/test/ui/generic-associated-types/missing_lifetime_args.stderr @@ -11,7 +11,7 @@ LL | type Y<'a, 'b>; | ^ -- -- help: add missing lifetime arguments | -LL | fn foo<'c, 'd>(_arg: Box<dyn X<Y<'c, 'd> = (&'c u32, &'d u32)>>) {} +LL | fn foo<'c, 'd>(_arg: Box<dyn X<Y<'_, '_> = (&'c u32, &'d u32)>>) {} | ~~~~~~~~~ error[E0107]: this struct takes 3 lifetime arguments but 2 lifetime arguments were supplied @@ -47,7 +47,7 @@ LL | struct Foo<'a, 'b, 'c> { | ^^^ -- -- -- help: add missing lifetime arguments | -LL | fn f<'a>(_arg: Foo<'a, 'b, 'c>) {} +LL | fn f<'a>(_arg: Foo<'a, 'a, 'a>) {} | ++++++++ error: aborting due to 3 previous errors diff --git a/src/test/ui/generic-associated-types/own-bound-span.rs b/src/test/ui/generic-associated-types/own-bound-span.rs new file mode 100644 index 000000000..3699f7296 --- /dev/null +++ b/src/test/ui/generic-associated-types/own-bound-span.rs @@ -0,0 +1,17 @@ +struct S; + +trait D { + type P<T: Copy>; + //~^ NOTE required by this bound in `D::P` + //~| NOTE required by a bound in `D::P` +} + +impl D for S { + type P<T: Copy> = (); +} + +fn main() { + let _: <S as D>::P<String>; + //~^ ERROR the trait bound `String: Copy` is not satisfied + //~| NOTE the trait `Copy` is not implemented for `String` +} diff --git a/src/test/ui/generic-associated-types/own-bound-span.stderr b/src/test/ui/generic-associated-types/own-bound-span.stderr new file mode 100644 index 000000000..8ab8ea623 --- /dev/null +++ b/src/test/ui/generic-associated-types/own-bound-span.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `String: Copy` is not satisfied + --> $DIR/own-bound-span.rs:14:12 + | +LL | let _: <S as D>::P<String>; + | ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` + | +note: required by a bound in `D::P` + --> $DIR/own-bound-span.rs:4:15 + | +LL | type P<T: Copy>; + | ^^^^ required by this bound in `D::P` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr b/src/test/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr index e00a414ef..0a09ec5dc 100644 --- a/src/test/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr +++ b/src/test/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr @@ -11,7 +11,7 @@ LL | type Y<'a>; | ^ -- help: add missing lifetime argument | -LL | fn f2<'a>(arg : Box<dyn X<Y<'a, 1> = &'a ()>>) {} +LL | fn f2<'a>(arg : Box<dyn X<Y<'_, 1> = &'a ()>>) {} | +++ error[E0107]: this associated type takes 0 generic arguments but 1 generic argument was supplied diff --git a/src/test/ui/generic-associated-types/projection-bound-cycle-generic.rs b/src/test/ui/generic-associated-types/projection-bound-cycle-generic.rs index 58d57df63..ecf6f69c9 100644 --- a/src/test/ui/generic-associated-types/projection-bound-cycle-generic.rs +++ b/src/test/ui/generic-associated-types/projection-bound-cycle-generic.rs @@ -21,6 +21,7 @@ impl<T> Foo for Number<T> { // ``` // which it is :) type Item = [T] where [T]: Sized; + //~^ ERROR overflow evaluating the requirement `<Number<T> as Foo>::Item == _` } struct OnlySized<T> where T: Sized { f: T } @@ -40,7 +41,6 @@ impl<T> Bar for T where T: Foo { // can use the bound on `Foo::Item` for this, but that requires // `wf(<T as Foo>::Item)`, which is an invalid cycle. type Assoc = OnlySized<<T as Foo>::Item>; - //~^ ERROR overflow evaluating the requirement `<T as Foo>::Item: Sized` } fn foo<T: Print>() { diff --git a/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr b/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr index 27c1a8299..aae9a56bb 100644 --- a/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr +++ b/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr @@ -1,14 +1,8 @@ -error[E0275]: overflow evaluating the requirement `<T as Foo>::Item: Sized` - --> $DIR/projection-bound-cycle-generic.rs:42:18 +error[E0275]: overflow evaluating the requirement `<Number<T> as Foo>::Item == _` + --> $DIR/projection-bound-cycle-generic.rs:23:5 | -LL | type Assoc = OnlySized<<T as Foo>::Item>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: required by a bound in `OnlySized` - --> $DIR/projection-bound-cycle-generic.rs:26:18 - | -LL | struct OnlySized<T> where T: Sized { f: T } - | ^ required by this bound in `OnlySized` +LL | type Item = [T] where [T]: Sized; + | ^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/projection-bound-cycle.rs b/src/test/ui/generic-associated-types/projection-bound-cycle.rs index 4cad1f613..b51ae7ef2 100644 --- a/src/test/ui/generic-associated-types/projection-bound-cycle.rs +++ b/src/test/ui/generic-associated-types/projection-bound-cycle.rs @@ -24,6 +24,7 @@ impl Foo for Number { // ``` // which it is :) type Item = str where str: Sized; + //~^ ERROR overflow evaluating the requirement `<Number as Foo>::Item == _` } struct OnlySized<T> where T: Sized { f: T } @@ -43,7 +44,6 @@ impl<T> Bar for T where T: Foo { // can use the bound on `Foo::Item` for this, but that requires // `wf(<T as Foo>::Item)`, which is an invalid cycle. type Assoc = OnlySized<<T as Foo>::Item>; - //~^ ERROR overflow evaluating the requirement `<T as Foo>::Item: Sized` } fn foo<T: Print>() { diff --git a/src/test/ui/generic-associated-types/projection-bound-cycle.stderr b/src/test/ui/generic-associated-types/projection-bound-cycle.stderr index a46518c80..b1b8afeec 100644 --- a/src/test/ui/generic-associated-types/projection-bound-cycle.stderr +++ b/src/test/ui/generic-associated-types/projection-bound-cycle.stderr @@ -1,14 +1,8 @@ -error[E0275]: overflow evaluating the requirement `<T as Foo>::Item: Sized` - --> $DIR/projection-bound-cycle.rs:45:18 +error[E0275]: overflow evaluating the requirement `<Number as Foo>::Item == _` + --> $DIR/projection-bound-cycle.rs:26:5 | -LL | type Assoc = OnlySized<<T as Foo>::Item>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: required by a bound in `OnlySized` - --> $DIR/projection-bound-cycle.rs:29:18 - | -LL | struct OnlySized<T> where T: Sized { f: T } - | ^ required by this bound in `OnlySized` +LL | type Item = str where str: Sized; + | ^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/self-outlives-lint.stderr b/src/test/ui/generic-associated-types/self-outlives-lint.stderr index 58172bf06..9e9b2e18a 100644 --- a/src/test/ui/generic-associated-types/self-outlives-lint.stderr +++ b/src/test/ui/generic-associated-types/self-outlives-lint.stderr @@ -108,17 +108,6 @@ LL | type Bar<'b>; = note: this bound is currently required to ensure that impls have maximum flexibility = note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information -error: missing required bound on `Item` - --> $DIR/self-outlives-lint.rs:140:5 - | -LL | type Item<'a>; - | ^^^^^^^^^^^^^- - | | - | help: add the required where clause: `where Self: 'a` - | - = note: this bound is currently required to ensure that impls have maximum flexibility - = note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information - error: missing required bound on `Iterator` --> $DIR/self-outlives-lint.rs:142:5 | @@ -131,6 +120,17 @@ LL | type Iterator<'a>: Iterator<Item = Self::Item<'a>>; = note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information error: missing required bound on `Item` + --> $DIR/self-outlives-lint.rs:140:5 + | +LL | type Item<'a>; + | ^^^^^^^^^^^^^- + | | + | help: add the required where clause: `where Self: 'a` + | + = note: this bound is currently required to ensure that impls have maximum flexibility + = note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information + +error: missing required bound on `Item` --> $DIR/self-outlives-lint.rs:148:5 | LL | type Item<'a>; diff --git a/src/test/ui/generics/wrong-number-of-args.stderr b/src/test/ui/generics/wrong-number-of-args.stderr index 388c23fc2..0475eb908 100644 --- a/src/test/ui/generics/wrong-number-of-args.stderr +++ b/src/test/ui/generics/wrong-number-of-args.stderr @@ -812,8 +812,8 @@ LL | trait GenericLifetimeLifetimeAT<'a, 'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^ -- -- help: add missing lifetime argument | -LL | type B = Box<dyn GenericLifetimeLifetimeAT<'static, 'b, AssocTy=()>>; - | ++++ +LL | type B = Box<dyn GenericLifetimeLifetimeAT<'static, 'static, AssocTy=()>>; + | +++++++++ error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied --> $DIR/wrong-number-of-args.rs:287:26 @@ -846,8 +846,8 @@ LL | trait GenericLifetimeLifetimeTypeAT<'a, 'b, A> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- -- help: add missing lifetime argument | -LL | type B = Box<dyn GenericLifetimeLifetimeTypeAT<'static, 'b, AssocTy=()>>; - | ++++ +LL | type B = Box<dyn GenericLifetimeLifetimeTypeAT<'static, 'static, AssocTy=()>>; + | +++++++++ error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied --> $DIR/wrong-number-of-args.rs:294:26 @@ -880,8 +880,8 @@ LL | trait GenericLifetimeLifetimeTypeAT<'a, 'b, A> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- -- help: add missing lifetime argument | -LL | type C = Box<dyn GenericLifetimeLifetimeTypeAT<'static, 'b, (), AssocTy=()>>; - | ++++ +LL | type C = Box<dyn GenericLifetimeLifetimeTypeAT<'static, 'static, (), AssocTy=()>>; + | +++++++++ error[E0107]: missing generics for struct `HashMap` --> $DIR/wrong-number-of-args.rs:310:18 diff --git a/src/test/ui/issues/issue-36139-normalize-closure-sig.rs b/src/test/ui/higher-rank-trait-bounds/issue-36139-normalize-closure-sig.rs index 2d49151ff..2d49151ff 100644 --- a/src/test/ui/issues/issue-36139-normalize-closure-sig.rs +++ b/src/test/ui/higher-rank-trait-bounds/issue-36139-normalize-closure-sig.rs diff --git a/src/test/ui/issues/issue-43623.rs b/src/test/ui/higher-rank-trait-bounds/issue-43623.rs index cedcf7c36..cedcf7c36 100644 --- a/src/test/ui/issues/issue-43623.rs +++ b/src/test/ui/higher-rank-trait-bounds/issue-43623.rs diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90950.rs b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90950.rs new file mode 100644 index 000000000..ab9d9a7ce --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90950.rs @@ -0,0 +1,53 @@ +// check-fail +// known-bug: #90950 + +trait Yokeable<'a>: 'static { + type Output: 'a; +} + + +trait IsCovariant<'a> {} + +struct Yoke<Y: for<'a> Yokeable<'a>> { + data: Y, +} + + +// impl<Y: for<'a> Yokeable<'a>> Yoke<Y> { +// fn project<Y2: for<'a> Yokeable<'a>>( +// &self, +// f: for<'a> fn(<Y as Yokeable<'a>>::Output, &'a (), +// ) -> <Y2 as Yokeable<'a>>::Output) -> Yoke<Y2> { +// unimplemented!() +// } +// } + +fn upcast<Y>(x: Yoke<Y>) -> Yoke<Box<dyn IsCovariant<'static> + 'static>> where + Y: for<'a> Yokeable<'a>, + for<'a> <Y as Yokeable<'a>>::Output: IsCovariant<'a> + { + // x.project(|data, _| { + // Box::new(data) + // }) + unimplemented!() +} + + +impl<'a> Yokeable<'a> for Box<dyn IsCovariant<'static> + 'static> { + type Output = Box<dyn IsCovariant<'a> + 'a>; +} + +// this impl is mostly an example and unnecessary for the pure repro +use std::borrow::*; +impl<'a, T: ToOwned + ?Sized> Yokeable<'a> for Cow<'static, T> { + type Output = Cow<'a, T>; +} +impl<'a, T: ToOwned + ?Sized> IsCovariant<'a> for Cow<'a, T> {} + + + +fn upcast_yoke(y: Yoke<Cow<'static, str>>) -> Yoke<Box<dyn IsCovariant<'static> + 'static>> { + upcast(y) +} + +fn main() {} diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90950.stderr b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90950.stderr new file mode 100644 index 000000000..6206b167b --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90950.stderr @@ -0,0 +1,21 @@ +error[E0277]: the trait bound `for<'a> <_ as Yokeable<'a>>::Output: IsCovariant<'a>` is not satisfied + --> $DIR/issue-90950.rs:50:12 + | +LL | upcast(y) + | ------ ^ the trait `for<'a> IsCovariant<'a>` is not implemented for `<_ as Yokeable<'a>>::Output` + | | + | required by a bound introduced by this call + | + = help: the trait `IsCovariant<'a>` is implemented for `std::borrow::Cow<'a, T>` +note: required by a bound in `upcast` + --> $DIR/issue-90950.rs:27:42 + | +LL | fn upcast<Y>(x: Yoke<Y>) -> Yoke<Box<dyn IsCovariant<'static> + 'static>> where + | ------ required by a bound in this +LL | Y: for<'a> Yokeable<'a>, +LL | for<'a> <Y as Yokeable<'a>>::Output: IsCovariant<'a> + | ^^^^^^^^^^^^^^^ required by this bound in `upcast` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/norm-before-method-resolution.rs b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/norm-before-method-resolution.rs new file mode 100644 index 000000000..7693b1182 --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/norm-before-method-resolution.rs @@ -0,0 +1,23 @@ +// check-fail +// known-bug: #89196 + +// Should pass, but we normalize and check bounds before we resolve the generics +// of the function (which we know because of the return type). + +trait Trait<'a> { + type Out; +} + +impl<'a, T> Trait<'a> for T { + type Out = T; +} + +fn weird_bound<X>() -> X + where + for<'a> X: Trait<'a>, + for<'a> <X as Trait<'a>>::Out: Copy +{ todo!() } + +fn main() { + let _: () = weird_bound(); +} diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/norm-before-method-resolution.stderr b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/norm-before-method-resolution.stderr new file mode 100644 index 000000000..51c964600 --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/norm-before-method-resolution.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `for<'a> <_ as Trait<'a>>::Out: Copy` is not satisfied + --> $DIR/norm-before-method-resolution.rs:22:17 + | +LL | let _: () = weird_bound(); + | ^^^^^^^^^^^ the trait `for<'a> Copy` is not implemented for `<_ as Trait<'a>>::Out` + | +note: required by a bound in `weird_bound` + --> $DIR/norm-before-method-resolution.rs:18:40 + | +LL | fn weird_bound<X>() -> X + | ----------- required by a bound in this +... +LL | for<'a> <X as Trait<'a>>::Out: Copy + | ^^^^ required by this bound in `weird_bound` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/hygiene/no_implicit_prelude.stderr b/src/test/ui/hygiene/no_implicit_prelude.stderr index 0f2ff96b5..c48c84035 100644 --- a/src/test/ui/hygiene/no_implicit_prelude.stderr +++ b/src/test/ui/hygiene/no_implicit_prelude.stderr @@ -5,7 +5,7 @@ LL | fn f() { ::bar::m!(); } | ----------- in this macro invocation ... LL | Vec::new(); - | ^^^ not found in this scope + | ^^^ use of undeclared type `Vec` | = note: this error originates in the macro `::bar::m` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider importing this struct diff --git a/src/test/ui/hygiene/panic-location.run.stderr b/src/test/ui/hygiene/panic-location.run.stderr index 216b31586..0b23b1cc2 100644 --- a/src/test/ui/hygiene/panic-location.run.stderr +++ b/src/test/ui/hygiene/panic-location.run.stderr @@ -1,2 +1,2 @@ -thread 'main' panicked at 'capacity overflow', $SRC_DIR/alloc/src/collections/vec_deque/mod.rs:LL:COL +thread 'main' panicked at 'capacity overflow', library/alloc/src/raw_vec.rs:518:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/src/test/ui/impl-trait/auto-trait.rs b/src/test/ui/impl-trait/auto-trait.rs index afa95645a..35994e4a5 100644 --- a/src/test/ui/impl-trait/auto-trait.rs +++ b/src/test/ui/impl-trait/auto-trait.rs @@ -20,7 +20,6 @@ impl<T: Send> AnotherTrait for T {} // in the future.) impl AnotherTrait for D<OpaqueType> { //~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>` - //~| ERROR cannot implement trait on type alias impl trait } fn main() {} diff --git a/src/test/ui/impl-trait/auto-trait.stderr b/src/test/ui/impl-trait/auto-trait.stderr index 5e10272b0..81009413c 100644 --- a/src/test/ui/impl-trait/auto-trait.stderr +++ b/src/test/ui/impl-trait/auto-trait.stderr @@ -7,18 +7,6 @@ LL | impl<T: Send> AnotherTrait for T {} LL | impl AnotherTrait for D<OpaqueType> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<OpaqueType>` -error: cannot implement trait on type alias impl trait - --> $DIR/auto-trait.rs:21:25 - | -LL | impl AnotherTrait for D<OpaqueType> { - | ^^^^^^^^^^ - | -note: type alias impl trait defined here - --> $DIR/auto-trait.rs:7:19 - | -LL | type OpaqueType = impl OpaqueTrait; - | ^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/impl-trait/bound-normalization-fail.stderr b/src/test/ui/impl-trait/bound-normalization-fail.stderr index bd8d3d3d2..a9fa2da56 100644 --- a/src/test/ui/impl-trait/bound-normalization-fail.stderr +++ b/src/test/ui/impl-trait/bound-normalization-fail.stderr @@ -19,17 +19,20 @@ help: consider constraining the associated type `<T as impl_trait::Trait>::Assoc LL | fn foo_fail<T: Trait<Assoc = ()>>() -> impl FooLike<Output = T::Assoc> { | ++++++++++++ -error[E0760]: `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope +error[E0658]: `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope --> $DIR/bound-normalization-fail.rs:41:41 | LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #103532 <https://github.com/rust-lang/rust/issues/103532> for more information + = help: add `#![feature(impl_trait_projections)]` to the crate attributes to enable -error[E0271]: type mismatch resolving `<Foo<()> as FooLike>::Output == <T as lifetimes::Trait<'static>>::Assoc` +error[E0271]: type mismatch resolving `<Foo<()> as FooLike>::Output == <T as lifetimes::Trait<'a>>::Assoc` --> $DIR/bound-normalization-fail.rs:41:41 | LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Foo<()> as FooLike>::Output == <T as lifetimes::Trait<'static>>::Assoc` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Foo<()> as FooLike>::Output == <T as lifetimes::Trait<'a>>::Assoc` ... LL | Foo(()) | ------- return type was inferred to be `Foo<()>` here @@ -40,13 +43,13 @@ note: expected this to be `()` LL | type Output = T; | ^ = note: expected unit type `()` - found associated type `<T as lifetimes::Trait<'static>>::Assoc` -help: consider constraining the associated type `<T as lifetimes::Trait<'static>>::Assoc` to `()` + found associated type `<T as lifetimes::Trait<'a>>::Assoc` +help: consider constraining the associated type `<T as lifetimes::Trait<'a>>::Assoc` to `()` | LL | fn foo2_fail<'a, T: Trait<'a, Assoc = ()>>() -> impl FooLike<Output = T::Assoc> { | ++++++++++++ error: aborting due to 3 previous errors -Some errors have detailed explanations: E0271, E0760. +Some errors have detailed explanations: E0271, E0658. For more information about an error, try `rustc --explain E0271`. diff --git a/src/test/ui/impl-trait/cross-return-site-inference.rs b/src/test/ui/impl-trait/cross-return-site-inference.rs index d881af9ed..00aed2ad9 100644 --- a/src/test/ui/impl-trait/cross-return-site-inference.rs +++ b/src/test/ui/impl-trait/cross-return-site-inference.rs @@ -30,16 +30,19 @@ fn baa(b: bool) -> impl std::fmt::Debug { fn muh() -> Result<(), impl std::fmt::Debug> { Err("whoops")?; - Ok(()) //~ ERROR type annotations needed + Ok(()) + //~^ ERROR type annotations needed } fn muh2() -> Result<(), impl std::fmt::Debug> { - return Err(From::from("foo")); //~ ERROR type annotations needed + return Err(From::from("foo")); + //~^ ERROR type annotations needed Ok(()) } fn muh3() -> Result<(), impl std::fmt::Debug> { - Err(From::from("foo")) //~ ERROR type annotations needed + Err(From::from("foo")) + //~^ ERROR type annotations needed } fn main() {} diff --git a/src/test/ui/impl-trait/cross-return-site-inference.stderr b/src/test/ui/impl-trait/cross-return-site-inference.stderr index 1ff777e65..766614e9e 100644 --- a/src/test/ui/impl-trait/cross-return-site-inference.stderr +++ b/src/test/ui/impl-trait/cross-return-site-inference.stderr @@ -10,7 +10,7 @@ LL | Ok::<(), E>(()) | +++++++++ error[E0282]: type annotations needed - --> $DIR/cross-return-site-inference.rs:37:12 + --> $DIR/cross-return-site-inference.rs:38:12 | LL | return Err(From::from("foo")); | ^^^ cannot infer type of the type parameter `E` declared on the enum `Result` @@ -21,7 +21,7 @@ LL | return Err::<(), E>(From::from("foo")); | +++++++++ error[E0282]: type annotations needed - --> $DIR/cross-return-site-inference.rs:42:5 + --> $DIR/cross-return-site-inference.rs:44:5 | LL | Err(From::from("foo")) | ^^^ cannot infer type of the type parameter `E` declared on the enum `Result` diff --git a/src/test/ui/impl-trait/deduce-signature-from-supertrait.rs b/src/test/ui/impl-trait/deduce-signature-from-supertrait.rs new file mode 100644 index 000000000..d2c347920 --- /dev/null +++ b/src/test/ui/impl-trait/deduce-signature-from-supertrait.rs @@ -0,0 +1,15 @@ +// check-pass + +#![feature(type_alias_impl_trait)] + +trait SuperExpectation: Fn(i32) {} + +impl<T: Fn(i32)> SuperExpectation for T {} + +type Foo = impl SuperExpectation; + +fn main() { + let _: Foo = |x| { + let _ = x.to_string(); + }; +} diff --git a/src/test/ui/impl-trait/equality.stderr b/src/test/ui/impl-trait/equality.stderr index 1841b8e5d..69f4cbbbf 100644 --- a/src/test/ui/impl-trait/equality.stderr +++ b/src/test/ui/impl-trait/equality.stderr @@ -30,15 +30,10 @@ LL | n + sum_to(n - 1) | = help: the trait `Add<impl Foo>` is not implemented for `u32` = help: the following other types implement trait `Add<Rhs>`: - <&'a f32 as Add<f32>> - <&'a f64 as Add<f64>> - <&'a i128 as Add<i128>> - <&'a i16 as Add<i16>> - <&'a i32 as Add<i32>> - <&'a i64 as Add<i64>> - <&'a i8 as Add<i8>> - <&'a isize as Add<isize>> - and 48 others + <&'a u32 as Add<u32>> + <&u32 as Add<&u32>> + <u32 as Add<&u32>> + <u32 as Add> error: aborting due to 2 previous errors; 1 warning emitted diff --git a/src/test/ui/impl-trait/feature-self-return-type.rs b/src/test/ui/impl-trait/feature-self-return-type.rs new file mode 100644 index 000000000..51877e9cc --- /dev/null +++ b/src/test/ui/impl-trait/feature-self-return-type.rs @@ -0,0 +1,102 @@ +// edition:2018 +#![feature(impl_trait_projections)] + +// This test checks that we emit the correct borrowck error when `Self` or a projection is used as +// a return type. See #61949 for context. + +mod with_self { + pub struct Foo<'a> { + pub bar: &'a i32, + } + + impl<'a> Foo<'a> { + pub fn new(_bar: &'a i32) -> impl Into<Self> { + Foo { + bar: &22 + } + } + } + + fn foo() { + let x = { + let bar = 22; + Foo::new(&bar).into() + //~^ ERROR `bar` does not live long enough + }; + drop(x); + } +} + +struct Foo<T>(T); + +trait FooLike { + type Output; +} + +impl<T> FooLike for Foo<T> { + type Output = T; +} + +mod impl_trait { + use super::*; + + trait Trait { + type Assoc; + + fn make_assoc(self) -> Self::Assoc; + } + + /// `T::Assoc` can't be normalized any further here. + fn foo<T: Trait>(x: T) -> impl FooLike<Output = T::Assoc> { + Foo(x.make_assoc()) + } + + impl<'a> Trait for &'a () { + type Assoc = &'a (); + + fn make_assoc(self) -> &'a () { &() } + } + + fn usage() { + let x = { + let y = (); + foo(&y) + //~^ ERROR `y` does not live long enough + }; + drop(x); + } +} + +// Same with lifetimes in the trait + +mod lifetimes { + use super::*; + + trait Trait<'a> { + type Assoc; + + fn make_assoc(self) -> Self::Assoc; + } + + /// Missing bound constraining `Assoc`, `T::Assoc` can't be normalized further. + fn foo<'a, T: Trait<'a>>(x: T) -> impl FooLike<Output = T::Assoc> { + Foo(x.make_assoc()) + } + + impl<'a> Trait<'a> for &'a () { + type Assoc = &'a (); + + fn make_assoc(self) -> &'a () { &() } + } + + fn usage() { + let x = { + let y = (); + foo(&y) + //~^ ERROR `y` does not live long enough + }; + drop(x); + } +} + +fn main() { } diff --git a/src/test/ui/impl-trait/feature-self-return-type.stderr b/src/test/ui/impl-trait/feature-self-return-type.stderr new file mode 100644 index 000000000..601e53b76 --- /dev/null +++ b/src/test/ui/impl-trait/feature-self-return-type.stderr @@ -0,0 +1,39 @@ +error[E0597]: `bar` does not live long enough + --> $DIR/feature-self-return-type.rs:23:22 + | +LL | let x = { + | - borrow later stored here +LL | let bar = 22; +LL | Foo::new(&bar).into() + | ^^^^ borrowed value does not live long enough +LL | +LL | }; + | - `bar` dropped here while still borrowed + +error[E0597]: `y` does not live long enough + --> $DIR/feature-self-return-type.rs:63:17 + | +LL | let x = { + | - borrow later stored here +LL | let y = (); +LL | foo(&y) + | ^^ borrowed value does not live long enough +LL | +LL | }; + | - `y` dropped here while still borrowed + +error[E0597]: `y` does not live long enough + --> $DIR/feature-self-return-type.rs:95:17 + | +LL | let x = { + | - borrow later stored here +LL | let y = (); +LL | foo(&y) + | ^^ borrowed value does not live long enough +LL | +LL | }; + | - `y` dropped here while still borrowed + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2021.stderr b/src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2021.stderr index 88e2520bf..30fbba168 100644 --- a/src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2021.stderr +++ b/src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2021.stderr @@ -9,13 +9,6 @@ help: add `dyn` keyword before this trait LL | fn ice() -> impl AsRef<dyn Fn(&())> { | +++ -error[E0277]: the trait bound `(): AsRef<(dyn for<'a> Fn(&'a ()) + 'static)>` is not satisfied - --> $DIR/generic-with-implicit-hrtb-without-dyn.rs:6:13 - | -LL | fn ice() -> impl AsRef<Fn(&())> { - | ^^^^^^^^^^^^^^^^^^^ the trait `AsRef<(dyn for<'a> Fn(&'a ()) + 'static)>` is not implemented for `()` - -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0277, E0782. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0782`. diff --git a/src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.rs b/src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.rs index 5a922697f..bed81c4bc 100644 --- a/src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.rs +++ b/src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.rs @@ -4,8 +4,8 @@ #![allow(warnings)] fn ice() -> impl AsRef<Fn(&())> { - //~^ ERROR: the trait bound `(): AsRef<(dyn for<'a> Fn(&'a ()) + 'static)>` is not satisfied [E0277] - //[edition2021]~| ERROR: trait objects must include the `dyn` keyword [E0782] + //[edition2015]~^ ERROR: the trait bound `(): AsRef<(dyn for<'a> Fn(&'a ()) + 'static)>` is not satisfied [E0277] + //[edition2021]~^^ ERROR: trait objects must include the `dyn` keyword [E0782] todo!() } diff --git a/src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.rs b/src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.rs new file mode 100644 index 000000000..b0aeded0e --- /dev/null +++ b/src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.rs @@ -0,0 +1,8 @@ +#![feature(impl_trait_in_fn_trait_return)] +use std::fmt::Debug; + +fn a() -> impl Fn(&u8) -> impl Debug { + |x| x //~ ERROR hidden type for `impl Debug` captures lifetime that does not appear in bounds +} + +fn main() {} diff --git a/src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr b/src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr new file mode 100644 index 000000000..433b76b7a --- /dev/null +++ b/src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr @@ -0,0 +1,11 @@ +error[E0700]: hidden type for `impl Debug` captures lifetime that does not appear in bounds + --> $DIR/impl-fn-hrtb-bounds-2.rs:5:9 + | +LL | |x| x + | --- ^ + | | + | hidden type `&u8` captures the anonymous lifetime #1 defined here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/impl-trait/impl-fn-hrtb-bounds.rs b/src/test/ui/impl-trait/impl-fn-hrtb-bounds.rs new file mode 100644 index 000000000..527a4586f --- /dev/null +++ b/src/test/ui/impl-trait/impl-fn-hrtb-bounds.rs @@ -0,0 +1,24 @@ +#![feature(impl_trait_in_fn_trait_return)] +use std::fmt::Debug; + +fn a() -> impl Fn(&u8) -> (impl Debug + '_) { + //~^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet + |x| x +} + +fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) { + //~^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet + |x| x +} + +fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) { + //~^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet + |x| x +} + +fn d() -> impl Fn() -> (impl Debug + '_) { + //~^ ERROR missing lifetime specifier + || () +} + +fn main() {} diff --git a/src/test/ui/impl-trait/impl-fn-hrtb-bounds.stderr b/src/test/ui/impl-trait/impl-fn-hrtb-bounds.stderr new file mode 100644 index 000000000..443ffeb55 --- /dev/null +++ b/src/test/ui/impl-trait/impl-fn-hrtb-bounds.stderr @@ -0,0 +1,51 @@ +error[E0106]: missing lifetime specifier + --> $DIR/impl-fn-hrtb-bounds.rs:19:38 + | +LL | fn d() -> impl Fn() -> (impl Debug + '_) { + | ^^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from +help: consider using the `'static` lifetime + | +LL | fn d() -> impl Fn() -> (impl Debug + 'static) { + | ~~~~~~~ + +error: higher kinded lifetime bounds on nested opaque types are not supported yet + --> $DIR/impl-fn-hrtb-bounds.rs:4:41 + | +LL | fn a() -> impl Fn(&u8) -> (impl Debug + '_) { + | ^^ + | +note: lifetime declared here + --> $DIR/impl-fn-hrtb-bounds.rs:4:19 + | +LL | fn a() -> impl Fn(&u8) -> (impl Debug + '_) { + | ^ + +error: higher kinded lifetime bounds on nested opaque types are not supported yet + --> $DIR/impl-fn-hrtb-bounds.rs:9:52 + | +LL | fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) { + | ^^ + | +note: lifetime declared here + --> $DIR/impl-fn-hrtb-bounds.rs:9:20 + | +LL | fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) { + | ^^ + +error: higher kinded lifetime bounds on nested opaque types are not supported yet + --> $DIR/impl-fn-hrtb-bounds.rs:14:52 + | +LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) { + | ^^ + | +note: lifetime declared here + --> $DIR/impl-fn-hrtb-bounds.rs:14:20 + | +LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) { + | ^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/impl-trait/impl-fn-parsing-ambiguities.rs b/src/test/ui/impl-trait/impl-fn-parsing-ambiguities.rs new file mode 100644 index 000000000..61303a5b2 --- /dev/null +++ b/src/test/ui/impl-trait/impl-fn-parsing-ambiguities.rs @@ -0,0 +1,15 @@ +#![feature(impl_trait_in_fn_trait_return)] +use std::fmt::Debug; + +fn a() -> impl Fn(&u8) -> impl Debug + '_ { + //~^ ERROR ambiguous `+` in a type + //~| ERROR higher kinded lifetime bounds on nested opaque types are not supported yet + |x| x +} + +fn b() -> impl Fn() -> impl Debug + Send { + //~^ ERROR ambiguous `+` in a type + || () +} + +fn main() {} diff --git a/src/test/ui/impl-trait/impl-fn-parsing-ambiguities.stderr b/src/test/ui/impl-trait/impl-fn-parsing-ambiguities.stderr new file mode 100644 index 000000000..cf6e5ef7b --- /dev/null +++ b/src/test/ui/impl-trait/impl-fn-parsing-ambiguities.stderr @@ -0,0 +1,26 @@ +error: ambiguous `+` in a type + --> $DIR/impl-fn-parsing-ambiguities.rs:4:27 + | +LL | fn a() -> impl Fn(&u8) -> impl Debug + '_ { + | ^^^^^^^^^^^^^^^ help: use parentheses to disambiguate: `(impl Debug + '_)` + +error: ambiguous `+` in a type + --> $DIR/impl-fn-parsing-ambiguities.rs:10:24 + | +LL | fn b() -> impl Fn() -> impl Debug + Send { + | ^^^^^^^^^^^^^^^^^ help: use parentheses to disambiguate: `(impl Debug + Send)` + +error: higher kinded lifetime bounds on nested opaque types are not supported yet + --> $DIR/impl-fn-parsing-ambiguities.rs:4:40 + | +LL | fn a() -> impl Fn(&u8) -> impl Debug + '_ { + | ^^ + | +note: lifetime declared here + --> $DIR/impl-fn-parsing-ambiguities.rs:4:19 + | +LL | fn a() -> impl Fn(&u8) -> impl Debug + '_ { + | ^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.rs b/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.rs new file mode 100644 index 000000000..157786623 --- /dev/null +++ b/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.rs @@ -0,0 +1,15 @@ +#![feature(impl_trait_in_fn_trait_return)] +use std::fmt::Debug; + +fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) { + //~^ ERROR cannot resolve opaque type + + |x| x + //~^ ERROR concrete type differs from previous defining opaque type use +} + +fn _b<'a>() -> impl Fn(&'a u8) -> (impl Debug + 'a) { + a() +} + +fn main() {} diff --git a/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.stderr b/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.stderr new file mode 100644 index 000000000..c19420bbb --- /dev/null +++ b/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.stderr @@ -0,0 +1,21 @@ +error: concrete type differs from previous defining opaque type use + --> $DIR/impl-fn-predefined-lifetimes.rs:7:9 + | +LL | |x| x + | ^ expected `impl Debug + '_`, got `&u8` + | +note: previous use here + --> $DIR/impl-fn-predefined-lifetimes.rs:7:5 + | +LL | |x| x + | ^^^^^ + +error[E0720]: cannot resolve opaque type + --> $DIR/impl-fn-predefined-lifetimes.rs:4:35 + | +LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) { + | ^^^^^^^^^^^^^^^ cannot resolve opaque type + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0720`. diff --git a/src/test/ui/impl-trait/impl_fn_associativity.rs b/src/test/ui/impl-trait/impl_fn_associativity.rs new file mode 100644 index 000000000..71a8f9c77 --- /dev/null +++ b/src/test/ui/impl-trait/impl_fn_associativity.rs @@ -0,0 +1,26 @@ +// run-pass +#![feature(impl_trait_in_fn_trait_return)] +use std::fmt::Debug; + +fn f_debug() -> impl Fn() -> impl Debug { + || () +} + +fn ff_debug() -> impl Fn() -> impl Fn() -> impl Debug { + || f_debug() +} + +fn multi() -> impl Fn() -> (impl Debug + Send) { + || () +} + +fn main() { + // Check that `ff_debug` is `() -> (() -> Debug)` and not `(() -> ()) -> Debug` + let debug = ff_debug()()(); + assert_eq!(format!("{:?}", debug), "()"); + + let x = multi()(); + assert_eq!(format!("{:?}", x), "()"); + fn assert_send(_: &impl Send) {} + assert_send(&x); +} diff --git a/src/test/ui/impl-trait/in-trait/generics-mismatch.rs b/src/test/ui/impl-trait/in-trait/generics-mismatch.rs new file mode 100644 index 000000000..cc0fc720e --- /dev/null +++ b/src/test/ui/impl-trait/in-trait/generics-mismatch.rs @@ -0,0 +1,17 @@ +#![feature(return_position_impl_trait_in_trait)] +#![allow(incomplete_features)] + +struct U; + +trait Foo { + fn bar(&self) -> impl Sized; +} + +impl Foo for U { + fn bar<T>(&self) {} + //~^ ERROR method `bar` has 1 type parameter but its trait declaration has 0 type parameters +} + +fn main() { + U.bar(); +} diff --git a/src/test/ui/impl-trait/in-trait/generics-mismatch.stderr b/src/test/ui/impl-trait/in-trait/generics-mismatch.stderr new file mode 100644 index 000000000..cd42683e0 --- /dev/null +++ b/src/test/ui/impl-trait/in-trait/generics-mismatch.stderr @@ -0,0 +1,12 @@ +error[E0049]: method `bar` has 1 type parameter but its trait declaration has 0 type parameters + --> $DIR/generics-mismatch.rs:11:12 + | +LL | fn bar(&self) -> impl Sized; + | - expected 0 type parameters +... +LL | fn bar<T>(&self) {} + | ^ found 1 type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0049`. diff --git a/src/test/ui/impl-trait/in-trait/method-signature-matches.rs b/src/test/ui/impl-trait/in-trait/method-signature-matches.rs new file mode 100644 index 000000000..c848ee3f6 --- /dev/null +++ b/src/test/ui/impl-trait/in-trait/method-signature-matches.rs @@ -0,0 +1,51 @@ +// edition: 2021 + +#![feature(return_position_impl_trait_in_trait, async_fn_in_trait)] +#![allow(incomplete_features)] + +trait Uwu { + fn owo(x: ()) -> impl Sized; +} + +impl Uwu for () { + fn owo(_: u8) {} + //~^ ERROR method `owo` has an incompatible type for trait +} + +trait AsyncUwu { + async fn owo(x: ()) {} +} + +impl AsyncUwu for () { + async fn owo(_: u8) {} + //~^ ERROR method `owo` has an incompatible type for trait +} + +trait TooMuch { + fn calm_down_please() -> impl Sized; +} + +impl TooMuch for () { + fn calm_down_please(_: (), _: (), _: ()) {} + //~^ ERROR method `calm_down_please` has 3 parameters but the declaration in trait `TooMuch::calm_down_please` has 0 +} + +trait TooLittle { + fn come_on_a_little_more_effort(_: (), _: (), _: ()) -> impl Sized; +} + +impl TooLittle for () { + fn come_on_a_little_more_effort() {} + //~^ ERROR method `come_on_a_little_more_effort` has 0 parameters but the declaration in trait `TooLittle::come_on_a_little_more_effort` has 3 +} + +trait Lifetimes { + fn early<'early, T>(x: &'early T) -> impl Sized; +} + +impl Lifetimes for () { + fn early<'late, T>(_: &'late ()) {} + //~^ ERROR method `early` has an incompatible type for trait +} + +fn main() {} diff --git a/src/test/ui/impl-trait/in-trait/method-signature-matches.stderr b/src/test/ui/impl-trait/in-trait/method-signature-matches.stderr new file mode 100644 index 000000000..2b32c52c8 --- /dev/null +++ b/src/test/ui/impl-trait/in-trait/method-signature-matches.stderr @@ -0,0 +1,84 @@ +error[E0053]: method `owo` has an incompatible type for trait + --> $DIR/method-signature-matches.rs:11:15 + | +LL | fn owo(_: u8) {} + | ^^ + | | + | expected `()`, found `u8` + | help: change the parameter type to match the trait: `()` + | +note: type in trait + --> $DIR/method-signature-matches.rs:7:15 + | +LL | fn owo(x: ()) -> impl Sized; + | ^^ + = note: expected fn pointer `fn(())` + found fn pointer `fn(u8)` + +error[E0053]: method `owo` has an incompatible type for trait + --> $DIR/method-signature-matches.rs:20:21 + | +LL | async fn owo(_: u8) {} + | ^^ + | | + | expected `()`, found `u8` + | help: change the parameter type to match the trait: `()` + | +note: while checking the return type of the `async fn` + --> $DIR/method-signature-matches.rs:20:25 + | +LL | async fn owo(_: u8) {} + | ^ checked the `Output` of this `async fn`, expected opaque type +note: while checking the return type of the `async fn` + --> $DIR/method-signature-matches.rs:20:25 + | +LL | async fn owo(_: u8) {} + | ^ checked the `Output` of this `async fn`, found opaque type +note: type in trait + --> $DIR/method-signature-matches.rs:16:21 + | +LL | async fn owo(x: ()) {} + | ^^ + = note: expected fn pointer `fn(()) -> _` + found fn pointer `fn(u8) -> _` + +error[E0050]: method `calm_down_please` has 3 parameters but the declaration in trait `TooMuch::calm_down_please` has 0 + --> $DIR/method-signature-matches.rs:29:28 + | +LL | fn calm_down_please() -> impl Sized; + | ------------------------------------ trait requires 0 parameters +... +LL | fn calm_down_please(_: (), _: (), _: ()) {} + | ^^^^^^^^^^^^^^^^ expected 0 parameters, found 3 + +error[E0050]: method `come_on_a_little_more_effort` has 0 parameters but the declaration in trait `TooLittle::come_on_a_little_more_effort` has 3 + --> $DIR/method-signature-matches.rs:38:5 + | +LL | fn come_on_a_little_more_effort(_: (), _: (), _: ()) -> impl Sized; + | ---------------- trait requires 3 parameters +... +LL | fn come_on_a_little_more_effort() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 3 parameters, found 0 + +error[E0053]: method `early` has an incompatible type for trait + --> $DIR/method-signature-matches.rs:47:27 + | +LL | fn early<'late, T>(_: &'late ()) {} + | - ^^^^^^^^^ + | | | + | | expected type parameter `T`, found `()` + | | help: change the parameter type to match the trait: `&'early T` + | this type parameter + | +note: type in trait + --> $DIR/method-signature-matches.rs:43:28 + | +LL | fn early<'early, T>(x: &'early T) -> impl Sized; + | ^^^^^^^^^ + = note: expected fn pointer `fn(&'early T)` + found fn pointer `fn(&())` + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0050, E0053. +For more information about an error, try `rustc --explain E0050`. diff --git a/src/test/ui/impl-trait/in-trait/object-safety.stderr b/src/test/ui/impl-trait/in-trait/object-safety.stderr index 9a1554b5e..ca0e760ff 100644 --- a/src/test/ui/impl-trait/in-trait/object-safety.stderr +++ b/src/test/ui/impl-trait/in-trait/object-safety.stderr @@ -5,12 +5,12 @@ LL | let i = Box::new(42_u32) as Box<dyn Foo>; | ^^^^^^^^^^^^ `Foo` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> - --> $DIR/object-safety.rs:7:8 + --> $DIR/object-safety.rs:7:22 | LL | trait Foo { | --- this trait cannot be made into an object... LL | fn baz(&self) -> impl Debug; - | ^^^ ...because method `baz` references an `impl Trait` type in its return type + | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type = help: consider moving `baz` to another trait error[E0038]: the trait `Foo` cannot be made into an object @@ -20,12 +20,12 @@ LL | let s = i.baz(); | ^^^^^^^ `Foo` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> - --> $DIR/object-safety.rs:7:8 + --> $DIR/object-safety.rs:7:22 | LL | trait Foo { | --- this trait cannot be made into an object... LL | fn baz(&self) -> impl Debug; - | ^^^ ...because method `baz` references an `impl Trait` type in its return type + | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type = help: consider moving `baz` to another trait error[E0038]: the trait `Foo` cannot be made into an object @@ -35,12 +35,12 @@ LL | let i = Box::new(42_u32) as Box<dyn Foo>; | ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> - --> $DIR/object-safety.rs:7:8 + --> $DIR/object-safety.rs:7:22 | LL | trait Foo { | --- this trait cannot be made into an object... LL | fn baz(&self) -> impl Debug; - | ^^^ ...because method `baz` references an `impl Trait` type in its return type + | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type = help: consider moving `baz` to another trait = note: required for `Box<u32>` to implement `CoerceUnsized<Box<dyn Foo>>` = note: required by cast to type `Box<dyn Foo>` diff --git a/src/test/ui/impl-trait/in-trait/specialization-broken.rs b/src/test/ui/impl-trait/in-trait/specialization-broken.rs new file mode 100644 index 000000000..9d27d3710 --- /dev/null +++ b/src/test/ui/impl-trait/in-trait/specialization-broken.rs @@ -0,0 +1,26 @@ +// FIXME(compiler-errors): I'm not exactly sure if this is expected to pass or not. +// But we fixed an ICE anyways. + +#![feature(specialization)] +#![feature(return_position_impl_trait_in_trait)] +#![allow(incomplete_features)] + +trait Foo { + fn bar(&self) -> impl Sized; +} + +default impl<U> Foo for U +where + U: Copy, +{ + fn bar(&self) -> U { + //~^ ERROR method `bar` has an incompatible type for trait + *self + } +} + +impl Foo for i32 {} + +fn main() { + 1i32.bar(); +} diff --git a/src/test/ui/impl-trait/in-trait/specialization-broken.stderr b/src/test/ui/impl-trait/in-trait/specialization-broken.stderr new file mode 100644 index 000000000..a30e6346b --- /dev/null +++ b/src/test/ui/impl-trait/in-trait/specialization-broken.stderr @@ -0,0 +1,23 @@ +error[E0053]: method `bar` has an incompatible type for trait + --> $DIR/specialization-broken.rs:16:22 + | +LL | default impl<U> Foo for U + | - this type parameter +... +LL | fn bar(&self) -> U { + | ^ + | | + | expected associated type, found type parameter `U` + | help: change the output type to match the trait: `impl Sized` + | +note: type in trait + --> $DIR/specialization-broken.rs:9:22 + | +LL | fn bar(&self) -> impl Sized; + | ^^^^^^^^^^ + = note: expected fn pointer `fn(&U) -> impl Sized` + found fn pointer `fn(&U) -> U` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0053`. diff --git a/src/test/ui/impl-trait/in-trait/specialization-substs-remap.rs b/src/test/ui/impl-trait/in-trait/specialization-substs-remap.rs new file mode 100644 index 000000000..c9ee877db --- /dev/null +++ b/src/test/ui/impl-trait/in-trait/specialization-substs-remap.rs @@ -0,0 +1,24 @@ +// check-pass + +#![feature(specialization)] +#![feature(return_position_impl_trait_in_trait)] +#![allow(incomplete_features)] + +trait Foo { + fn bar(&self) -> impl Sized; +} + +impl<U> Foo for U +where + U: Copy, +{ + fn bar(&self) -> U { + *self + } +} + +impl Foo for i32 {} + +fn main() { + let _: i32 = 1i32.bar(); +} diff --git a/src/test/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs b/src/test/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs new file mode 100644 index 000000000..0bbe50ea6 --- /dev/null +++ b/src/test/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs @@ -0,0 +1,17 @@ +#![feature(return_position_impl_trait_in_trait)] +#![allow(incomplete_features)] + +struct S; + +trait Foo { + fn bar<T>() -> impl Sized; +} + +impl Foo for S { + fn bar() -> impl Sized {} + //~^ ERROR method `bar` has 0 type parameters but its trait declaration has 1 type parameter +} + +fn main() { + S::bar(); +} diff --git a/src/test/ui/impl-trait/in-trait/trait-more-generics-than-impl.stderr b/src/test/ui/impl-trait/in-trait/trait-more-generics-than-impl.stderr new file mode 100644 index 000000000..8ff54cad9 --- /dev/null +++ b/src/test/ui/impl-trait/in-trait/trait-more-generics-than-impl.stderr @@ -0,0 +1,12 @@ +error[E0049]: method `bar` has 0 type parameters but its trait declaration has 1 type parameter + --> $DIR/trait-more-generics-than-impl.rs:11:11 + | +LL | fn bar<T>() -> impl Sized; + | - expected 1 type parameter +... +LL | fn bar() -> impl Sized {} + | ^ found 0 type parameters + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0049`. diff --git a/src/test/ui/impl-trait/in-trait/where-clause.rs b/src/test/ui/impl-trait/in-trait/where-clause.rs new file mode 100644 index 000000000..87bac519c --- /dev/null +++ b/src/test/ui/impl-trait/in-trait/where-clause.rs @@ -0,0 +1,24 @@ +// check-pass +// edition: 2021 + +#![feature(return_position_impl_trait_in_trait)] +#![allow(incomplete_features)] + +use std::fmt::Debug; + +trait Foo<Item> { + fn foo<'a>(&'a self) -> impl Debug + where + Item: 'a; +} + +impl<Item, D: Debug + Clone> Foo<Item> for D { + fn foo<'a>(&'a self) -> impl Debug + where + Item: 'a, + { + self.clone() + } +} + +fn main() {} diff --git a/src/test/ui/issues/issue-35668.rs b/src/test/ui/impl-trait/issue-35668.rs index c970163fc..c970163fc 100644 --- a/src/test/ui/issues/issue-35668.rs +++ b/src/test/ui/impl-trait/issue-35668.rs diff --git a/src/test/ui/issues/issue-35668.stderr b/src/test/ui/impl-trait/issue-35668.stderr index 84add5799..84add5799 100644 --- a/src/test/ui/issues/issue-35668.stderr +++ b/src/test/ui/impl-trait/issue-35668.stderr diff --git a/src/test/ui/issues/issue-49556.rs b/src/test/ui/impl-trait/issue-49556.rs index c8c172f0e..c8c172f0e 100644 --- a/src/test/ui/issues/issue-49556.rs +++ b/src/test/ui/impl-trait/issue-49556.rs diff --git a/src/test/ui/impl-trait/issue-55872-3.rs b/src/test/ui/impl-trait/issue-55872-3.rs index 3ffce85e6..91811df93 100644 --- a/src/test/ui/impl-trait/issue-55872-3.rs +++ b/src/test/ui/impl-trait/issue-55872-3.rs @@ -12,7 +12,7 @@ pub trait Bar { impl<S> Bar for S { type E = impl std::marker::Copy; fn foo<T>() -> Self::E { - //~^ ERROR the trait bound `impl Future<Output = ()>: Copy` is not satisfied [E0277] + //~^ ERROR : Copy` is not satisfied [E0277] async {} } } diff --git a/src/test/ui/impl-trait/issue-55872-3.stderr b/src/test/ui/impl-trait/issue-55872-3.stderr index 6ab540e87..c6e10f0f3 100644 --- a/src/test/ui/impl-trait/issue-55872-3.stderr +++ b/src/test/ui/impl-trait/issue-55872-3.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `impl Future<Output = ()>: Copy` is not satisfied +error[E0277]: the trait bound `[async block@$DIR/issue-55872-3.rs:16:9: 16:17]: Copy` is not satisfied --> $DIR/issue-55872-3.rs:14:20 | LL | fn foo<T>() -> Self::E { - | ^^^^^^^ the trait `Copy` is not implemented for `impl Future<Output = ()>` + | ^^^^^^^ the trait `Copy` is not implemented for `[async block@$DIR/issue-55872-3.rs:16:9: 16:17]` error: aborting due to previous error diff --git a/src/test/ui/impl-trait/issues/issue-104815.rs b/src/test/ui/impl-trait/issues/issue-104815.rs new file mode 100644 index 000000000..7a9826a8d --- /dev/null +++ b/src/test/ui/impl-trait/issues/issue-104815.rs @@ -0,0 +1,66 @@ +// check-pass + +struct It; + +struct Data { + items: Vec<It>, +} + +impl Data { + fn new() -> Self { + Self { + items: vec![It, It], + } + } + + fn content(&self) -> impl Iterator<Item = &It> { + self.items.iter() + } +} + +struct Container<'a> { + name: String, + resolver: Box<dyn Resolver + 'a>, +} + +impl<'a> Container<'a> { + fn new<R: Resolver + 'a>(name: &str, resolver: R) -> Self { + Self { + name: name.to_owned(), + resolver: Box::new(resolver), + } + } +} + +trait Resolver {} + +impl<R: Resolver> Resolver for &R {} + +impl Resolver for It {} + +fn get<'a>(mut items: impl Iterator<Item = &'a It>) -> impl Resolver + 'a { + items.next().unwrap() +} + +fn get2<'a, 'b: 'b>(mut items: impl Iterator<Item = &'a It>) -> impl Resolver + 'a { + items.next().unwrap() +} + +fn main() { + let data = Data::new(); + let resolver = get(data.content()); + + let _ = ["a", "b"] + .iter() + .map(|&n| Container::new(n, &resolver)) + .map(|c| c.name) + .collect::<Vec<_>>(); + + let resolver = get2(data.content()); + + let _ = ["a", "b"] + .iter() + .map(|&n| Container::new(n, &resolver)) + .map(|c| c.name) + .collect::<Vec<_>>(); +} diff --git a/src/test/ui/impl-trait/issues/issue-105826.rs b/src/test/ui/impl-trait/issues/issue-105826.rs new file mode 100644 index 000000000..06dc2d4c8 --- /dev/null +++ b/src/test/ui/impl-trait/issues/issue-105826.rs @@ -0,0 +1,39 @@ +// check-pass + +use std::io::Write; + +struct A(Vec<u8>); + +struct B<'a> { + one: &'a mut A, + two: &'a mut Vec<u8>, + three: Vec<u8>, +} + +impl<'a> B<'a> { + fn one(&mut self) -> &mut impl Write { + &mut self.one.0 + } + fn two(&mut self) -> &mut impl Write { + &mut *self.two + } + fn three(&mut self) -> &mut impl Write { + &mut self.three + } +} + +struct C<'a>(B<'a>); + +impl<'a> C<'a> { + fn one(&mut self) -> &mut impl Write { + self.0.one() + } + fn two(&mut self) -> &mut impl Write { + self.0.two() + } + fn three(&mut self) -> &mut impl Write { + self.0.three() + } +} + +fn main() {} diff --git a/src/test/ui/impl-trait/issues/issue-78722.rs b/src/test/ui/impl-trait/issues/issue-78722.rs index 9ee1ba3d3..78233f300 100644 --- a/src/test/ui/impl-trait/issues/issue-78722.rs +++ b/src/test/ui/impl-trait/issues/issue-78722.rs @@ -7,7 +7,7 @@ type F = impl core::future::Future<Output = u8>; struct Bug { V1: [(); { fn concrete_use() -> F { - //~^ ERROR expected `impl Future<Output = ()>` to be a future that resolves to `u8`, but it resolves to `()` + //~^ ERROR to be a future that resolves to `u8`, but it resolves to `()` async {} } let f: F = async { 1 }; diff --git a/src/test/ui/impl-trait/issues/issue-78722.stderr b/src/test/ui/impl-trait/issues/issue-78722.stderr index a96994f5a..c00df8087 100644 --- a/src/test/ui/impl-trait/issues/issue-78722.stderr +++ b/src/test/ui/impl-trait/issues/issue-78722.stderr @@ -16,7 +16,7 @@ LL | let f: F = async { 1 }; LL | }], | - value is dropped here -error[E0271]: expected `impl Future<Output = ()>` to be a future that resolves to `u8`, but it resolves to `()` +error[E0271]: expected `[async block@$DIR/issue-78722.rs:11:13: 11:21]` to be a future that resolves to `u8`, but it resolves to `()` --> $DIR/issue-78722.rs:9:30 | LL | fn concrete_use() -> F { diff --git a/src/test/ui/impl-trait/issues/issue-92305.rs b/src/test/ui/impl-trait/issues/issue-92305.rs index 1518c116b..4a89238d0 100644 --- a/src/test/ui/impl-trait/issues/issue-92305.rs +++ b/src/test/ui/impl-trait/issues/issue-92305.rs @@ -4,11 +4,10 @@ use std::iter; fn f<T>(data: &[T]) -> impl Iterator<Item = Vec> { //~^ ERROR: missing generics for struct `Vec` [E0107] - iter::empty() //~ ERROR: type annotations needed [E0282] + iter::empty() } fn g<T>(data: &[T], target: T) -> impl Iterator<Item = Vec<T>> { - //~^ ERROR: type annotations needed [E0282] f(data).filter(|x| x == target) } diff --git a/src/test/ui/impl-trait/issues/issue-92305.stderr b/src/test/ui/impl-trait/issues/issue-92305.stderr index e8575b76b..34d5c2d61 100644 --- a/src/test/ui/impl-trait/issues/issue-92305.stderr +++ b/src/test/ui/impl-trait/issues/issue-92305.stderr @@ -14,24 +14,6 @@ help: add missing generic argument LL | fn f<T>(data: &[T]) -> impl Iterator<Item = Vec<T>> { | ~~~~~~ -error[E0282]: type annotations needed - --> $DIR/issue-92305.rs:7:5 - | -LL | iter::empty() - | ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty` - | -help: consider specifying the generic argument - | -LL | iter::empty::<T>() - | +++++ - -error[E0282]: type annotations needed - --> $DIR/issue-92305.rs:10:35 - | -LL | fn g<T>(data: &[T], target: T) -> impl Iterator<Item = Vec<T>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type - -error: aborting due to 3 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0107, E0282. -For more information about an error, try `rustc --explain E0107`. +For more information about this error, try `rustc --explain E0107`. diff --git a/src/test/ui/impl-trait/negative-reasoning.rs b/src/test/ui/impl-trait/negative-reasoning.rs index da69bb349..70e24a3a9 100644 --- a/src/test/ui/impl-trait/negative-reasoning.rs +++ b/src/test/ui/impl-trait/negative-reasoning.rs @@ -18,7 +18,6 @@ impl<T: std::fmt::Debug> AnotherTrait for T {} // This is in error, because we cannot assume that `OpaqueType: !Debug` impl AnotherTrait for D<OpaqueType> { //~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>` - //~| ERROR cannot implement trait on type alias impl trait } fn main() {} diff --git a/src/test/ui/impl-trait/negative-reasoning.stderr b/src/test/ui/impl-trait/negative-reasoning.stderr index 479b45185..6b8cc9e73 100644 --- a/src/test/ui/impl-trait/negative-reasoning.stderr +++ b/src/test/ui/impl-trait/negative-reasoning.stderr @@ -9,18 +9,6 @@ LL | impl AnotherTrait for D<OpaqueType> { | = note: upstream crates may add a new impl of trait `std::fmt::Debug` for type `OpaqueType` in future versions -error: cannot implement trait on type alias impl trait - --> $DIR/negative-reasoning.rs:19:25 - | -LL | impl AnotherTrait for D<OpaqueType> { - | ^^^^^^^^^^ - | -note: type alias impl trait defined here - --> $DIR/negative-reasoning.rs:7:19 - | -LL | type OpaqueType = impl OpaqueTrait; - | ^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/impl-trait/nested-return-type4.rs b/src/test/ui/impl-trait/nested-return-type4.rs new file mode 100644 index 000000000..cec70bb1a --- /dev/null +++ b/src/test/ui/impl-trait/nested-return-type4.rs @@ -0,0 +1,8 @@ +// edition: 2021 + +fn test<'s: 's>(s: &'s str) -> impl std::future::Future<Output = impl Sized> { + async move { let _s = s; } + //~^ ERROR hidden type for `impl Future<Output = impl Sized>` captures lifetime that does not appear in bounds +} + +fn main() {} diff --git a/src/test/ui/impl-trait/nested-return-type4.stderr b/src/test/ui/impl-trait/nested-return-type4.stderr new file mode 100644 index 000000000..e761a60e7 --- /dev/null +++ b/src/test/ui/impl-trait/nested-return-type4.stderr @@ -0,0 +1,20 @@ +error[E0700]: hidden type for `impl Future<Output = impl Sized>` captures lifetime that does not appear in bounds + --> $DIR/nested-return-type4.rs:4:5 + | +LL | fn test<'s: 's>(s: &'s str) -> impl std::future::Future<Output = impl Sized> { + | -- hidden type `[async block@$DIR/nested-return-type4.rs:4:5: 4:31]` captures the lifetime `'s` as defined here +LL | async move { let _s = s; } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: to declare that `impl Future<Output = impl Sized>` captures `'s`, you can add an explicit `'s` lifetime bound + | +LL | fn test<'s: 's>(s: &'s str) -> impl std::future::Future<Output = impl Sized> + 's { + | ++++ +help: to declare that `impl Sized` captures `'s`, you can add an explicit `'s` lifetime bound + | +LL | fn test<'s: 's>(s: &'s str) -> impl std::future::Future<Output = impl Sized + 's> { + | ++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/impl-trait/nested-rpit-hrtb.rs b/src/test/ui/impl-trait/nested-rpit-hrtb.rs index abf6a7e95..a5db10d3a 100644 --- a/src/test/ui/impl-trait/nested-rpit-hrtb.rs +++ b/src/test/ui/impl-trait/nested-rpit-hrtb.rs @@ -35,26 +35,26 @@ fn one_hrtb_outlives_uses() -> impl for<'a> Bar<'a, Assoc = impl Sized + 'a> {} fn one_hrtb_trait_param_uses() -> impl for<'a> Bar<'a, Assoc = impl Qux<'a>> {} //~^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet -// This should pass. +// This should resolve. fn one_hrtb_mention_fn_trait_param<'b>() -> impl for<'a> Foo<'a, Assoc = impl Qux<'b>> {} -// This should pass. +// This should resolve. fn one_hrtb_mention_fn_outlives<'b>() -> impl for<'a> Foo<'a, Assoc = impl Sized + 'b> {} -// This should pass. +// This should resolve. fn one_hrtb_mention_fn_trait_param_uses<'b>() -> impl for<'a> Bar<'a, Assoc = impl Qux<'b>> {} -// This should pass. +// This should resolve. fn one_hrtb_mention_fn_outlives_uses<'b>() -> impl for<'a> Bar<'a, Assoc = impl Sized + 'b> {} -// This should pass. +// This should resolve. fn two_htrb_trait_param() -> impl for<'a> Foo<'a, Assoc = impl for<'b> Qux<'b>> {} // `'b` is not in scope for the outlives bound. fn two_htrb_outlives() -> impl for<'a> Foo<'a, Assoc = impl for<'b> Sized + 'b> {} //~^ ERROR use of undeclared lifetime name `'b` [E0261] -// This should pass. +// This should resolve. fn two_htrb_trait_param_uses() -> impl for<'a> Bar<'a, Assoc = impl for<'b> Qux<'b>> {} // `'b` is not in scope for the outlives bound. diff --git a/src/test/ui/impl-trait/nested_impl_trait.rs b/src/test/ui/impl-trait/nested_impl_trait.rs index 85c6f8c46..e95fab3b6 100644 --- a/src/test/ui/impl-trait/nested_impl_trait.rs +++ b/src/test/ui/impl-trait/nested_impl_trait.rs @@ -1,3 +1,4 @@ +#![feature(impl_trait_in_fn_trait_return)] use std::fmt::Debug; fn fine(x: impl Into<u32>) -> impl Into<u32> { x } @@ -25,8 +26,7 @@ fn allowed_in_assoc_type() -> impl Iterator<Item=impl Fn()> { } fn allowed_in_ret_type() -> impl Fn() -> impl Into<u32> { -//~^ `impl Trait` only allowed in function and inherent method return types - || 5 + || 5u8 } fn main() {} diff --git a/src/test/ui/impl-trait/nested_impl_trait.stderr b/src/test/ui/impl-trait/nested_impl_trait.stderr index 3291cad68..9a8f5a340 100644 --- a/src/test/ui/impl-trait/nested_impl_trait.stderr +++ b/src/test/ui/impl-trait/nested_impl_trait.stderr @@ -1,5 +1,5 @@ error[E0666]: nested `impl Trait` is not allowed - --> $DIR/nested_impl_trait.rs:5:56 + --> $DIR/nested_impl_trait.rs:6:56 | LL | fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x } | ----------^^^^^^^^^^- @@ -8,7 +8,7 @@ LL | fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x } | outer `impl Trait` error[E0666]: nested `impl Trait` is not allowed - --> $DIR/nested_impl_trait.rs:9:42 + --> $DIR/nested_impl_trait.rs:10:42 | LL | fn bad_in_fn_syntax(x: fn() -> impl Into<impl Debug>) {} | ----------^^^^^^^^^^- @@ -17,7 +17,7 @@ LL | fn bad_in_fn_syntax(x: fn() -> impl Into<impl Debug>) {} | outer `impl Trait` error[E0666]: nested `impl Trait` is not allowed - --> $DIR/nested_impl_trait.rs:13:37 + --> $DIR/nested_impl_trait.rs:14:37 | LL | fn bad_in_arg_position(_: impl Into<impl Debug>) { } | ----------^^^^^^^^^^- @@ -26,7 +26,7 @@ LL | fn bad_in_arg_position(_: impl Into<impl Debug>) { } | outer `impl Trait` error[E0666]: nested `impl Trait` is not allowed - --> $DIR/nested_impl_trait.rs:18:44 + --> $DIR/nested_impl_trait.rs:19:44 | LL | fn bad(x: impl Into<u32>) -> impl Into<impl Debug> { x } | ----------^^^^^^^^^^- @@ -35,19 +35,13 @@ LL | fn bad(x: impl Into<u32>) -> impl Into<impl Debug> { x } | outer `impl Trait` error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return - --> $DIR/nested_impl_trait.rs:9:32 + --> $DIR/nested_impl_trait.rs:10:32 | LL | fn bad_in_fn_syntax(x: fn() -> impl Into<impl Debug>) {} | ^^^^^^^^^^^^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return - --> $DIR/nested_impl_trait.rs:27:42 - | -LL | fn allowed_in_ret_type() -> impl Fn() -> impl Into<u32> { - | ^^^^^^^^^^^^^^ - error[E0277]: the trait bound `impl Debug: From<impl Into<u32>>` is not satisfied - --> $DIR/nested_impl_trait.rs:5:46 + --> $DIR/nested_impl_trait.rs:6:46 | LL | fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x } | ^^^^^^^^^^^^^^^^^^^^^ the trait `From<impl Into<u32>>` is not implemented for `impl Debug` @@ -56,7 +50,7 @@ LL | fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x } = note: required for `impl Into<u32>` to implement `Into<impl Debug>` error[E0277]: the trait bound `impl Debug: From<impl Into<u32>>` is not satisfied - --> $DIR/nested_impl_trait.rs:18:34 + --> $DIR/nested_impl_trait.rs:19:34 | LL | fn bad(x: impl Into<u32>) -> impl Into<impl Debug> { x } | ^^^^^^^^^^^^^^^^^^^^^ the trait `From<impl Into<u32>>` is not implemented for `impl Debug` @@ -64,7 +58,7 @@ LL | fn bad(x: impl Into<u32>) -> impl Into<impl Debug> { x } = help: the trait `Into<U>` is implemented for `T` = note: required for `impl Into<u32>` to implement `Into<impl Debug>` -error: aborting due to 8 previous errors +error: aborting due to 7 previous errors Some errors have detailed explanations: E0277, E0562, E0666. For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs b/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs index 621c4ea6e..af9dfe25b 100644 --- a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs +++ b/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs @@ -5,13 +5,13 @@ type Foo = impl PartialEq<(Foo, i32)>; struct Bar; impl PartialEq<(Foo, i32)> for Bar { -//~^ ERROR cannot implement trait on type alias impl trait fn eq(&self, _other: &(Foo, i32)) -> bool { true } } fn foo() -> Foo { + //~^ ERROR can't compare `Bar` with `(Bar, i32)` Bar } diff --git a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.stderr b/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.stderr index 2ef1697ba..7b63a3d0b 100644 --- a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.stderr +++ b/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.stderr @@ -1,14 +1,15 @@ -error: cannot implement trait on type alias impl trait - --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs:7:17 +error[E0277]: can't compare `Bar` with `(Bar, i32)` + --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs:13:13 | -LL | impl PartialEq<(Foo, i32)> for Bar { - | ^^^ +LL | fn foo() -> Foo { + | ^^^ no implementation for `Bar == (Bar, i32)` +LL | +LL | Bar + | --- return type was inferred to be `Bar` here | -note: type alias impl trait defined here - --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs:3:12 - | -LL | type Foo = impl PartialEq<(Foo, i32)>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: the trait `PartialEq<(Bar, i32)>` is not implemented for `Bar` + = help: the trait `PartialEq<(Foo, i32)>` is implemented for `Bar` error: aborting due to previous error +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.rs b/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.rs index df7966f00..91f1ed481 100644 --- a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.rs +++ b/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.rs @@ -2,11 +2,13 @@ mod a { type Foo = impl PartialEq<(Foo, i32)>; + //~^ ERROR: unconstrained opaque type struct Bar; impl PartialEq<(Bar, i32)> for Bar { fn eq(&self, _other: &(Foo, i32)) -> bool { + //~^ ERROR: `eq` has an incompatible type for trait true } } @@ -14,12 +16,13 @@ mod a { mod b { type Foo = impl PartialEq<(Foo, i32)>; + //~^ ERROR: unconstrained opaque type struct Bar; impl PartialEq<(Foo, i32)> for Bar { - //~^ ERROR cannot implement trait on type alias impl trait fn eq(&self, _other: &(Bar, i32)) -> bool { + //~^ ERROR: `eq` has an incompatible type for trait true } } diff --git a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr b/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr index 6cd63dcf8..3dda5761a 100644 --- a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr +++ b/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr @@ -1,14 +1,49 @@ -error: cannot implement trait on type alias impl trait - --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:20:21 +error: unconstrained opaque type + --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:4:16 | -LL | impl PartialEq<(Foo, i32)> for Bar { - | ^^^ +LL | type Foo = impl PartialEq<(Foo, i32)>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `Foo` must be used in combination with a concrete type within the same module + +error[E0053]: method `eq` has an incompatible type for trait + --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:10:30 + | +LL | type Foo = impl PartialEq<(Foo, i32)>; + | -------------------------- the found opaque type +... +LL | fn eq(&self, _other: &(Foo, i32)) -> bool { + | ^^^^^^^^^^^ + | | + | expected struct `a::Bar`, found opaque type + | help: change the parameter type to match the trait: `&(a::Bar, i32)` | -note: type alias impl trait defined here - --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:16:16 + = note: expected fn pointer `fn(&a::Bar, &(a::Bar, i32)) -> _` + found fn pointer `fn(&a::Bar, &(a::Foo, i32)) -> _` + +error: unconstrained opaque type + --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:18:16 | LL | type Foo = impl PartialEq<(Foo, i32)>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `Foo` must be used in combination with a concrete type within the same module + +error[E0053]: method `eq` has an incompatible type for trait + --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:24:30 + | +LL | type Foo = impl PartialEq<(Foo, i32)>; + | -------------------------- the expected opaque type +... +LL | fn eq(&self, _other: &(Bar, i32)) -> bool { + | ^^^^^^^^^^^ + | | + | expected opaque type, found struct `b::Bar` + | help: change the parameter type to match the trait: `&(b::Foo, i32)` + | + = note: expected fn pointer `fn(&b::Bar, &(b::Foo, i32)) -> _` + found fn pointer `fn(&b::Bar, &(b::Bar, i32)) -> _` -error: aborting due to previous error +error: aborting due to 4 previous errors +For more information about this error, try `rustc --explain E0053`. diff --git a/src/test/ui/impl-trait/where-allowed.rs b/src/test/ui/impl-trait/where-allowed.rs index c1dd46c7f..ff63b04c2 100644 --- a/src/test/ui/impl-trait/where-allowed.rs +++ b/src/test/ui/impl-trait/where-allowed.rs @@ -1,5 +1,6 @@ //! A simple test for testing many permutations of allowedness of //! impl Trait +#![feature(impl_trait_in_fn_trait_return)] use std::fmt::Debug; // Allowed @@ -39,9 +40,8 @@ fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() } fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() } //~^ ERROR `impl Trait` only allowed in function and inherent method return types -// Disallowed +// Allowed fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types // Disallowed fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } @@ -57,9 +57,8 @@ fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } //~^ ERROR `impl Trait` only allowed in function and inherent method return types //~| ERROR nested `impl Trait` is not allowed -// Disallowed +// Allowed fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types // Disallowed fn in_Fn_parameter_in_generics<F: Fn(impl Debug)> (_: F) { panic!() } diff --git a/src/test/ui/impl-trait/where-allowed.stderr b/src/test/ui/impl-trait/where-allowed.stderr index 2e7c7ca40..3ad0a9f9d 100644 --- a/src/test/ui/impl-trait/where-allowed.stderr +++ b/src/test/ui/impl-trait/where-allowed.stderr @@ -17,7 +17,7 @@ LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic | outer `impl Trait` error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:119:16 + --> $DIR/where-allowed.rs:118:16 | LL | type Out = impl Debug; | ^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | type Out = impl Debug; = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:154:23 + --> $DIR/where-allowed.rs:153:23 | LL | type InTypeAlias<R> = impl Debug; | ^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | type InTypeAlias<R> = impl Debug; = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:157:39 + --> $DIR/where-allowed.rs:156:39 | LL | type InReturnInTypeAlias<R> = fn() -> impl Debug; | ^^^^^^^^^^ @@ -44,53 +44,47 @@ LL | type InReturnInTypeAlias<R> = fn() -> impl Debug; = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer param - --> $DIR/where-allowed.rs:15:40 + --> $DIR/where-allowed.rs:16:40 | LL | fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return - --> $DIR/where-allowed.rs:19:42 + --> $DIR/where-allowed.rs:20:42 | LL | fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer param - --> $DIR/where-allowed.rs:23:38 + --> $DIR/where-allowed.rs:24:38 | LL | fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return - --> $DIR/where-allowed.rs:27:40 + --> $DIR/where-allowed.rs:28:40 | LL | fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param - --> $DIR/where-allowed.rs:31:49 + --> $DIR/where-allowed.rs:32:49 | LL | fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return - --> $DIR/where-allowed.rs:35:51 + --> $DIR/where-allowed.rs:36:51 | LL | fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param - --> $DIR/where-allowed.rs:39:55 + --> $DIR/where-allowed.rs:40:55 | LL | fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return - --> $DIR/where-allowed.rs:43:57 - | -LL | fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic!() } - | ^^^^^^^^^^ - error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param --> $DIR/where-allowed.rs:47:51 | @@ -109,56 +103,50 @@ error[E0562]: `impl Trait` only allowed in function and inherent method return t LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return - --> $DIR/where-allowed.rs:61:59 - | -LL | fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() } - | ^^^^^^^^^^ - error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param - --> $DIR/where-allowed.rs:65:38 + --> $DIR/where-allowed.rs:64:38 | LL | fn in_Fn_parameter_in_generics<F: Fn(impl Debug)> (_: F) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return - --> $DIR/where-allowed.rs:69:40 + --> $DIR/where-allowed.rs:68:40 | LL | fn in_Fn_return_in_generics<F: Fn() -> impl Debug> (_: F) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:82:32 + --> $DIR/where-allowed.rs:81:32 | LL | struct InBraceStructField { x: impl Debug } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in path - --> $DIR/where-allowed.rs:86:41 + --> $DIR/where-allowed.rs:85:41 | LL | struct InAdtInBraceStructField { x: Vec<impl Debug> } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:90:27 + --> $DIR/where-allowed.rs:89:27 | LL | struct InTupleStructField(impl Debug); | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:95:25 + --> $DIR/where-allowed.rs:94:25 | LL | InBraceVariant { x: impl Debug }, | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:97:20 + --> $DIR/where-allowed.rs:96:20 | LL | InTupleVariant(impl Debug), | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return - --> $DIR/where-allowed.rs:108:23 + --> $DIR/where-allowed.rs:107:23 | LL | fn in_return() -> impl Debug; | ^^^^^^^^^^ @@ -167,7 +155,7 @@ LL | fn in_return() -> impl Debug; = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `impl` method return - --> $DIR/where-allowed.rs:125:34 + --> $DIR/where-allowed.rs:124:34 | LL | fn in_trait_impl_return() -> impl Debug { () } | ^^^^^^^^^^ @@ -176,127 +164,127 @@ LL | fn in_trait_impl_return() -> impl Debug { () } = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `extern fn` param - --> $DIR/where-allowed.rs:138:33 + --> $DIR/where-allowed.rs:137:33 | LL | fn in_foreign_parameters(_: impl Debug); | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `extern fn` return - --> $DIR/where-allowed.rs:141:31 + --> $DIR/where-allowed.rs:140:31 | LL | fn in_foreign_return() -> impl Debug; | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return - --> $DIR/where-allowed.rs:157:39 + --> $DIR/where-allowed.rs:156:39 | LL | type InReturnInTypeAlias<R> = fn() -> impl Debug; | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait - --> $DIR/where-allowed.rs:162:16 + --> $DIR/where-allowed.rs:161:16 | LL | impl PartialEq<impl Debug> for () { | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:167:24 + --> $DIR/where-allowed.rs:166:24 | LL | impl PartialEq<()> for impl Debug { | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:172:6 + --> $DIR/where-allowed.rs:171:6 | LL | impl impl Debug { | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:178:24 + --> $DIR/where-allowed.rs:177:24 | LL | impl InInherentImplAdt<impl Debug> { | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:184:11 + --> $DIR/where-allowed.rs:183:11 | LL | where impl Debug: Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:191:15 + --> $DIR/where-allowed.rs:190:15 | LL | where Vec<impl Debug>: Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in bound - --> $DIR/where-allowed.rs:198:24 + --> $DIR/where-allowed.rs:197:24 | LL | where T: PartialEq<impl Debug> | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param - --> $DIR/where-allowed.rs:205:17 + --> $DIR/where-allowed.rs:204:17 | LL | where T: Fn(impl Debug) | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return - --> $DIR/where-allowed.rs:212:22 + --> $DIR/where-allowed.rs:211:22 | LL | where T: Fn() -> impl Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:218:40 + --> $DIR/where-allowed.rs:217:40 | LL | struct InStructGenericParamDefault<T = impl Debug>(T); | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:222:36 + --> $DIR/where-allowed.rs:221:36 | LL | enum InEnumGenericParamDefault<T = impl Debug> { Variant(T) } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:226:38 + --> $DIR/where-allowed.rs:225:38 | LL | trait InTraitGenericParamDefault<T = impl Debug> {} | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:230:41 + --> $DIR/where-allowed.rs:229:41 | LL | type InTypeAliasGenericParamDefault<T = impl Debug> = T; | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:234:11 + --> $DIR/where-allowed.rs:233:11 | LL | impl <T = impl Debug> T {} | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:241:40 + --> $DIR/where-allowed.rs:240:40 | LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {} | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding - --> $DIR/where-allowed.rs:247:29 + --> $DIR/where-allowed.rs:246:29 | LL | let _in_local_variable: impl Fn() = || {}; | ^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in closure return - --> $DIR/where-allowed.rs:249:46 + --> $DIR/where-allowed.rs:248:46 | LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; | ^^^^^^^^^ error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:234:7 + --> $DIR/where-allowed.rs:233:7 | LL | impl <T = impl Debug> T {} | ^^^^^^^^^^^^^^ @@ -306,7 +294,7 @@ LL | impl <T = impl Debug> T {} = note: `#[deny(invalid_type_param_default)]` on by default error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:241:36 + --> $DIR/where-allowed.rs:240:36 | LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {} | ^^^^^^^^^^^^^^ @@ -315,14 +303,14 @@ LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {} = note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887> error[E0118]: no nominal type found for inherent implementation - --> $DIR/where-allowed.rs:234:23 + --> $DIR/where-allowed.rs:233:23 | LL | impl <T = impl Debug> T {} | ^ impl requires a nominal type | = note: either implement a trait on it or create a newtype to wrap it instead -error: aborting due to 49 previous errors +error: aborting due to 47 previous errors Some errors have detailed explanations: E0118, E0562, E0658, E0666. For more information about an error, try `rustc --explain E0118`. diff --git a/src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.rs b/src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.rs index d9de73a38..79844dcbd 100644 --- a/src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.rs +++ b/src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.rs @@ -31,6 +31,16 @@ fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ T) -> &'out T { sadness.cast() } +fn badboi2<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ T) { + //~^ ERROR lifetime mismatch + let _: &'out T = sadness.cast(); +} + +fn badboi3<'in_, 'out, T>(a: Foo<'in_, 'out, (&'in_ T, &'out T)>, sadness: &'in_ T) { + //~^ ERROR lifetime mismatch + let _: &'out T = sadness.cast(); +} + fn bad<'short, T>(value: &'short T) -> &'static T { let x: for<'in_, 'out> fn(Foo<'in_, 'out, T>, &'in_ T) -> &'out T = badboi; let x: for<'out> fn(Foo<'short, 'out, T>, &'short T) -> &'out T = x; diff --git a/src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.stderr b/src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.stderr index b020ea64b..0c00bbc38 100644 --- a/src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.stderr +++ b/src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.stderr @@ -7,6 +7,24 @@ LL | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ T) -> &'out | this parameter and the return type are declared with different lifetimes... | ...but data from `x` is returned here -error: aborting due to previous error +error[E0623]: lifetime mismatch + --> $DIR/hrlt-implied-trait-bounds-guard.rs:34:30 + | +LL | fn badboi2<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ T) { + | ^^^^^^^^^^^^^^^^^^ + | | + | this type is declared with multiple lifetimes... + | ...but data with one lifetime flows into the other here + +error[E0623]: lifetime mismatch + --> $DIR/hrlt-implied-trait-bounds-guard.rs:39:30 + | +LL | fn badboi3<'in_, 'out, T>(a: Foo<'in_, 'out, (&'in_ T, &'out T)>, sadness: &'in_ T) { + | ^^^^^^^^^^^^^^^^^-------^^-------^^ + | | | + | | these two types are declared with different lifetimes... + | ...but data from `a` flows into `a` here + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.rs b/src/test/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.rs new file mode 100644 index 000000000..6ccbb5bb2 --- /dev/null +++ b/src/test/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.rs @@ -0,0 +1,22 @@ +#![deny(implied_bounds_entailment)] + +trait Project { + type Ty; +} +impl Project for &'_ &'_ () { + type Ty = (); +} +trait Trait { + fn get<'s>(s: &'s str, _: ()) -> &'static str; +} +impl Trait for () { + fn get<'s>(s: &'s str, _: <&'static &'s () as Project>::Ty) -> &'static str { + //~^ ERROR impl method assumes more implied bounds than the corresponding trait method + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + s + } +} +fn main() { + let val = <() as Trait>::get(&String::from("blah blah blah"), ()); + println!("{}", val); +} diff --git a/src/test/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.stderr b/src/test/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.stderr new file mode 100644 index 000000000..0ac31c642 --- /dev/null +++ b/src/test/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.stderr @@ -0,0 +1,16 @@ +error: impl method assumes more implied bounds than the corresponding trait method + --> $DIR/impl-implied-bounds-compatibility-unnormalized.rs:13:5 + | +LL | fn get<'s>(s: &'s str, _: <&'static &'s () as Project>::Ty) -> &'static str { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #105572 <https://github.com/rust-lang/rust/issues/105572> +note: the lint level is defined here + --> $DIR/impl-implied-bounds-compatibility-unnormalized.rs:1:9 + | +LL | #![deny(implied_bounds_entailment)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/implied-bounds/impl-implied-bounds-compatibility.rs b/src/test/ui/implied-bounds/impl-implied-bounds-compatibility.rs new file mode 100644 index 000000000..d097bc16a --- /dev/null +++ b/src/test/ui/implied-bounds/impl-implied-bounds-compatibility.rs @@ -0,0 +1,21 @@ +#![deny(implied_bounds_entailment)] + +use std::cell::RefCell; + +pub struct MessageListeners<'a> { + listeners: RefCell<Vec<Box<dyn FnMut(()) + 'a>>>, +} + +pub trait MessageListenersInterface { + fn listeners<'c>(&'c self) -> &'c MessageListeners<'c>; +} + +impl<'a> MessageListenersInterface for MessageListeners<'a> { + fn listeners<'b>(&'b self) -> &'a MessageListeners<'b> { + //~^ ERROR impl method assumes more implied bounds than the corresponding trait method + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + self + } +} + +fn main() {} diff --git a/src/test/ui/implied-bounds/impl-implied-bounds-compatibility.stderr b/src/test/ui/implied-bounds/impl-implied-bounds-compatibility.stderr new file mode 100644 index 000000000..0dfa8167a --- /dev/null +++ b/src/test/ui/implied-bounds/impl-implied-bounds-compatibility.stderr @@ -0,0 +1,16 @@ +error: impl method assumes more implied bounds than the corresponding trait method + --> $DIR/impl-implied-bounds-compatibility.rs:14:5 + | +LL | fn listeners<'b>(&'b self) -> &'a MessageListeners<'b> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #105572 <https://github.com/rust-lang/rust/issues/105572> +note: the lint level is defined here + --> $DIR/impl-implied-bounds-compatibility.rs:1:9 + | +LL | #![deny(implied_bounds_entailment)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/inference/cannot-infer-async.rs b/src/test/ui/inference/cannot-infer-async.rs index e7fabd0ff..b5152d04f 100644 --- a/src/test/ui/inference/cannot-infer-async.rs +++ b/src/test/ui/inference/cannot-infer-async.rs @@ -10,6 +10,7 @@ fn main() { let fut = async { make_unit()?; - Ok(()) //~ ERROR type annotations needed + Ok(()) + //~^ ERROR type annotations needed }; } diff --git a/src/test/ui/inference/cannot-infer-closure.rs b/src/test/ui/inference/cannot-infer-closure.rs index 1c350b18f..bd5d10b41 100644 --- a/src/test/ui/inference/cannot-infer-closure.rs +++ b/src/test/ui/inference/cannot-infer-closure.rs @@ -1,6 +1,7 @@ fn main() { let x = |a: (), b: ()| { Err(a)?; - Ok(b) //~ ERROR type annotations needed + Ok(b) + //~^ ERROR type annotations needed }; } diff --git a/src/test/ui/inference/deref-suggestion.stderr b/src/test/ui/inference/deref-suggestion.stderr index d729f2d68..034005697 100644 --- a/src/test/ui/inference/deref-suggestion.stderr +++ b/src/test/ui/inference/deref-suggestion.stderr @@ -157,11 +157,11 @@ error[E0308]: `if` and `else` have incompatible types --> $DIR/deref-suggestion.rs:69:12 | LL | let val = if true { - | _______________- -LL | | *a - | | -- expected because of this -LL | | } else if true { - | |____________^ + | ________________- +LL | | *a + | | -- expected because of this +LL | | } else if true { + | | ____________^ LL | || LL | || b LL | || } else { @@ -169,7 +169,7 @@ LL | || &0 LL | || }; | || ^ | ||_____| - | |______`if` and `else` have incompatible types + | |_____`if` and `else` have incompatible types | expected `i32`, found `&{integer}` error: aborting due to 13 previous errors diff --git a/src/test/ui/inference/issue-103587.rs b/src/test/ui/inference/issue-103587.rs new file mode 100644 index 000000000..11536f9f4 --- /dev/null +++ b/src/test/ui/inference/issue-103587.rs @@ -0,0 +1,12 @@ +fn main() { + let x = Some(123); + + if let Some(_) == x {} + //~^ ERROR expected `=`, found `==` + + if Some(_) = x {} + //~^ ERROR mismatched types + + if None = x { } + //~^ ERROR mismatched types +} diff --git a/src/test/ui/inference/issue-103587.stderr b/src/test/ui/inference/issue-103587.stderr new file mode 100644 index 000000000..b373fbfbb --- /dev/null +++ b/src/test/ui/inference/issue-103587.stderr @@ -0,0 +1,40 @@ +error: expected `=`, found `==` + --> $DIR/issue-103587.rs:4:20 + | +LL | if let Some(_) == x {} + | ^^ + | +help: consider using `=` here + | +LL | if let Some(_) = x {} + | ~ + +error[E0308]: mismatched types + --> $DIR/issue-103587.rs:7:8 + | +LL | if Some(_) = x {} + | ^^^^^^^^^^^ expected `bool`, found `()` + | +help: consider adding `let` + | +LL | if let Some(_) = x {} + | +++ + +error[E0308]: mismatched types + --> $DIR/issue-103587.rs:10:8 + | +LL | if None = x { } + | ^^^^^^^^ expected `bool`, found `()` + | +help: you might have meant to use pattern matching + | +LL | if let None = x { } + | +++ +help: you might have meant to compare for equality + | +LL | if None == x { } + | + + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/inference/issue-104649.rs b/src/test/ui/inference/issue-104649.rs new file mode 100644 index 000000000..4637b884d --- /dev/null +++ b/src/test/ui/inference/issue-104649.rs @@ -0,0 +1,32 @@ +type Result<T, E = Error> = ::std::result::Result<T, E>; +struct Error; + +trait ForEach { + type Input; + fn for_each<F, U>(self, f: F) + where + F: FnOnce(Self::Input) -> U; +} + +impl<T> ForEach for A<T> { + type Input = T; + fn for_each<F, U>(self, f: F) + where + F: FnOnce(Self::Input) -> U, + { + todo!() + } +} + +struct A<T>(T); + +fn main() { + let a = A(Result::Ok(Result::Ok(()))); //~ ERROR type annotations needed + a.for_each(|a: Result<_>| { + let f = || match a { + Ok(Ok(a)) => {} + Ok(Err(a)) => {} + Err(a) => {} + }; + }); +} diff --git a/src/test/ui/inference/issue-104649.stderr b/src/test/ui/inference/issue-104649.stderr new file mode 100644 index 000000000..4962b21f9 --- /dev/null +++ b/src/test/ui/inference/issue-104649.stderr @@ -0,0 +1,14 @@ +error[E0282]: type annotations needed for `A<std::result::Result<std::result::Result<(), E>, Error>>` + --> $DIR/issue-104649.rs:24:9 + | +LL | let a = A(Result::Ok(Result::Ok(()))); + | ^ + | +help: consider giving `a` an explicit type, where the type for type parameter `E` is specified + | +LL | let a: A<std::result::Result<std::result::Result<(), E>, Error>> = A(Result::Ok(Result::Ok(()))); + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/src/test/ui/inference/issue-71732.rs b/src/test/ui/inference/issue-71732.rs index 30063a095..8a9d2b235 100644 --- a/src/test/ui/inference/issue-71732.rs +++ b/src/test/ui/inference/issue-71732.rs @@ -15,7 +15,8 @@ use std::collections::hash_map::HashMap; fn foo(parameters: &HashMap<String, String>) -> bool { parameters - .get(&"key".into()) //~ ERROR: type annotations needed + .get(&"key".into()) + //~^ ERROR type annotations needed .and_then(|found: &String| Some(false)) .unwrap_or(false) } diff --git a/src/test/ui/inference/issue-72616.rs b/src/test/ui/inference/issue-72616.rs index 5e5a3babf..69ade1a75 100644 --- a/src/test/ui/inference/issue-72616.rs +++ b/src/test/ui/inference/issue-72616.rs @@ -1,3 +1,5 @@ +// ignore-wasm32 FIXME: ignoring wasm as it suggests slightly different impls + // Regression test for #72616, it used to emit incorrect diagnostics, like: // error[E0283]: type annotations needed for `String` // --> src/main.rs:8:30 @@ -18,7 +20,8 @@ pub fn main() { } { if String::from("a") == "a".try_into().unwrap() {} - //~^ ERROR: type annotations needed + //~^ ERROR type annotations needed + //~| ERROR type annotations needed } { let _: String = match "_".try_into() { diff --git a/src/test/ui/inference/issue-72616.stderr b/src/test/ui/inference/issue-72616.stderr index a71ce9a8e..6ee0626ca 100644 --- a/src/test/ui/inference/issue-72616.stderr +++ b/src/test/ui/inference/issue-72616.stderr @@ -1,5 +1,5 @@ error[E0283]: type annotations needed - --> $DIR/issue-72616.rs:20:37 + --> $DIR/issue-72616.rs:22:37 | LL | if String::from("a") == "a".try_into().unwrap() {} | -- ^^^^^^^^ @@ -16,6 +16,22 @@ help: try using a fully qualified path to specify the expected types LL | if String::from("a") == <&str as TryInto<T>>::try_into("a").unwrap() {} | +++++++++++++++++++++++++++++++ ~ -error: aborting due to previous error +error[E0283]: type annotations needed + --> $DIR/issue-72616.rs:22:37 + | +LL | if String::from("a") == "a".try_into().unwrap() {} + | ^^^^^^^^ + | + = note: multiple `impl`s satisfying `_: TryFrom<&str>` found in the following crates: `core`, `std`: + - impl<> TryFrom<&str> for std::sys_common::net::LookupHost; + - impl<T, U> TryFrom<U> for T + where U: Into<T>; + = note: required for `&str` to implement `TryInto<_>` +help: try using a fully qualified path to specify the expected types + | +LL | if String::from("a") == <&str as TryInto<T>>::try_into("a").unwrap() {} + | +++++++++++++++++++++++++++++++ ~ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0283`. diff --git a/src/test/ui/inference/question-mark-type-infer.rs b/src/test/ui/inference/question-mark-type-infer.rs index 64333a293..10560f85e 100644 --- a/src/test/ui/inference/question-mark-type-infer.rs +++ b/src/test/ui/inference/question-mark-type-infer.rs @@ -7,7 +7,8 @@ fn f(x: &i32) -> Result<i32, ()> { fn g() -> Result<Vec<i32>, ()> { let l = [1, 2, 3, 4]; - l.iter().map(f).collect()? //~ ERROR type annotations needed + l.iter().map(f).collect()? + //~^ ERROR type annotations needed } fn main() { diff --git a/src/test/ui/infinite/infinite-instantiation.stderr b/src/test/ui/infinite/infinite-instantiation.stderr index 52f578134..951e0f587 100644 --- a/src/test/ui/infinite/infinite-instantiation.stderr +++ b/src/test/ui/infinite/infinite-instantiation.stderr @@ -1,4 +1,4 @@ -error: reached the recursion limit while instantiating `function::<Option<Option<Option<...>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` +error: reached the recursion limit while instantiating `function::<Option<Option<Option<Option<Option<...>>>>>>` --> $DIR/infinite-instantiation.rs:22:9 | LL | function(counter - 1, t.to_option()); diff --git a/src/test/ui/infinite/infinite-recursion-const-fn.stderr b/src/test/ui/infinite/infinite-recursion-const-fn.stderr index 620c9e110..53b603a47 100644 --- a/src/test/ui/infinite/infinite-recursion-const-fn.stderr +++ b/src/test/ui/infinite/infinite-recursion-const-fn.stderr @@ -2,143 +2,648 @@ error[E0080]: evaluation of constant value failed --> $DIR/infinite-recursion-const-fn.rs:4:5 | LL | b() + | ^^^ reached the configured maximum number of stack frames + | +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() | ^^^ - | | - | reached the configured maximum number of stack frames - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 - | inside `a` at $DIR/infinite-recursion-const-fn.rs:4:5 -... -LL | a() - | --- - | | - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 - | inside `b` at $DIR/infinite-recursion-const-fn.rs:7:5 -LL | } +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `b` + --> $DIR/infinite-recursion-const-fn.rs:7:5 + | +LL | a() + | ^^^ +note: inside `a` + --> $DIR/infinite-recursion-const-fn.rs:4:5 + | +LL | b() + | ^^^ +note: inside `ARR::{constant#0}` + --> $DIR/infinite-recursion-const-fn.rs:9:18 + | LL | const ARR: [i32; a()] = [5; 6]; - | --- inside `ARR::{constant#0}` at $DIR/infinite-recursion-const-fn.rs:9:18 + | ^^^ error: aborting due to previous error diff --git a/src/test/ui/inline-const/expr-with-block-err.rs b/src/test/ui/inline-const/expr-with-block-err.rs new file mode 100644 index 000000000..f7547742d --- /dev/null +++ b/src/test/ui/inline-const/expr-with-block-err.rs @@ -0,0 +1,6 @@ +#![feature(inline_const)] + +fn main() { + const { 2 } - const { 1 }; + //~^ ERROR mismatched types +} diff --git a/src/test/ui/inline-const/expr-with-block-err.stderr b/src/test/ui/inline-const/expr-with-block-err.stderr new file mode 100644 index 000000000..6f7408f4e --- /dev/null +++ b/src/test/ui/inline-const/expr-with-block-err.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/expr-with-block-err.rs:4:13 + | +LL | const { 2 } - const { 1 }; + | ^ expected `()`, found integer + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/inline-const/expr-with-block.rs b/src/test/ui/inline-const/expr-with-block.rs new file mode 100644 index 000000000..391872476 --- /dev/null +++ b/src/test/ui/inline-const/expr-with-block.rs @@ -0,0 +1,10 @@ +// check-pass +#![feature(inline_const)] +fn main() { + match true { + true => const {} + false => () + } + const {} + () +} diff --git a/src/test/ui/issues/issue-105330.rs b/src/test/ui/issues/issue-105330.rs new file mode 100644 index 000000000..86e45f10b --- /dev/null +++ b/src/test/ui/issues/issue-105330.rs @@ -0,0 +1,21 @@ +pub trait TraitWAssocConst { + const A: usize; +} +pub struct Demo {} + +impl TraitWAssocConst for impl Demo { //~ ERROR E0404 + //~^ ERROR E0562 + pubconst A: str = 32; //~ ERROR expected one of +} + +fn foo<A: TraitWAssocConst<A=32>>() { //~ ERROR E0658 + foo::<Demo>()(); //~ ERROR E0271 + //~^ ERROR E0618 + //~| ERROR E0277 +} + +fn main<A: TraitWAssocConst<A=32>>() { //~ ERROR E0131 + //~^ ERROR E0658 + foo::<Demo>(); //~ ERROR E0277 + //~^ ERROR E0271 +} diff --git a/src/test/ui/issues/issue-105330.stderr b/src/test/ui/issues/issue-105330.stderr new file mode 100644 index 000000000..92f2ccb65 --- /dev/null +++ b/src/test/ui/issues/issue-105330.stderr @@ -0,0 +1,109 @@ +error: expected one of `!` or `::`, found `A` + --> $DIR/issue-105330.rs:8:14 + | +LL | impl TraitWAssocConst for impl Demo { + | - while parsing this item list starting here +LL | +LL | pubconst A: str = 32; + | ^ expected one of `!` or `::` +LL | } + | - the item list ends here + +error[E0404]: expected trait, found struct `Demo` + --> $DIR/issue-105330.rs:6:32 + | +LL | impl TraitWAssocConst for impl Demo { + | ^^^^ not a trait + +error[E0658]: associated const equality is incomplete + --> $DIR/issue-105330.rs:11:28 + | +LL | fn foo<A: TraitWAssocConst<A=32>>() { + | ^^^^ + | + = note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information + = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable + +error[E0658]: associated const equality is incomplete + --> $DIR/issue-105330.rs:17:29 + | +LL | fn main<A: TraitWAssocConst<A=32>>() { + | ^^^^ + | + = note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information + = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable + +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type + --> $DIR/issue-105330.rs:6:27 + | +LL | impl TraitWAssocConst for impl Demo { + | ^^^^^^^^^ + +error[E0277]: the trait bound `Demo: TraitWAssocConst` is not satisfied + --> $DIR/issue-105330.rs:12:11 + | +LL | foo::<Demo>()(); + | ^^^^ the trait `TraitWAssocConst` is not implemented for `Demo` + | +note: required by a bound in `foo` + --> $DIR/issue-105330.rs:11:11 + | +LL | fn foo<A: TraitWAssocConst<A=32>>() { + | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `foo` + +error[E0271]: type mismatch resolving `<Demo as TraitWAssocConst>::A == 32` + --> $DIR/issue-105330.rs:12:11 + | +LL | foo::<Demo>()(); + | ^^^^ types differ + | +note: required by a bound in `foo` + --> $DIR/issue-105330.rs:11:28 + | +LL | fn foo<A: TraitWAssocConst<A=32>>() { + | ^^^^ required by this bound in `foo` + +error[E0618]: expected function, found `()` + --> $DIR/issue-105330.rs:12:5 + | +LL | fn foo<A: TraitWAssocConst<A=32>>() { + | ----------------------------------- `foo::<Demo>` defined here returns `()` +LL | foo::<Demo>()(); + | ^^^^^^^^^^^^^-- + | | + | call expression requires function + +error[E0277]: the trait bound `Demo: TraitWAssocConst` is not satisfied + --> $DIR/issue-105330.rs:19:11 + | +LL | foo::<Demo>(); + | ^^^^ the trait `TraitWAssocConst` is not implemented for `Demo` + | +note: required by a bound in `foo` + --> $DIR/issue-105330.rs:11:11 + | +LL | fn foo<A: TraitWAssocConst<A=32>>() { + | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `foo` + +error[E0271]: type mismatch resolving `<Demo as TraitWAssocConst>::A == 32` + --> $DIR/issue-105330.rs:19:11 + | +LL | foo::<Demo>(); + | ^^^^ types differ + | +note: required by a bound in `foo` + --> $DIR/issue-105330.rs:11:28 + | +LL | fn foo<A: TraitWAssocConst<A=32>>() { + | ^^^^ required by this bound in `foo` + +error[E0131]: `main` function is not allowed to have generic parameters + --> $DIR/issue-105330.rs:17:8 + | +LL | fn main<A: TraitWAssocConst<A=32>>() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `main` cannot have generic parameters + +error: aborting due to 11 previous errors + +Some errors have detailed explanations: E0131, E0271, E0277, E0404, E0562, E0618, E0658. +For more information about an error, try `rustc --explain E0131`. diff --git a/src/test/ui/issues/issue-12127.rs b/src/test/ui/issues/issue-12127.rs index 8b30ddc2d..199d542e8 100644 --- a/src/test/ui/issues/issue-12127.rs +++ b/src/test/ui/issues/issue-12127.rs @@ -1,6 +1,6 @@ -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] -fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f } +fn to_fn_once<A:std::marker::Tuple,F:FnOnce<A>>(f: F) -> F { f } fn do_it(x: &isize) { } fn main() { diff --git a/src/test/ui/issues/issue-13497-2.stderr b/src/test/ui/issues/issue-13497-2.stderr index 6f72b79f2..3abeadf9e 100644 --- a/src/test/ui/issues/issue-13497-2.stderr +++ b/src/test/ui/issues/issue-13497-2.stderr @@ -2,12 +2,12 @@ error[E0515]: cannot return value referencing local variable `rawLines` --> $DIR/issue-13497-2.rs:3:5 | LL | rawLines - | _____^ - | |_____| + | ______^ + | | _____| | || LL | || .iter().map(|l| l.trim()).collect() | ||_______________-___________________________^ returns a value referencing data owned by the current function - | |________________| + | |_______________| | `rawLines` is borrowed here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-1460.stderr b/src/test/ui/issues/issue-1460.stderr index f0ff2cafd..eb7661fad 100644 --- a/src/test/ui/issues/issue-1460.stderr +++ b/src/test/ui/issues/issue-1460.stderr @@ -2,7 +2,7 @@ warning: unused closure that must be used --> $DIR/issue-1460.rs:6:5 | LL | {|i: u32| if 1 == i { }}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: closures are lazy and do nothing unless called = note: `#[warn(unused_must_use)]` on by default diff --git a/src/test/ui/issues/issue-16256.stderr b/src/test/ui/issues/issue-16256.stderr index ca8e9a1be..d920530b5 100644 --- a/src/test/ui/issues/issue-16256.stderr +++ b/src/test/ui/issues/issue-16256.stderr @@ -2,7 +2,7 @@ warning: unused closure that must be used --> $DIR/issue-16256.rs:6:5 | LL | |c: u8| buf.push(c); - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ | = note: closures are lazy and do nothing unless called = note: `#[warn(unused_must_use)]` on by default diff --git a/src/test/ui/issues/issue-17252.stderr b/src/test/ui/issues/issue-17252.stderr index 4856418ed..aca5242b2 100644 --- a/src/test/ui/issues/issue-17252.stderr +++ b/src/test/ui/issues/issue-17252.stderr @@ -1,8 +1,8 @@ error[E0391]: cycle detected when const-evaluating + checking `FOO` - --> $DIR/issue-17252.rs:1:1 + --> $DIR/issue-17252.rs:1:20 | LL | const FOO: usize = FOO; - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ | = note: ...which immediately requires const-evaluating + checking `FOO` again note: cycle used when const-evaluating + checking `main::{constant#0}` diff --git a/src/test/ui/issues/issue-19086.rs b/src/test/ui/issues/issue-19086.rs index cc83874cb..42148c5f5 100644 --- a/src/test/ui/issues/issue-19086.rs +++ b/src/test/ui/issues/issue-19086.rs @@ -8,6 +8,6 @@ fn main() { let f = FooB { x: 3, y: 4 }; match f { FooB(a, b) => println!("{} {}", a, b), - //~^ ERROR expected tuple struct or tuple variant, found struct variant `FooB` + //~^ ERROR expected tuple struct or tuple variant, found variant `FooB` } } diff --git a/src/test/ui/issues/issue-19086.stderr b/src/test/ui/issues/issue-19086.stderr index a54f1008e..a3c06a725 100644 --- a/src/test/ui/issues/issue-19086.stderr +++ b/src/test/ui/issues/issue-19086.stderr @@ -1,4 +1,4 @@ -error[E0532]: expected tuple struct or tuple variant, found struct variant `FooB` +error[E0532]: expected tuple struct or tuple variant, found variant `FooB` --> $DIR/issue-19086.rs:10:9 | LL | FooB { x: i32, y: i32 } diff --git a/src/test/ui/issues/issue-20413.rs b/src/test/ui/issues/issue-20413.rs index 138a235e6..4de22f0c9 100644 --- a/src/test/ui/issues/issue-20413.rs +++ b/src/test/ui/issues/issue-20413.rs @@ -1,3 +1,4 @@ +// normalize-stderr-test: "long-type-\d+" -> "long-type-hash" trait Foo { fn answer(self); } diff --git a/src/test/ui/issues/issue-20413.stderr b/src/test/ui/issues/issue-20413.stderr index 2db60b641..78df44597 100644 --- a/src/test/ui/issues/issue-20413.stderr +++ b/src/test/ui/issues/issue-20413.stderr @@ -1,5 +1,5 @@ error[E0392]: parameter `T` is never used - --> $DIR/issue-20413.rs:5:15 + --> $DIR/issue-20413.rs:6:15 | LL | struct NoData<T>; | ^ unused parameter @@ -7,58 +7,63 @@ LL | struct NoData<T>; = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` = help: if you intended `T` to be a const parameter, use `const T: usize` instead -error[E0275]: overflow evaluating the requirement `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Foo` - --> $DIR/issue-20413.rs:8:36 +error[E0275]: overflow evaluating the requirement `NoData<NoData<NoData<NoData<NoData<NoData<NoData<...>>>>>>>: Foo` + --> $DIR/issue-20413.rs:9:36 | LL | impl<T> Foo for T where NoData<T>: Foo { | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) -note: required for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Foo` - --> $DIR/issue-20413.rs:8:9 +note: required for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<...>>>>>>>>>>>>>` to implement `Foo` + --> $DIR/issue-20413.rs:9:9 | LL | impl<T> Foo for T where NoData<T>: Foo { | ^^^ ^ + = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt' = note: 127 redundant requirements hidden = note: required for `NoData<T>` to implement `Foo` -error[E0275]: overflow evaluating the requirement `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Baz` - --> $DIR/issue-20413.rs:27:42 +error[E0275]: overflow evaluating the requirement `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<...>>>>>>>: Baz` + --> $DIR/issue-20413.rs:28:42 | LL | impl<T> Bar for T where EvenLessData<T>: Baz { | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) -note: required for `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Bar` - --> $DIR/issue-20413.rs:27:9 +note: required for `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<...>>>>>>>` to implement `Bar` + --> $DIR/issue-20413.rs:28:9 | LL | impl<T> Bar for T where EvenLessData<T>: Baz { | ^^^ ^ -note: required for `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Baz` - --> $DIR/issue-20413.rs:34:9 + = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt' +note: required for `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<...>>>>>>>` to implement `Baz` + --> $DIR/issue-20413.rs:35:9 | LL | impl<T> Baz for T where AlmostNoData<T>: Bar { | ^^^ ^ + = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt' = note: 126 redundant requirements hidden = note: required for `EvenLessData<T>` to implement `Baz` -error[E0275]: overflow evaluating the requirement `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Bar` - --> $DIR/issue-20413.rs:34:42 +error[E0275]: overflow evaluating the requirement `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<...>>>>>>>: Bar` + --> $DIR/issue-20413.rs:35:42 | LL | impl<T> Baz for T where AlmostNoData<T>: Bar { | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) -note: required for `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Baz` - --> $DIR/issue-20413.rs:34:9 +note: required for `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<...>>>>>>>` to implement `Baz` + --> $DIR/issue-20413.rs:35:9 | LL | impl<T> Baz for T where AlmostNoData<T>: Bar { | ^^^ ^ -note: required for `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Bar` - --> $DIR/issue-20413.rs:27:9 + = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt' +note: required for `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<...>>>>>>>` to implement `Bar` + --> $DIR/issue-20413.rs:28:9 | LL | impl<T> Bar for T where EvenLessData<T>: Baz { | ^^^ ^ + = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt' = note: 126 redundant requirements hidden = note: required for `AlmostNoData<T>` to implement `Bar` diff --git a/src/test/ui/issues/issue-22638.stderr b/src/test/ui/issues/issue-22638.stderr index 1354ec8e8..1caa4221f 100644 --- a/src/test/ui/issues/issue-22638.stderr +++ b/src/test/ui/issues/issue-22638.stderr @@ -9,7 +9,6 @@ note: `A::matches` defined here | LL | pub fn matches<F: Fn()>(&self, f: &F) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-22638/issue-22638.long-type.txt' error: aborting due to previous error diff --git a/src/test/ui/issues/issue-23024.stderr b/src/test/ui/issues/issue-23024.stderr index 73f93c51d..dc8b34a70 100644 --- a/src/test/ui/issues/issue-23024.stderr +++ b/src/test/ui/issues/issue-23024.stderr @@ -16,7 +16,7 @@ LL | println!("{:?}",(vfnfer[0] as dyn Fn)(3)); note: trait defined here, with 1 generic parameter: `Args` --> $SRC_DIR/core/src/ops/function.rs:LL:COL | -LL | pub trait Fn<Args>: FnMut<Args> { +LL | pub trait Fn<Args: Tuple>: FnMut<Args> { | ^^ ---- help: add missing generic argument | diff --git a/src/test/ui/issues/issue-23122-2.stderr b/src/test/ui/issues/issue-23122-2.stderr index 0111cf569..1f50b06a0 100644 --- a/src/test/ui/issues/issue-23122-2.stderr +++ b/src/test/ui/issues/issue-23122-2.stderr @@ -1,15 +1,16 @@ -error[E0275]: overflow evaluating the requirement `<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: Sized` +error[E0275]: overflow evaluating the requirement `<<<<<<<... as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: Sized` --> $DIR/issue-23122-2.rs:11:17 | LL | type Next = <GetNext<T::Next> as Next>::Next; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_23122_2`) -note: required for `GetNext<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>` to implement `Next` +note: required for `GetNext<<<<<<<... as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>` to implement `Next` --> $DIR/issue-23122-2.rs:10:15 | LL | impl<T: Next> Next for GetNext<T> { | ^^^^ ^^^^^^^^^^ + = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-23122-2/issue-23122-2.long-type-hash.txt' error: aborting due to previous error diff --git a/src/test/ui/issues/issue-23302-3.stderr b/src/test/ui/issues/issue-23302-3.stderr index 074939f68..c6cafe575 100644 --- a/src/test/ui/issues/issue-23302-3.stderr +++ b/src/test/ui/issues/issue-23302-3.stderr @@ -1,14 +1,14 @@ error[E0391]: cycle detected when const-evaluating + checking `A` - --> $DIR/issue-23302-3.rs:1:1 + --> $DIR/issue-23302-3.rs:1:16 | LL | const A: i32 = B; - | ^^^^^^^^^^^^^^^^^ + | ^ | note: ...which requires const-evaluating + checking `B`... - --> $DIR/issue-23302-3.rs:3:1 + --> $DIR/issue-23302-3.rs:3:16 | LL | const B: i32 = A; - | ^^^^^^^^^^^^^^^^^ + | ^ = note: ...which again requires const-evaluating + checking `A`, completing the cycle note: cycle used when simplifying constant for the type system `A` --> $DIR/issue-23302-3.rs:1:1 diff --git a/src/test/ui/issues/issue-24352.stderr b/src/test/ui/issues/issue-24352.stderr index 118f37f69..1f51b6e29 100644 --- a/src/test/ui/issues/issue-24352.stderr +++ b/src/test/ui/issues/issue-24352.stderr @@ -6,15 +6,10 @@ LL | 1.0f64 - 1 | = help: the trait `Sub<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Sub<Rhs>`: - <&'a f32 as Sub<f32>> <&'a f64 as Sub<f64>> - <&'a i128 as Sub<i128>> - <&'a i16 as Sub<i16>> - <&'a i32 as Sub<i32>> - <&'a i64 as Sub<i64>> - <&'a i8 as Sub<i8>> - <&'a isize as Sub<isize>> - and 48 others + <&f64 as Sub<&f64>> + <f64 as Sub<&f64>> + <f64 as Sub> help: consider using a floating-point literal by writing it with `.0` | LL | 1.0f64 - 1.0 diff --git a/src/test/ui/issues/issue-28105.stderr b/src/test/ui/issues/issue-28105.stderr index 42ed838d7..f450256f3 100644 --- a/src/test/ui/issues/issue-28105.stderr +++ b/src/test/ui/issues/issue-28105.stderr @@ -4,11 +4,11 @@ error[E0268]: `continue` outside of a loop LL | continue | ^^^^^^^^ cannot `continue` outside of a loop -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/issue-28105.rs:6:5 | LL | break - | ^^^^^ cannot `break` outside of a loop + | ^^^^^ cannot `break` outside of a loop or labeled block error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-28568.stderr b/src/test/ui/issues/issue-28568.stderr index be3f7c627..960259080 100644 --- a/src/test/ui/issues/issue-28568.stderr +++ b/src/test/ui/issues/issue-28568.stderr @@ -1,4 +1,4 @@ -error[E0119]: conflicting implementations of trait `std::ops::Drop` for type `MyStruct` +error[E0119]: conflicting implementations of trait `Drop` for type `MyStruct` --> $DIR/issue-28568.rs:7:1 | LL | impl Drop for MyStruct { diff --git a/src/test/ui/issues/issue-28992-empty.stderr b/src/test/ui/issues/issue-28992-empty.stderr index 71f337278..f69773b8c 100644 --- a/src/test/ui/issues/issue-28992-empty.stderr +++ b/src/test/ui/issues/issue-28992-empty.stderr @@ -8,7 +8,7 @@ error[E0164]: expected tuple struct or tuple variant, found associated constant --> $DIR/issue-28992-empty.rs:14:12 | LL | if let S::C2(..) = 0 {} - | ^^^^^^^^^ not a tuple variant or struct + | ^^^^^^^^^ not a tuple struct or tuple variant error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-29723.stderr b/src/test/ui/issues/issue-29723.stderr index e39ddfc81..92ee5cf22 100644 --- a/src/test/ui/issues/issue-29723.stderr +++ b/src/test/ui/issues/issue-29723.stderr @@ -9,6 +9,11 @@ LL | 0 if { drop(s); false } => String::from("oops"), ... LL | s | ^ value used here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | 0 if { drop(s.clone()); false } => String::from("oops"), + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-30490.rs b/src/test/ui/issues/issue-30490.rs index 68d9c4de4..4f0eeac8f 100644 --- a/src/test/ui/issues/issue-30490.rs +++ b/src/test/ui/issues/issue-30490.rs @@ -10,7 +10,7 @@ // This test checks to avoid that regression. #![cfg_attr(unix, feature(rustc_private))] -#![cfg_attr(windows, allow(unused_imports))] +#![cfg_attr(not(unix), allow(unused_imports))] #[cfg(unix)] extern crate libc; diff --git a/src/test/ui/issues/issue-32655.stderr b/src/test/ui/issues/issue-32655.stderr index 2d9ce430a..5a758c700 100644 --- a/src/test/ui/issues/issue-32655.stderr +++ b/src/test/ui/issues/issue-32655.stderr @@ -2,18 +2,28 @@ error: cannot find attribute `derive_Clone` in this scope --> $DIR/issue-32655.rs:3:11 | LL | #[derive_Clone] - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^ help: an attribute macro with a similar name exists: `derive_const` ... LL | foo!(); | ------ in this macro invocation | + ::: $SRC_DIR/core/src/macros/mod.rs:LL:COL + | +LL | pub macro derive_const($item:item) { + | ---------------------- similarly named attribute macro `derive_const` defined here + | = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) error: cannot find attribute `derive_Clone` in this scope --> $DIR/issue-32655.rs:15:7 | LL | #[derive_Clone] - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^ help: an attribute macro with a similar name exists: `derive_const` + | + ::: $SRC_DIR/core/src/macros/mod.rs:LL:COL + | +LL | pub macro derive_const($item:item) { + | ---------------------- similarly named attribute macro `derive_const` defined here error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-35976.rs b/src/test/ui/issues/issue-35976.rs index d075794d9..aa6f74cb5 100644 --- a/src/test/ui/issues/issue-35976.rs +++ b/src/test/ui/issues/issue-35976.rs @@ -1,5 +1,9 @@ +// revisions: imported unimported +//[imported] check-pass + mod private { pub trait Future { + //[unimported]~^^ HELP perhaps add a `use` for it fn wait(&self) where Self: Sized; } @@ -8,13 +12,13 @@ mod private { } } -//use private::Future; +#[cfg(imported)] +use private::Future; fn bar(arg: Box<dyn private::Future>) { + // Importing the trait means that we don't autoderef `Box<dyn Future>` arg.wait(); - //~^ ERROR the `wait` method cannot be invoked on a trait object + //[unimported]~^ ERROR the `wait` method cannot be invoked on a trait object } -fn main() { - -} +fn main() {} diff --git a/src/test/ui/issues/issue-35976.stderr b/src/test/ui/issues/issue-35976.unimported.stderr index fe16f97b9..5d61bb8ea 100644 --- a/src/test/ui/issues/issue-35976.stderr +++ b/src/test/ui/issues/issue-35976.unimported.stderr @@ -1,11 +1,16 @@ error: the `wait` method cannot be invoked on a trait object - --> $DIR/issue-35976.rs:14:9 + --> $DIR/issue-35976.rs:20:9 | LL | fn wait(&self) where Self: Sized; | ----- this has a `Sized` requirement ... LL | arg.wait(); | ^^^^ + | +help: another candidate was found in the following trait, perhaps add a `use` for it: + | +LL | use private::Future; + | error: aborting due to previous error diff --git a/src/test/ui/issues/issue-3707.stderr b/src/test/ui/issues/issue-3707.stderr index 6ca2deee3..07c8101cb 100644 --- a/src/test/ui/issues/issue-3707.stderr +++ b/src/test/ui/issues/issue-3707.stderr @@ -2,10 +2,10 @@ error[E0599]: no method named `boom` found for reference `&Obj` in the current s --> $DIR/issue-3707.rs:10:14 | LL | self.boom(); - | -----^^^^ + | -----^^^^-- | | | | | this is an associated function, not a method - | help: use associated function syntax instead: `Obj::boom` + | help: use associated function syntax instead: `Obj::boom()` | = note: found the following associated functions; to be used as methods, functions must have a `self` parameter note: the candidate is defined in an impl for the type `Obj` diff --git a/src/test/ui/issues/issue-37311-type-length-limit/issue-37311.stderr b/src/test/ui/issues/issue-37311-type-length-limit/issue-37311.stderr index 93aeb8946..5b8299fe8 100644 --- a/src/test/ui/issues/issue-37311-type-length-limit/issue-37311.stderr +++ b/src/test/ui/issues/issue-37311-type-length-limit/issue-37311.stderr @@ -1,4 +1,4 @@ -error: reached the recursion limit while instantiating `<(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(.....), ...), ...) as Foo>::recurse` +error: reached the recursion limit while instantiating `<(&(&(..., ...), ...), ...) as Foo>::recurse` --> $DIR/issue-37311.rs:17:9 | LL | (self, self).recurse(); diff --git a/src/test/ui/issues/issue-41394.rs b/src/test/ui/issues/issue-41394.rs index 64873ac35..07cad8796 100644 --- a/src/test/ui/issues/issue-41394.rs +++ b/src/test/ui/issues/issue-41394.rs @@ -5,7 +5,7 @@ enum Foo { enum Bar { A = Foo::A as isize - //~^ ERROR evaluation of constant value failed + //~^ const } fn main() {} diff --git a/src/test/ui/issues/issue-41394.stderr b/src/test/ui/issues/issue-41394.stderr index 47a24547d..1b5c64628 100644 --- a/src/test/ui/issues/issue-41394.stderr +++ b/src/test/ui/issues/issue-41394.stderr @@ -6,13 +6,12 @@ LL | A = "" + 1 | | | &str -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/issue-41394.rs:7:9 | LL | A = Foo::A as isize - | ^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0080, E0369. -For more information about an error, try `rustc --explain E0080`. +For more information about this error, try `rustc --explain E0369`. diff --git a/src/test/ui/issues/issue-42796.stderr b/src/test/ui/issues/issue-42796.stderr index f3e0e7b20..f2971df5d 100644 --- a/src/test/ui/issues/issue-42796.stderr +++ b/src/test/ui/issues/issue-42796.stderr @@ -10,6 +10,10 @@ LL | println!("{}", s); | ^ value borrowed here after move | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider cloning the value if the performance cost is acceptable + | +LL | let mut s_copy = s.clone(); + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-43162.stderr b/src/test/ui/issues/issue-43162.stderr index a443db407..40d920005 100644 --- a/src/test/ui/issues/issue-43162.stderr +++ b/src/test/ui/issues/issue-43162.stderr @@ -1,14 +1,14 @@ -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/issue-43162.rs:3:5 | LL | break true; - | ^^^^^^^^^^ cannot `break` outside of a loop + | ^^^^^^^^^^ cannot `break` outside of a loop or labeled block -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/issue-43162.rs:7:5 | LL | break {}; - | ^^^^^^^^ cannot `break` outside of a loop + | ^^^^^^^^ cannot `break` outside of a loop or labeled block error[E0308]: mismatched types --> $DIR/issue-43162.rs:1:13 diff --git a/src/test/ui/issues/issue-43355.stderr b/src/test/ui/issues/issue-43355.stderr index 531130fec..57adc8ad5 100644 --- a/src/test/ui/issues/issue-43355.stderr +++ b/src/test/ui/issues/issue-43355.stderr @@ -1,4 +1,4 @@ -error[E0119]: conflicting implementations of trait `Trait1<std::boxed::Box<_>>` for type `A` +error[E0119]: conflicting implementations of trait `Trait1<Box<_>>` for type `A` --> $DIR/issue-43355.rs:13:1 | LL | impl<X, T> Trait1<X> for T where T: Trait2<X> { diff --git a/src/test/ui/issues/issue-47184.stderr b/src/test/ui/issues/issue-47184.stderr index f97713b4a..c2c7df7a3 100644 --- a/src/test/ui/issues/issue-47184.stderr +++ b/src/test/ui/issues/issue-47184.stderr @@ -4,7 +4,7 @@ error[E0716]: temporary value dropped while borrowed LL | let _vec: Vec<&'static String> = vec![&String::new()]; | -------------------- ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement | | | - | | creates a temporary which is freed while still in use + | | creates a temporary value which is freed while still in use | type annotation requires that borrow lasts for `'static` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-47511.stderr b/src/test/ui/issues/issue-47511.stderr deleted file mode 100644 index 9998ee0e8..000000000 --- a/src/test/ui/issues/issue-47511.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types - --> $DIR/issue-47511.rs:8:15 - | -LL | fn f(_: X) -> X { - | ^ - | - = note: lifetimes appearing in an associated or opaque type are not considered constrained - = note: consider introducing a named lifetime parameter - -error[E0581]: return type references lifetime `'a`, which is not constrained by the fn input types - --> $DIR/issue-47511.rs:12:23 - | -LL | fn g<'a>(_: X<'a>) -> X<'a> { - | ^^^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0581`. diff --git a/src/test/ui/issues/issue-48728.rs b/src/test/ui/issues/issue-48728.rs index 8405a3047..cbdc10bd2 100644 --- a/src/test/ui/issues/issue-48728.rs +++ b/src/test/ui/issues/issue-48728.rs @@ -1,7 +1,7 @@ // Regression test for #48728, an ICE that occurred computing // coherence "help" information. -#[derive(Clone)] //~ ERROR conflicting implementations of trait `std::clone::Clone` +#[derive(Clone)] //~ ERROR conflicting implementations of trait `Clone` struct Node<T: ?Sized>(Box<T>); impl<T: Clone + ?Sized> Clone for Node<[T]> { diff --git a/src/test/ui/issues/issue-48728.stderr b/src/test/ui/issues/issue-48728.stderr index 628f026b6..0bb46724f 100644 --- a/src/test/ui/issues/issue-48728.stderr +++ b/src/test/ui/issues/issue-48728.stderr @@ -1,4 +1,4 @@ -error[E0119]: conflicting implementations of trait `std::clone::Clone` for type `Node<[_]>` +error[E0119]: conflicting implementations of trait `Clone` for type `Node<[_]>` --> $DIR/issue-48728.rs:4:10 | LL | #[derive(Clone)] diff --git a/src/test/ui/issues/issue-50576.stderr b/src/test/ui/issues/issue-50576.stderr index 9fea14110..4ec22fde9 100644 --- a/src/test/ui/issues/issue-50576.stderr +++ b/src/test/ui/issues/issue-50576.stderr @@ -4,17 +4,17 @@ error[E0426]: use of undeclared label `'L` LL | |bool: [u8; break 'L]| 0; | ^^ undeclared label `'L` -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/issue-50576.rs:2:17 | LL | |bool: [u8; break 'L]| 0; - | ^^^^^^^^ cannot `break` outside of a loop + | ^^^^^^^^ cannot `break` outside of a loop or labeled block -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/issue-50576.rs:5:16 | LL | Vec::<[u8; break]>::new(); - | ^^^^^ cannot `break` outside of a loop + | ^^^^^ cannot `break` outside of a loop or labeled block error: aborting due to 3 previous errors diff --git a/src/test/ui/issues/issue-50581.stderr b/src/test/ui/issues/issue-50581.stderr index 35d6fc49c..07b6df072 100644 --- a/src/test/ui/issues/issue-50581.stderr +++ b/src/test/ui/issues/issue-50581.stderr @@ -1,8 +1,8 @@ -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/issue-50581.rs:2:14 | LL | |_: [u8; break]| (); - | ^^^^^ cannot `break` outside of a loop + | ^^^^^ cannot `break` outside of a loop or labeled block error: aborting due to previous error diff --git a/src/test/ui/issues/issue-52049.stderr b/src/test/ui/issues/issue-52049.stderr index 55929d85d..b25dbd1cb 100644 --- a/src/test/ui/issues/issue-52049.stderr +++ b/src/test/ui/issues/issue-52049.stderr @@ -4,7 +4,7 @@ error[E0716]: temporary value dropped while borrowed LL | foo(&unpromotable(5u32)); | -----^^^^^^^^^^^^^^^^^^- | | | - | | creates a temporary which is freed while still in use + | | creates a temporary value which is freed while still in use | argument requires that borrow lasts for `'static` LL | } | - temporary value is freed at the end of this statement diff --git a/src/test/ui/issues/issue-52262.rs b/src/test/ui/issues/issue-52262.rs index 2195b8955..547643f0d 100644 --- a/src/test/ui/issues/issue-52262.rs +++ b/src/test/ui/issues/issue-52262.rs @@ -1,4 +1,3 @@ -// compile-flags:-Ztreat-err-as-bug=5 #[derive(Debug)] enum MyError { NotFound { key: Vec<u8> }, diff --git a/src/test/ui/issues/issue-52262.stderr b/src/test/ui/issues/issue-52262.stderr index c0bde4b23..ef41f078b 100644 --- a/src/test/ui/issues/issue-52262.stderr +++ b/src/test/ui/issues/issue-52262.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of `*key` which is behind a shared reference - --> $DIR/issue-52262.rs:16:35 + --> $DIR/issue-52262.rs:15:35 | LL | String::from_utf8(*key).unwrap() | ^^^^ move occurs because `*key` has type `Vec<u8>`, which does not implement the `Copy` trait diff --git a/src/test/ui/issues/issue-56835.stderr b/src/test/ui/issues/issue-56835.stderr index c200ba8d5..e949ae7b3 100644 --- a/src/test/ui/issues/issue-56835.stderr +++ b/src/test/ui/issues/issue-56835.stderr @@ -8,7 +8,7 @@ error[E0164]: expected tuple struct or tuple variant, found self constructor `Se --> $DIR/issue-56835.rs:4:12 | LL | fn bar(Self(foo): Self) {} - | ^^^^^^^^^ not a tuple variant or struct + | ^^^^^^^^^ not a tuple struct or tuple variant error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-63983.stderr b/src/test/ui/issues/issue-63983.stderr index eb0428341..f90c81116 100644 --- a/src/test/ui/issues/issue-63983.stderr +++ b/src/test/ui/issues/issue-63983.stderr @@ -7,15 +7,13 @@ LL | Tuple(i32), LL | MyEnum::Tuple => "", | ^^^^^^^^^^^^^ help: use the tuple variant pattern syntax instead: `MyEnum::Tuple(_)` -error[E0532]: expected unit struct, unit variant or constant, found struct variant `MyEnum::Struct` +error[E0533]: expected unit struct, unit variant or constant, found struct variant `MyEnum::Struct` --> $DIR/issue-63983.rs:10:9 | -LL | Struct{ s: i32 }, - | ---------------- `MyEnum::Struct` defined here -... LL | MyEnum::Struct => "", - | ^^^^^^^^^^^^^^ help: use struct pattern syntax instead: `MyEnum::Struct { s }` + | ^^^^^^^^^^^^^^ not a unit struct, unit variant or constant error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0532`. +Some errors have detailed explanations: E0532, E0533. +For more information about an error, try `rustc --explain E0532`. diff --git a/src/test/ui/issues/issue-67552.stderr b/src/test/ui/issues/issue-67552.stderr index 2968be7c7..4746f918b 100644 --- a/src/test/ui/issues/issue-67552.stderr +++ b/src/test/ui/issues/issue-67552.stderr @@ -1,4 +1,4 @@ -error: reached the recursion limit while instantiating `rec::<&mut &mut &mut &mut &mut &... &mut &mut &mut &mut &mut Empty>` +error: reached the recursion limit while instantiating `rec::<&mut &mut &mut &mut &mut ...>` --> $DIR/issue-67552.rs:29:9 | LL | rec(identity(&mut it)) diff --git a/src/test/ui/issues/issue-69396-const-no-type-in-macro.stderr b/src/test/ui/issues/issue-69396-const-no-type-in-macro.stderr index f581429a2..89aeafeba 100644 --- a/src/test/ui/issues/issue-69396-const-no-type-in-macro.stderr +++ b/src/test/ui/issues/issue-69396-const-no-type-in-macro.stderr @@ -2,10 +2,7 @@ error[E0428]: the name `A` is defined multiple times --> $DIR/issue-69396-const-no-type-in-macro.rs:4:13 | LL | const A = "A".$fn(); - | ^^^^^^^^^^^^^^^^^^^^ - | | - | `A` redefined here - | previous definition of the value `A` here + | ^^^^^^^^^^^^^^^^^^^^ `A` redefined here ... LL | / suite! { LL | | len; diff --git a/src/test/ui/issues/issue-69602-type-err-during-codegen-ice.rs b/src/test/ui/issues/issue-69602-type-err-during-codegen-ice.rs index 6851b67cb..e98affc5c 100644 --- a/src/test/ui/issues/issue-69602-type-err-during-codegen-ice.rs +++ b/src/test/ui/issues/issue-69602-type-err-during-codegen-ice.rs @@ -19,5 +19,5 @@ impl TraitB for B { //~ ERROR not all trait items implemented, missing: `MyA` fn main() { let _ = [0; B::VALUE]; - //~^ ERROR evaluation of constant value failed + //~^ constant } diff --git a/src/test/ui/issues/issue-69602-type-err-during-codegen-ice.stderr b/src/test/ui/issues/issue-69602-type-err-during-codegen-ice.stderr index 2c2cd5c52..ba385d887 100644 --- a/src/test/ui/issues/issue-69602-type-err-during-codegen-ice.stderr +++ b/src/test/ui/issues/issue-69602-type-err-during-codegen-ice.stderr @@ -13,13 +13,13 @@ LL | type MyA: TraitA; LL | impl TraitB for B { | ^^^^^^^^^^^^^^^^^ missing `MyA` in implementation -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/issue-69602-type-err-during-codegen-ice.rs:21:17 | LL | let _ = [0; B::VALUE]; - | ^^^^^^^^ referenced constant has errors + | ^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0046, E0080, E0437. +Some errors have detailed explanations: E0046, E0437. For more information about an error, try `rustc --explain E0046`. diff --git a/src/test/ui/issues/issue-71584.rs b/src/test/ui/issues/issue-71584.rs index c96cd598f..7bf3ed60e 100644 --- a/src/test/ui/issues/issue-71584.rs +++ b/src/test/ui/issues/issue-71584.rs @@ -1,5 +1,6 @@ fn main() { let n: u32 = 1; let mut d: u64 = 2; - d = d % n.into(); //~ ERROR type annotations needed + d = d % n.into(); + //~^ ERROR type annotations needed } diff --git a/src/test/ui/issues/issue-7607-1.stderr b/src/test/ui/issues/issue-7607-1.stderr index ecff8b42b..f1ab0ad26 100644 --- a/src/test/ui/issues/issue-7607-1.stderr +++ b/src/test/ui/issues/issue-7607-1.stderr @@ -6,8 +6,8 @@ LL | impl Fo { | ::: $SRC_DIR/core/src/ops/function.rs:LL:COL | -LL | pub trait Fn<Args>: FnMut<Args> { - | ------------------------------- similarly named trait `Fn` defined here +LL | pub trait Fn<Args: Tuple>: FnMut<Args> { + | -------------------------------------- similarly named trait `Fn` defined here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-7970a.stderr b/src/test/ui/issues/issue-7970a.stderr index ea400d7e1..b04a0eef3 100644 --- a/src/test/ui/issues/issue-7970a.stderr +++ b/src/test/ui/issues/issue-7970a.stderr @@ -6,6 +6,12 @@ LL | macro_rules! one_arg_macro { ... LL | one_arg_macro!(); | ^^^^^^^^^^^^^^^^ missing tokens in macro arguments + | +note: while trying to match meta-variable `$fmt:expr` + --> $DIR/issue-7970a.rs:2:6 + | +LL | ($fmt:expr) => (print!(concat!($fmt, "\n"))); + | ^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-83048.rs b/src/test/ui/issues/issue-83048.rs index 520ae9743..8e4fb6eae 100644 --- a/src/test/ui/issues/issue-83048.rs +++ b/src/test/ui/issues/issue-83048.rs @@ -1,5 +1,5 @@ // compile-flags: -Z unpretty=thir-tree pub fn main() { - break; //~ ERROR: `break` outside of a loop [E0268] + break; //~ ERROR: `break` outside of a loop or labeled block [E0268] } diff --git a/src/test/ui/issues/issue-83048.stderr b/src/test/ui/issues/issue-83048.stderr index 62d67d758..dade9e469 100644 --- a/src/test/ui/issues/issue-83048.stderr +++ b/src/test/ui/issues/issue-83048.stderr @@ -1,8 +1,8 @@ -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/issue-83048.rs:4:5 | LL | break; - | ^^^^^ cannot `break` outside of a loop + | ^^^^^ cannot `break` outside of a loop or labeled block error: aborting due to previous error diff --git a/src/test/ui/issues/issue-8727.stderr b/src/test/ui/issues/issue-8727.stderr index 5e1fdad60..22332b357 100644 --- a/src/test/ui/issues/issue-8727.stderr +++ b/src/test/ui/issues/issue-8727.stderr @@ -9,7 +9,7 @@ LL | generic::<Option<T>>(); = help: a `loop` may express intention better if this is on purpose = note: `#[warn(unconditional_recursion)]` on by default -error: reached the recursion limit while instantiating `generic::<Option<Option<Option<O...>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` +error: reached the recursion limit while instantiating `generic::<Option<Option<Option<Option<Option<...>>>>>>` --> $DIR/issue-8727.rs:8:5 | LL | generic::<Option<T>>(); diff --git a/src/test/ui/iterators/collect-into-array.rs b/src/test/ui/iterators/collect-into-array.rs index 7d35da825..4c424999b 100644 --- a/src/test/ui/iterators/collect-into-array.rs +++ b/src/test/ui/iterators/collect-into-array.rs @@ -1,5 +1,4 @@ fn main() { - //~^ NOTE required by a bound in this let whatever: [u32; 10] = (0..10).collect(); //~^ ERROR an array of type `[u32; 10]` cannot be built directly from an iterator //~| NOTE try collecting into a `Vec<{integer}>`, then using `.try_into()` diff --git a/src/test/ui/iterators/collect-into-array.stderr b/src/test/ui/iterators/collect-into-array.stderr index 7fe9707e6..a23a36a88 100644 --- a/src/test/ui/iterators/collect-into-array.stderr +++ b/src/test/ui/iterators/collect-into-array.stderr @@ -1,5 +1,5 @@ error[E0277]: an array of type `[u32; 10]` cannot be built directly from an iterator - --> $DIR/collect-into-array.rs:3:31 + --> $DIR/collect-into-array.rs:2:31 | LL | let whatever: [u32; 10] = (0..10).collect(); | ^^^^^^^ ------- required by a bound introduced by this call diff --git a/src/test/ui/iterators/collect-into-slice.rs b/src/test/ui/iterators/collect-into-slice.rs index 5eade0756..09832c260 100644 --- a/src/test/ui/iterators/collect-into-slice.rs +++ b/src/test/ui/iterators/collect-into-slice.rs @@ -1,6 +1,4 @@ fn process_slice(data: &[i32]) { - //~^ NOTE required by a bound in this - //~| NOTE required by a bound in this todo!() } diff --git a/src/test/ui/iterators/collect-into-slice.stderr b/src/test/ui/iterators/collect-into-slice.stderr index bce40118b..bc152467c 100644 --- a/src/test/ui/iterators/collect-into-slice.stderr +++ b/src/test/ui/iterators/collect-into-slice.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `[i32]` cannot be known at compilation time - --> $DIR/collect-into-slice.rs:8:9 + --> $DIR/collect-into-slice.rs:6:9 | LL | let some_generated_vec = (0..10).collect(); | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -9,7 +9,7 @@ LL | let some_generated_vec = (0..10).collect(); = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `[i32]` cannot be known at compilation time - --> $DIR/collect-into-slice.rs:8:38 + --> $DIR/collect-into-slice.rs:6:38 | LL | let some_generated_vec = (0..10).collect(); | ^^^^^^^ doesn't have a size known at compile-time @@ -22,7 +22,7 @@ LL | fn collect<B: FromIterator<Self::Item>>(self) -> B | ^ required by this bound in `collect` error[E0277]: a slice of type `[i32]` cannot be built since `[i32]` has no definite size - --> $DIR/collect-into-slice.rs:8:30 + --> $DIR/collect-into-slice.rs:6:30 | LL | let some_generated_vec = (0..10).collect(); | ^^^^^^^ ------- required by a bound introduced by this call diff --git a/src/test/ui/kindck/kindck-copy.stderr b/src/test/ui/kindck/kindck-copy.stderr index 025a5008d..9af89159a 100644 --- a/src/test/ui/kindck/kindck-copy.stderr +++ b/src/test/ui/kindck/kindck-copy.stderr @@ -4,16 +4,7 @@ error[E0277]: the trait bound `&'static mut isize: Copy` is not satisfied LL | assert_copy::<&'static mut isize>(); | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `&'static mut isize` | - = help: the following other types implement trait `Copy`: - f32 - f64 - i128 - i16 - i32 - i64 - i8 - isize - and 6 others + = help: the trait `Copy` is implemented for `isize` note: required by a bound in `assert_copy` --> $DIR/kindck-copy.rs:5:18 | @@ -26,16 +17,7 @@ error[E0277]: the trait bound `&'a mut isize: Copy` is not satisfied LL | assert_copy::<&'a mut isize>(); | ^^^^^^^^^^^^^ the trait `Copy` is not implemented for `&'a mut isize` | - = help: the following other types implement trait `Copy`: - f32 - f64 - i128 - i16 - i32 - i64 - i8 - isize - and 6 others + = help: the trait `Copy` is implemented for `isize` note: required by a bound in `assert_copy` --> $DIR/kindck-copy.rs:5:18 | diff --git a/src/test/ui/lang-items/lang-item-generic-requirements.rs b/src/test/ui/lang-items/lang-item-generic-requirements.rs index fbb56e528..3d33adf68 100644 --- a/src/test/ui/lang-items/lang-item-generic-requirements.rs +++ b/src/test/ui/lang-items/lang-item-generic-requirements.rs @@ -22,8 +22,6 @@ trait MyIndex<'a, T> {} #[lang = "phantom_data"] //~^ ERROR `phantom_data` language item must be applied to a struct with 1 generic argument struct MyPhantomData<T, U>; -//~^ ERROR parameter `T` is never used -//~| ERROR parameter `U` is never used #[lang = "owned_box"] //~^ ERROR `owned_box` language item must be applied to a struct with at least 1 generic argument diff --git a/src/test/ui/lang-items/lang-item-generic-requirements.stderr b/src/test/ui/lang-items/lang-item-generic-requirements.stderr index 326f5b0d5..4d349a25f 100644 --- a/src/test/ui/lang-items/lang-item-generic-requirements.stderr +++ b/src/test/ui/lang-items/lang-item-generic-requirements.stderr @@ -33,7 +33,7 @@ LL | struct MyPhantomData<T, U>; | ------ this struct has 2 generic arguments error[E0718]: `owned_box` language item must be applied to a struct with at least 1 generic argument - --> $DIR/lang-item-generic-requirements.rs:28:1 + --> $DIR/lang-item-generic-requirements.rs:26:1 | LL | #[lang = "owned_box"] | ^^^^^^^^^^^^^^^^^^^^^ @@ -42,7 +42,7 @@ LL | struct Foo; | - this struct has 0 generic arguments error[E0718]: `start` language item must be applied to a function with 1 generic argument - --> $DIR/lang-item-generic-requirements.rs:34:1 + --> $DIR/lang-item-generic-requirements.rs:32:1 | LL | #[lang = "start"] | ^^^^^^^^^^^^^^^^^ @@ -50,25 +50,6 @@ LL | LL | fn start(_: *const u8, _: isize, _: *const *const u8) -> isize { | - this function has 0 generic arguments -error[E0392]: parameter `T` is never used - --> $DIR/lang-item-generic-requirements.rs:24:22 - | -LL | struct MyPhantomData<T, U>; - | ^ unused parameter - | - = help: consider removing `T` or referring to it in a field - = help: if you intended `T` to be a const parameter, use `const T: usize` instead - -error[E0392]: parameter `U` is never used - --> $DIR/lang-item-generic-requirements.rs:24:25 - | -LL | struct MyPhantomData<T, U>; - | ^ unused parameter - | - = help: consider removing `U` or referring to it in a field - = help: if you intended `U` to be a const parameter, use `const U: usize` instead - -error: aborting due to 8 previous errors +error: aborting due to 6 previous errors -Some errors have detailed explanations: E0392, E0718. -For more information about an error, try `rustc --explain E0392`. +For more information about this error, try `rustc --explain E0718`. diff --git a/src/test/ui/lang-items/lang-item-missing-generator.rs b/src/test/ui/lang-items/lang-item-missing-generator.rs index 0c3295429..9b9aff38e 100644 --- a/src/test/ui/lang-items/lang-item-missing-generator.rs +++ b/src/test/ui/lang-items/lang-item-missing-generator.rs @@ -1,12 +1,14 @@ // error-pattern: requires `generator` lang_item -#![feature(no_core, lang_items, unboxed_closures)] +#![feature(no_core, lang_items, unboxed_closures, tuple_trait)] #![no_core] #[lang = "sized"] pub trait Sized { } +#[lang = "tuple_trait"] pub trait Tuple { } + #[lang = "fn_once"] #[rustc_paren_sugar] -pub trait FnOnce<Args> { +pub trait FnOnce<Args: Tuple> { type Output; extern "rust-call" fn call_once(self, args: Args) -> Self::Output; diff --git a/src/test/ui/lang-items/lang-item-missing-generator.stderr b/src/test/ui/lang-items/lang-item-missing-generator.stderr index fa13bf0b1..a24fdb5fb 100644 --- a/src/test/ui/lang-items/lang-item-missing-generator.stderr +++ b/src/test/ui/lang-items/lang-item-missing-generator.stderr @@ -1,8 +1,15 @@ +error[E0635]: unknown feature `tuple_trait` + --> $DIR/lang-item-missing-generator.rs:2:51 + | +LL | #![feature(no_core, lang_items, unboxed_closures, tuple_trait)] + | ^^^^^^^^^^^ + error: requires `generator` lang_item - --> $DIR/lang-item-missing-generator.rs:15:17 + --> $DIR/lang-item-missing-generator.rs:17:17 | LL | pub fn abc() -> impl FnOnce(f32) { | ^^^^^^^^^^^^^^^^ -error: aborting due to previous error +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0635`. diff --git a/src/test/ui/lang-items/missing-clone-for-suggestion.rs b/src/test/ui/lang-items/missing-clone-for-suggestion.rs new file mode 100644 index 000000000..e8290c009 --- /dev/null +++ b/src/test/ui/lang-items/missing-clone-for-suggestion.rs @@ -0,0 +1,20 @@ +// Avoid panicking if the Clone trait is not found while building error suggestions +// See #104870 + +#![feature(no_core, lang_items)] +#![no_core] + +#[lang = "sized"] +trait Sized {} + +#[lang = "copy"] +trait Copy {} + +fn g<T>(x: T) {} + +fn f(x: *mut u8) { + g(x); + g(x); //~ ERROR use of moved value: `x` +} + +fn main() {} diff --git a/src/test/ui/lang-items/missing-clone-for-suggestion.stderr b/src/test/ui/lang-items/missing-clone-for-suggestion.stderr new file mode 100644 index 000000000..35783a1be --- /dev/null +++ b/src/test/ui/lang-items/missing-clone-for-suggestion.stderr @@ -0,0 +1,21 @@ +error[E0382]: use of moved value: `x` + --> $DIR/missing-clone-for-suggestion.rs:17:7 + | +LL | fn f(x: *mut u8) { + | - move occurs because `x` has type `*mut u8`, which does not implement the `Copy` trait +LL | g(x); + | - value moved here +LL | g(x); + | ^ value used here after move + | +note: consider changing this parameter type in function `g` to borrow instead if owning the value isn't necessary + --> $DIR/missing-clone-for-suggestion.rs:13:12 + | +LL | fn g<T>(x: T) {} + | - ^ this parameter takes ownership of the value + | | + | in this function + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/late-bound-lifetimes/auxiliary/upstream_alias.rs b/src/test/ui/late-bound-lifetimes/auxiliary/upstream_alias.rs new file mode 100644 index 000000000..5b9dc0e43 --- /dev/null +++ b/src/test/ui/late-bound-lifetimes/auxiliary/upstream_alias.rs @@ -0,0 +1,5 @@ +pub trait Trait<'a> { + type Assoc; +} + +pub type Alias<'a, T> = <T as Trait<'a>>::Assoc; diff --git a/src/test/ui/late-bound-lifetimes/cross_crate_alias.rs b/src/test/ui/late-bound-lifetimes/cross_crate_alias.rs new file mode 100644 index 000000000..4154c2792 --- /dev/null +++ b/src/test/ui/late-bound-lifetimes/cross_crate_alias.rs @@ -0,0 +1,10 @@ +// aux-build:upstream_alias.rs +// check-pass + +extern crate upstream_alias; + +fn foo<'a, T: for<'b> upstream_alias::Trait<'b>>(_: upstream_alias::Alias<'a, T>) -> &'a () { + todo!() +} + +fn main() {} diff --git a/src/test/ui/late-bound-lifetimes/downgraded_to_early_through_alias.rs b/src/test/ui/late-bound-lifetimes/downgraded_to_early_through_alias.rs new file mode 100644 index 000000000..e56a34218 --- /dev/null +++ b/src/test/ui/late-bound-lifetimes/downgraded_to_early_through_alias.rs @@ -0,0 +1,24 @@ +// check-pass + +trait Gats<'a> { + type Assoc; + type Assoc2; +} + +trait Trait: for<'a> Gats<'a> { + fn foo<'a>(_: &mut <Self as Gats<'a>>::Assoc) -> <Self as Gats<'a>>::Assoc2; +} + +impl<'a> Gats<'a> for () { + type Assoc = &'a u32; + type Assoc2 = (); +} + +type GatsAssoc<'a, T> = <T as Gats<'a>>::Assoc; +type GatsAssoc2<'a, T> = <T as Gats<'a>>::Assoc2; + +impl Trait for () { + fn foo<'a>(_: &mut GatsAssoc<'a, Self>) -> GatsAssoc2<'a, Self> {} +} + +fn main() {} diff --git a/src/test/ui/issues/issue-47511.rs b/src/test/ui/late-bound-lifetimes/issue-47511.rs index eb4860e75..789443515 100644 --- a/src/test/ui/issues/issue-47511.rs +++ b/src/test/ui/late-bound-lifetimes/issue-47511.rs @@ -1,9 +1,4 @@ -// check-fail -// known-bug: #47511 - -// Regression test for #47511: anonymous lifetimes can appear -// unconstrained in a return type, but only if they appear just once -// in the input, as the input to a projection. +// check-pass fn f(_: X) -> X { unimplemented!() diff --git a/src/test/ui/late-bound-lifetimes/late_bound_through_alias.rs b/src/test/ui/late-bound-lifetimes/late_bound_through_alias.rs new file mode 100644 index 000000000..91839673c --- /dev/null +++ b/src/test/ui/late-bound-lifetimes/late_bound_through_alias.rs @@ -0,0 +1,16 @@ +// check-pass + +fn f(_: X) -> X { + unimplemented!() +} + +fn g<'a>(_: X<'a>) -> X<'a> { + unimplemented!() +} + +type X<'a> = &'a (); + +fn main() { + let _: for<'a> fn(X<'a>) -> X<'a> = g; + let _: for<'a> fn(X<'a>) -> X<'a> = f; +} diff --git a/src/test/ui/late-bound-lifetimes/mismatched_arg_count.rs b/src/test/ui/late-bound-lifetimes/mismatched_arg_count.rs new file mode 100644 index 000000000..0b331e203 --- /dev/null +++ b/src/test/ui/late-bound-lifetimes/mismatched_arg_count.rs @@ -0,0 +1,12 @@ +// ensures that we don't ICE when there are too many args supplied to the alias. + +trait Trait<'a> { + type Assoc; +} + +type Alias<'a, T> = <T as Trait<'a>>::Assoc; + +fn bar<'a, T: Trait<'a>>(_: Alias<'a, 'a, T>) {} +//~^ error: this type alias takes 1 lifetime argument but 2 lifetime arguments were supplied + +fn main() {} diff --git a/src/test/ui/late-bound-lifetimes/mismatched_arg_count.stderr b/src/test/ui/late-bound-lifetimes/mismatched_arg_count.stderr new file mode 100644 index 000000000..3704d9bb9 --- /dev/null +++ b/src/test/ui/late-bound-lifetimes/mismatched_arg_count.stderr @@ -0,0 +1,17 @@ +error[E0107]: this type alias takes 1 lifetime argument but 2 lifetime arguments were supplied + --> $DIR/mismatched_arg_count.rs:9:29 + | +LL | fn bar<'a, T: Trait<'a>>(_: Alias<'a, 'a, T>) {} + | ^^^^^ -- help: remove this lifetime argument + | | + | expected 1 lifetime argument + | +note: type alias defined here, with 1 lifetime parameter: `'a` + --> $DIR/mismatched_arg_count.rs:7:6 + | +LL | type Alias<'a, T> = <T as Trait<'a>>::Assoc; + | ^^^^^ -- + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0107`. diff --git a/src/test/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr b/src/test/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr index bfabe2d12..20d4c418e 100644 --- a/src/test/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr +++ b/src/test/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr @@ -370,23 +370,23 @@ error: layout_of(NicheFirst) = Layout { pref: $PREF_ALIGN, }, abi: ScalarPair( - Initialized { + Union { value: Int( I8, false, ), - valid_range: 0..=4, }, - Union { + Initialized { value: Int( I8, false, ), + valid_range: 0..=4, }, ), fields: Arbitrary { offsets: [ - Size(0 bytes), + Size(1 bytes), ], memory_index: [ 0, @@ -394,7 +394,7 @@ error: layout_of(NicheFirst) = Layout { }, largest_niche: Some( Niche { - offset: Size(0 bytes), + offset: Size(1 bytes), value: Int( I8, false, @@ -429,29 +429,29 @@ error: layout_of(NicheFirst) = Layout { I8, false, ), - valid_range: 0..=2, + valid_range: 0..=255, }, Initialized { value: Int( I8, false, ), - valid_range: 0..=255, + valid_range: 0..=2, }, ), fields: Arbitrary { offsets: [ - Size(0 bytes), Size(1 bytes), + Size(0 bytes), ], memory_index: [ - 0, 1, + 0, ], }, largest_niche: Some( Niche { - offset: Size(0 bytes), + offset: Size(1 bytes), value: Int( I8, false, diff --git a/src/test/ui/layout/valid_range_oob.rs b/src/test/ui/layout/valid_range_oob.rs new file mode 100644 index 000000000..74aa47fe4 --- /dev/null +++ b/src/test/ui/layout/valid_range_oob.rs @@ -0,0 +1,15 @@ +// failure-status: 101 +// normalize-stderr-test "note: .*\n\n" -> "" +// normalize-stderr-test "thread 'rustc' panicked.*\n" -> "" +// rustc-env:RUST_BACKTRACE=0 + +#![feature(rustc_attrs)] + +#[rustc_layout_scalar_valid_range_end(257)] +struct Foo(i8); + +// Need to do in a constant, as runtime codegen +// does not compute the layout of `Foo` in check builds. +const FOO: Foo = unsafe { Foo(1) }; + +fn main() {} diff --git a/src/test/ui/layout/valid_range_oob.stderr b/src/test/ui/layout/valid_range_oob.stderr new file mode 100644 index 000000000..7398f0164 --- /dev/null +++ b/src/test/ui/layout/valid_range_oob.stderr @@ -0,0 +1,6 @@ +error: internal compiler error: unexpected panic + +query stack during panic: +#0 [layout_of] computing layout of `Foo` +#1 [eval_to_allocation_raw] const-evaluating + checking `FOO` +end of query stack diff --git a/src/test/ui/lazy-type-alias-impl-trait/freeze_cycle.rs b/src/test/ui/lazy-type-alias-impl-trait/freeze_cycle.rs index 10f6bd740..f02a93ed4 100644 --- a/src/test/ui/lazy-type-alias-impl-trait/freeze_cycle.rs +++ b/src/test/ui/lazy-type-alias-impl-trait/freeze_cycle.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(gen_future, generator_trait, negative_impls)] +#![feature(generator_trait, negative_impls)] use std::ops::{Generator, GeneratorState}; use std::task::{Poll, Context}; diff --git a/src/test/ui/let-else/let-else-irrefutable.rs b/src/test/ui/let-else/let-else-irrefutable.rs index 1cb68ecb8..f4b338eb0 100644 --- a/src/test/ui/let-else/let-else-irrefutable.rs +++ b/src/test/ui/let-else/let-else-irrefutable.rs @@ -1,7 +1,11 @@ // check-pass - - fn main() { let x = 1 else { return }; //~ WARN irrefutable `let...else` pattern + + // Multiline else blocks should not get printed + let x = 1 else { //~ WARN irrefutable `let...else` pattern + eprintln!("problem case encountered"); + return + }; } diff --git a/src/test/ui/let-else/let-else-irrefutable.stderr b/src/test/ui/let-else/let-else-irrefutable.stderr index e0581f4d9..73d4e5f34 100644 --- a/src/test/ui/let-else/let-else-irrefutable.stderr +++ b/src/test/ui/let-else/let-else-irrefutable.stderr @@ -1,12 +1,21 @@ warning: irrefutable `let...else` pattern - --> $DIR/let-else-irrefutable.rs:6:5 + --> $DIR/let-else-irrefutable.rs:4:5 | LL | let x = 1 else { return }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: this pattern will always match, so the `else` clause is useless = help: consider removing the `else` clause = note: `#[warn(irrefutable_let_patterns)]` on by default -warning: 1 warning emitted +warning: irrefutable `let...else` pattern + --> $DIR/let-else-irrefutable.rs:7:5 + | +LL | let x = 1 else { + | ^^^^^^^^^ + | + = note: this pattern will always match, so the `else` clause is useless + = help: consider removing the `else` clause + +warning: 2 warnings emitted diff --git a/src/test/ui/lexer/error-stage.rs b/src/test/ui/lexer/error-stage.rs new file mode 100644 index 000000000..c8d88f745 --- /dev/null +++ b/src/test/ui/lexer/error-stage.rs @@ -0,0 +1,80 @@ +// This test is about the treatment of invalid literals. In particular, some +// literals are only considered invalid if they survive to HIR lowering. +// +// Literals with bad suffixes +// -------------------------- +// Literals consist of a primary part and an optional suffix. +// https://doc.rust-lang.org/reference/tokens.html#suffixes says: +// +// Any kind of literal (string, integer, etc) with any suffix is valid as a +// token, and can be passed to a macro without producing an error. The macro +// itself will decide how to interpret such a token and whether to produce an +// error or not. +// +// ``` +// macro_rules! blackhole { ($tt:tt) => () } +// blackhole!("string"suffix); // OK +// ``` +// +// However, suffixes on literal tokens parsed as Rust code are restricted. +// Any suffixes are rejected on non-numeric literal tokens, and numeric +// literal tokens are accepted only with suffixes from the list below. +// +// Integer: u8, i8, u16, i16, u32, i32, u64, i64, u128, i128, usize, isize +// Floating-point: f32, f64 +// +// This means that something like `"string"any_suffix` is a token accepted by +// the lexer, but rejected later for being an invalid combination of primary +// part and suffix. +// +// `0b10f32` is a similar case. `0b10` is a valid primary part that is a valid +// *integer* literal when no suffix is present. It only causes an error later +// when combined with the `f32` float suffix. +// +// However, `0b10.0f32` is different. It is rejected by the lexer because +// `0b10.0` is not a valid token even on its own. +// +// This difference is unfortunate, but it's baked into the language now. +// +// Too-large integer literals +// -------------------------- +// https://doc.rust-lang.org/reference/tokens.html#integer-literals says that +// literals like `128_i8` and `256_u8` "are too big for their type, but are +// still valid tokens". + +macro_rules! sink { + ($($x:tt;)*) => {()} +} + +// The invalid literals are ignored because the macro consumes them. Except for +// `0b10.0f32` because it's a lexer error. +const _: () = sink! { + "string"any_suffix; // OK + 10u123; // OK + 10.0f123; // OK + 0b10f32; // OK + 0b10.0f32; //~ ERROR binary float literal is not supported + 999340282366920938463463374607431768211455999; // OK +}; + +// The invalid literals used to cause errors, but this was changed by #102944. +// Except for `0b010.0f32`, because it's a lexer error. +#[cfg(FALSE)] +fn configured_out() { + "string"any_suffix; // OK + 10u123; // OK + 10.0f123; // OK + 0b10f32; // OK + 0b10.0f32; //~ ERROR binary float literal is not supported + 999340282366920938463463374607431768211455999; // OK +} + +// All the invalid literals cause errors. +fn main() { + "string"any_suffix; //~ ERROR suffixes on string literals are invalid + 10u123; //~ ERROR invalid width `123` for integer literal + 10.0f123; //~ ERROR invalid width `123` for float literal + 0b10f32; //~ ERROR binary float literal is not supported + 0b10.0f32; //~ ERROR binary float literal is not supported + 999340282366920938463463374607431768211455999; //~ ERROR integer literal is too large +} diff --git a/src/test/ui/lexer/error-stage.stderr b/src/test/ui/lexer/error-stage.stderr new file mode 100644 index 000000000..697a7c28d --- /dev/null +++ b/src/test/ui/lexer/error-stage.stderr @@ -0,0 +1,54 @@ +error: binary float literal is not supported + --> $DIR/error-stage.rs:56:5 + | +LL | 0b10.0f32; + | ^^^^^^ + +error: binary float literal is not supported + --> $DIR/error-stage.rs:68:5 + | +LL | 0b10.0f32; + | ^^^^^^ + +error: binary float literal is not supported + --> $DIR/error-stage.rs:78:5 + | +LL | 0b10.0f32; + | ^^^^^^ + +error: suffixes on string literals are invalid + --> $DIR/error-stage.rs:74:5 + | +LL | "string"any_suffix; + | ^^^^^^^^^^^^^^^^^^ invalid suffix `any_suffix` + +error: invalid width `123` for integer literal + --> $DIR/error-stage.rs:75:5 + | +LL | 10u123; + | ^^^^^^ + | + = help: valid widths are 8, 16, 32, 64 and 128 + +error: invalid width `123` for float literal + --> $DIR/error-stage.rs:76:5 + | +LL | 10.0f123; + | ^^^^^^^^ + | + = help: valid widths are 32 and 64 + +error: binary float literal is not supported + --> $DIR/error-stage.rs:77:5 + | +LL | 0b10f32; + | ^^^^^^^ not supported + +error: integer literal is too large + --> $DIR/error-stage.rs:79:5 + | +LL | 999340282366920938463463374607431768211455999; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 8 previous errors + diff --git a/src/test/ui/lexer/lex-bad-char-literals-6.stderr b/src/test/ui/lexer/lex-bad-char-literals-6.stderr index afef0cb60..ce4194246 100644 --- a/src/test/ui/lexer/lex-bad-char-literals-6.stderr +++ b/src/test/ui/lexer/lex-bad-char-literals-6.stderr @@ -42,12 +42,11 @@ LL | if x == y {} <&'a str as PartialEq<OsString>> <&'a str as PartialEq<String>> <&'b str as PartialEq<Cow<'a, str>>> - <String as PartialEq<&'a str>> - <String as PartialEq<Cow<'a, str>>> - <String as PartialEq<str>> - <String as PartialEq> <str as PartialEq<Cow<'a, str>>> - and 4 others + <str as PartialEq<OsStr>> + <str as PartialEq<OsString>> + <str as PartialEq<String>> + <str as PartialEq> error[E0308]: mismatched types --> $DIR/lex-bad-char-literals-6.rs:15:20 @@ -68,12 +67,11 @@ LL | if x == z {} <&'a str as PartialEq<OsString>> <&'a str as PartialEq<String>> <&'b str as PartialEq<Cow<'a, str>>> - <String as PartialEq<&'a str>> - <String as PartialEq<Cow<'a, str>>> - <String as PartialEq<str>> - <String as PartialEq> <str as PartialEq<Cow<'a, str>>> - and 4 others + <str as PartialEq<OsStr>> + <str as PartialEq<OsString>> + <str as PartialEq<String>> + <str as PartialEq> error: aborting due to 6 previous errors diff --git a/src/test/ui/lexical-scopes.stderr b/src/test/ui/lexical-scopes.stderr index 535985452..f0eaa1a5c 100644 --- a/src/test/ui/lexical-scopes.stderr +++ b/src/test/ui/lexical-scopes.stderr @@ -2,7 +2,7 @@ error[E0574]: expected struct, variant or union type, found type parameter `T` --> $DIR/lexical-scopes.rs:3:13 | LL | struct T { i: i32 } - | ------------------- you might have meant to refer to this struct + | - you might have meant to refer to this struct LL | fn f<T>() { | - found this type parameter LL | let t = T { i: 0 }; diff --git a/src/test/ui/lifetimes/borrowck-let-suggestion.stderr b/src/test/ui/lifetimes/borrowck-let-suggestion.stderr index bbf04c984..987b051b1 100644 --- a/src/test/ui/lifetimes/borrowck-let-suggestion.stderr +++ b/src/test/ui/lifetimes/borrowck-let-suggestion.stderr @@ -4,7 +4,7 @@ error[E0716]: temporary value dropped while borrowed LL | let mut x = vec![1].iter(); | ^^^^^^^ - temporary value is freed at the end of this statement | | - | creates a temporary which is freed while still in use + | creates a temporary value which is freed while still in use LL | LL | x.use_mut(); | ----------- borrow later used here diff --git a/src/test/ui/limits/issue-55878.stderr b/src/test/ui/limits/issue-55878.stderr index ee6aab748..f17f8141b 100644 --- a/src/test/ui/limits/issue-55878.stderr +++ b/src/test/ui/limits/issue-55878.stderr @@ -2,21 +2,43 @@ error[E0080]: values of the type `[u8; SIZE]` are too big for the current archit --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | intrinsics::size_of::<T>() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ inside `std::mem::size_of::<[u8; SIZE]>` at $SRC_DIR/core/src/mem/mod.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - ::: $DIR/issue-55878.rs:7:26 +note: inside `std::mem::size_of::<[u8; SIZE]>` + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + | +LL | intrinsics::size_of::<T>() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `main` + --> $DIR/issue-55878.rs:7:26 + | +LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: erroneous constant used + --> $DIR/issue-55878.rs:7:26 | LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); - | ---------------------------------------------- inside `main` at $DIR/issue-55878.rs:7:26 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +note: erroneous constant used + --> $DIR/issue-55878.rs:7:26 + | +LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: erroneous constant used +note: erroneous constant used --> $DIR/issue-55878.rs:7:26 | LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/linkage-attr/auxiliary/def_illtyped_external.rs b/src/test/ui/linkage-attr/auxiliary/def_external.rs index 2300930e5..2300930e5 100644 --- a/src/test/ui/linkage-attr/auxiliary/def_illtyped_external.rs +++ b/src/test/ui/linkage-attr/auxiliary/def_external.rs diff --git a/src/test/ui/linkage-attr/link-attr-validation-late.rs b/src/test/ui/linkage-attr/link-attr-validation-late.rs index b454fbd0e..34f720dd2 100644 --- a/src/test/ui/linkage-attr/link-attr-validation-late.rs +++ b/src/test/ui/linkage-attr/link-attr-validation-late.rs @@ -1,4 +1,3 @@ -#![feature(native_link_modifiers_verbatim)] #![feature(link_cfg)] // Top-level ill-formed diff --git a/src/test/ui/linkage-attr/link-attr-validation-late.stderr b/src/test/ui/linkage-attr/link-attr-validation-late.stderr index dd0f1dba2..1ad5fbaf7 100644 --- a/src/test/ui/linkage-attr/link-attr-validation-late.stderr +++ b/src/test/ui/linkage-attr/link-attr-validation-late.stderr @@ -1,143 +1,143 @@ error: unexpected `#[link]` argument, expected one of: name, kind, modifiers, cfg, wasm_import_module, import_name_type - --> $DIR/link-attr-validation-late.rs:5:22 + --> $DIR/link-attr-validation-late.rs:4:22 | LL | #[link(name = "...", "literal")] | ^^^^^^^^^ error: unexpected `#[link]` argument, expected one of: name, kind, modifiers, cfg, wasm_import_module, import_name_type - --> $DIR/link-attr-validation-late.rs:6:22 + --> $DIR/link-attr-validation-late.rs:5:22 | LL | #[link(name = "...", unknown)] | ^^^^^^^ error: multiple `name` arguments in a single `#[link]` attribute - --> $DIR/link-attr-validation-late.rs:10:22 + --> $DIR/link-attr-validation-late.rs:9:22 | LL | #[link(name = "foo", name = "bar")] | ^^^^^^^^^^^^ error: multiple `kind` arguments in a single `#[link]` attribute - --> $DIR/link-attr-validation-late.rs:11:38 + --> $DIR/link-attr-validation-late.rs:10:38 | LL | #[link(name = "...", kind = "dylib", kind = "bar")] | ^^^^^^^^^^^^ error: multiple `modifiers` arguments in a single `#[link]` attribute - --> $DIR/link-attr-validation-late.rs:12:47 + --> $DIR/link-attr-validation-late.rs:11:47 | LL | #[link(name = "...", modifiers = "+verbatim", modifiers = "bar")] | ^^^^^^^^^^^^^^^^^ error: multiple `cfg` arguments in a single `#[link]` attribute - --> $DIR/link-attr-validation-late.rs:13:34 + --> $DIR/link-attr-validation-late.rs:12:34 | LL | #[link(name = "...", cfg(FALSE), cfg(FALSE))] | ^^^^^^^^^^ error: multiple `wasm_import_module` arguments in a single `#[link]` attribute - --> $DIR/link-attr-validation-late.rs:14:36 + --> $DIR/link-attr-validation-late.rs:13:36 | LL | #[link(wasm_import_module = "foo", wasm_import_module = "bar")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: link name must be of the form `name = "string"` - --> $DIR/link-attr-validation-late.rs:18:8 + --> $DIR/link-attr-validation-late.rs:17:8 | LL | #[link(name)] | ^^^^ error[E0459]: `#[link]` attribute requires a `name = "string"` argument - --> $DIR/link-attr-validation-late.rs:18:1 + --> $DIR/link-attr-validation-late.rs:17:1 | LL | #[link(name)] | ^^^^^^^^^^^^^ missing `name` argument error: link name must be of the form `name = "string"` - --> $DIR/link-attr-validation-late.rs:20:8 + --> $DIR/link-attr-validation-late.rs:19:8 | LL | #[link(name())] | ^^^^^^ error[E0459]: `#[link]` attribute requires a `name = "string"` argument - --> $DIR/link-attr-validation-late.rs:20:1 + --> $DIR/link-attr-validation-late.rs:19:1 | LL | #[link(name())] | ^^^^^^^^^^^^^^^ missing `name` argument error: link kind must be of the form `kind = "string"` - --> $DIR/link-attr-validation-late.rs:22:22 + --> $DIR/link-attr-validation-late.rs:21:22 | LL | #[link(name = "...", kind)] | ^^^^ error: link kind must be of the form `kind = "string"` - --> $DIR/link-attr-validation-late.rs:23:22 + --> $DIR/link-attr-validation-late.rs:22:22 | LL | #[link(name = "...", kind())] | ^^^^^^ error: link modifiers must be of the form `modifiers = "string"` - --> $DIR/link-attr-validation-late.rs:24:22 + --> $DIR/link-attr-validation-late.rs:23:22 | LL | #[link(name = "...", modifiers)] | ^^^^^^^^^ error: link modifiers must be of the form `modifiers = "string"` - --> $DIR/link-attr-validation-late.rs:25:22 + --> $DIR/link-attr-validation-late.rs:24:22 | LL | #[link(name = "...", modifiers())] | ^^^^^^^^^^^ error: link cfg must be of the form `cfg(/* predicate */)` - --> $DIR/link-attr-validation-late.rs:26:22 + --> $DIR/link-attr-validation-late.rs:25:22 | LL | #[link(name = "...", cfg)] | ^^^ error: link cfg must be of the form `cfg(/* predicate */)` - --> $DIR/link-attr-validation-late.rs:27:22 + --> $DIR/link-attr-validation-late.rs:26:22 | LL | #[link(name = "...", cfg = "literal")] | ^^^^^^^^^^^^^^^ error: link cfg must have a single predicate argument - --> $DIR/link-attr-validation-late.rs:28:22 + --> $DIR/link-attr-validation-late.rs:27:22 | LL | #[link(name = "...", cfg("literal"))] | ^^^^^^^^^^^^^^ error: wasm import module must be of the form `wasm_import_module = "string"` - --> $DIR/link-attr-validation-late.rs:29:22 + --> $DIR/link-attr-validation-late.rs:28:22 | LL | #[link(name = "...", wasm_import_module)] | ^^^^^^^^^^^^^^^^^^ error: wasm import module must be of the form `wasm_import_module = "string"` - --> $DIR/link-attr-validation-late.rs:30:22 + --> $DIR/link-attr-validation-late.rs:29:22 | LL | #[link(name = "...", wasm_import_module())] | ^^^^^^^^^^^^^^^^^^^^ error: invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed - --> $DIR/link-attr-validation-late.rs:34:34 + --> $DIR/link-attr-validation-late.rs:33:34 | LL | #[link(name = "...", modifiers = "")] | ^^ error: invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed - --> $DIR/link-attr-validation-late.rs:35:34 + --> $DIR/link-attr-validation-late.rs:34:34 | LL | #[link(name = "...", modifiers = "no-plus-minus")] | ^^^^^^^^^^^^^^^ error: unknown linking modifier `unknown`, expected one of: bundle, verbatim, whole-archive, as-needed - --> $DIR/link-attr-validation-late.rs:36:34 + --> $DIR/link-attr-validation-late.rs:35:34 | LL | #[link(name = "...", modifiers = "+unknown")] | ^^^^^^^^^^ error: multiple `verbatim` modifiers in a single `modifiers` argument - --> $DIR/link-attr-validation-late.rs:37:34 + --> $DIR/link-attr-validation-late.rs:36:34 | LL | #[link(name = "...", modifiers = "+verbatim,+verbatim")] | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/linkage-attr/linkage-import.rs b/src/test/ui/linkage-attr/linkage-import.rs new file mode 100644 index 000000000..f754ddc6e --- /dev/null +++ b/src/test/ui/linkage-attr/linkage-import.rs @@ -0,0 +1,8 @@ +// build-pass +// aux-build:def_external.rs + +extern crate def_external as dep; + +fn main() { + println!("{:p}", &dep::EXTERN); +} diff --git a/src/test/ui/linkage-attr/linkage-requires-raw-ptr.rs b/src/test/ui/linkage-attr/linkage-requires-raw-ptr.rs deleted file mode 100644 index 93afc537f..000000000 --- a/src/test/ui/linkage-attr/linkage-requires-raw-ptr.rs +++ /dev/null @@ -1,11 +0,0 @@ -// rust-lang/rust#59548: We used to ICE when trying to use a static -// with a type that violated its own `#[linkage]`. - -// build-fail -// aux-build:def_illtyped_external.rs - -extern crate def_illtyped_external as dep; - -fn main() { - println!("{:p}", &dep::EXTERN); -} diff --git a/src/test/ui/linkage-attr/linkage-requires-raw-ptr.stderr b/src/test/ui/linkage-attr/linkage-requires-raw-ptr.stderr deleted file mode 100644 index 5abbe745c..000000000 --- a/src/test/ui/linkage-attr/linkage-requires-raw-ptr.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: must have type `*const T` or `*mut T` due to `#[linkage]` attribute - --> $DIR/auxiliary/def_illtyped_external.rs:5:1 - | -LL | pub static EXTERN: u32 = 0; - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/linkage-attr/linkage2.rs b/src/test/ui/linkage-attr/linkage2.rs index a7be19852..aa42874f7 100644 --- a/src/test/ui/linkage-attr/linkage2.rs +++ b/src/test/ui/linkage-attr/linkage2.rs @@ -1,16 +1,11 @@ -// FIXME https://github.com/rust-lang/rust/issues/59774 - -// build-fail -// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> "" -// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> "" -// ignore-sgx no weak linkages permitted +// check-fail #![feature(linkage)] extern "C" { #[linkage = "extern_weak"] static foo: i32; -//~^ ERROR: must have type `*const T` or `*mut T` due to `#[linkage]` attribute +//~^ ERROR: invalid type for variable with `#[linkage]` attribute } fn main() { diff --git a/src/test/ui/linkage-attr/linkage2.stderr b/src/test/ui/linkage-attr/linkage2.stderr index a6ac0aad0..7265f711f 100644 --- a/src/test/ui/linkage-attr/linkage2.stderr +++ b/src/test/ui/linkage-attr/linkage2.stderr @@ -1,8 +1,9 @@ -error: must have type `*const T` or `*mut T` due to `#[linkage]` attribute - --> $DIR/linkage2.rs:12:5 +error[E0791]: invalid type for variable with `#[linkage]` attribute + --> $DIR/linkage2.rs:7:5 | LL | static foo: i32; | ^^^^^^^^^^^^^^^ error: aborting due to previous error +For more information about this error, try `rustc --explain E0791`. diff --git a/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs b/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs index e3935cf91..2003e1e29 100644 --- a/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs +++ b/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs @@ -7,7 +7,7 @@ struct Bar { b: usize, //~ ERROR field `b` is never read #[deny(dead_code)] c: usize, //~ ERROR fields `c` and `e` are never read - d: usize, //~ WARN fields `d`, `f` and `g` are never read + d: usize, //~ WARN fields `d`, `f`, and `g` are never read #[deny(dead_code)] e: usize, f: usize, diff --git a/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr b/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr index c0f1ed38f..0e5c78a71 100644 --- a/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr +++ b/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr @@ -1,4 +1,4 @@ -warning: fields `d`, `f` and `g` are never read +warning: fields `d`, `f`, and `g` are never read --> $DIR/multiple-dead-codes-in-the-same-struct.rs:10:5 | LL | struct Bar { diff --git a/src/test/ui/lint/dead-code/tuple-struct-field.rs b/src/test/ui/lint/dead-code/tuple-struct-field.rs index b15d70636..14fb30be9 100644 --- a/src/test/ui/lint/dead-code/tuple-struct-field.rs +++ b/src/test/ui/lint/dead-code/tuple-struct-field.rs @@ -11,7 +11,7 @@ struct SingleUnused(i32, [u8; LEN], String); //~| HELP: consider changing the field to be of unit type struct MultipleUnused(i32, f32, String, u8); -//~^ ERROR: fields `0`, `1`, `2` and `3` are never read +//~^ ERROR: fields `0`, `1`, `2`, and `3` are never read //~| NOTE: fields in this struct //~| HELP: consider changing the fields to be of unit type diff --git a/src/test/ui/lint/dead-code/tuple-struct-field.stderr b/src/test/ui/lint/dead-code/tuple-struct-field.stderr index ca0989f5b..b8ad5cbe4 100644 --- a/src/test/ui/lint/dead-code/tuple-struct-field.stderr +++ b/src/test/ui/lint/dead-code/tuple-struct-field.stderr @@ -16,7 +16,7 @@ help: consider changing the field to be of unit type to suppress this warning wh LL | struct SingleUnused(i32, (), String); | ~~ -error: fields `0`, `1`, `2` and `3` are never read +error: fields `0`, `1`, `2`, and `3` are never read --> $DIR/tuple-struct-field.rs:13:23 | LL | struct MultipleUnused(i32, f32, String, u8); diff --git a/src/test/ui/lint/fn_must_use.stderr b/src/test/ui/lint/fn_must_use.stderr index 2805720f0..657f23c60 100644 --- a/src/test/ui/lint/fn_must_use.stderr +++ b/src/test/ui/lint/fn_must_use.stderr @@ -2,7 +2,7 @@ warning: unused return value of `need_to_use_this_value` that must be used --> $DIR/fn_must_use.rs:55:5 | LL | need_to_use_this_value(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: it's important note: the lint level is defined here @@ -15,13 +15,13 @@ warning: unused return value of `MyStruct::need_to_use_this_method_value` that m --> $DIR/fn_must_use.rs:60:5 | LL | m.need_to_use_this_method_value(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused return value of `EvenNature::is_even` that must be used --> $DIR/fn_must_use.rs:61:5 | LL | m.is_even(); // trait method! - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^ | = note: no side effects @@ -29,19 +29,19 @@ warning: unused return value of `MyStruct::need_to_use_this_associated_function_ --> $DIR/fn_must_use.rs:64:5 | LL | MyStruct::need_to_use_this_associated_function_value(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused return value of `std::cmp::PartialEq::eq` that must be used --> $DIR/fn_must_use.rs:70:5 | LL | 2.eq(&3); - | ^^^^^^^^^ + | ^^^^^^^^ warning: unused return value of `std::cmp::PartialEq::eq` that must be used --> $DIR/fn_must_use.rs:71:5 | LL | m.eq(&n); - | ^^^^^^^^^ + | ^^^^^^^^ warning: unused comparison that must be used --> $DIR/fn_must_use.rs:74:5 diff --git a/src/test/ui/lint/invalid_value.stderr b/src/test/ui/lint/invalid_value.stderr index 76afb765f..5370660d6 100644 --- a/src/test/ui/lint/invalid_value.stderr +++ b/src/test/ui/lint/invalid_value.stderr @@ -34,7 +34,8 @@ LL | let _val: Wrap<&'static T> = mem::zeroed(); | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | -note: references must be non-null (in this struct field) + = note: `Wrap<&T>` must be non-null +note: because references must be non-null (in this struct field) --> $DIR/invalid_value.rs:17:18 | LL | struct Wrap<T> { wrapped: T } @@ -49,7 +50,8 @@ LL | let _val: Wrap<&'static T> = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | -note: references must be non-null (in this struct field) + = note: `Wrap<&T>` must be non-null +note: because references must be non-null (in this struct field) --> $DIR/invalid_value.rs:17:18 | LL | struct Wrap<T> { wrapped: T } @@ -97,7 +99,7 @@ LL | let _val: (i32, !) = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | - = note: integers must not be uninitialized + = note: integers must be initialized error: the type `Void` does not permit zero-initialization --> $DIR/invalid_value.rs:71:26 @@ -160,7 +162,8 @@ LL | let _val: Ref = mem::zeroed(); | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | -note: references must be non-null (in this struct field) + = note: `Ref` must be non-null +note: because references must be non-null (in this struct field) --> $DIR/invalid_value.rs:14:12 | LL | struct Ref(&'static i32); @@ -175,7 +178,8 @@ LL | let _val: Ref = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | -note: references must be non-null (in this struct field) + = note: `Ref` must be non-null +note: because references must be non-null (in this struct field) --> $DIR/invalid_value.rs:14:12 | LL | struct Ref(&'static i32); @@ -212,7 +216,8 @@ LL | let _val: Wrap<fn()> = mem::zeroed(); | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | -note: function pointers must be non-null (in this struct field) + = note: `Wrap<fn()>` must be non-null +note: because function pointers must be non-null (in this struct field) --> $DIR/invalid_value.rs:17:18 | LL | struct Wrap<T> { wrapped: T } @@ -227,7 +232,8 @@ LL | let _val: Wrap<fn()> = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | -note: function pointers must be non-null (in this struct field) + = note: `Wrap<fn()>` must be non-null +note: because function pointers must be non-null (in this struct field) --> $DIR/invalid_value.rs:17:18 | LL | struct Wrap<T> { wrapped: T } @@ -242,7 +248,8 @@ LL | let _val: WrapEnum<fn()> = mem::zeroed(); | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | -note: function pointers must be non-null (in this field of the only potentially inhabited enum variant) + = note: `WrapEnum<fn()>` must be non-null +note: because function pointers must be non-null (in this field of the only potentially inhabited enum variant) --> $DIR/invalid_value.rs:18:28 | LL | enum WrapEnum<T> { Wrapped(T) } @@ -257,7 +264,8 @@ LL | let _val: WrapEnum<fn()> = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | -note: function pointers must be non-null (in this field of the only potentially inhabited enum variant) + = note: `WrapEnum<fn()>` must be non-null +note: because function pointers must be non-null (in this field of the only potentially inhabited enum variant) --> $DIR/invalid_value.rs:18:28 | LL | enum WrapEnum<T> { Wrapped(T) } @@ -272,7 +280,12 @@ LL | let _val: Wrap<(RefPair, i32)> = mem::zeroed(); | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | -note: references must be non-null (in this struct field) +note: `RefPair` must be non-null (in this struct field) + --> $DIR/invalid_value.rs:17:18 + | +LL | struct Wrap<T> { wrapped: T } + | ^^^^^^^^^^ +note: because references must be non-null (in this struct field) --> $DIR/invalid_value.rs:15:16 | LL | struct RefPair((&'static i32, i32)); @@ -287,7 +300,12 @@ LL | let _val: Wrap<(RefPair, i32)> = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | -note: references must be non-null (in this struct field) +note: `RefPair` must be non-null (in this struct field) + --> $DIR/invalid_value.rs:17:18 + | +LL | struct Wrap<T> { wrapped: T } + | ^^^^^^^^^^ +note: because references must be non-null (in this struct field) --> $DIR/invalid_value.rs:15:16 | LL | struct RefPair((&'static i32, i32)); @@ -314,6 +332,7 @@ LL | let _val: NonNull<i32> = mem::uninitialized(); | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | = note: `std::ptr::NonNull<i32>` must be non-null + = note: raw pointers must be initialized error: the type `(NonZeroU32, i32)` does not permit zero-initialization --> $DIR/invalid_value.rs:95:39 @@ -336,6 +355,7 @@ LL | let _val: (NonZeroU32, i32) = mem::uninitialized(); | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | = note: `std::num::NonZeroU32` must be non-null + = note: integers must be initialized error: the type `*const dyn Send` does not permit zero-initialization --> $DIR/invalid_value.rs:98:37 @@ -420,7 +440,8 @@ LL | let _val: OneFruitNonZero = mem::zeroed(); | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | -note: `std::num::NonZeroU32` must be non-null (in this field of the only potentially inhabited enum variant) + = note: `OneFruitNonZero` must be non-null +note: because `std::num::NonZeroU32` must be non-null (in this field of the only potentially inhabited enum variant) --> $DIR/invalid_value.rs:39:12 | LL | Banana(NonZeroU32), @@ -435,11 +456,13 @@ LL | let _val: OneFruitNonZero = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | -note: `std::num::NonZeroU32` must be non-null (in this field of the only potentially inhabited enum variant) + = note: `OneFruitNonZero` must be non-null +note: because `std::num::NonZeroU32` must be non-null (in this field of the only potentially inhabited enum variant) --> $DIR/invalid_value.rs:39:12 | LL | Banana(NonZeroU32), | ^^^^^^^^^^ + = note: integers must be initialized error: the type `bool` does not permit being left uninitialized --> $DIR/invalid_value.rs:112:26 @@ -461,6 +484,7 @@ LL | let _val: Wrap<char> = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | + = note: `Wrap<char>` must be initialized inside its custom valid range note: characters must be a valid Unicode codepoint (in this struct field) --> $DIR/invalid_value.rs:17:18 | @@ -477,6 +501,11 @@ LL | let _val: NonBig = mem::uninitialized(); | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | = note: `NonBig` must be initialized inside its custom valid range +note: integers must be initialized (in this struct field) + --> $DIR/invalid_value.rs:23:26 + | +LL | pub(crate) struct NonBig(u64); + | ^^^ error: the type `Fruit` does not permit being left uninitialized --> $DIR/invalid_value.rs:121:27 @@ -513,7 +542,7 @@ LL | let _val: i32 = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | - = note: integers must not be uninitialized + = note: integers must be initialized error: the type `f32` does not permit being left uninitialized --> $DIR/invalid_value.rs:130:25 @@ -524,7 +553,7 @@ LL | let _val: f32 = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | - = note: floats must not be uninitialized + = note: floats must be initialized error: the type `*const ()` does not permit being left uninitialized --> $DIR/invalid_value.rs:133:31 @@ -535,7 +564,7 @@ LL | let _val: *const () = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | - = note: raw pointers must not be uninitialized + = note: raw pointers must be initialized error: the type `*const [()]` does not permit being left uninitialized --> $DIR/invalid_value.rs:136:33 @@ -546,7 +575,7 @@ LL | let _val: *const [()] = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | - = note: raw pointers must not be uninitialized + = note: raw pointers must be initialized error: the type `WrapAroundRange` does not permit being left uninitialized --> $DIR/invalid_value.rs:139:37 @@ -558,6 +587,11 @@ LL | let _val: WrapAroundRange = mem::uninitialized(); | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | = note: `WrapAroundRange` must be initialized inside its custom valid range +note: integers must be initialized (in this struct field) + --> $DIR/invalid_value.rs:49:35 + | +LL | pub(crate) struct WrapAroundRange(u8); + | ^^ error: the type `Result<i32, i32>` does not permit being left uninitialized --> $DIR/invalid_value.rs:144:38 @@ -628,6 +662,7 @@ LL | let _val: NonNull<i32> = MaybeUninit::uninit().assume_init(); | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | = note: `std::ptr::NonNull<i32>` must be non-null + = note: raw pointers must be initialized error: the type `bool` does not permit being left uninitialized --> $DIR/invalid_value.rs:159:26 diff --git a/src/test/ui/lint/issue-103317.fixed b/src/test/ui/lint/issue-103317.fixed new file mode 100644 index 000000000..5a987423e --- /dev/null +++ b/src/test/ui/lint/issue-103317.fixed @@ -0,0 +1,14 @@ +// check-pass +// run-rustfix + +#[warn(unreachable_pub)] +mod inner { + #[allow(unused)] + pub(crate) enum T { + //~^ WARN unreachable `pub` item + A(u8), + X { a: f32, b: () }, + } +} + +fn main() {} diff --git a/src/test/ui/lint/issue-103317.rs b/src/test/ui/lint/issue-103317.rs new file mode 100644 index 000000000..c2ba939e1 --- /dev/null +++ b/src/test/ui/lint/issue-103317.rs @@ -0,0 +1,14 @@ +// check-pass +// run-rustfix + +#[warn(unreachable_pub)] +mod inner { + #[allow(unused)] + pub enum T { + //~^ WARN unreachable `pub` item + A(u8), + X { a: f32, b: () }, + } +} + +fn main() {} diff --git a/src/test/ui/lint/issue-103317.stderr b/src/test/ui/lint/issue-103317.stderr new file mode 100644 index 000000000..9c982ddc3 --- /dev/null +++ b/src/test/ui/lint/issue-103317.stderr @@ -0,0 +1,17 @@ +warning: unreachable `pub` item + --> $DIR/issue-103317.rs:7:5 + | +LL | pub enum T { + | ---^^^^^^^ + | | + | help: consider restricting its visibility: `pub(crate)` + | + = help: or consider exporting it for use by other crates +note: the lint level is defined here + --> $DIR/issue-103317.rs:4:8 + | +LL | #[warn(unreachable_pub)] + | ^^^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/src/test/ui/lint/issue-103435-extra-parentheses.fixed b/src/test/ui/lint/issue-103435-extra-parentheses.fixed new file mode 100644 index 000000000..2b01b414b --- /dev/null +++ b/src/test/ui/lint/issue-103435-extra-parentheses.fixed @@ -0,0 +1,18 @@ +// run-rustfix +#![deny(unused_parens)] + +fn main() { + if let Some(_) = Some(1) {} + //~^ ERROR unnecessary parentheses around pattern + + for _x in 1..10 {} + //~^ ERROR unnecessary parentheses around pattern + + if 2 == 1 {} + //~^ ERROR unnecessary parentheses around `if` condition + + // reported by parser + for _x in 1..10 {} + //~^ ERROR expected one of + //~| ERROR unexpected parentheses surrounding +} diff --git a/src/test/ui/lint/issue-103435-extra-parentheses.rs b/src/test/ui/lint/issue-103435-extra-parentheses.rs new file mode 100644 index 000000000..8261610cf --- /dev/null +++ b/src/test/ui/lint/issue-103435-extra-parentheses.rs @@ -0,0 +1,18 @@ +// run-rustfix +#![deny(unused_parens)] + +fn main() { + if let(Some(_))= Some(1) {} + //~^ ERROR unnecessary parentheses around pattern + + for(_x)in 1..10 {} + //~^ ERROR unnecessary parentheses around pattern + + if(2 == 1){} + //~^ ERROR unnecessary parentheses around `if` condition + + // reported by parser + for(_x in 1..10){} + //~^ ERROR expected one of + //~| ERROR unexpected parentheses surrounding +} diff --git a/src/test/ui/lint/issue-103435-extra-parentheses.stderr b/src/test/ui/lint/issue-103435-extra-parentheses.stderr new file mode 100644 index 000000000..29c41c910 --- /dev/null +++ b/src/test/ui/lint/issue-103435-extra-parentheses.stderr @@ -0,0 +1,61 @@ +error: expected one of `)`, `,`, `@`, or `|`, found keyword `in` + --> $DIR/issue-103435-extra-parentheses.rs:15:12 + | +LL | for(_x in 1..10){} + | ^^ expected one of `)`, `,`, `@`, or `|` + +error: unexpected parentheses surrounding `for` loop head + --> $DIR/issue-103435-extra-parentheses.rs:15:8 + | +LL | for(_x in 1..10){} + | ^ ^ + | +help: remove parentheses in `for` loop + | +LL - for(_x in 1..10){} +LL + for _x in 1..10 {} + | + +error: unnecessary parentheses around pattern + --> $DIR/issue-103435-extra-parentheses.rs:5:11 + | +LL | if let(Some(_))= Some(1) {} + | ^ ^ + | +note: the lint level is defined here + --> $DIR/issue-103435-extra-parentheses.rs:2:9 + | +LL | #![deny(unused_parens)] + | ^^^^^^^^^^^^^ +help: remove these parentheses + | +LL - if let(Some(_))= Some(1) {} +LL + if let Some(_) = Some(1) {} + | + +error: unnecessary parentheses around pattern + --> $DIR/issue-103435-extra-parentheses.rs:8:8 + | +LL | for(_x)in 1..10 {} + | ^ ^ + | +help: remove these parentheses + | +LL - for(_x)in 1..10 {} +LL + for _x in 1..10 {} + | + +error: unnecessary parentheses around `if` condition + --> $DIR/issue-103435-extra-parentheses.rs:11:7 + | +LL | if(2 == 1){} + | ^ ^ + | +help: remove these parentheses + | +LL - if(2 == 1){} +LL + if 2 == 1 {} + | + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/lint/issue-104392.rs b/src/test/ui/lint/issue-104392.rs new file mode 100644 index 000000000..d5608edb4 --- /dev/null +++ b/src/test/ui/lint/issue-104392.rs @@ -0,0 +1,11 @@ +fn main() { + { unsafe 92 } //~ ERROR expected `{`, found `92` +} + +fn foo() { + { mod 92 } //~ ERROR expected identifier, found `92` +} + +fn bar() { + { trait 92 } //~ ERROR expected identifier, found `92` +} diff --git a/src/test/ui/lint/issue-104392.stderr b/src/test/ui/lint/issue-104392.stderr new file mode 100644 index 000000000..8e466439a --- /dev/null +++ b/src/test/ui/lint/issue-104392.stderr @@ -0,0 +1,27 @@ +error: expected `{`, found `92` + --> $DIR/issue-104392.rs:2:14 + | +LL | { unsafe 92 } + | ------ ^^ expected `{` + | | + | while parsing this `unsafe` expression + | +help: try placing this code inside a block + | +LL | { unsafe { 92 } } + | + + + +error: expected identifier, found `92` + --> $DIR/issue-104392.rs:6:11 + | +LL | { mod 92 } + | ^^ expected identifier + +error: expected identifier, found `92` + --> $DIR/issue-104392.rs:10:13 + | +LL | { trait 92 } + | ^^ expected identifier + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/lint/issue-104897.rs b/src/test/ui/lint/issue-104897.rs new file mode 100644 index 000000000..5fbc658f1 --- /dev/null +++ b/src/test/ui/lint/issue-104897.rs @@ -0,0 +1,6 @@ +// error-pattern: this file contains an unclosed delimiter +// error-pattern: this file contains an unclosed delimiter +// error-pattern: this file contains an unclosed delimiter +// error-pattern: format argument must be a string literal + +fn f(){(print!(á diff --git a/src/test/ui/lint/issue-104897.stderr b/src/test/ui/lint/issue-104897.stderr new file mode 100644 index 000000000..817a93c2f --- /dev/null +++ b/src/test/ui/lint/issue-104897.stderr @@ -0,0 +1,43 @@ +error: this file contains an unclosed delimiter + --> $DIR/issue-104897.rs:6:18 + | +LL | fn f(){(print!(á + | -- - ^ + | || | + | || unclosed delimiter + | |unclosed delimiter + | unclosed delimiter + +error: this file contains an unclosed delimiter + --> $DIR/issue-104897.rs:6:18 + | +LL | fn f(){(print!(á + | -- - ^ + | || | + | || unclosed delimiter + | |unclosed delimiter + | unclosed delimiter + +error: this file contains an unclosed delimiter + --> $DIR/issue-104897.rs:6:18 + | +LL | fn f(){(print!(á + | -- - ^ + | || | + | || unclosed delimiter + | |unclosed delimiter + | unclosed delimiter + +error: format argument must be a string literal + --> $DIR/issue-104897.rs:6:16 + | +LL | fn f(){(print!(á + | ^ + | +help: you might be missing a string literal to format with + | +LL | fn f(){(print!("{}", á + | +++++ + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/lint/issue-97094.interleaved.stderr b/src/test/ui/lint/issue-97094.interleaved.stderr deleted file mode 100644 index a25816589..000000000 --- a/src/test/ui/lint/issue-97094.interleaved.stderr +++ /dev/null @@ -1,53 +0,0 @@ -error: unknown lint: `nonex_lint_top_level` - --> $DIR/issue-97094.rs:14:26 - | -LL | #![cfg_attr(all(), allow(nonex_lint_top_level))] - | ^^^^^^^^^^^^^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/issue-97094.rs:10:9 - | -LL | #![deny(warnings)] - | ^^^^^^^^ - = note: `#[deny(unknown_lints)]` implied by `#[deny(warnings)]` - -error: lint `bare_trait_object` has been renamed to `bare_trait_objects` - --> $DIR/issue-97094.rs:16:26 - | -LL | #![cfg_attr(all(), allow(bare_trait_object))] - | ^^^^^^^^^^^^^^^^^ help: use the new name: `bare_trait_objects` - | - = note: `#[deny(renamed_and_removed_lints)]` implied by `#[deny(warnings)]` - -error: unknown lint: `nonex_lint_mod` - --> $DIR/issue-97094.rs:19:25 - | -LL | #[cfg_attr(all(), allow(nonex_lint_mod))] - | ^^^^^^^^^^^^^^ - -error: unknown lint: `nonex_lint_mod_inner` - --> $DIR/issue-97094.rs:22:30 - | -LL | #![cfg_attr(all(), allow(nonex_lint_mod_inner))] - | ^^^^^^^^^^^^^^^^^^^^ - -error: unknown lint: `nonex_lint_fn` - --> $DIR/issue-97094.rs:26:25 - | -LL | #[cfg_attr(all(), allow(nonex_lint_fn))] - | ^^^^^^^^^^^^^ - -error: unknown lint: `nonex_lint_in_macro` - --> $DIR/issue-97094.rs:37:29 - | -LL | #[cfg_attr(all(), allow(nonex_lint_in_macro))] - | ^^^^^^^^^^^^^^^^^^^ - -error: unknown lint: `nonex_lint_fn` - --> $DIR/issue-97094.rs:56:13 - | -LL | #[allow(nonex_lint_fn)] - | ^^^^^^^^^^^^^ - -error: aborting due to 7 previous errors - diff --git a/src/test/ui/lint/issue-97094.rs b/src/test/ui/lint/issue-97094.rs index aeaead1bd..22525ca11 100644 --- a/src/test/ui/lint/issue-97094.rs +++ b/src/test/ui/lint/issue-97094.rs @@ -1,12 +1,3 @@ -// revisions: interleaved nointerleaved -// [nointerleaved]compile-flags: -Z no-interleave-lints - -// This test has two revisions because the logic change -// needed to make this test pass had to be adjusted -// for no-interleave-lints. Should the debug option -// be removed one day, please don't remove this -// test entirely, just remove the revision from it. - #![deny(warnings)] // Ensure that unknown lints inside cfg-attr's are linted for diff --git a/src/test/ui/lint/issue-97094.nointerleaved.stderr b/src/test/ui/lint/issue-97094.stderr index a25816589..1a0a3eaf2 100644 --- a/src/test/ui/lint/issue-97094.nointerleaved.stderr +++ b/src/test/ui/lint/issue-97094.stderr @@ -1,18 +1,18 @@ error: unknown lint: `nonex_lint_top_level` - --> $DIR/issue-97094.rs:14:26 + --> $DIR/issue-97094.rs:5:26 | LL | #![cfg_attr(all(), allow(nonex_lint_top_level))] | ^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/issue-97094.rs:10:9 + --> $DIR/issue-97094.rs:1:9 | LL | #![deny(warnings)] | ^^^^^^^^ = note: `#[deny(unknown_lints)]` implied by `#[deny(warnings)]` error: lint `bare_trait_object` has been renamed to `bare_trait_objects` - --> $DIR/issue-97094.rs:16:26 + --> $DIR/issue-97094.rs:7:26 | LL | #![cfg_attr(all(), allow(bare_trait_object))] | ^^^^^^^^^^^^^^^^^ help: use the new name: `bare_trait_objects` @@ -20,31 +20,31 @@ LL | #![cfg_attr(all(), allow(bare_trait_object))] = note: `#[deny(renamed_and_removed_lints)]` implied by `#[deny(warnings)]` error: unknown lint: `nonex_lint_mod` - --> $DIR/issue-97094.rs:19:25 + --> $DIR/issue-97094.rs:10:25 | LL | #[cfg_attr(all(), allow(nonex_lint_mod))] | ^^^^^^^^^^^^^^ error: unknown lint: `nonex_lint_mod_inner` - --> $DIR/issue-97094.rs:22:30 + --> $DIR/issue-97094.rs:13:30 | LL | #![cfg_attr(all(), allow(nonex_lint_mod_inner))] | ^^^^^^^^^^^^^^^^^^^^ error: unknown lint: `nonex_lint_fn` - --> $DIR/issue-97094.rs:26:25 + --> $DIR/issue-97094.rs:17:25 | LL | #[cfg_attr(all(), allow(nonex_lint_fn))] | ^^^^^^^^^^^^^ error: unknown lint: `nonex_lint_in_macro` - --> $DIR/issue-97094.rs:37:29 + --> $DIR/issue-97094.rs:28:29 | LL | #[cfg_attr(all(), allow(nonex_lint_in_macro))] | ^^^^^^^^^^^^^^^^^^^ error: unknown lint: `nonex_lint_fn` - --> $DIR/issue-97094.rs:56:13 + --> $DIR/issue-97094.rs:47:13 | LL | #[allow(nonex_lint_fn)] | ^^^^^^^^^^^^^ diff --git a/src/test/ui/lint/lint-incoherent-auto-trait-objects.stderr b/src/test/ui/lint/lint-incoherent-auto-trait-objects.stderr index 2cc4d382d..553ab3869 100644 --- a/src/test/ui/lint/lint-incoherent-auto-trait-objects.stderr +++ b/src/test/ui/lint/lint-incoherent-auto-trait-objects.stderr @@ -1,36 +1,36 @@ -error: conflicting implementations of trait `Foo` for type `(dyn std::marker::Send + 'static)`: (E0119) +error: conflicting implementations of trait `Foo` for type `(dyn Send + 'static)`: (E0119) --> $DIR/lint-incoherent-auto-trait-objects.rs:5:1 | LL | impl Foo for dyn Send {} | --------------------- first implementation here LL | LL | impl Foo for dyn Send + Send {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + 'static)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Send + 'static)` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> = note: `#[deny(order_dependent_trait_objects)]` on by default -error: conflicting implementations of trait `Foo` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) +error: conflicting implementations of trait `Foo` for type `(dyn Send + Sync + 'static)`: (E0119) --> $DIR/lint-incoherent-auto-trait-objects.rs:11:1 | LL | impl Foo for dyn Send + Sync {} | ---------------------------- first implementation here LL | LL | impl Foo for dyn Sync + Send {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Send + Sync + 'static)` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> -error: conflicting implementations of trait `Foo` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) +error: conflicting implementations of trait `Foo` for type `(dyn Send + Sync + 'static)`: (E0119) --> $DIR/lint-incoherent-auto-trait-objects.rs:15:1 | LL | impl Foo for dyn Sync + Send {} | ---------------------------- first implementation here ... LL | impl Foo for dyn Send + Sync + Send {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Send + Sync + 'static)` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> @@ -38,42 +38,42 @@ LL | impl Foo for dyn Send + Sync + Send {} error: aborting due to 3 previous errors Future incompatibility report: Future breakage diagnostic: -error: conflicting implementations of trait `Foo` for type `(dyn std::marker::Send + 'static)`: (E0119) +error: conflicting implementations of trait `Foo` for type `(dyn Send + 'static)`: (E0119) --> $DIR/lint-incoherent-auto-trait-objects.rs:5:1 | LL | impl Foo for dyn Send {} | --------------------- first implementation here LL | LL | impl Foo for dyn Send + Send {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + 'static)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Send + 'static)` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> = note: `#[deny(order_dependent_trait_objects)]` on by default Future breakage diagnostic: -error: conflicting implementations of trait `Foo` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) +error: conflicting implementations of trait `Foo` for type `(dyn Send + Sync + 'static)`: (E0119) --> $DIR/lint-incoherent-auto-trait-objects.rs:11:1 | LL | impl Foo for dyn Send + Sync {} | ---------------------------- first implementation here LL | LL | impl Foo for dyn Sync + Send {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Send + Sync + 'static)` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> = note: `#[deny(order_dependent_trait_objects)]` on by default Future breakage diagnostic: -error: conflicting implementations of trait `Foo` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) +error: conflicting implementations of trait `Foo` for type `(dyn Send + Sync + 'static)`: (E0119) --> $DIR/lint-incoherent-auto-trait-objects.rs:15:1 | LL | impl Foo for dyn Sync + Send {} | ---------------------------- first implementation here ... LL | impl Foo for dyn Send + Sync + Send {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Send + Sync + 'static)` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> diff --git a/src/test/ui/lint/opaque-ty-ffi-normalization-cycle.rs b/src/test/ui/lint/opaque-ty-ffi-normalization-cycle.rs new file mode 100644 index 000000000..c83bca4a4 --- /dev/null +++ b/src/test/ui/lint/opaque-ty-ffi-normalization-cycle.rs @@ -0,0 +1,41 @@ +#![feature(type_alias_impl_trait)] +#![allow(unused)] +#![deny(improper_ctypes)] + +pub trait TraitA { + type Assoc; +} + +impl TraitA for u32 { + type Assoc = u32; +} + +pub trait TraitB { + type Assoc; +} + +impl<T> TraitB for T +where + T: TraitA, +{ + type Assoc = <T as TraitA>::Assoc; +} + +type AliasA = impl TraitA<Assoc = u32>; + +type AliasB = impl TraitB; + +fn use_of_a() -> AliasA { + 3 +} + +fn use_of_b() -> AliasB { + 3 +} + +extern "C" { + fn lint_me() -> <AliasB as TraitB>::Assoc; + //~^ ERROR `extern` block uses type `AliasB`, which is not FFI-safe +} + +fn main() {} diff --git a/src/test/ui/lint/opaque-ty-ffi-normalization-cycle.stderr b/src/test/ui/lint/opaque-ty-ffi-normalization-cycle.stderr new file mode 100644 index 000000000..e8d696477 --- /dev/null +++ b/src/test/ui/lint/opaque-ty-ffi-normalization-cycle.stderr @@ -0,0 +1,15 @@ +error: `extern` block uses type `AliasB`, which is not FFI-safe + --> $DIR/opaque-ty-ffi-normalization-cycle.rs:37:21 + | +LL | fn lint_me() -> <AliasB as TraitB>::Assoc; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe + | + = note: opaque types have no C equivalent +note: the lint level is defined here + --> $DIR/opaque-ty-ffi-normalization-cycle.rs:3:9 + | +LL | #![deny(improper_ctypes)] + | ^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/lint/suggestions.stderr b/src/test/ui/lint/suggestions.stderr index f4c0e2141..4caee777a 100644 --- a/src/test/ui/lint/suggestions.stderr +++ b/src/test/ui/lint/suggestions.stderr @@ -41,12 +41,12 @@ warning: variable does not need to be mutable --> $DIR/suggestions.rs:54:13 | LL | let mut - | _____________^ - | |_____________| + | ______________^ + | | _____________| | || LL | || b = 1; | ||____________-^ - | |____________| + | |_____________| | help: remove this `mut` error: const items should never be `#[no_mangle]` diff --git a/src/test/ui/lint/unused/issue-104397.rs b/src/test/ui/lint/unused/issue-104397.rs new file mode 100644 index 000000000..94e15cd96 --- /dev/null +++ b/src/test/ui/lint/unused/issue-104397.rs @@ -0,0 +1,18 @@ +// check-pass + +#![warn(unused)] +#![deny(warnings)] + +struct Inv<'a>(&'a mut &'a ()); + +trait Trait {} +impl Trait for for<'a> fn(Inv<'a>) {} + +fn with_bound() +where + (for<'a> fn(Inv<'a>)): Trait, +{} + +fn main() { + with_bound(); +} diff --git a/src/test/ui/lint/unused/issue-88519-unused-paren.rs b/src/test/ui/lint/unused/issue-88519-unused-paren.rs index be02fcd3f..ce3d15ac1 100644 --- a/src/test/ui/lint/unused/issue-88519-unused-paren.rs +++ b/src/test/ui/lint/unused/issue-88519-unused-paren.rs @@ -51,22 +51,13 @@ mod casts { mod typeascription { fn outside() -> u8 { - ({ 0 }): u8 - } - fn inside() -> u8 { - ({ 0 }: u8) + type_ascribe!(({ 0 }), u8) } fn outside_match() -> u8 { - (match 0 { x => x }): u8 - } - fn inside_match() -> u8 { - (match 0 { x => x }: u8) + type_ascribe!((match 0 { x => x }), u8) } fn outside_if() -> u8 { - (if false { 0 } else { 0 }): u8 - } - fn inside_if() -> u8 { - (if false { 0 } else { 0 }: u8) + type_ascribe!((if false { 0 } else { 0 }), u8) } } diff --git a/src/test/ui/lint/unused/must-use-box-from-raw.stderr b/src/test/ui/lint/unused/must-use-box-from-raw.stderr index 011acc3bf..721182757 100644 --- a/src/test/ui/lint/unused/must-use-box-from-raw.stderr +++ b/src/test/ui/lint/unused/must-use-box-from-raw.stderr @@ -2,7 +2,7 @@ warning: unused return value of `Box::<T>::from_raw` that must be used --> $DIR/must-use-box-from-raw.rs:8:5 | LL | Box::from_raw(ptr); - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ | = note: call `drop(from_raw(ptr))` if you intend to drop the `Box` note: the lint level is defined here diff --git a/src/test/ui/lint/unused/must-use-ops.rs b/src/test/ui/lint/unused/must-use-ops.rs index 3e425727e..60f877aa8 100644 --- a/src/test/ui/lint/unused/must-use-ops.rs +++ b/src/test/ui/lint/unused/must-use-ops.rs @@ -3,12 +3,18 @@ // check-pass #![warn(unused_must_use)] +#![feature(never_type)] + +fn deref_never(x: &!) { + // Don't lint for uninhabited typess + *x; +} fn main() { let val = 1; let val_pointer = &val; -// Comparison Operators + // Comparison Operators val == 1; //~ WARNING unused comparison val < 1; //~ WARNING unused comparison val <= 1; //~ WARNING unused comparison @@ -16,26 +22,30 @@ fn main() { val >= 1; //~ WARNING unused comparison val > 1; //~ WARNING unused comparison -// Arithmetic Operators + // Arithmetic Operators val + 2; //~ WARNING unused arithmetic operation val - 2; //~ WARNING unused arithmetic operation val / 2; //~ WARNING unused arithmetic operation val * 2; //~ WARNING unused arithmetic operation val % 2; //~ WARNING unused arithmetic operation -// Logical Operators + // Logical Operators true && true; //~ WARNING unused logical operation false || true; //~ WARNING unused logical operation -// Bitwise Operators + // Bitwise Operators 5 ^ val; //~ WARNING unused bitwise operation 5 & val; //~ WARNING unused bitwise operation 5 | val; //~ WARNING unused bitwise operation 5 << val; //~ WARNING unused bitwise operation 5 >> val; //~ WARNING unused bitwise operation -// Unary Operators + // Unary Operators !val; //~ WARNING unused unary operation -val; //~ WARNING unused unary operation *val_pointer; //~ WARNING unused unary operation + + if false { + deref_never(&panic!()); + } } diff --git a/src/test/ui/lint/unused/must-use-ops.stderr b/src/test/ui/lint/unused/must-use-ops.stderr index b248dd0fe..79a53d39c 100644 --- a/src/test/ui/lint/unused/must-use-ops.stderr +++ b/src/test/ui/lint/unused/must-use-ops.stderr @@ -1,5 +1,5 @@ warning: unused comparison that must be used - --> $DIR/must-use-ops.rs:12:5 + --> $DIR/must-use-ops.rs:18:5 | LL | val == 1; | ^^^^^^^^ the comparison produces a value @@ -15,7 +15,7 @@ LL | let _ = val == 1; | +++++++ warning: unused comparison that must be used - --> $DIR/must-use-ops.rs:13:5 + --> $DIR/must-use-ops.rs:19:5 | LL | val < 1; | ^^^^^^^ the comparison produces a value @@ -26,7 +26,7 @@ LL | let _ = val < 1; | +++++++ warning: unused comparison that must be used - --> $DIR/must-use-ops.rs:14:5 + --> $DIR/must-use-ops.rs:20:5 | LL | val <= 1; | ^^^^^^^^ the comparison produces a value @@ -37,7 +37,7 @@ LL | let _ = val <= 1; | +++++++ warning: unused comparison that must be used - --> $DIR/must-use-ops.rs:15:5 + --> $DIR/must-use-ops.rs:21:5 | LL | val != 1; | ^^^^^^^^ the comparison produces a value @@ -48,7 +48,7 @@ LL | let _ = val != 1; | +++++++ warning: unused comparison that must be used - --> $DIR/must-use-ops.rs:16:5 + --> $DIR/must-use-ops.rs:22:5 | LL | val >= 1; | ^^^^^^^^ the comparison produces a value @@ -59,7 +59,7 @@ LL | let _ = val >= 1; | +++++++ warning: unused comparison that must be used - --> $DIR/must-use-ops.rs:17:5 + --> $DIR/must-use-ops.rs:23:5 | LL | val > 1; | ^^^^^^^ the comparison produces a value @@ -70,7 +70,7 @@ LL | let _ = val > 1; | +++++++ warning: unused arithmetic operation that must be used - --> $DIR/must-use-ops.rs:20:5 + --> $DIR/must-use-ops.rs:26:5 | LL | val + 2; | ^^^^^^^ the arithmetic operation produces a value @@ -81,7 +81,7 @@ LL | let _ = val + 2; | +++++++ warning: unused arithmetic operation that must be used - --> $DIR/must-use-ops.rs:21:5 + --> $DIR/must-use-ops.rs:27:5 | LL | val - 2; | ^^^^^^^ the arithmetic operation produces a value @@ -92,7 +92,7 @@ LL | let _ = val - 2; | +++++++ warning: unused arithmetic operation that must be used - --> $DIR/must-use-ops.rs:22:5 + --> $DIR/must-use-ops.rs:28:5 | LL | val / 2; | ^^^^^^^ the arithmetic operation produces a value @@ -103,7 +103,7 @@ LL | let _ = val / 2; | +++++++ warning: unused arithmetic operation that must be used - --> $DIR/must-use-ops.rs:23:5 + --> $DIR/must-use-ops.rs:29:5 | LL | val * 2; | ^^^^^^^ the arithmetic operation produces a value @@ -114,7 +114,7 @@ LL | let _ = val * 2; | +++++++ warning: unused arithmetic operation that must be used - --> $DIR/must-use-ops.rs:24:5 + --> $DIR/must-use-ops.rs:30:5 | LL | val % 2; | ^^^^^^^ the arithmetic operation produces a value @@ -125,7 +125,7 @@ LL | let _ = val % 2; | +++++++ warning: unused logical operation that must be used - --> $DIR/must-use-ops.rs:27:5 + --> $DIR/must-use-ops.rs:33:5 | LL | true && true; | ^^^^^^^^^^^^ the logical operation produces a value @@ -136,7 +136,7 @@ LL | let _ = true && true; | +++++++ warning: unused logical operation that must be used - --> $DIR/must-use-ops.rs:28:5 + --> $DIR/must-use-ops.rs:34:5 | LL | false || true; | ^^^^^^^^^^^^^ the logical operation produces a value @@ -147,7 +147,7 @@ LL | let _ = false || true; | +++++++ warning: unused bitwise operation that must be used - --> $DIR/must-use-ops.rs:31:5 + --> $DIR/must-use-ops.rs:37:5 | LL | 5 ^ val; | ^^^^^^^ the bitwise operation produces a value @@ -158,7 +158,7 @@ LL | let _ = 5 ^ val; | +++++++ warning: unused bitwise operation that must be used - --> $DIR/must-use-ops.rs:32:5 + --> $DIR/must-use-ops.rs:38:5 | LL | 5 & val; | ^^^^^^^ the bitwise operation produces a value @@ -169,7 +169,7 @@ LL | let _ = 5 & val; | +++++++ warning: unused bitwise operation that must be used - --> $DIR/must-use-ops.rs:33:5 + --> $DIR/must-use-ops.rs:39:5 | LL | 5 | val; | ^^^^^^^ the bitwise operation produces a value @@ -180,7 +180,7 @@ LL | let _ = 5 | val; | +++++++ warning: unused bitwise operation that must be used - --> $DIR/must-use-ops.rs:34:5 + --> $DIR/must-use-ops.rs:40:5 | LL | 5 << val; | ^^^^^^^^ the bitwise operation produces a value @@ -191,7 +191,7 @@ LL | let _ = 5 << val; | +++++++ warning: unused bitwise operation that must be used - --> $DIR/must-use-ops.rs:35:5 + --> $DIR/must-use-ops.rs:41:5 | LL | 5 >> val; | ^^^^^^^^ the bitwise operation produces a value @@ -202,7 +202,7 @@ LL | let _ = 5 >> val; | +++++++ warning: unused unary operation that must be used - --> $DIR/must-use-ops.rs:38:5 + --> $DIR/must-use-ops.rs:44:5 | LL | !val; | ^^^^ the unary operation produces a value @@ -213,7 +213,7 @@ LL | let _ = !val; | +++++++ warning: unused unary operation that must be used - --> $DIR/must-use-ops.rs:39:5 + --> $DIR/must-use-ops.rs:45:5 | LL | -val; | ^^^^ the unary operation produces a value @@ -224,7 +224,7 @@ LL | let _ = -val; | +++++++ warning: unused unary operation that must be used - --> $DIR/must-use-ops.rs:40:5 + --> $DIR/must-use-ops.rs:46:5 | LL | *val_pointer; | ^^^^^^^^^^^^ the unary operation produces a value diff --git a/src/test/ui/lint/unused/must_use-array.rs b/src/test/ui/lint/unused/must_use-array.rs index 97825dd2f..b7bae4b0a 100644 --- a/src/test/ui/lint/unused/must_use-array.rs +++ b/src/test/ui/lint/unused/must_use-array.rs @@ -1,6 +1,7 @@ #![deny(unused_must_use)] #[must_use] +#[derive(Clone, Copy)] struct S; struct A; @@ -34,6 +35,10 @@ fn array_of_arrays_of_arrays() -> [[[S; 1]; 2]; 1] { [[[S], [S]]] } +fn usize_max() -> [S; usize::MAX] { + [S; usize::MAX] +} + fn main() { empty(); // ok singleton(); //~ ERROR unused array of `S` that must be used @@ -44,4 +49,6 @@ fn main() { //~^ ERROR unused array of boxed `T` trait objects in tuple element 1 that must be used array_of_arrays_of_arrays(); //~^ ERROR unused array of arrays of arrays of `S` that must be used + usize_max(); + //~^ ERROR unused array of `S` that must be used } diff --git a/src/test/ui/lint/unused/must_use-array.stderr b/src/test/ui/lint/unused/must_use-array.stderr index 45a5317fc..61ef2088d 100644 --- a/src/test/ui/lint/unused/must_use-array.stderr +++ b/src/test/ui/lint/unused/must_use-array.stderr @@ -1,8 +1,8 @@ error: unused array of `S` that must be used - --> $DIR/must_use-array.rs:39:5 + --> $DIR/must_use-array.rs:44:5 | LL | singleton(); - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^ | note: the lint level is defined here --> $DIR/must_use-array.rs:1:9 @@ -11,34 +11,40 @@ LL | #![deny(unused_must_use)] | ^^^^^^^^^^^^^^^ error: unused array of `S` that must be used - --> $DIR/must_use-array.rs:40:5 + --> $DIR/must_use-array.rs:45:5 | LL | many(); - | ^^^^^^^ + | ^^^^^^ error: unused array of `S` in tuple element 0 that must be used - --> $DIR/must_use-array.rs:41:6 + --> $DIR/must_use-array.rs:46:6 | LL | ([S], 0, ()); | ^^^ error: unused array of implementers of `T` that must be used - --> $DIR/must_use-array.rs:42:5 + --> $DIR/must_use-array.rs:47:5 | LL | array_of_impl_trait(); - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^ error: unused array of boxed `T` trait objects in tuple element 1 that must be used - --> $DIR/must_use-array.rs:43:5 + --> $DIR/must_use-array.rs:48:5 | LL | impl_array(); | ^^^^^^^^^^^^ error: unused array of arrays of arrays of `S` that must be used - --> $DIR/must_use-array.rs:45:5 + --> $DIR/must_use-array.rs:50:5 | LL | array_of_arrays_of_arrays(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: unused array of `S` that must be used + --> $DIR/must_use-array.rs:52:5 + | +LL | usize_max(); + | ^^^^^^^^^^^ -error: aborting due to 6 previous errors +error: aborting due to 7 previous errors diff --git a/src/test/ui/lint/unused/must_use-in-stdlib-traits.stderr b/src/test/ui/lint/unused/must_use-in-stdlib-traits.stderr index f5199f43c..ef738708d 100644 --- a/src/test/ui/lint/unused/must_use-in-stdlib-traits.stderr +++ b/src/test/ui/lint/unused/must_use-in-stdlib-traits.stderr @@ -2,7 +2,7 @@ error: unused implementer of `Iterator` that must be used --> $DIR/must_use-in-stdlib-traits.rs:42:4 | LL | iterator(); - | ^^^^^^^^^^^ + | ^^^^^^^^^^ | = note: iterators are lazy and do nothing unless consumed note: the lint level is defined here @@ -15,7 +15,7 @@ error: unused implementer of `Future` that must be used --> $DIR/must_use-in-stdlib-traits.rs:43:4 | LL | future(); - | ^^^^^^^^^ + | ^^^^^^^^ | = note: futures do nothing unless you `.await` or poll them @@ -23,7 +23,7 @@ error: unused implementer of `FnOnce` that must be used --> $DIR/must_use-in-stdlib-traits.rs:44:4 | LL | square_fn_once(); - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ | = note: closures are lazy and do nothing unless called @@ -31,7 +31,7 @@ error: unused implementer of `FnMut` that must be used --> $DIR/must_use-in-stdlib-traits.rs:45:4 | LL | square_fn_mut(); - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ | = note: closures are lazy and do nothing unless called @@ -39,7 +39,7 @@ error: unused implementer of `Fn` that must be used --> $DIR/must_use-in-stdlib-traits.rs:46:4 | LL | square_fn(); - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^ | = note: closures are lazy and do nothing unless called diff --git a/src/test/ui/lint/unused/must_use-trait.stderr b/src/test/ui/lint/unused/must_use-trait.stderr index a42eb8841..2f5496484 100644 --- a/src/test/ui/lint/unused/must_use-trait.stderr +++ b/src/test/ui/lint/unused/must_use-trait.stderr @@ -2,7 +2,7 @@ error: unused implementer of `Critical` that must be used --> $DIR/must_use-trait.rs:33:5 | LL | get_critical(); - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^ | note: the lint level is defined here --> $DIR/must_use-trait.rs:1:9 @@ -14,13 +14,13 @@ error: unused boxed `Critical` trait object that must be used --> $DIR/must_use-trait.rs:34:5 | LL | get_boxed_critical(); - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ error: unused boxed boxed `Critical` trait object that must be used --> $DIR/must_use-trait.rs:35:5 | LL | get_nested_boxed_critical(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unused boxed `Critical` trait object in tuple element 1 that must be used --> $DIR/must_use-trait.rs:37:5 diff --git a/src/test/ui/lint/unused/must_use-unit.stderr b/src/test/ui/lint/unused/must_use-unit.stderr index 7f25a1935..9fcbc5074 100644 --- a/src/test/ui/lint/unused/must_use-unit.stderr +++ b/src/test/ui/lint/unused/must_use-unit.stderr @@ -2,7 +2,7 @@ error: unused return value of `foo` that must be used --> $DIR/must_use-unit.rs:13:5 | LL | foo(); - | ^^^^^^ + | ^^^^^ | note: the lint level is defined here --> $DIR/must_use-unit.rs:2:9 @@ -14,7 +14,7 @@ error: unused return value of `bar` that must be used --> $DIR/must_use-unit.rs:15:5 | LL | bar(); - | ^^^^^^ + | ^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/lint/unused/unused-async.rs b/src/test/ui/lint/unused/unused-async.rs index 7d17af115..4be93aa15 100644 --- a/src/test/ui/lint/unused/unused-async.rs +++ b/src/test/ui/lint/unused/unused-async.rs @@ -1,24 +1,43 @@ // edition:2018 -// run-pass -#![allow(dead_code)] +#![deny(unused_must_use)] + #[must_use] -//~^ WARNING `must_use` -async fn test() -> i32 { +async fn foo() -> i32 { 1 } +#[must_use] +fn bar() -> impl std::future::Future<Output=i32> { + async { + 42 + } +} + +async fn baz() -> i32 { + 0 +} struct Wowee {} impl Wowee { #[must_use] - //~^ WARNING `must_use` async fn test_method() -> i32 { 1 } } +async fn test() { + foo(); //~ ERROR unused return value of `foo` that must be used + //~^ ERROR unused implementer of `Future` that must be used + foo().await; //~ ERROR unused output of future returned by `foo` that must be used + bar(); //~ ERROR unused return value of `bar` that must be used + //~^ ERROR unused implementer of `Future` that must be used + bar().await; //~ ERROR unused output of future returned by `bar` that must be used + baz(); //~ ERROR unused implementer of `Future` that must be used + baz().await; // ok +} + /* FIXME(guswynn) update this test when async-fn-in-traits works trait Doer { #[must_use] diff --git a/src/test/ui/lint/unused/unused-async.stderr b/src/test/ui/lint/unused/unused-async.stderr index 6bbc9e2bf..4bcb26dc1 100644 --- a/src/test/ui/lint/unused/unused-async.stderr +++ b/src/test/ui/lint/unused/unused-async.stderr @@ -1,26 +1,55 @@ -warning: `must_use` attribute on `async` functions applies to the anonymous `Future` returned by the function, not the value within - --> $DIR/unused-async.rs:5:1 - | -LL | #[must_use] - | ^^^^^^^^^^^ -LL | -LL | / async fn test() -> i32 { -LL | | 1 -LL | | } - | |_- this attribute does nothing, the `Future`s returned by async functions are already `must_use` - | - = note: `#[warn(unused_attributes)]` on by default - -warning: `must_use` attribute on `async` functions applies to the anonymous `Future` returned by the function, not the value within - --> $DIR/unused-async.rs:15:5 - | -LL | #[must_use] - | ^^^^^^^^^^^ -LL | -LL | / async fn test_method() -> i32 { -LL | | 1 -LL | | } - | |_____- this attribute does nothing, the `Future`s returned by async functions are already `must_use` - -warning: 2 warnings emitted +error: unused implementer of `Future` that must be used + --> $DIR/unused-async.rs:31:5 + | +LL | foo(); + | ^^^^^ + | + = note: futures do nothing unless you `.await` or poll them +note: the lint level is defined here + --> $DIR/unused-async.rs:2:9 + | +LL | #![deny(unused_must_use)] + | ^^^^^^^^^^^^^^^ + +error: unused return value of `foo` that must be used + --> $DIR/unused-async.rs:31:5 + | +LL | foo(); + | ^^^^^ + +error: unused output of future returned by `foo` that must be used + --> $DIR/unused-async.rs:33:5 + | +LL | foo().await; + | ^^^^^^^^^^^ + +error: unused implementer of `Future` that must be used + --> $DIR/unused-async.rs:34:5 + | +LL | bar(); + | ^^^^^ + | + = note: futures do nothing unless you `.await` or poll them + +error: unused return value of `bar` that must be used + --> $DIR/unused-async.rs:34:5 + | +LL | bar(); + | ^^^^^ + +error: unused output of future returned by `bar` that must be used + --> $DIR/unused-async.rs:36:5 + | +LL | bar().await; + | ^^^^^^^^^^^ + +error: unused implementer of `Future` that must be used + --> $DIR/unused-async.rs:37:5 + | +LL | baz(); + | ^^^^^ + | + = note: futures do nothing unless you `.await` or poll them + +error: aborting due to 7 previous errors diff --git a/src/test/ui/lint/unused/unused-closure.stderr b/src/test/ui/lint/unused/unused-closure.stderr index 4362abd20..c3a82402e 100644 --- a/src/test/ui/lint/unused/unused-closure.stderr +++ b/src/test/ui/lint/unused/unused-closure.stderr @@ -4,7 +4,7 @@ error: unused closure that must be used LL | / || { LL | | println!("Hello!"); LL | | }; - | |______^ + | |_____^ | = note: closures are lazy and do nothing unless called note: the lint level is defined here @@ -17,7 +17,7 @@ error: unused implementer of `Future` that must be used --> $DIR/unused-closure.rs:13:5 | LL | async {}; - | ^^^^^^^^^ + | ^^^^^^^^ | = note: futures do nothing unless you `.await` or poll them @@ -25,7 +25,7 @@ error: unused closure that must be used --> $DIR/unused-closure.rs:14:5 | LL | || async {}; - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^ | = note: closures are lazy and do nothing unless called @@ -33,7 +33,7 @@ error: unused closure that must be used --> $DIR/unused-closure.rs:15:5 | LL | async || {}; - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^ | = note: closures are lazy and do nothing unless called @@ -41,7 +41,7 @@ error: unused array of boxed arrays of closures that must be used --> $DIR/unused-closure.rs:18:5 | LL | [Box::new([|| {}; 10]); 1]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: closures are lazy and do nothing unless called @@ -49,7 +49,7 @@ error: unused closure that must be used --> $DIR/unused-closure.rs:20:5 | LL | vec![|| "a"].pop().unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: closures are lazy and do nothing unless called @@ -57,7 +57,7 @@ error: unused closure that must be used --> $DIR/unused-closure.rs:23:9 | LL | || true; - | ^^^^^^^^ + | ^^^^^^^ | = note: closures are lazy and do nothing unless called diff --git a/src/test/ui/lint/unused/unused-result.stderr b/src/test/ui/lint/unused/unused-result.stderr index 087e06341..4e1ba1fd9 100644 --- a/src/test/ui/lint/unused/unused-result.stderr +++ b/src/test/ui/lint/unused/unused-result.stderr @@ -2,7 +2,7 @@ error: unused `MustUse` that must be used --> $DIR/unused-result.rs:21:5 | LL | foo::<MustUse>(); - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ | note: the lint level is defined here --> $DIR/unused-result.rs:2:25 @@ -14,7 +14,7 @@ error: unused `MustUseMsg` that must be used --> $DIR/unused-result.rs:22:5 | LL | foo::<MustUseMsg>(); - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ | = note: some message @@ -34,13 +34,13 @@ error: unused `MustUse` that must be used --> $DIR/unused-result.rs:35:5 | LL | foo::<MustUse>(); - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ error: unused `MustUseMsg` that must be used --> $DIR/unused-result.rs:36:5 | LL | foo::<MustUseMsg>(); - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ | = note: some message diff --git a/src/test/ui/lint/unused/unused-supertrait.stderr b/src/test/ui/lint/unused/unused-supertrait.stderr index d2f8c0078..cb45add9c 100644 --- a/src/test/ui/lint/unused/unused-supertrait.stderr +++ b/src/test/ui/lint/unused/unused-supertrait.stderr @@ -2,7 +2,7 @@ error: unused implementer of `Iterator` that must be used --> $DIR/unused-supertrait.rs:9:5 | LL | it(); - | ^^^^^ + | ^^^^ | = note: iterators are lazy and do nothing unless consumed note: the lint level is defined here diff --git a/src/test/ui/lint/unused/unused_attributes-must_use.stderr b/src/test/ui/lint/unused/unused_attributes-must_use.stderr index ce959ddbc..0f699429e 100644 --- a/src/test/ui/lint/unused/unused_attributes-must_use.stderr +++ b/src/test/ui/lint/unused/unused_attributes-must_use.stderr @@ -139,7 +139,7 @@ error: unused `X` that must be used --> $DIR/unused_attributes-must_use.rs:103:5 | LL | X; - | ^^ + | ^ | note: the lint level is defined here --> $DIR/unused_attributes-must_use.rs:2:28 @@ -151,37 +151,37 @@ error: unused `Y` that must be used --> $DIR/unused_attributes-must_use.rs:104:5 | LL | Y::Z; - | ^^^^^ + | ^^^^ error: unused `U` that must be used --> $DIR/unused_attributes-must_use.rs:105:5 | LL | U { unit: () }; - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^ error: unused return value of `U::method` that must be used --> $DIR/unused_attributes-must_use.rs:106:5 | LL | U::method(); - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^ error: unused return value of `foo` that must be used --> $DIR/unused_attributes-must_use.rs:107:5 | LL | foo(); - | ^^^^^^ + | ^^^^^ error: unused return value of `foreign_foo` that must be used --> $DIR/unused_attributes-must_use.rs:110:9 | LL | foreign_foo(); - | ^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ error: unused return value of `Use::get_four` that must be used --> $DIR/unused_attributes-must_use.rs:118:5 | LL | ().get_four(); - | ^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ error: aborting due to 28 previous errors diff --git a/src/test/ui/liveness/liveness-move-call-arg.stderr b/src/test/ui/liveness/liveness-move-call-arg.stderr index 7c0e916ed..d14cd6cb4 100644 --- a/src/test/ui/liveness/liveness-move-call-arg.stderr +++ b/src/test/ui/liveness/liveness-move-call-arg.stderr @@ -3,9 +3,23 @@ error[E0382]: use of moved value: `x` | LL | let x: Box<isize> = Box::new(25); | - move occurs because `x` has type `Box<isize>`, which does not implement the `Copy` trait -... +LL | +LL | loop { + | ---- inside of this loop LL | take(x); | ^ value moved here, in previous iteration of loop + | +note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary + --> $DIR/liveness-move-call-arg.rs:1:13 + | +LL | fn take(_x: Box<isize>) {} + | ---- ^^^^^^^^^^ this parameter takes ownership of the value + | | + | in this function +help: consider cloning the value if the performance cost is acceptable + | +LL | take(x.clone()); + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/liveness/liveness-move-in-loop.stderr b/src/test/ui/liveness/liveness-move-in-loop.stderr index 832d4f8fa..a060914f1 100644 --- a/src/test/ui/liveness/liveness-move-in-loop.stderr +++ b/src/test/ui/liveness/liveness-move-in-loop.stderr @@ -4,8 +4,22 @@ error[E0382]: use of moved value: `y` LL | let y: Box<isize> = 42.into(); | - move occurs because `y` has type `Box<isize>`, which does not implement the `Copy` trait ... +LL | loop { + | ---- inside of this loop +LL | println!("{}", y); +LL | loop { + | ---- inside of this loop +LL | loop { + | ---- inside of this loop +LL | loop { + | ---- inside of this loop LL | x = y; | ^ value moved here, in previous iteration of loop + | +help: consider cloning the value if the performance cost is acceptable + | +LL | x = y.clone(); + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/liveness/liveness-move-in-while.stderr b/src/test/ui/liveness/liveness-move-in-while.stderr index b04a05fe4..4dff7447d 100644 --- a/src/test/ui/liveness/liveness-move-in-while.stderr +++ b/src/test/ui/liveness/liveness-move-in-while.stderr @@ -24,12 +24,22 @@ error[E0382]: borrow of moved value: `y` LL | let y: Box<isize> = 42.into(); | - move occurs because `y` has type `Box<isize>`, which does not implement the `Copy` trait ... +LL | loop { + | ---- inside of this loop LL | println!("{}", y); | ^ value borrowed here after move LL | while true { while true { while true { x = y; x.clone(); } } } - | - value moved here, in previous iteration of loop + | ---------- ---------- ---------- - value moved here, in previous iteration of loop + | | | | + | | | inside of this loop + | | inside of this loop + | inside of this loop | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider cloning the value if the performance cost is acceptable + | +LL | while true { while true { while true { x = y.clone(); x.clone(); } } } + | ++++++++ error: aborting due to previous error; 3 warnings emitted diff --git a/src/test/ui/liveness/liveness-use-after-move.stderr b/src/test/ui/liveness/liveness-use-after-move.stderr index 218b93c8e..3accba197 100644 --- a/src/test/ui/liveness/liveness-use-after-move.stderr +++ b/src/test/ui/liveness/liveness-use-after-move.stderr @@ -10,6 +10,10 @@ LL | println!("{}", *x); | ^^ value borrowed here after move | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider cloning the value if the performance cost is acceptable + | +LL | let y = x.clone(); + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/liveness/liveness-use-after-send.stderr b/src/test/ui/liveness/liveness-use-after-send.stderr index 8edc0463f..65d55ca8f 100644 --- a/src/test/ui/liveness/liveness-use-after-send.stderr +++ b/src/test/ui/liveness/liveness-use-after-send.stderr @@ -8,7 +8,16 @@ LL | send(ch, message); LL | println!("{}", message); | ^^^^^^^ value borrowed here after move | +note: consider changing this parameter type in function `send` to borrow instead if owning the value isn't necessary + --> $DIR/liveness-use-after-send.rs:3:54 + | +LL | fn send<T:Send + std::fmt::Debug>(ch: Chan<T>, data: T) { + | ---- in this function ^ this parameter takes ownership of the value = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider cloning the value if the performance cost is acceptable + | +LL | send(ch, message.clone()); + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/lto/auxiliary/thinlto-dylib.rs b/src/test/ui/lto/auxiliary/thinlto-dylib.rs new file mode 100644 index 000000000..9d17c35da --- /dev/null +++ b/src/test/ui/lto/auxiliary/thinlto-dylib.rs @@ -0,0 +1,23 @@ +// Auxiliary crate for test issue-105637: the LTOed dylib which had duplicate symbols from libstd, +// breaking the panic hook feature. +// +// This simulates the `rustc_driver` crate, and the main crate simulates rustc's main binary hooking +// into this driver. + +// compile-flags: -Zdylib-lto -C lto=thin + +use std::panic; + +pub fn main() { + // Install the hook we want to see executed + panic::set_hook(Box::new(|_| { + eprintln!("LTOed auxiliary crate panic hook"); + })); + + // Trigger the panic hook with an ICE + run_compiler(); +} + +fn run_compiler() { + panic!("ICEing"); +} diff --git a/src/test/ui/lto/issue-105637.rs b/src/test/ui/lto/issue-105637.rs new file mode 100644 index 000000000..0d9f0bec0 --- /dev/null +++ b/src/test/ui/lto/issue-105637.rs @@ -0,0 +1,28 @@ +// Regression test for issue #105637: `-Zdylib-lto` with LTO duplicated symbols from other dylibs, +// in this case from libstd. +// +// That manifested as both `rustc_driver` and rustc's "main" (`compiler/rustc`) having their own +// `std::panicking::HOOK` static, and the hook in rustc's main (the default stdlib's) being executed +// when rustc ICEs, instead of the overriden hook from `rustc_driver` (which also displays the query +// stack and information on how to open a GH issue for the encountered ICE). +// +// In this test, we reproduce this setup by installing a panic hook in both the main and an LTOed +// dylib: the last hook set should be the one being executed, the dylib's. + +// aux-build: thinlto-dylib.rs +// run-fail +// check-run-results + +extern crate thinlto_dylib; + +use std::panic; + +fn main() { + // We don't want to see this panic hook executed + std::panic::set_hook(Box::new(|_| { + eprintln!("main crate panic hook"); + })); + + // Have the LTOed dylib install its own hook and panic, we want to see its hook executed. + thinlto_dylib::main(); +} diff --git a/src/test/ui/lto/issue-105637.run.stderr b/src/test/ui/lto/issue-105637.run.stderr new file mode 100644 index 000000000..43388e776 --- /dev/null +++ b/src/test/ui/lto/issue-105637.run.stderr @@ -0,0 +1 @@ +LTOed auxiliary crate panic hook diff --git a/src/test/ui/macros/assert-trailing-junk.with-generic-asset.stderr b/src/test/ui/macros/assert-trailing-junk.with-generic-asset.stderr index 09dd16a0b..1e73320e4 100644 --- a/src/test/ui/macros/assert-trailing-junk.with-generic-asset.stderr +++ b/src/test/ui/macros/assert-trailing-junk.with-generic-asset.stderr @@ -17,6 +17,8 @@ LL | assert!(true, "whatever" blah); | -^^^^ no rules expected this token in macro call | | | help: missing comma here + | + = note: while trying to match sequence start error: unexpected string literal --> $DIR/assert-trailing-junk.rs:18:18 @@ -33,6 +35,8 @@ LL | assert!(true "whatever" blah); | -^^^^ no rules expected this token in macro call | | | help: missing comma here + | + = note: while trying to match sequence start error: macro requires an expression as an argument --> $DIR/assert-trailing-junk.rs:22:5 diff --git a/src/test/ui/macros/assert-trailing-junk.without-generic-asset.stderr b/src/test/ui/macros/assert-trailing-junk.without-generic-asset.stderr index 09dd16a0b..1e73320e4 100644 --- a/src/test/ui/macros/assert-trailing-junk.without-generic-asset.stderr +++ b/src/test/ui/macros/assert-trailing-junk.without-generic-asset.stderr @@ -17,6 +17,8 @@ LL | assert!(true, "whatever" blah); | -^^^^ no rules expected this token in macro call | | | help: missing comma here + | + = note: while trying to match sequence start error: unexpected string literal --> $DIR/assert-trailing-junk.rs:18:18 @@ -33,6 +35,8 @@ LL | assert!(true "whatever" blah); | -^^^^ no rules expected this token in macro call | | | help: missing comma here + | + = note: while trying to match sequence start error: macro requires an expression as an argument --> $DIR/assert-trailing-junk.rs:22:5 diff --git a/src/test/ui/attr-from-macro.rs b/src/test/ui/macros/attr-from-macro.rs index bb3a5c94d..bb3a5c94d 100644 --- a/src/test/ui/attr-from-macro.rs +++ b/src/test/ui/macros/attr-from-macro.rs diff --git a/src/test/ui/auxiliary/attr-from-macro.rs b/src/test/ui/macros/auxiliary/attr-from-macro.rs index 9b388675c..9b388675c 100644 --- a/src/test/ui/auxiliary/attr-from-macro.rs +++ b/src/test/ui/macros/auxiliary/attr-from-macro.rs diff --git a/src/test/ui/macros/issue-103529.rs b/src/test/ui/macros/issue-103529.rs new file mode 100644 index 000000000..fa05baed7 --- /dev/null +++ b/src/test/ui/macros/issue-103529.rs @@ -0,0 +1,13 @@ +macro_rules! m { + ($s:stmt) => {} +} + +m! { mut x } +//~^ ERROR expected expression, found keyword `mut` +//~| ERROR expected a statement +m! { auto x } +//~^ ERROR invalid variable declaration +m! { var x } +//~^ ERROR invalid variable declaration + +fn main() {} diff --git a/src/test/ui/macros/issue-103529.stderr b/src/test/ui/macros/issue-103529.stderr new file mode 100644 index 000000000..61e322afc --- /dev/null +++ b/src/test/ui/macros/issue-103529.stderr @@ -0,0 +1,39 @@ +error: expected expression, found keyword `mut` + --> $DIR/issue-103529.rs:5:6 + | +LL | m! { mut x } + | ^^^ expected expression + +error: expected a statement + --> $DIR/issue-103529.rs:5:10 + | +LL | ($s:stmt) => {} + | ------- while parsing argument for this `stmt` macro fragment +... +LL | m! { mut x } + | ^ + +error: invalid variable declaration + --> $DIR/issue-103529.rs:8:6 + | +LL | m! { auto x } + | ^^^^ + | +help: write `let` instead of `auto` to introduce a new variable + | +LL | m! { let x } + | ~~~ + +error: invalid variable declaration + --> $DIR/issue-103529.rs:10:6 + | +LL | m! { var x } + | ^^^ + | +help: write `let` instead of `var` to introduce a new variable + | +LL | m! { let x } + | ~~~ + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/macros/issue-104769-concat_bytes-invalid-literal.rs b/src/test/ui/macros/issue-104769-concat_bytes-invalid-literal.rs new file mode 100644 index 000000000..24150376e --- /dev/null +++ b/src/test/ui/macros/issue-104769-concat_bytes-invalid-literal.rs @@ -0,0 +1,8 @@ +#![feature(concat_bytes)] + +fn main() { + concat_bytes!(7Y); + //~^ ERROR invalid suffix `Y` for number literal + concat_bytes!(888888888888888888888888888888888888888); + //~^ ERROR integer literal is too large +} diff --git a/src/test/ui/macros/issue-104769-concat_bytes-invalid-literal.stderr b/src/test/ui/macros/issue-104769-concat_bytes-invalid-literal.stderr new file mode 100644 index 000000000..8d70faa49 --- /dev/null +++ b/src/test/ui/macros/issue-104769-concat_bytes-invalid-literal.stderr @@ -0,0 +1,16 @@ +error: invalid suffix `Y` for number literal + --> $DIR/issue-104769-concat_bytes-invalid-literal.rs:4:19 + | +LL | concat_bytes!(7Y); + | ^^ invalid suffix `Y` + | + = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) + +error: integer literal is too large + --> $DIR/issue-104769-concat_bytes-invalid-literal.rs:6:19 + | +LL | concat_bytes!(888888888888888888888888888888888888888); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/macros/issue-105011.rs b/src/test/ui/macros/issue-105011.rs new file mode 100644 index 000000000..da12c3814 --- /dev/null +++ b/src/test/ui/macros/issue-105011.rs @@ -0,0 +1,3 @@ +fn main() { + println!(""y); //~ ERROR suffixes on string literals are invalid +} diff --git a/src/test/ui/macros/issue-105011.stderr b/src/test/ui/macros/issue-105011.stderr new file mode 100644 index 000000000..e898af7fa --- /dev/null +++ b/src/test/ui/macros/issue-105011.stderr @@ -0,0 +1,8 @@ +error: suffixes on string literals are invalid + --> $DIR/issue-105011.rs:2:14 + | +LL | println!(""y); + | ^^^ invalid suffix `y` + +error: aborting due to previous error + diff --git a/src/test/ui/macros/issue-38715.rs b/src/test/ui/macros/issue-38715.rs index 9a9a501ca..85ed97663 100644 --- a/src/test/ui/macros/issue-38715.rs +++ b/src/test/ui/macros/issue-38715.rs @@ -1,7 +1,17 @@ #[macro_export] -macro_rules! foo { ($i:ident) => {} } +macro_rules! foo { () => {} } #[macro_export] macro_rules! foo { () => {} } //~ ERROR the name `foo` is defined multiple times +mod inner1 { + #[macro_export] + macro_rules! bar { () => {} } +} + +mod inner2 { + #[macro_export] + macro_rules! bar { () => {} } //~ ERROR the name `bar` is defined multiple times +} + fn main() {} diff --git a/src/test/ui/macros/issue-38715.stderr b/src/test/ui/macros/issue-38715.stderr index c87d9f736..828a7f459 100644 --- a/src/test/ui/macros/issue-38715.stderr +++ b/src/test/ui/macros/issue-38715.stderr @@ -1,7 +1,7 @@ error[E0428]: the name `foo` is defined multiple times --> $DIR/issue-38715.rs:5:1 | -LL | macro_rules! foo { ($i:ident) => {} } +LL | macro_rules! foo { () => {} } | ---------------- previous definition of the macro `foo` here ... LL | macro_rules! foo { () => {} } @@ -9,6 +9,17 @@ LL | macro_rules! foo { () => {} } | = note: `foo` must be defined only once in the macro namespace of this module -error: aborting due to previous error +error[E0428]: the name `bar` is defined multiple times + --> $DIR/issue-38715.rs:14:5 + | +LL | macro_rules! bar { () => {} } + | ---------------- previous definition of the macro `bar` here +... +LL | macro_rules! bar { () => {} } + | ^^^^^^^^^^^^^^^^ `bar` redefined here + | + = note: `bar` must be defined only once in the macro namespace of this module + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0428`. diff --git a/src/test/ui/macros/issue-68060.rs b/src/test/ui/macros/issue-68060.rs index aa8f578ad..fb40cd538 100644 --- a/src/test/ui/macros/issue-68060.rs +++ b/src/test/ui/macros/issue-68060.rs @@ -3,7 +3,11 @@ fn main() { .map( #[target_feature(enable = "")] //~^ ERROR: attribute should be applied to a function + //~| ERROR: feature named `` is not valid + //~| NOTE: `` is not valid for this target #[track_caller] + //~^ ERROR: `#[track_caller]` on closures is currently unstable + //~| NOTE: see issue #87417 |_| (), //~^ NOTE: not a function ) diff --git a/src/test/ui/macros/issue-68060.stderr b/src/test/ui/macros/issue-68060.stderr index b13e418e6..52e6ed92e 100644 --- a/src/test/ui/macros/issue-68060.stderr +++ b/src/test/ui/macros/issue-68060.stderr @@ -7,5 +7,21 @@ LL | #[target_feature(enable = "")] LL | |_| (), | ------ not a function definition -error: aborting due to previous error +error: the feature named `` is not valid for this target + --> $DIR/issue-68060.rs:4:30 + | +LL | #[target_feature(enable = "")] + | ^^^^^^^^^^^ `` is not valid for this target + +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/issue-68060.rs:8:13 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/macros/macro-at-most-once-rep-2015.stderr b/src/test/ui/macros/macro-at-most-once-rep-2015.stderr index 9a3df858e..7c45b85bc 100644 --- a/src/test/ui/macros/macro-at-most-once-rep-2015.stderr +++ b/src/test/ui/macros/macro-at-most-once-rep-2015.stderr @@ -12,6 +12,8 @@ LL | macro_rules! foo { ... LL | foo!(a?); | ^ no rules expected this token in macro call + | + = note: while trying to match sequence end error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2015.rs:26:11 @@ -21,6 +23,8 @@ LL | macro_rules! foo { ... LL | foo!(a?a); | ^ no rules expected this token in macro call + | + = note: while trying to match sequence end error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2015.rs:27:11 @@ -30,6 +34,8 @@ LL | macro_rules! foo { ... LL | foo!(a?a?a); | ^ no rules expected this token in macro call + | + = note: while trying to match sequence end error: unexpected end of macro invocation --> $DIR/macro-at-most-once-rep-2015.rs:29:5 @@ -39,6 +45,12 @@ LL | macro_rules! barplus { ... LL | barplus!(); | ^^^^^^^^^^ missing tokens in macro arguments + | +note: while trying to match `+` + --> $DIR/macro-at-most-once-rep-2015.rs:15:11 + | +LL | ($(a)?+) => {}; // ok. matches "a+" and "+" + | ^ error: unexpected end of macro invocation --> $DIR/macro-at-most-once-rep-2015.rs:30:15 @@ -48,6 +60,12 @@ LL | macro_rules! barplus { ... LL | barplus!(a); | ^ missing tokens in macro arguments + | +note: while trying to match `+` + --> $DIR/macro-at-most-once-rep-2015.rs:15:11 + | +LL | ($(a)?+) => {}; // ok. matches "a+" and "+" + | ^ error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2015.rs:31:15 @@ -57,6 +75,12 @@ LL | macro_rules! barplus { ... LL | barplus!(a?); | ^ no rules expected this token in macro call + | +note: while trying to match `+` + --> $DIR/macro-at-most-once-rep-2015.rs:15:11 + | +LL | ($(a)?+) => {}; // ok. matches "a+" and "+" + | ^ error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2015.rs:32:15 @@ -66,6 +90,12 @@ LL | macro_rules! barplus { ... LL | barplus!(a?a); | ^ no rules expected this token in macro call + | +note: while trying to match `+` + --> $DIR/macro-at-most-once-rep-2015.rs:15:11 + | +LL | ($(a)?+) => {}; // ok. matches "a+" and "+" + | ^ error: unexpected end of macro invocation --> $DIR/macro-at-most-once-rep-2015.rs:36:5 @@ -75,6 +105,12 @@ LL | macro_rules! barstar { ... LL | barstar!(); | ^^^^^^^^^^ missing tokens in macro arguments + | +note: while trying to match `*` + --> $DIR/macro-at-most-once-rep-2015.rs:19:11 + | +LL | ($(a)?*) => {}; // ok. matches "a*" and "*" + | ^ error: unexpected end of macro invocation --> $DIR/macro-at-most-once-rep-2015.rs:37:15 @@ -84,6 +120,12 @@ LL | macro_rules! barstar { ... LL | barstar!(a); | ^ missing tokens in macro arguments + | +note: while trying to match `*` + --> $DIR/macro-at-most-once-rep-2015.rs:19:11 + | +LL | ($(a)?*) => {}; // ok. matches "a*" and "*" + | ^ error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2015.rs:38:15 @@ -93,6 +135,12 @@ LL | macro_rules! barstar { ... LL | barstar!(a?); | ^ no rules expected this token in macro call + | +note: while trying to match `*` + --> $DIR/macro-at-most-once-rep-2015.rs:19:11 + | +LL | ($(a)?*) => {}; // ok. matches "a*" and "*" + | ^ error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2015.rs:39:15 @@ -102,6 +150,12 @@ LL | macro_rules! barstar { ... LL | barstar!(a?a); | ^ no rules expected this token in macro call + | +note: while trying to match `*` + --> $DIR/macro-at-most-once-rep-2015.rs:19:11 + | +LL | ($(a)?*) => {}; // ok. matches "a*" and "*" + | ^ error: aborting due to 12 previous errors diff --git a/src/test/ui/macros/macro-at-most-once-rep-2018.stderr b/src/test/ui/macros/macro-at-most-once-rep-2018.stderr index 013fabe13..696520b28 100644 --- a/src/test/ui/macros/macro-at-most-once-rep-2018.stderr +++ b/src/test/ui/macros/macro-at-most-once-rep-2018.stderr @@ -12,6 +12,8 @@ LL | macro_rules! foo { ... LL | foo!(a?); | ^ no rules expected this token in macro call + | + = note: while trying to match sequence end error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:26:11 @@ -21,6 +23,8 @@ LL | macro_rules! foo { ... LL | foo!(a?a); | ^ no rules expected this token in macro call + | + = note: while trying to match sequence end error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:27:11 @@ -30,6 +34,8 @@ LL | macro_rules! foo { ... LL | foo!(a?a?a); | ^ no rules expected this token in macro call + | + = note: while trying to match sequence end error: unexpected end of macro invocation --> $DIR/macro-at-most-once-rep-2018.rs:29:5 @@ -39,6 +45,12 @@ LL | macro_rules! barplus { ... LL | barplus!(); | ^^^^^^^^^^ missing tokens in macro arguments + | +note: while trying to match `+` + --> $DIR/macro-at-most-once-rep-2018.rs:15:11 + | +LL | ($(a)?+) => {}; // ok. matches "a+" and "+" + | ^ error: unexpected end of macro invocation --> $DIR/macro-at-most-once-rep-2018.rs:30:15 @@ -48,6 +60,12 @@ LL | macro_rules! barplus { ... LL | barplus!(a); | ^ missing tokens in macro arguments + | +note: while trying to match `+` + --> $DIR/macro-at-most-once-rep-2018.rs:15:11 + | +LL | ($(a)?+) => {}; // ok. matches "a+" and "+" + | ^ error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:31:15 @@ -57,6 +75,12 @@ LL | macro_rules! barplus { ... LL | barplus!(a?); | ^ no rules expected this token in macro call + | +note: while trying to match `+` + --> $DIR/macro-at-most-once-rep-2018.rs:15:11 + | +LL | ($(a)?+) => {}; // ok. matches "a+" and "+" + | ^ error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:32:15 @@ -66,6 +90,12 @@ LL | macro_rules! barplus { ... LL | barplus!(a?a); | ^ no rules expected this token in macro call + | +note: while trying to match `+` + --> $DIR/macro-at-most-once-rep-2018.rs:15:11 + | +LL | ($(a)?+) => {}; // ok. matches "a+" and "+" + | ^ error: unexpected end of macro invocation --> $DIR/macro-at-most-once-rep-2018.rs:36:5 @@ -75,6 +105,12 @@ LL | macro_rules! barstar { ... LL | barstar!(); | ^^^^^^^^^^ missing tokens in macro arguments + | +note: while trying to match `*` + --> $DIR/macro-at-most-once-rep-2018.rs:19:11 + | +LL | ($(a)?*) => {}; // ok. matches "a*" and "*" + | ^ error: unexpected end of macro invocation --> $DIR/macro-at-most-once-rep-2018.rs:37:15 @@ -84,6 +120,12 @@ LL | macro_rules! barstar { ... LL | barstar!(a); | ^ missing tokens in macro arguments + | +note: while trying to match `*` + --> $DIR/macro-at-most-once-rep-2018.rs:19:11 + | +LL | ($(a)?*) => {}; // ok. matches "a*" and "*" + | ^ error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:38:15 @@ -93,6 +135,12 @@ LL | macro_rules! barstar { ... LL | barstar!(a?); | ^ no rules expected this token in macro call + | +note: while trying to match `*` + --> $DIR/macro-at-most-once-rep-2018.rs:19:11 + | +LL | ($(a)?*) => {}; // ok. matches "a*" and "*" + | ^ error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:39:15 @@ -102,6 +150,12 @@ LL | macro_rules! barstar { ... LL | barstar!(a?a); | ^ no rules expected this token in macro call + | +note: while trying to match `*` + --> $DIR/macro-at-most-once-rep-2018.rs:19:11 + | +LL | ($(a)?*) => {}; // ok. matches "a*" and "*" + | ^ error: aborting due to 12 previous errors diff --git a/src/test/ui/macros/macro-non-lifetime.stderr b/src/test/ui/macros/macro-non-lifetime.stderr index 6234735df..e1ed87f94 100644 --- a/src/test/ui/macros/macro-non-lifetime.stderr +++ b/src/test/ui/macros/macro-non-lifetime.stderr @@ -6,6 +6,12 @@ LL | macro_rules! m { ($x:lifetime) => { } } ... LL | m!(a); | ^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$x:lifetime` + --> $DIR/macro-non-lifetime.rs:3:19 + | +LL | macro_rules! m { ($x:lifetime) => { } } + | ^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/macros/missing-comma.stderr b/src/test/ui/macros/missing-comma.stderr index 6da92bdea..81877a29e 100644 --- a/src/test/ui/macros/missing-comma.stderr +++ b/src/test/ui/macros/missing-comma.stderr @@ -14,6 +14,12 @@ LL | foo!(a b); | -^ no rules expected this token in macro call | | | help: missing comma here + | +note: while trying to match meta-variable `$a:ident` + --> $DIR/missing-comma.rs:2:6 + | +LL | ($a:ident) => (); + | ^^^^^^^^ error: no rules expected the token `e` --> $DIR/missing-comma.rs:23:21 @@ -25,6 +31,12 @@ LL | foo!(a, b, c, d e); | -^ no rules expected this token in macro call | | | help: missing comma here + | +note: while trying to match meta-variable `$d:ident` + --> $DIR/missing-comma.rs:5:36 + | +LL | ($a:ident, $b:ident, $c:ident, $d:ident) => (); + | ^^^^^^^^ error: no rules expected the token `d` --> $DIR/missing-comma.rs:25:18 @@ -36,6 +48,12 @@ LL | foo!(a, b, c d, e); | -^ no rules expected this token in macro call | | | help: missing comma here + | +note: while trying to match meta-variable `$c:ident` + --> $DIR/missing-comma.rs:4:26 + | +LL | ($a:ident, $b:ident, $c:ident) => (); + | ^^^^^^^^ error: no rules expected the token `d` --> $DIR/missing-comma.rs:27:18 @@ -45,6 +63,12 @@ LL | macro_rules! foo { ... LL | foo!(a, b, c d e); | ^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$c:ident` + --> $DIR/missing-comma.rs:4:26 + | +LL | ($a:ident, $b:ident, $c:ident) => (); + | ^^^^^^^^ error: unexpected end of macro invocation --> $DIR/missing-comma.rs:29:23 @@ -54,6 +78,12 @@ LL | macro_rules! bar { ... LL | bar!(Level::Error, ); | ^ missing tokens in macro arguments + | +note: while trying to match meta-variable `$arg:tt` + --> $DIR/missing-comma.rs:10:19 + | +LL | ($lvl:expr, $($arg:tt)+) => {} + | ^^^^^^^ error: no rules expected the token `,` --> $DIR/missing-comma.rs:32:38 @@ -63,6 +93,12 @@ LL | macro_rules! check { ... LL | check!(<str as Debug>::fmt, "fmt",); | ^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$expected:expr` + --> $DIR/missing-comma.rs:14:14 + | +LL | ($ty:ty, $expected:expr) => {}; + | ^^^^^^^^^^^^^^ error: aborting due to 7 previous errors diff --git a/src/test/ui/macros/nonterminal-matching.stderr b/src/test/ui/macros/nonterminal-matching.stderr index 585f23553..5bbd54390 100644 --- a/src/test/ui/macros/nonterminal-matching.stderr +++ b/src/test/ui/macros/nonterminal-matching.stderr @@ -10,6 +10,14 @@ LL | n!(a $nt_item b); LL | complex_nonterminal!(enum E {}); | ------------------------------- in this macro invocation | +note: while trying to match `enum E {}` + --> $DIR/nonterminal-matching.rs:15:15 + | +LL | macro n(a $nt_item b) { + | ^^^^^^^^ +... +LL | complex_nonterminal!(enum E {}); + | ------------------------------- in this macro invocation = note: this error originates in the macro `complex_nonterminal` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/macros/recovery-allowed.rs b/src/test/ui/macros/recovery-allowed.rs new file mode 100644 index 000000000..ebf65f1cc --- /dev/null +++ b/src/test/ui/macros/recovery-allowed.rs @@ -0,0 +1,8 @@ +macro_rules! please_recover { + ($a:expr) => {}; +} + +please_recover! { not 1 } +//~^ ERROR unexpected `1` after identifier + +fn main() {} diff --git a/src/test/ui/macros/recovery-allowed.stderr b/src/test/ui/macros/recovery-allowed.stderr new file mode 100644 index 000000000..ec036e8b1 --- /dev/null +++ b/src/test/ui/macros/recovery-allowed.stderr @@ -0,0 +1,10 @@ +error: unexpected `1` after identifier + --> $DIR/recovery-allowed.rs:5:23 + | +LL | please_recover! { not 1 } + | ----^ + | | + | help: use `!` to perform bitwise not + +error: aborting due to previous error + diff --git a/src/test/ui/macros/recovery-forbidden.rs b/src/test/ui/macros/recovery-forbidden.rs new file mode 100644 index 000000000..5dd261933 --- /dev/null +++ b/src/test/ui/macros/recovery-forbidden.rs @@ -0,0 +1,13 @@ +// check-pass + +macro_rules! dont_recover_here { + ($e:expr) => { + compile_error!("Must not recover to single !1 expr"); + }; + + (not $a:literal) => {}; +} + +dont_recover_here! { not 1 } + +fn main() {} diff --git a/src/test/ui/macros/syntax-error-recovery.stderr b/src/test/ui/macros/syntax-error-recovery.stderr index c153b3b91..c42ee9b29 100644 --- a/src/test/ui/macros/syntax-error-recovery.stderr +++ b/src/test/ui/macros/syntax-error-recovery.stderr @@ -7,6 +7,7 @@ LL | $token $($inner)? = $value, LL | values!(STRING(1) as (String) => cfg(test),); | -------------------------------------------- in this macro invocation | + = help: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }` = note: this error originates in the macro `values` (in Nightly builds, run with -Z macro-backtrace for more info) error: macro expansion ignores token `(String)` and any following diff --git a/src/test/ui/macros/trace_faulty_macros.stderr b/src/test/ui/macros/trace_faulty_macros.stderr index d6fc69402..21e47da07 100644 --- a/src/test/ui/macros/trace_faulty_macros.stderr +++ b/src/test/ui/macros/trace_faulty_macros.stderr @@ -10,6 +10,7 @@ LL | my_faulty_macro!(bcd); LL | my_faulty_macro!(); | ------------------ in this macro invocation | + = note: while trying to match end of macro = note: this error originates in the macro `my_faulty_macro` (in Nightly builds, run with -Z macro-backtrace for more info) note: trace_macro diff --git a/src/test/ui/issues/issue-12552.rs b/src/test/ui/match/issue-12552.rs index b7f71dd1c..b7f71dd1c 100644 --- a/src/test/ui/issues/issue-12552.rs +++ b/src/test/ui/match/issue-12552.rs diff --git a/src/test/ui/issues/issue-12552.stderr b/src/test/ui/match/issue-12552.stderr index 4b027eba2..4b027eba2 100644 --- a/src/test/ui/issues/issue-12552.stderr +++ b/src/test/ui/match/issue-12552.stderr diff --git a/src/test/ui/maximal_mir_to_hir_coverage.rs b/src/test/ui/maximal_mir_to_hir_coverage.rs new file mode 100644 index 000000000..5ca54633f --- /dev/null +++ b/src/test/ui/maximal_mir_to_hir_coverage.rs @@ -0,0 +1,10 @@ +// compile-flags: -Zmaximal-hir-to-mir-coverage +// run-pass + +// Just making sure this flag is accepted and doesn't crash the compiler + +fn main() { + let x = 1; + let y = x + 1; + println!("{y}"); +} diff --git a/src/test/ui/methods/method-call-lifetime-args-fail.stderr b/src/test/ui/methods/method-call-lifetime-args-fail.stderr index 835edb4b0..249b48ab1 100644 --- a/src/test/ui/methods/method-call-lifetime-args-fail.stderr +++ b/src/test/ui/methods/method-call-lifetime-args-fail.stderr @@ -13,8 +13,8 @@ LL | fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} } | ^^^^^ -- -- help: add missing lifetime argument | -LL | S.early::<'static, 'b>(); - | ++++ +LL | S.early::<'static, 'static>(); + | +++++++++ error[E0107]: this associated function takes 2 lifetime arguments but 3 lifetime arguments were supplied --> $DIR/method-call-lifetime-args-fail.rs:18:7 @@ -213,8 +213,8 @@ LL | fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} } | ^^^^^ -- -- help: add missing lifetime argument | -LL | S::early::<'static, 'b>(S); - | ++++ +LL | S::early::<'static, 'static>(S); + | +++++++++ error[E0107]: this associated function takes 2 lifetime arguments but 3 lifetime arguments were supplied --> $DIR/method-call-lifetime-args-fail.rs:65:8 diff --git a/src/test/ui/methods/method-path-in-pattern.stderr b/src/test/ui/methods/method-path-in-pattern.stderr index 1d1bdb6b0..63c7abe0e 100644 --- a/src/test/ui/methods/method-path-in-pattern.stderr +++ b/src/test/ui/methods/method-path-in-pattern.stderr @@ -2,37 +2,37 @@ error[E0533]: expected unit struct, unit variant or constant, found associated f --> $DIR/method-path-in-pattern.rs:15:9 | LL | Foo::bar => {} - | ^^^^^^^^ + | ^^^^^^^^ not a unit struct, unit variant or constant error[E0533]: expected unit struct, unit variant or constant, found associated function `Foo::bar` --> $DIR/method-path-in-pattern.rs:19:9 | LL | <Foo>::bar => {} - | ^^^^^^^^^^ + | ^^^^^^^^^^ not a unit struct, unit variant or constant error[E0533]: expected unit struct, unit variant or constant, found associated function `Foo::trait_bar` --> $DIR/method-path-in-pattern.rs:23:9 | LL | <Foo>::trait_bar => {} - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ not a unit struct, unit variant or constant error[E0533]: expected unit struct, unit variant or constant, found associated function `Foo::bar` --> $DIR/method-path-in-pattern.rs:26:12 | LL | if let Foo::bar = 0u32 {} - | ^^^^^^^^ + | ^^^^^^^^ not a unit struct, unit variant or constant error[E0533]: expected unit struct, unit variant or constant, found associated function `Foo::bar` --> $DIR/method-path-in-pattern.rs:28:12 | LL | if let <Foo>::bar = 0u32 {} - | ^^^^^^^^^^ + | ^^^^^^^^^^ not a unit struct, unit variant or constant error[E0533]: expected unit struct, unit variant or constant, found associated function `Foo::trait_bar` --> $DIR/method-path-in-pattern.rs:30:12 | LL | if let Foo::trait_bar = 0u32 {} - | ^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^ not a unit struct, unit variant or constant error: aborting due to 6 previous errors diff --git a/src/test/ui/mir/important-higher-ranked-regions.rs b/src/test/ui/mir/important-higher-ranked-regions.rs new file mode 100644 index 000000000..cadfb3b66 --- /dev/null +++ b/src/test/ui/mir/important-higher-ranked-regions.rs @@ -0,0 +1,26 @@ +// check-pass +// compile-flags: -Zvalidate-mir + +// This test checks that bivariant parameters are handled correctly +// in the mir. +#![allow(coherence_leak_check)] +trait Trait { + type Assoc; +} + +struct Foo<T, U>(T) +where + T: Trait<Assoc = U>; + +impl Trait for for<'a> fn(&'a ()) { + type Assoc = u32; +} +impl Trait for fn(&'static ()) { + type Assoc = String; +} + +fn foo(x: Foo<for<'a> fn(&'a ()), u32>) -> Foo<fn(&'static ()), String> { + x +} + +fn main() {} diff --git a/src/test/ui/mir/mir_ascription_coercion.rs b/src/test/ui/mir/mir_ascription_coercion.rs index 0ebd20e97..9e04d6019 100644 --- a/src/test/ui/mir/mir_ascription_coercion.rs +++ b/src/test/ui/mir/mir_ascription_coercion.rs @@ -6,5 +6,5 @@ fn main() { let x = [1, 2, 3]; // The RHS should coerce to &[i32] - let _y : &[i32] = &x : &[i32; 3]; + let _y : &[i32] = type_ascribe!(&x, &[i32; 3]); } diff --git a/src/test/ui/mir/issue-95978-validator-lifetime-comparison.rs b/src/test/ui/mir/validate/issue-95978-validator-lifetime-comparison.rs index cd6c5bf27..cd6c5bf27 100644 --- a/src/test/ui/mir/issue-95978-validator-lifetime-comparison.rs +++ b/src/test/ui/mir/validate/issue-95978-validator-lifetime-comparison.rs diff --git a/src/test/ui/mir/validate/needs-reveal-all.rs b/src/test/ui/mir/validate/needs-reveal-all.rs new file mode 100644 index 000000000..3852daf24 --- /dev/null +++ b/src/test/ui/mir/validate/needs-reveal-all.rs @@ -0,0 +1,52 @@ +// Regression test for #105009. the issue here was that even after the `RevealAll` pass, +// `validate` still used `Reveal::UserFacing`. This meant that it now ends up comparing +// opaque types with their revealed version, resulting in an ICE. +// +// We're using these flags to run the `RevealAll` pass while making it less likely to +// accidentally removing the assignment from `Foo<fn_ptr>` to `Foo<fn_def>`. + +// compile-flags: -Zinline_mir=yes -Zmir-opt-level=0 -Zvalidate-mir +// run-pass + +use std::hint::black_box; + +trait Func { + type Ret: Id; +} + +trait Id { + type Assoc; +} +impl Id for u32 { + type Assoc = u32; +} +impl Id for i32 { + type Assoc = i32; +} + +impl<F: FnOnce() -> R, R: Id> Func for F { + type Ret = R; +} + +fn bar() -> impl Copy + Id { + 0u32 +} + +struct Foo<T: Func> { + _func: T, + value: Option<<<T as Func>::Ret as Id>::Assoc>, +} + +fn main() { + let mut fn_def = black_box(Foo { + _func: bar, + value: None, + }); + let fn_ptr = black_box(Foo { + _func: bar as fn() -> _, + value: None, + }); + + fn_def.value = fn_ptr.value; + black_box(fn_def); +} diff --git a/src/test/ui/mismatched_types/binops.stderr b/src/test/ui/mismatched_types/binops.stderr index 3de652d87..3585587ed 100644 --- a/src/test/ui/mismatched_types/binops.stderr +++ b/src/test/ui/mismatched_types/binops.stderr @@ -24,15 +24,10 @@ LL | 2 as usize - Some(1); | = help: the trait `Sub<Option<{integer}>>` is not implemented for `usize` = help: the following other types implement trait `Sub<Rhs>`: - <&'a f32 as Sub<f32>> - <&'a f64 as Sub<f64>> - <&'a i128 as Sub<i128>> - <&'a i16 as Sub<i16>> - <&'a i32 as Sub<i32>> - <&'a i64 as Sub<i64>> - <&'a i8 as Sub<i8>> - <&'a isize as Sub<isize>> - and 48 others + <&'a usize as Sub<usize>> + <&usize as Sub<&usize>> + <usize as Sub<&usize>> + <usize as Sub> error[E0277]: cannot multiply `{integer}` by `()` --> $DIR/binops.rs:4:7 diff --git a/src/test/ui/mismatched_types/overloaded-calls-bad.rs b/src/test/ui/mismatched_types/overloaded-calls-bad.rs index 902a6ec81..232cd2ba8 100644 --- a/src/test/ui/mismatched_types/overloaded-calls-bad.rs +++ b/src/test/ui/mismatched_types/overloaded-calls-bad.rs @@ -20,14 +20,23 @@ impl FnOnce<(isize,)> for S { } } +struct F; + +impl FnOnce<(i32,)> for F { + type Output = (); + + extern "rust-call" fn call_once(self, args: (i32,)) -> Self::Output {} +} + fn main() { - let mut s = S { - x: 3, - y: 3, - }; - let ans = s("what"); //~ ERROR mismatched types + let mut s = S { x: 3, y: 3 }; + let ans = s("what"); + //~^ ERROR mismatched types let ans = s(); //~^ ERROR this function takes 1 argument but 0 arguments were supplied let ans = s("burma", "shave"); //~^ ERROR this function takes 1 argument but 2 arguments were supplied + + F(""); + //~^ ERROR mismatched types } diff --git a/src/test/ui/mismatched_types/overloaded-calls-bad.stderr b/src/test/ui/mismatched_types/overloaded-calls-bad.stderr index fb3597aa8..3a895acbd 100644 --- a/src/test/ui/mismatched_types/overloaded-calls-bad.stderr +++ b/src/test/ui/mismatched_types/overloaded-calls-bad.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/overloaded-calls-bad.rs:28:17 + --> $DIR/overloaded-calls-bad.rs:33:17 | LL | let ans = s("what"); | - ^^^^^^ expected `isize`, found `&str` @@ -13,7 +13,7 @@ LL | impl FnMut<(isize,)> for S { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0057]: this function takes 1 argument but 0 arguments were supplied - --> $DIR/overloaded-calls-bad.rs:29:15 + --> $DIR/overloaded-calls-bad.rs:35:15 | LL | let ans = s(); | ^-- an argument of type `isize` is missing @@ -29,7 +29,7 @@ LL | let ans = s(/* isize */); | ~~~~~~~~~~~~~ error[E0057]: this function takes 1 argument but 2 arguments were supplied - --> $DIR/overloaded-calls-bad.rs:31:15 + --> $DIR/overloaded-calls-bad.rs:37:15 | LL | let ans = s("burma", "shave"); | ^ ------- ------- argument of type `&'static str` unexpected @@ -46,7 +46,21 @@ help: remove the extra argument LL | let ans = s(/* isize */); | ~~~~~~~~~~~~~ -error: aborting due to 3 previous errors +error[E0308]: mismatched types + --> $DIR/overloaded-calls-bad.rs:40:7 + | +LL | F(""); + | - ^^ expected `i32`, found `&str` + | | + | arguments to this struct are incorrect + | +note: implementation defined here + --> $DIR/overloaded-calls-bad.rs:25:1 + | +LL | impl FnOnce<(i32,)> for F { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors Some errors have detailed explanations: E0057, E0308. For more information about an error, try `rustc --explain E0057`. diff --git a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs index 8dbe3472e..307104e47 100644 --- a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs +++ b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs @@ -1,8 +1,8 @@ -#![feature(unboxed_closures)] +#![feature(unboxed_closures,tuple_trait)] use std::ops::FnMut; -fn to_fn_mut<A, F: FnMut<A>>(f: F) -> F { f } +fn to_fn_mut<A:std::marker::Tuple, F:FnMut<A>>(f: F) -> F { f } fn call_it<F: FnMut(isize, isize) -> isize>(y: isize, mut f: F) -> isize { //~^ NOTE required by this bound in `call_it` diff --git a/src/test/ui/moves/borrow-closures-instead-of-move.stderr b/src/test/ui/moves/borrow-closures-instead-of-move.stderr index 3146b6959..9a84ddef7 100644 --- a/src/test/ui/moves/borrow-closures-instead-of-move.stderr +++ b/src/test/ui/moves/borrow-closures-instead-of-move.stderr @@ -4,9 +4,17 @@ error[E0382]: use of moved value: `f` LL | fn takes_fn(f: impl Fn()) { | - move occurs because `f` has type `impl Fn()`, which does not implement the `Copy` trait LL | loop { + | ---- inside of this loop LL | takes_fnonce(f); | ^ value moved here, in previous iteration of loop | +note: consider changing this parameter type in function `takes_fnonce` to borrow instead if owning the value isn't necessary + --> $DIR/borrow-closures-instead-of-move.rs:34:20 + | +LL | fn takes_fnonce(_: impl FnOnce()) {} + | ------------ ^^^^^^^^^^^^^ this parameter takes ownership of the value + | | + | in this function help: consider borrowing `f` | LL | takes_fnonce(&f); @@ -24,6 +32,13 @@ LL | takes_fnonce(m); LL | takes_fnonce(m); | ^ value used here after move | +note: consider changing this parameter type in function `takes_fnonce` to borrow instead if owning the value isn't necessary + --> $DIR/borrow-closures-instead-of-move.rs:34:20 + | +LL | fn takes_fnonce(_: impl FnOnce()) {} + | ------------ ^^^^^^^^^^^^^ this parameter takes ownership of the value + | | + | in this function help: consider mutably borrowing `m` | LL | takes_fnonce(&mut m); diff --git a/src/test/ui/moves/issue-46099-move-in-macro.stderr b/src/test/ui/moves/issue-46099-move-in-macro.stderr index baa87e3e9..94bc9e6f4 100644 --- a/src/test/ui/moves/issue-46099-move-in-macro.stderr +++ b/src/test/ui/moves/issue-46099-move-in-macro.stderr @@ -5,6 +5,11 @@ LL | let b = Box::new(true); | - move occurs because `b` has type `Box<bool>`, which does not implement the `Copy` trait LL | test!({b}); | ^ value used here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | test!({b.clone()}); + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/moves/issue-72649-uninit-in-loop.rs b/src/test/ui/moves/issue-72649-uninit-in-loop.rs index d76b69ecd..56c225bab 100644 --- a/src/test/ui/moves/issue-72649-uninit-in-loop.rs +++ b/src/test/ui/moves/issue-72649-uninit-in-loop.rs @@ -25,7 +25,7 @@ fn moved_here_1() { fn moved_here_2() { let value = NonCopy{}; //~^ NOTE move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait - loop { + loop { //~ NOTE inside of this loop let _used = value; //~^ NOTE value moved here loop { @@ -38,7 +38,7 @@ fn moved_here_2() { fn moved_loop_1() { let value = NonCopy{}; //~^ NOTE move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait - loop { + loop { //~ NOTE inside of this loop let _used = value; //~ ERROR use of moved value: `value` //~^ NOTE value moved here, in previous iteration of loop } @@ -49,7 +49,7 @@ fn moved_loop_2() { //~^ NOTE move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait let _used = value; value = NonCopy{}; - loop { + loop { //~ NOTE inside of this loop let _used2 = value; //~ ERROR use of moved value: `value` //~^ NOTE value moved here, in previous iteration of loop } diff --git a/src/test/ui/moves/issue-72649-uninit-in-loop.stderr b/src/test/ui/moves/issue-72649-uninit-in-loop.stderr index 974994223..7e119fe8c 100644 --- a/src/test/ui/moves/issue-72649-uninit-in-loop.stderr +++ b/src/test/ui/moves/issue-72649-uninit-in-loop.stderr @@ -15,7 +15,9 @@ error[E0382]: use of moved value: `value` | LL | let value = NonCopy{}; | ----- move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait -... +LL | +LL | loop { + | ---- inside of this loop LL | let _used = value; | ----- value moved here ... @@ -27,7 +29,9 @@ error[E0382]: use of moved value: `value` | LL | let value = NonCopy{}; | ----- move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait -... +LL | +LL | loop { + | ---- inside of this loop LL | let _used = value; | ^^^^^ value moved here, in previous iteration of loop @@ -37,6 +41,8 @@ error[E0382]: use of moved value: `value` LL | let mut value = NonCopy{}; | --------- move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait ... +LL | loop { + | ---- inside of this loop LL | let _used2 = value; | ^^^^^ value moved here, in previous iteration of loop diff --git a/src/test/ui/moves/move-fn-self-receiver.stderr b/src/test/ui/moves/move-fn-self-receiver.stderr index 3a686121a..c13dc5882 100644 --- a/src/test/ui/moves/move-fn-self-receiver.stderr +++ b/src/test/ui/moves/move-fn-self-receiver.stderr @@ -96,6 +96,10 @@ note: this function takes ownership of the receiver `self`, which moves `rc_foo` | LL | fn use_rc_self(self: Rc<Self>) {} | ^^^^ +help: consider cloning the value if the performance cost is acceptable + | +LL | rc_foo.clone().use_rc_self(); + | ++++++++ error[E0382]: use of moved value: `foo_add` --> $DIR/move-fn-self-receiver.rs:59:5 @@ -137,6 +141,11 @@ LL | for _val in explicit_into_iter.into_iter() {} | ----------- `explicit_into_iter` moved due to this method call LL | explicit_into_iter; | ^^^^^^^^^^^^^^^^^^ value used here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | for _val in explicit_into_iter.clone().into_iter() {} + | ++++++++ error[E0382]: use of moved value: `container` --> $DIR/move-fn-self-receiver.rs:71:5 @@ -160,6 +169,7 @@ error[E0382]: use of moved value: `foo2` LL | let foo2 = Foo; | ---- move occurs because `foo2` has type `Foo`, which does not implement the `Copy` trait LL | loop { + | ---- inside of this loop LL | foo2.use_self(); | ^^^^ ---------- `foo2` moved due to this method call, in previous iteration of loop diff --git a/src/test/ui/moves/move-guard-same-consts.stderr b/src/test/ui/moves/move-guard-same-consts.stderr index 2048fefef..86e5f6524 100644 --- a/src/test/ui/moves/move-guard-same-consts.stderr +++ b/src/test/ui/moves/move-guard-same-consts.stderr @@ -8,6 +8,18 @@ LL | (1, 2) if take(x) => (), | - value moved here LL | (1, 2) if take(x) => (), | ^ value used here after move + | +note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary + --> $DIR/move-guard-same-consts.rs:25:15 + | +LL | fn take<T>(_: T) -> bool { false } + | ---- ^ this parameter takes ownership of the value + | | + | in this function +help: consider cloning the value if the performance cost is acceptable + | +LL | (1, 2) if take(x.clone()) => (), + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/moves/move-in-guard-1.stderr b/src/test/ui/moves/move-in-guard-1.stderr index 5e9aa66b9..f04cb34d7 100644 --- a/src/test/ui/moves/move-in-guard-1.stderr +++ b/src/test/ui/moves/move-in-guard-1.stderr @@ -8,6 +8,18 @@ LL | (1, _) if take(x) => (), | - value moved here LL | (_, 2) if take(x) => (), | ^ value used here after move + | +note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary + --> $DIR/move-in-guard-1.rs:15:15 + | +LL | fn take<T>(_: T) -> bool { false } + | ---- ^ this parameter takes ownership of the value + | | + | in this function +help: consider cloning the value if the performance cost is acceptable + | +LL | (1, _) if take(x.clone()) => (), + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/moves/move-in-guard-2.stderr b/src/test/ui/moves/move-in-guard-2.stderr index 8d636c11b..26047861f 100644 --- a/src/test/ui/moves/move-in-guard-2.stderr +++ b/src/test/ui/moves/move-in-guard-2.stderr @@ -6,6 +6,18 @@ LL | let x: Box<_> = Box::new(1); ... LL | (_, 2) if take(x) => (), | ^ value used here after move + | +note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary + --> $DIR/move-in-guard-2.rs:13:15 + | +LL | fn take<T>(_: T) -> bool { false } + | ---- ^ this parameter takes ownership of the value + | | + | in this function +help: consider cloning the value if the performance cost is acceptable + | +LL | (_, 2) if take(x.clone()) => (), + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/moves/moves-based-on-type-access-to-field.stderr b/src/test/ui/moves/moves-based-on-type-access-to-field.stderr index 3cc8ca291..a49ee31b4 100644 --- a/src/test/ui/moves/moves-based-on-type-access-to-field.stderr +++ b/src/test/ui/moves/moves-based-on-type-access-to-field.stderr @@ -13,6 +13,10 @@ note: this function takes ownership of the receiver `self`, which moves `x` | LL | fn into_iter(self) -> Self::IntoIter; | ^^^^ +help: consider cloning the value if the performance cost is acceptable + | +LL | consume(x.clone().into_iter().next().unwrap()); + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr b/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr index a315bbaab..db4382b58 100644 --- a/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr +++ b/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr @@ -8,7 +8,7 @@ LL | consume(node) + r | ^^^^ value used here after partial move | = note: partial move occurs because value has type `Box<List>`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving `node.next.0` +help: borrow this binding in the pattern to avoid moving the value | LL | Some(ref right) => consume(right), | +++ diff --git a/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr b/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr index ee7971691..0930df148 100644 --- a/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr +++ b/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr @@ -9,6 +9,11 @@ LL | let _y = Foo { f:x }; LL | LL | touch(&x); | ^^ value borrowed here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | let _y = Foo { f:x.clone() }; + | ++++++++ error[E0382]: borrow of moved value: `x` --> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:21:11 @@ -21,6 +26,11 @@ LL | let _y = Foo { f:(((x))) }; LL | LL | touch(&x); | ^^ value borrowed here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | let _y = Foo { f:(((x))).clone() }; + | ++++++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/moves/moves-based-on-type-exprs.stderr b/src/test/ui/moves/moves-based-on-type-exprs.stderr index 9bcec3674..838b1282c 100644 --- a/src/test/ui/moves/moves-based-on-type-exprs.stderr +++ b/src/test/ui/moves/moves-based-on-type-exprs.stderr @@ -7,6 +7,11 @@ LL | let _y = Foo { f:x }; | - value moved here LL | touch(&x); | ^^ value borrowed here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | let _y = Foo { f:x.clone() }; + | ++++++++ error[E0382]: borrow of moved value: `x` --> $DIR/moves-based-on-type-exprs.rs:18:11 @@ -17,6 +22,11 @@ LL | let _y = (x, 3); | - value moved here LL | touch(&x); | ^^ value borrowed here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | let _y = (x.clone(), 3); + | ++++++++ error[E0382]: borrow of moved value: `x` --> $DIR/moves-based-on-type-exprs.rs:35:11 @@ -29,6 +39,11 @@ LL | x ... LL | touch(&x); | ^^ value borrowed here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | x.clone() + | ++++++++ error[E0382]: borrow of moved value: `y` --> $DIR/moves-based-on-type-exprs.rs:36:11 @@ -41,6 +56,11 @@ LL | y ... LL | touch(&y); | ^^ value borrowed here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | y.clone() + | ++++++++ error[E0382]: borrow of moved value: `x` --> $DIR/moves-based-on-type-exprs.rs:46:11 @@ -53,6 +73,11 @@ LL | true => x, ... LL | touch(&x); | ^^ value borrowed here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | true => x.clone(), + | ++++++++ error[E0382]: borrow of moved value: `y` --> $DIR/moves-based-on-type-exprs.rs:47:11 @@ -65,6 +90,11 @@ LL | false => y ... LL | touch(&y); | ^^ value borrowed here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | false => y.clone() + | ++++++++ error[E0382]: borrow of moved value: `x` --> $DIR/moves-based-on-type-exprs.rs:58:11 @@ -77,6 +107,18 @@ LL | _ if guard(x) => 10, ... LL | touch(&x); | ^^ value borrowed here after move + | +note: consider changing this parameter type in function `guard` to borrow instead if owning the value isn't necessary + --> $DIR/moves-based-on-type-exprs.rs:6:14 + | +LL | fn guard(_s: String) -> bool {panic!()} + | ----- ^^^^^^ this parameter takes ownership of the value + | | + | in this function +help: consider cloning the value if the performance cost is acceptable + | +LL | _ if guard(x.clone()) => 10, + | ++++++++ error[E0382]: borrow of moved value: `x` --> $DIR/moves-based-on-type-exprs.rs:65:11 @@ -87,6 +129,11 @@ LL | let _y = [x]; | - value moved here LL | touch(&x); | ^^ value borrowed here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | let _y = [x.clone()]; + | ++++++++ error[E0382]: borrow of moved value: `x` --> $DIR/moves-based-on-type-exprs.rs:71:11 @@ -97,6 +144,11 @@ LL | let _y = vec![x]; | - value moved here LL | touch(&x); | ^^ value borrowed here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | let _y = vec![x.clone()]; + | ++++++++ error[E0382]: borrow of moved value: `x` --> $DIR/moves-based-on-type-exprs.rs:77:11 @@ -113,6 +165,10 @@ note: this function takes ownership of the receiver `self`, which moves `x` | LL | fn into_iter(self) -> Self::IntoIter; | ^^^^ +help: consider cloning the value if the performance cost is acceptable + | +LL | let _y = x.clone().into_iter().next().unwrap(); + | ++++++++ error[E0382]: borrow of moved value: `x` --> $DIR/moves-based-on-type-exprs.rs:83:11 @@ -129,6 +185,10 @@ note: this function takes ownership of the receiver `self`, which moves `x` | LL | fn into_iter(self) -> Self::IntoIter; | ^^^^ +help: consider cloning the value if the performance cost is acceptable + | +LL | let _y = [x.clone().into_iter().next().unwrap(); 1]; + | ++++++++ error: aborting due to 11 previous errors diff --git a/src/test/ui/moves/moves-based-on-type-match-bindings.stderr b/src/test/ui/moves/moves-based-on-type-match-bindings.stderr index ad1a2db8b..225935532 100644 --- a/src/test/ui/moves/moves-based-on-type-match-bindings.stderr +++ b/src/test/ui/moves/moves-based-on-type-match-bindings.stderr @@ -8,6 +8,10 @@ LL | touch(&x); | ^^ value borrowed here after partial move | = note: partial move occurs because `x.f` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | Foo {ref f} => {} + | +++ error: aborting due to previous error diff --git a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs b/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs index 76b7aab54..490d91ac1 100644 --- a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs +++ b/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs @@ -1,6 +1,6 @@ -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] -fn to_fn<A,F:Fn<A>>(f: F) -> F { f } +fn to_fn<A:std::marker::Tuple,F:Fn<A>>(f: F) -> F { f } fn test(_x: Box<usize>) {} diff --git a/src/test/ui/moves/moves-based-on-type-tuple.stderr b/src/test/ui/moves/moves-based-on-type-tuple.stderr index eef8ce61f..0bcce3012 100644 --- a/src/test/ui/moves/moves-based-on-type-tuple.stderr +++ b/src/test/ui/moves/moves-based-on-type-tuple.stderr @@ -8,6 +8,11 @@ LL | Box::new((x, x)) | - ^ value used here after move | | | value moved here + | +help: consider cloning the value if the performance cost is acceptable + | +LL | Box::new((x.clone(), x)) + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/moves/use_of_moved_value_clone_suggestions.stderr b/src/test/ui/moves/use_of_moved_value_clone_suggestions.stderr index c25981e6f..22e7951db 100644 --- a/src/test/ui/moves/use_of_moved_value_clone_suggestions.stderr +++ b/src/test/ui/moves/use_of_moved_value_clone_suggestions.stderr @@ -7,6 +7,11 @@ LL | (t, t) | - ^ value used here after move | | | value moved here + | +help: consider cloning the value if the performance cost is acceptable + | +LL | (t.clone(), t) + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/namespace/namespace-mix.rs b/src/test/ui/namespace/namespace-mix.rs index b0f7e3c62..c5b30f148 100644 --- a/src/test/ui/namespace/namespace-mix.rs +++ b/src/test/ui/namespace/namespace-mix.rs @@ -97,13 +97,13 @@ mod m8 { fn f78() { check(m7::V{}); //~ ERROR c::Item - check(m7::V); //~ ERROR expected value, found struct variant `m7::V` + check(m7::V); //~ ERROR expected value, found type alias `m7::V` check(m8::V{}); //~ ERROR c::E check(m8::V); //~ ERROR c::Item } fn xf78() { check(xm7::V{}); //~ ERROR c::Item - check(xm7::V); //~ ERROR expected value, found struct variant `xm7::V` + check(xm7::V); //~ ERROR expected value, found type alias `xm7::V` check(xm8::V{}); //~ ERROR c::E check(xm8::V); //~ ERROR c::Item } diff --git a/src/test/ui/namespace/namespace-mix.stderr b/src/test/ui/namespace/namespace-mix.stderr index c07914df7..cb72d4a1c 100644 --- a/src/test/ui/namespace/namespace-mix.stderr +++ b/src/test/ui/namespace/namespace-mix.stderr @@ -52,21 +52,16 @@ LL - check(xm1::S); LL + check(S); | -error[E0423]: expected value, found struct variant `m7::V` +error[E0423]: expected value, found type alias `m7::V` --> $DIR/namespace-mix.rs:100:11 | -LL | V {}, - | ---- `m7::V` defined here LL | TV(), | ---- similarly named tuple variant `TV` defined here ... LL | check(m7::V); | ^^^^^ | -help: use struct literal syntax instead - | -LL | check(m7::V {}); - | ~~~~~~~~ + = note: can't use a type alias as a constructor help: a tuple variant with a similar name exists | LL | check(m7::TV); @@ -83,23 +78,18 @@ LL - check(m7::V); LL + check(V); | -error[E0423]: expected value, found struct variant `xm7::V` +error[E0423]: expected value, found type alias `xm7::V` --> $DIR/namespace-mix.rs:106:11 | LL | check(xm7::V); | ^^^^^^ | - ::: $DIR/auxiliary/namespace-mix.rs:6:9 + ::: $DIR/auxiliary/namespace-mix.rs:7:9 | -LL | V {}, - | - `xm7::V` defined here LL | TV(), | -- similarly named tuple variant `TV` defined here | -help: use struct literal syntax instead - | -LL | check(xm7::V { /* fields */ }); - | ~~~~~~~~~~~~~~~~~~~~~~~ + = note: can't use a type alias as a constructor help: a tuple variant with a similar name exists | LL | check(xm7::TV); diff --git a/src/test/ui/never_type/exhaustive_patterns.rs b/src/test/ui/never_type/exhaustive_patterns.rs new file mode 100644 index 000000000..2e23fa182 --- /dev/null +++ b/src/test/ui/never_type/exhaustive_patterns.rs @@ -0,0 +1,21 @@ +// check-fail +// known-bug: #104034 + +#![feature(exhaustive_patterns, never_type)] + +mod inner { + pub struct Wrapper<T>(T); +} + +enum Either<A, B> { + A(A), + B(inner::Wrapper<B>), +} + +fn foo() -> Either<(), !> { + Either::A(()) +} + +fn main() { + let Either::A(()) = foo(); +} diff --git a/src/test/ui/never_type/exhaustive_patterns.stderr b/src/test/ui/never_type/exhaustive_patterns.stderr new file mode 100644 index 000000000..e41baf862 --- /dev/null +++ b/src/test/ui/never_type/exhaustive_patterns.stderr @@ -0,0 +1,25 @@ +error[E0005]: refutable pattern in local binding: `Either::B(_)` not covered + --> $DIR/exhaustive_patterns.rs:20:9 + | +LL | let Either::A(()) = foo(); + | ^^^^^^^^^^^^^ pattern `Either::B(_)` not covered + | + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html +note: `Either<(), !>` defined here + --> $DIR/exhaustive_patterns.rs:12:5 + | +LL | enum Either<A, B> { + | ------ +LL | A(A), +LL | B(inner::Wrapper<B>), + | ^ not covered + = note: the matched value is of type `Either<(), !>` +help: you might want to use `if let` to ignore the variant that isn't matched + | +LL | if let Either::A(()) = foo() { todo!() } + | ++ ~~~~~~~~~~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0005`. diff --git a/src/test/ui/never_type/issue-13352.stderr b/src/test/ui/never_type/issue-13352.stderr index fed780e68..2d22da0b4 100644 --- a/src/test/ui/never_type/issue-13352.stderr +++ b/src/test/ui/never_type/issue-13352.stderr @@ -6,15 +6,10 @@ LL | 2_usize + (loop {}); | = help: the trait `Add<()>` is not implemented for `usize` = help: the following other types implement trait `Add<Rhs>`: - <&'a f32 as Add<f32>> - <&'a f64 as Add<f64>> - <&'a i128 as Add<i128>> - <&'a i16 as Add<i16>> - <&'a i32 as Add<i32>> - <&'a i64 as Add<i64>> - <&'a i8 as Add<i8>> - <&'a isize as Add<isize>> - and 48 others + <&'a usize as Add<usize>> + <&usize as Add<&usize>> + <usize as Add<&usize>> + <usize as Add> error: aborting due to previous error diff --git a/src/test/ui/nll/borrowed-temporary-error.stderr b/src/test/ui/nll/borrowed-temporary-error.stderr index 2c6bd9264..89781d96f 100644 --- a/src/test/ui/nll/borrowed-temporary-error.stderr +++ b/src/test/ui/nll/borrowed-temporary-error.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/borrowed-temporary-error.rs:8:10 | LL | &(v,) - | ^^^^ creates a temporary which is freed while still in use + | ^^^^ creates a temporary value which is freed while still in use LL | LL | }); | - temporary value is freed at the end of this statement diff --git a/src/test/ui/nll/closure-access-spans.stderr b/src/test/ui/nll/closure-access-spans.stderr index e9d7ca953..0a09353b8 100644 --- a/src/test/ui/nll/closure-access-spans.stderr +++ b/src/test/ui/nll/closure-access-spans.stderr @@ -67,6 +67,11 @@ LL | || x.len(); | ^^ - borrow occurs due to use in closure | | | value borrowed here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | let r = x.clone(); + | ++++++++ error[E0382]: borrow of moved value: `x` --> $DIR/closure-access-spans.rs:40:5 @@ -79,6 +84,11 @@ LL | || x = String::new(); | ^^ - borrow occurs due to use in closure | | | value borrowed here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | let r = x.clone(); + | ++++++++ error[E0382]: borrow of moved value: `x` --> $DIR/closure-access-spans.rs:45:5 diff --git a/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr b/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr index d2d26b23d..363ddfaff 100644 --- a/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr +++ b/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr @@ -6,7 +6,7 @@ LL | let mut closure = expect_sig(|p, y| *p = y); | = note: defining type: test::{closure#0} with closure substs [ i16, - for<'a, 'b, 'c> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) mut &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrNamed('c) }) i32)), + for<Region(BrAnon(0, None)), Region(BrAnon(1, None)), Region(BrAnon(2, None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) mut &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(2, None) }) i32)), (), ] diff --git a/src/test/ui/nll/closure-requirements/escape-argument.stderr b/src/test/ui/nll/closure-requirements/escape-argument.stderr index 6355d3295..f67c312b9 100644 --- a/src/test/ui/nll/closure-requirements/escape-argument.stderr +++ b/src/test/ui/nll/closure-requirements/escape-argument.stderr @@ -6,7 +6,7 @@ LL | let mut closure = expect_sig(|p, y| *p = y); | = note: defining type: test::{closure#0} with closure substs [ i16, - for<'a, 'b> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) mut &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) i32)), + for<Region(BrAnon(0, None)), Region(BrAnon(1, None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) mut &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) i32)), (), ] diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr index 5f9724ce3..7da6ce58b 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr @@ -6,7 +6,7 @@ LL | |_outlives1, _outlives2, _outlives3, x, y| { | = note: defining type: supply::{closure#0} with closure substs [ i16, - for<'a, 'b> extern "rust-call" fn((std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) u32>, std::cell::Cell<&'_#2r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) &'_#3r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>)), + for<Region(BrAnon(0, None)), Region(BrAnon(1, None))> extern "rust-call" fn((std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) u32>, std::cell::Cell<&'_#2r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) &'_#3r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>)), (), ] = note: late-bound region is '_#4r diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr index ec728ebd5..993687605 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr @@ -6,7 +6,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y | = note: defining type: supply::{closure#0} with closure substs [ i16, - for<'a, 'b, 'c, 'd, 'e, 'f> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrNamed('c) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrNamed('d) }) &'_#2r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrNamed('e) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrNamed('f) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrNamed('d) }) u32>)), + for<Region(BrAnon(0, None)), Region(BrAnon(1, None)), Region(BrAnon(2, None)), Region(BrAnon(3, None)), Region(BrAnon(4, None)), Region(BrAnon(5, None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(2, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(3, None) }) &'_#2r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(4, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon(5, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(3, None) }) u32>)), (), ] = note: late-bound region is '_#3r diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr index 012933797..7991abeb7 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr @@ -6,7 +6,7 @@ LL | foo(cell, |cell_a, cell_x| { | = note: defining type: case1::{closure#0} with closure substs [ i32, - for<'a> extern "rust-call" fn((std::cell::Cell<&'_#1r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) u32>)), + for<Region(BrAnon(0, None))> extern "rust-call" fn((std::cell::Cell<&'_#1r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) u32>)), (), ] @@ -36,7 +36,7 @@ LL | foo(cell, |cell_a, cell_x| { | = note: defining type: case2::{closure#0} with closure substs [ i32, - for<'a> extern "rust-call" fn((std::cell::Cell<&'_#1r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) u32>)), + for<Region(BrAnon(0, None))> extern "rust-call" fn((std::cell::Cell<&'_#1r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) u32>)), (), ] = note: number of external vids: 2 diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr index ce85b20b3..43dfc3bb9 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr @@ -6,7 +6,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { | = note: defining type: supply::{closure#0} with closure substs [ i16, - for<'a, 'b, 'c, 'd, 'e> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrNamed('c) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrNamed('d) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrNamed('e) }) u32>)), + for<Region(BrAnon(0, None)), Region(BrAnon(1, None)), Region(BrAnon(2, None)), Region(BrAnon(3, None)), Region(BrAnon(4, None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(2, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(3, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(4, None) }) u32>)), (), ] = note: late-bound region is '_#2r diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr index 20c7967b7..96c734226 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr @@ -6,7 +6,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y | = note: defining type: supply::{closure#0} with closure substs [ i16, - for<'a, 'b, 'c, 'd, 'e, 'f> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrNamed('c) }) std::cell::Cell<&'_#2r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrNamed('d) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrNamed('e) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrNamed('f) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrNamed('d) }) u32>)), + for<Region(BrAnon(0, None)), Region(BrAnon(1, None)), Region(BrAnon(2, None)), Region(BrAnon(3, None)), Region(BrAnon(4, None)), Region(BrAnon(5, None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(2, None) }) std::cell::Cell<&'_#2r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(3, None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(4, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon(5, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(3, None) }) u32>)), (), ] = note: late-bound region is '_#3r diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr index f7db5ab1f..03dbd686e 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr @@ -6,7 +6,7 @@ LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| { | = note: defining type: test::{closure#0} with closure substs [ i16, - for<'a, 'b> extern "rust-call" fn((std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) &'_#2r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>)), + for<Region(BrAnon(0, None)), Region(BrAnon(1, None))> extern "rust-call" fn((std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) &'_#2r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>)), (), ] = note: late-bound region is '_#3r diff --git a/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr b/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr index 3488edc75..d716d3de2 100644 --- a/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr @@ -6,7 +6,7 @@ LL | |_outlives1, _outlives2, x, y| { | = note: defining type: supply::{closure#0} with closure substs [ i16, - for<'a, 'b> extern "rust-call" fn((std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) &'_#2r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>)), + for<Region(BrAnon(0, None)), Region(BrAnon(1, None))> extern "rust-call" fn((std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) &'_#2r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>)), (), ] = note: late-bound region is '_#3r diff --git a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr index 0dc2d0de9..b924873fc 100644 --- a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr @@ -6,7 +6,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { | = note: defining type: supply::{closure#0} with closure substs [ i16, - for<'a, 'b, 'c, 'd, 'e> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) &'_#1r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrNamed('c) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrNamed('d) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrNamed('e) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>)), + for<Region(BrAnon(0, None)), Region(BrAnon(1, None)), Region(BrAnon(2, None)), Region(BrAnon(3, None)), Region(BrAnon(4, None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) &'_#1r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(2, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(3, None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(4, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>)), (), ] = note: late-bound region is '_#2r diff --git a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr index 4c9e026ea..9b25efd0b 100644 --- a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr @@ -6,7 +6,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y | = note: defining type: supply::{closure#0} with closure substs [ i16, - for<'a, 'b, 'c, 'd, 'e, 'f> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) &'_#1r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrNamed('c) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrNamed('d) }) &'_#2r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrNamed('e) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrNamed('f) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrNamed('d) }) u32>)), + for<Region(BrAnon(0, None)), Region(BrAnon(1, None)), Region(BrAnon(2, None)), Region(BrAnon(3, None)), Region(BrAnon(4, None)), Region(BrAnon(5, None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) &'_#1r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(2, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(3, None) }) &'_#2r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(4, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon(5, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(3, None) }) u32>)), (), ] = note: late-bound region is '_#3r diff --git a/src/test/ui/nll/closure-requirements/propagate-from-trait-match.rs b/src/test/ui/nll/closure-requirements/propagate-from-trait-match.rs index 3bdb54339..cda781d8e 100644 --- a/src/test/ui/nll/closure-requirements/propagate-from-trait-match.rs +++ b/src/test/ui/nll/closure-requirements/propagate-from-trait-match.rs @@ -30,8 +30,6 @@ where T: Trait<'a>, { establish_relationships(value, |value| { - //~^ ERROR the parameter type `T` may not live long enough - // This function call requires that // // (a) T: Trait<'a> @@ -43,6 +41,7 @@ where // The latter does not hold. require(value); + //~^ ERROR the parameter type `T` may not live long enough }); } diff --git a/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr b/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr index 750b08bbe..038a5e11f 100644 --- a/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr @@ -23,17 +23,10 @@ LL | | T: Trait<'a>, = note: defining type: supply::<'_#1r, T> error[E0309]: the parameter type `T` may not live long enough - --> $DIR/propagate-from-trait-match.rs:32:36 + --> $DIR/propagate-from-trait-match.rs:43:9 | -LL | establish_relationships(value, |value| { - | ____________________________________^ -LL | | -LL | | -LL | | // This function call requires that -... | -LL | | require(value); -LL | | }); - | |_____^ ...so that the type `T` will meet its required lifetime bounds +LL | require(value); + | ^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound... | diff --git a/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr b/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr index 68429142e..6db72b886 100644 --- a/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr +++ b/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr @@ -6,7 +6,7 @@ LL | expect_sig(|a, b| b); // ought to return `a` | = note: defining type: test::{closure#0} with closure substs [ i16, - for<'a, 'b> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) i32)) -> &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) i32, + for<Region(BrAnon(0, None)), Region(BrAnon(1, None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) i32)) -> &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) i32, (), ] diff --git a/src/test/ui/nll/issue-21232-partial-init-and-use.stderr b/src/test/ui/nll/issue-21232-partial-init-and-use.stderr index 947c9e29b..97ed414b1 100644 --- a/src/test/ui/nll/issue-21232-partial-init-and-use.stderr +++ b/src/test/ui/nll/issue-21232-partial-init-and-use.stderr @@ -37,6 +37,11 @@ LL | let mut t: T = (0, Box::new(0)); drop(t); | move occurs because `t` has type `(u32, Box<u32>)`, which does not implement the `Copy` trait LL | t.0 = 10; t.1 = Box::new(20); | ^^^^^^^^ value partially assigned here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | let mut t: T = (0, Box::new(0)); drop(t.clone()); + | ++++++++ error[E0381]: partially assigned binding `s` isn't fully initialized --> $DIR/issue-21232-partial-init-and-use.rs:123:5 @@ -77,6 +82,11 @@ LL | let mut t: T = (0, Box::new(0)); drop(t); | move occurs because `t` has type `(u32, Box<u32>)`, which does not implement the `Copy` trait LL | t.0 = 10; | ^^^^^^^^ value partially assigned here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | let mut t: T = (0, Box::new(0)); drop(t.clone()); + | ++++++++ error[E0381]: partially assigned binding `s` isn't fully initialized --> $DIR/issue-21232-partial-init-and-use.rs:149:5 @@ -208,6 +218,11 @@ LL | c2 => { | -- value moved here LL | c.0 = 2; | ^^^^^^^ value partially assigned here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref c2 => { + | +++ error[E0382]: assign to part of moved value: `c` --> $DIR/issue-21232-partial-init-and-use.rs:255:13 @@ -219,6 +234,11 @@ LL | c2 => { | -- value moved here LL | (c.1).0 = 2; | ^^^^^^^^^^^ value partially assigned here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref c2 => { + | +++ error[E0382]: assign to part of moved value: `c.1` --> $DIR/issue-21232-partial-init-and-use.rs:263:13 @@ -229,6 +249,10 @@ LL | ((c.1).1).0 = 3; | ^^^^^^^^^^^^^^^ value partially assigned here after move | = note: move occurs because `c.1` has type `(i32, (i32, String))`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref c2 => { + | +++ error: aborting due to 23 previous errors diff --git a/src/test/ui/nll/issue-48623-generator.stderr b/src/test/ui/nll/issue-48623-generator.stderr index 1b35165db..bfdfca210 100644 --- a/src/test/ui/nll/issue-48623-generator.stderr +++ b/src/test/ui/nll/issue-48623-generator.stderr @@ -2,7 +2,7 @@ warning: unused generator that must be used --> $DIR/issue-48623-generator.rs:15:5 | LL | move || { d; yield; &mut *r }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: generators are lazy and do nothing unless resumed = note: `#[warn(unused_must_use)]` on by default diff --git a/src/test/ui/nll/issue-51512.stderr b/src/test/ui/nll/issue-51512.stderr index e591ca082..072e96788 100644 --- a/src/test/ui/nll/issue-51512.stderr +++ b/src/test/ui/nll/issue-51512.stderr @@ -7,6 +7,11 @@ LL | let r = range; | ----- value moved here LL | let x = range.start; | ^^^^^^^^^^^ value used here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | let r = range.clone(); + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/nll/issue-53807.stderr b/src/test/ui/nll/issue-53807.stderr index 574a11434..d8f58b591 100644 --- a/src/test/ui/nll/issue-53807.stderr +++ b/src/test/ui/nll/issue-53807.stderr @@ -5,7 +5,7 @@ LL | if let Some(thing) = maybe { | ^^^^^ value moved here, in previous iteration of loop | = note: move occurs because value has type `Vec<bool>`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving `maybe.0` +help: borrow this binding in the pattern to avoid moving the value | LL | if let Some(ref thing) = maybe { | +++ diff --git a/src/test/ui/issues/issue-54943.rs b/src/test/ui/nll/issue-54943.rs index 85722300b..85722300b 100644 --- a/src/test/ui/issues/issue-54943.rs +++ b/src/test/ui/nll/issue-54943.rs diff --git a/src/test/ui/issues/issue-54943.stderr b/src/test/ui/nll/issue-54943.stderr index 59be0f983..59be0f983 100644 --- a/src/test/ui/issues/issue-54943.stderr +++ b/src/test/ui/nll/issue-54943.stderr diff --git a/src/test/ui/nll/issue-57265-return-type-wf-check.stderr b/src/test/ui/nll/issue-57265-return-type-wf-check.stderr index 20add62b9..bb45575fa 100644 --- a/src/test/ui/nll/issue-57265-return-type-wf-check.stderr +++ b/src/test/ui/nll/issue-57265-return-type-wf-check.stderr @@ -4,7 +4,7 @@ error[E0716]: temporary value dropped while borrowed LL | let (_, z) = foo(&"hello".to_string()); | -----^^^^^^^^^^^^^^^^^^^-- temporary value is freed at the end of this statement | | | - | | creates a temporary which is freed while still in use + | | creates a temporary value which is freed while still in use | argument requires that borrow lasts for `'static` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-57843.rs b/src/test/ui/nll/issue-57843.rs index 11629690e..11629690e 100644 --- a/src/test/ui/issues/issue-57843.rs +++ b/src/test/ui/nll/issue-57843.rs diff --git a/src/test/ui/issues/issue-57843.stderr b/src/test/ui/nll/issue-57843.stderr index 2ab49ec61..2ab49ec61 100644 --- a/src/test/ui/issues/issue-57843.stderr +++ b/src/test/ui/nll/issue-57843.stderr diff --git a/src/test/ui/nll/issue-98589-closures-relate-named-regions.stderr b/src/test/ui/nll/issue-98589-closures-relate-named-regions.stderr index 6def5602e..d8b26f0b0 100644 --- a/src/test/ui/nll/issue-98589-closures-relate-named-regions.stderr +++ b/src/test/ui/nll/issue-98589-closures-relate-named-regions.stderr @@ -35,10 +35,10 @@ LL | || { None::<&'a &'b ()>; }; = help: consider adding the following bound: `'b: 'a` error[E0309]: the parameter type `T` may not live long enough - --> $DIR/issue-98589-closures-relate-named-regions.rs:26:5 + --> $DIR/issue-98589-closures-relate-named-regions.rs:26:10 | LL | || { None::<&'a T>; }; - | ^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | ^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound... | @@ -46,10 +46,10 @@ LL | fn test_early_type<'a: 'a, T: 'a>() { | ++++ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/issue-98589-closures-relate-named-regions.rs:32:5 + --> $DIR/issue-98589-closures-relate-named-regions.rs:32:10 | LL | || { None::<&'a T>; }; - | ^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | ^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound... | diff --git a/src/test/ui/nll/issue-98693.rs b/src/test/ui/nll/issue-98693.rs index 18e6ec630..7a325e2e9 100644 --- a/src/test/ui/nll/issue-98693.rs +++ b/src/test/ui/nll/issue-98693.rs @@ -13,8 +13,8 @@ where fn test<T>() { || { - //~^ ERROR the parameter type `T` may not live long enough assert_static::<T>(); + //~^ ERROR the parameter type `T` may not live long enough }; } diff --git a/src/test/ui/nll/issue-98693.stderr b/src/test/ui/nll/issue-98693.stderr index 31689620c..15ca38aa2 100644 --- a/src/test/ui/nll/issue-98693.stderr +++ b/src/test/ui/nll/issue-98693.stderr @@ -1,11 +1,8 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/issue-98693.rs:15:5 + --> $DIR/issue-98693.rs:16:9 | -LL | / || { -LL | | -LL | | assert_static::<T>(); -LL | | }; - | |_____^ ...so that the type `T` will meet its required lifetime bounds +LL | assert_static::<T>(); + | ^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound... | diff --git a/src/test/ui/nll/match-cfg-fake-edges.stderr b/src/test/ui/nll/match-cfg-fake-edges.stderr index 2d48a9142..f72ed3af7 100644 --- a/src/test/ui/nll/match-cfg-fake-edges.stderr +++ b/src/test/ui/nll/match-cfg-fake-edges.stderr @@ -26,6 +26,11 @@ LL | false if { drop(x); true } => 1, LL | true => { LL | x; | ^ value used here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | false if { drop(x.clone()); true } => 1, + | ++++++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/nll/ref-suggestion.stderr b/src/test/ui/nll/ref-suggestion.stderr index a973c583a..b1f5117cb 100644 --- a/src/test/ui/nll/ref-suggestion.stderr +++ b/src/test/ui/nll/ref-suggestion.stderr @@ -7,6 +7,11 @@ LL | let y = x; | - value moved here LL | x; | ^ value used here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | let y = x.clone(); + | ++++++++ error[E0382]: use of moved value: `x` --> $DIR/ref-suggestion.rs:8:5 @@ -17,6 +22,11 @@ LL | let mut y = x; | - value moved here LL | x; | ^ value used here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | let mut y = x.clone(); + | ++++++++ error[E0382]: use of partially moved value: `x` --> $DIR/ref-suggestion.rs:16:5 @@ -28,7 +38,7 @@ LL | x; | ^ value used here after partial move | = note: partial move occurs because value has type `Vec<i32>`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving `x.0.0` +help: borrow this binding in the pattern to avoid moving the value | LL | (Some(ref y), ()) => {}, | +++ diff --git a/src/test/ui/nll/ty-outlives/impl-trait-captures.stderr b/src/test/ui/nll/ty-outlives/impl-trait-captures.stderr index 737cb3584..7b9ed171d 100644 --- a/src/test/ui/nll/ty-outlives/impl-trait-captures.stderr +++ b/src/test/ui/nll/ty-outlives/impl-trait-captures.stderr @@ -1,4 +1,4 @@ -error[E0700]: hidden type for `Opaque(DefId(0:13 ~ impl_trait_captures[1afc]::foo::{opaque#0}), [ReStatic, T, ReEarlyBound(0, 'a)])` captures lifetime that does not appear in bounds +error[E0700]: hidden type for `Opaque(DefId(0:13 ~ impl_trait_captures[1afc]::foo::{opaque#0}), [ReEarlyBound(0, 'a), T, ReEarlyBound(0, 'a)])` captures lifetime that does not appear in bounds --> $DIR/impl-trait-captures.rs:11:5 | LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> { diff --git a/src/test/ui/nll/ty-outlives/projection-implied-bounds.stderr b/src/test/ui/nll/ty-outlives/projection-implied-bounds.stderr index 3b9b2956c..d949e29b2 100644 --- a/src/test/ui/nll/ty-outlives/projection-implied-bounds.stderr +++ b/src/test/ui/nll/ty-outlives/projection-implied-bounds.stderr @@ -1,8 +1,8 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/projection-implied-bounds.rs:30:18 + --> $DIR/projection-implied-bounds.rs:30:36 | LL | twice(value, |value_ref, item| invoke2(value_ref, item)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound... | diff --git a/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr b/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr index ee1f7b64b..4933b9348 100644 --- a/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr @@ -23,10 +23,10 @@ LL | | T: Iterator, = note: defining type: no_region::<'_#1r, T> error[E0309]: the associated type `<T as Iterator>::Item` may not live long enough - --> $DIR/projection-no-regions-closure.rs:25:23 + --> $DIR/projection-no-regions-closure.rs:25:31 | LL | with_signature(x, |mut y| Box::new(y.next())) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ | = help: consider adding an explicit lifetime bound `<T as Iterator>::Item: 'a`... = note: ...so that the type `<T as Iterator>::Item` will meet its required lifetime bounds @@ -80,10 +80,10 @@ LL | | T: 'b + Iterator, = note: defining type: wrong_region::<'_#1r, '_#2r, T> error[E0309]: the associated type `<T as Iterator>::Item` may not live long enough - --> $DIR/projection-no-regions-closure.rs:42:23 + --> $DIR/projection-no-regions-closure.rs:42:31 | LL | with_signature(x, |mut y| Box::new(y.next())) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ | = help: consider adding an explicit lifetime bound `<T as Iterator>::Item: 'a`... = note: ...so that the type `<T as Iterator>::Item` will meet its required lifetime bounds diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr b/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr index 4e57dfad7..dbda04c42 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr @@ -25,10 +25,10 @@ LL | | T: Anything<'b>, = note: defining type: no_relationships_late::<'_#1r, T> error[E0309]: the parameter type `T` may not live long enough - --> $DIR/projection-one-region-closure.rs:45:29 + --> $DIR/projection-one-region-closure.rs:45:39 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound... | @@ -75,10 +75,10 @@ LL | | 'a: 'a, = note: defining type: no_relationships_early::<'_#1r, '_#2r, T> error[E0309]: the parameter type `T` may not live long enough - --> $DIR/projection-one-region-closure.rs:56:29 + --> $DIR/projection-one-region-closure.rs:56:39 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound... | diff --git a/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr b/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr index 0195a693e..90f049142 100644 --- a/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr @@ -24,10 +24,10 @@ LL | | T: Anything<'b, 'c>, = note: defining type: no_relationships_late::<'_#1r, '_#2r, T> error[E0309]: the associated type `<T as Anything<ReEarlyBound(0, 'b), ReEarlyBound(1, 'c)>>::AssocType` may not live long enough - --> $DIR/projection-two-region-trait-bound-closure.rs:38:29 + --> $DIR/projection-two-region-trait-bound-closure.rs:38:39 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ | = help: consider adding an explicit lifetime bound `<T as Anything<ReEarlyBound(0, 'b), ReEarlyBound(1, 'c)>>::AssocType: 'a`... = note: ...so that the type `<T as Anything<ReEarlyBound(0, 'b), ReEarlyBound(1, 'c)>>::AssocType` will meet its required lifetime bounds @@ -58,10 +58,10 @@ LL | | 'a: 'a, = note: defining type: no_relationships_early::<'_#1r, '_#2r, '_#3r, T> error[E0309]: the associated type `<T as Anything<ReEarlyBound(1, 'b), ReEarlyBound(2, 'c)>>::AssocType` may not live long enough - --> $DIR/projection-two-region-trait-bound-closure.rs:48:29 + --> $DIR/projection-two-region-trait-bound-closure.rs:48:39 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ | = help: consider adding an explicit lifetime bound `<T as Anything<ReEarlyBound(1, 'b), ReEarlyBound(2, 'c)>>::AssocType: 'a`... = note: ...so that the type `<T as Anything<ReEarlyBound(1, 'b), ReEarlyBound(2, 'c)>>::AssocType` will meet its required lifetime bounds @@ -167,7 +167,7 @@ LL | | T: Anything<'b, 'b>, = note: defining type: two_regions::<'_#1r, T> error: lifetime may not live long enough - --> $DIR/projection-two-region-trait-bound-closure.rs:87:29 + --> $DIR/projection-two-region-trait-bound-closure.rs:87:5 | LL | fn two_regions<'a, 'b, T>(cell: Cell<&'a ()>, t: T) | -- -- lifetime `'b` defined here @@ -175,9 +175,12 @@ LL | fn two_regions<'a, 'b, T>(cell: Cell<&'a ()>, t: T) | lifetime `'a` defined here ... LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ closure body requires that `'b` must outlive `'a` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` | = help: consider adding the following bound: `'b: 'a` + = note: requirement occurs because of the type `Cell<&'_#8r ()>`, which makes the generic argument `&'_#8r ()` invariant + = note: the struct `Cell<T>` is invariant over the parameter `T` + = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:97:29 diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr index 61c7d2550..a442cf12d 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr @@ -6,7 +6,7 @@ LL | twice(cell, value, |a, b| invoke(a, b)); | = note: defining type: generic::<T>::{closure#0} with closure substs [ i16, - for<'a, 'b> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) ()>>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) T)), + for<Region(BrAnon(0, None)), Region(BrAnon(1, None))> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) ()>>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) T)), (), ] = note: number of external vids: 2 @@ -28,7 +28,7 @@ LL | twice(cell, value, |a, b| invoke(a, b)); | = note: defining type: generic_fail::<T>::{closure#0} with closure substs [ i16, - for<'a, 'b> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) ()>>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) T)), + for<Region(BrAnon(0, None)), Region(BrAnon(1, None))> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) ()>>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) T)), (), ] = note: late-bound region is '_#2r @@ -44,10 +44,10 @@ LL | fn generic_fail<'a, T>(cell: Cell<&'a ()>, value: T) { = note: defining type: generic_fail::<T> error[E0309]: the parameter type `T` may not live long enough - --> $DIR/ty-param-closure-approximate-lower-bound.rs:29:24 + --> $DIR/ty-param-closure-approximate-lower-bound.rs:29:31 | LL | twice(cell, value, |a, b| invoke(a, b)); - | ^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | ^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound... | diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr index 50d9e3aab..35979c8bf 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr @@ -23,10 +23,10 @@ LL | | T: Debug, = note: defining type: no_region::<'_#1r, T> error[E0309]: the parameter type `T` may not live long enough - --> $DIR/ty-param-closure-outlives-from-return-type.rs:26:23 + --> $DIR/ty-param-closure-outlives-from-return-type.rs:26:27 | LL | with_signature(x, |y| y) - | ^^^^^ ...so that the type `T` will meet its required lifetime bounds + | ^ ...so that the type `T` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound... | diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.rs b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.rs index d7702def3..b80287610 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.rs +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.rs @@ -25,13 +25,12 @@ where #[rustc_regions] fn no_region<'a, T>(a: Cell<&'a ()>, b: T) { with_signature(a, b, |x, y| { - //~^ ERROR the parameter type `T` may not live long enough - // // See `correct_region`, which explains the point of this // test. The only difference is that, in the case of this // function, there is no where clause *anywhere*, and hence we // get an error (but reported by the closure creator). require(&x, &y) + //~^ ERROR the parameter type `T` may not live long enough }) } @@ -62,9 +61,9 @@ where T: 'b, { with_signature(a, b, |x, y| { - //~^ ERROR the parameter type `T` may not live long enough // See `correct_region` require(&x, &y) + //~^ ERROR the parameter type `T` may not live long enough }) } diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr index 14c55e32a..4c97db58c 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr @@ -22,17 +22,10 @@ LL | fn no_region<'a, T>(a: Cell<&'a ()>, b: T) { = note: defining type: no_region::<T> error[E0309]: the parameter type `T` may not live long enough - --> $DIR/ty-param-closure-outlives-from-where-clause.rs:27:26 + --> $DIR/ty-param-closure-outlives-from-where-clause.rs:32:9 | -LL | with_signature(a, b, |x, y| { - | __________________________^ -LL | | -LL | | // -LL | | // See `correct_region`, which explains the point of this -... | -LL | | require(&x, &y) -LL | | }) - | |_____^ ...so that the type `T` will meet its required lifetime bounds +LL | require(&x, &y) + | ^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound... | @@ -40,7 +33,7 @@ LL | fn no_region<'a, T: 'a>(a: Cell<&'a ()>, b: T) { | ++++ note: external requirements - --> $DIR/ty-param-closure-outlives-from-where-clause.rs:43:26 + --> $DIR/ty-param-closure-outlives-from-where-clause.rs:42:26 | LL | with_signature(a, b, |x, y| { | ^^^^^^ @@ -54,7 +47,7 @@ LL | with_signature(a, b, |x, y| { = note: where T: '_#2r note: no external requirements - --> $DIR/ty-param-closure-outlives-from-where-clause.rs:39:1 + --> $DIR/ty-param-closure-outlives-from-where-clause.rs:38:1 | LL | / fn correct_region<'a, T>(a: Cell<&'a ()>, b: T) LL | | where @@ -64,7 +57,7 @@ LL | | T: 'a, = note: defining type: correct_region::<'_#1r, T> note: external requirements - --> $DIR/ty-param-closure-outlives-from-where-clause.rs:64:26 + --> $DIR/ty-param-closure-outlives-from-where-clause.rs:63:26 | LL | with_signature(a, b, |x, y| { | ^^^^^^ @@ -79,7 +72,7 @@ LL | with_signature(a, b, |x, y| { = note: where T: '_#2r note: no external requirements - --> $DIR/ty-param-closure-outlives-from-where-clause.rs:60:1 + --> $DIR/ty-param-closure-outlives-from-where-clause.rs:59:1 | LL | / fn wrong_region<'a, 'b, T>(a: Cell<&'a ()>, b: T) LL | | where @@ -89,15 +82,10 @@ LL | | T: 'b, = note: defining type: wrong_region::<'_#1r, T> error[E0309]: the parameter type `T` may not live long enough - --> $DIR/ty-param-closure-outlives-from-where-clause.rs:64:26 + --> $DIR/ty-param-closure-outlives-from-where-clause.rs:65:9 | -LL | with_signature(a, b, |x, y| { - | __________________________^ -LL | | -LL | | // See `correct_region` -LL | | require(&x, &y) -LL | | }) - | |_____^ ...so that the type `T` will meet its required lifetime bounds +LL | require(&x, &y) + | ^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound... | @@ -105,7 +93,7 @@ LL | T: 'b + 'a, | ++++ note: external requirements - --> $DIR/ty-param-closure-outlives-from-where-clause.rs:77:26 + --> $DIR/ty-param-closure-outlives-from-where-clause.rs:76:26 | LL | with_signature(a, b, |x, y| { | ^^^^^^ @@ -119,7 +107,7 @@ LL | with_signature(a, b, |x, y| { = note: where T: '_#3r note: no external requirements - --> $DIR/ty-param-closure-outlives-from-where-clause.rs:72:1 + --> $DIR/ty-param-closure-outlives-from-where-clause.rs:71:1 | LL | / fn outlives_region<'a, 'b, T>(a: Cell<&'a ()>, b: T) LL | | where diff --git a/src/test/ui/nll/user-annotations/ascribed-type-wf.rs b/src/test/ui/nll/user-annotations/ascribed-type-wf.rs new file mode 100644 index 000000000..14460dea5 --- /dev/null +++ b/src/test/ui/nll/user-annotations/ascribed-type-wf.rs @@ -0,0 +1,16 @@ +// check-pass +// known-bug: #101350 + +trait Trait { + type Ty; +} + +impl Trait for &'static () { + type Ty = (); +} + +fn extend<'a>() { + None::<<&'a () as Trait>::Ty>; +} + +fn main() {} diff --git a/src/test/ui/nll/user-annotations/issue-57731-ascibed-coupled-types.rs b/src/test/ui/nll/user-annotations/issue-57731-ascibed-coupled-types.rs index 9b3ec702c..95c655654 100644 --- a/src/test/ui/nll/user-annotations/issue-57731-ascibed-coupled-types.rs +++ b/src/test/ui/nll/user-annotations/issue-57731-ascibed-coupled-types.rs @@ -8,17 +8,17 @@ type PairCoupledTypes<T> = (T, T); type PairCoupledRegions<'a, T> = (&'a T, &'a T); fn uncoupled_wilds_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { - let ((y, _z),) = ((s, _x),): (PairUncoupled<_>,); + let ((y, _z),) = type_ascribe!(((s, _x),), (PairUncoupled<_>,)); y // OK } fn coupled_wilds_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { - let ((y, _z),) = ((s, _x),): (PairCoupledTypes<_>,); + let ((y, _z),) = type_ascribe!(((s, _x),), (PairCoupledTypes<_>,)); y //~ ERROR lifetime may not live long enough } fn coupled_regions_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { - let ((y, _z),) = ((s, _x),): (PairCoupledRegions<_>,); + let ((y, _z),) = type_ascribe!(((s, _x),), (PairCoupledRegions<_>,)); y //~ ERROR lifetime may not live long enough } diff --git a/src/test/ui/nll/user-annotations/issue-57731-ascibed-coupled-types.stderr b/src/test/ui/nll/user-annotations/issue-57731-ascibed-coupled-types.stderr index c99f53c5a..8601691e8 100644 --- a/src/test/ui/nll/user-annotations/issue-57731-ascibed-coupled-types.stderr +++ b/src/test/ui/nll/user-annotations/issue-57731-ascibed-coupled-types.stderr @@ -3,7 +3,7 @@ error: lifetime may not live long enough | LL | fn coupled_wilds_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { | -- lifetime `'a` defined here -LL | let ((y, _z),) = ((s, _x),): (PairCoupledTypes<_>,); +LL | let ((y, _z),) = type_ascribe!(((s, _x),), (PairCoupledTypes<_>,)); LL | y | ^ returning this value requires that `'a` must outlive `'static` @@ -12,7 +12,7 @@ error: lifetime may not live long enough | LL | fn coupled_regions_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { | -- lifetime `'a` defined here -LL | let ((y, _z),) = ((s, _x),): (PairCoupledRegions<_>,); +LL | let ((y, _z),) = type_ascribe!(((s, _x),), (PairCoupledRegions<_>,)); LL | y | ^ returning this value requires that `'a` must outlive `'static` diff --git a/src/test/ui/nll/user-annotations/patterns.stderr b/src/test/ui/nll/user-annotations/patterns.stderr index 60d6e6db3..de6f8f80f 100644 --- a/src/test/ui/nll/user-annotations/patterns.stderr +++ b/src/test/ui/nll/user-annotations/patterns.stderr @@ -76,7 +76,7 @@ error[E0716]: temporary value dropped while borrowed LL | let _: Vec<&'static String> = vec![&String::new()]; | -------------------- ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement | | | - | | creates a temporary which is freed while still in use + | | creates a temporary value which is freed while still in use | type annotation requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed @@ -85,7 +85,7 @@ error[E0716]: temporary value dropped while borrowed LL | let (_, a): (Vec<&'static String>, _) = (vec![&String::new()], 44); | ------------------------- ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement | | | - | | creates a temporary which is freed while still in use + | | creates a temporary value which is freed while still in use | type annotation requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed @@ -94,7 +94,7 @@ error[E0716]: temporary value dropped while borrowed LL | let (_a, b): (Vec<&'static String>, _) = (vec![&String::new()], 44); | ------------------------- ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement | | | - | | creates a temporary which is freed while still in use + | | creates a temporary value which is freed while still in use | type annotation requires that borrow lasts for `'static` error[E0597]: `x` does not live long enough diff --git a/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.rs b/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.rs index 101b5cfab..88d646dee 100644 --- a/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.rs +++ b/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.rs @@ -3,5 +3,5 @@ fn main() { let x = 22_u32; - let y: &u32 = &x: &'static u32; //~ ERROR E0597 + let y: &u32 = type_ascribe!(&x, &'static u32); //~ ERROR E0597 } diff --git a/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.stderr b/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.stderr index 133bbef52..ccbf3c1d9 100644 --- a/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.stderr +++ b/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.stderr @@ -1,10 +1,10 @@ error[E0597]: `x` does not live long enough - --> $DIR/type_ascription_static_lifetime.rs:6:19 + --> $DIR/type_ascription_static_lifetime.rs:6:33 | -LL | let y: &u32 = &x: &'static u32; - | ^^-------------- - | | - | borrowed value does not live long enough +LL | let y: &u32 = type_ascribe!(&x, &'static u32); + | --------------^^--------------- + | | | + | | borrowed value does not live long enough | type annotation requires that `x` is borrowed for `'static` LL | } | - `x` dropped here while still borrowed diff --git a/src/test/ui/numbers-arithmetic/not-suggest-float-literal.stderr b/src/test/ui/numbers-arithmetic/not-suggest-float-literal.stderr index 6aa1ad8dd..8f0eef237 100644 --- a/src/test/ui/numbers-arithmetic/not-suggest-float-literal.stderr +++ b/src/test/ui/numbers-arithmetic/not-suggest-float-literal.stderr @@ -6,15 +6,10 @@ LL | x + 100.0 | = help: the trait `Add<{float}>` is not implemented for `u8` = help: the following other types implement trait `Add<Rhs>`: - <&'a f32 as Add<f32>> - <&'a f64 as Add<f64>> - <&'a i128 as Add<i128>> - <&'a i16 as Add<i16>> - <&'a i32 as Add<i32>> - <&'a i64 as Add<i64>> - <&'a i8 as Add<i8>> - <&'a isize as Add<isize>> - and 48 others + <&'a u8 as Add<u8>> + <&u8 as Add<&u8>> + <u8 as Add<&u8>> + <u8 as Add> error[E0277]: cannot add `&str` to `f64` --> $DIR/not-suggest-float-literal.rs:6:7 @@ -24,15 +19,10 @@ LL | x + "foo" | = help: the trait `Add<&str>` is not implemented for `f64` = help: the following other types implement trait `Add<Rhs>`: - <&'a f32 as Add<f32>> <&'a f64 as Add<f64>> - <&'a i128 as Add<i128>> - <&'a i16 as Add<i16>> - <&'a i32 as Add<i32>> - <&'a i64 as Add<i64>> - <&'a i8 as Add<i8>> - <&'a isize as Add<isize>> - and 48 others + <&f64 as Add<&f64>> + <f64 as Add<&f64>> + <f64 as Add> error[E0277]: cannot add `{integer}` to `f64` --> $DIR/not-suggest-float-literal.rs:11:7 @@ -42,15 +32,10 @@ LL | x + y | = help: the trait `Add<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Add<Rhs>`: - <&'a f32 as Add<f32>> <&'a f64 as Add<f64>> - <&'a i128 as Add<i128>> - <&'a i16 as Add<i16>> - <&'a i32 as Add<i32>> - <&'a i64 as Add<i64>> - <&'a i8 as Add<i8>> - <&'a isize as Add<isize>> - and 48 others + <&f64 as Add<&f64>> + <f64 as Add<&f64>> + <f64 as Add> error[E0277]: cannot subtract `{float}` from `u8` --> $DIR/not-suggest-float-literal.rs:15:7 @@ -60,15 +45,10 @@ LL | x - 100.0 | = help: the trait `Sub<{float}>` is not implemented for `u8` = help: the following other types implement trait `Sub<Rhs>`: - <&'a f32 as Sub<f32>> - <&'a f64 as Sub<f64>> - <&'a i128 as Sub<i128>> - <&'a i16 as Sub<i16>> - <&'a i32 as Sub<i32>> - <&'a i64 as Sub<i64>> - <&'a i8 as Sub<i8>> - <&'a isize as Sub<isize>> - and 48 others + <&'a u8 as Sub<u8>> + <&u8 as Sub<&u8>> + <u8 as Sub<&u8>> + <u8 as Sub> error[E0277]: cannot subtract `&str` from `f64` --> $DIR/not-suggest-float-literal.rs:19:7 @@ -78,15 +58,10 @@ LL | x - "foo" | = help: the trait `Sub<&str>` is not implemented for `f64` = help: the following other types implement trait `Sub<Rhs>`: - <&'a f32 as Sub<f32>> <&'a f64 as Sub<f64>> - <&'a i128 as Sub<i128>> - <&'a i16 as Sub<i16>> - <&'a i32 as Sub<i32>> - <&'a i64 as Sub<i64>> - <&'a i8 as Sub<i8>> - <&'a isize as Sub<isize>> - and 48 others + <&f64 as Sub<&f64>> + <f64 as Sub<&f64>> + <f64 as Sub> error[E0277]: cannot subtract `{integer}` from `f64` --> $DIR/not-suggest-float-literal.rs:24:7 @@ -96,15 +71,10 @@ LL | x - y | = help: the trait `Sub<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Sub<Rhs>`: - <&'a f32 as Sub<f32>> <&'a f64 as Sub<f64>> - <&'a i128 as Sub<i128>> - <&'a i16 as Sub<i16>> - <&'a i32 as Sub<i32>> - <&'a i64 as Sub<i64>> - <&'a i8 as Sub<i8>> - <&'a isize as Sub<isize>> - and 48 others + <&f64 as Sub<&f64>> + <f64 as Sub<&f64>> + <f64 as Sub> error[E0277]: cannot multiply `u8` by `{float}` --> $DIR/not-suggest-float-literal.rs:28:7 @@ -114,15 +84,10 @@ LL | x * 100.0 | = help: the trait `Mul<{float}>` is not implemented for `u8` = help: the following other types implement trait `Mul<Rhs>`: - <&'a f32 as Mul<f32>> - <&'a f64 as Mul<f64>> - <&'a i128 as Mul<i128>> - <&'a i16 as Mul<i16>> - <&'a i32 as Mul<i32>> - <&'a i64 as Mul<i64>> - <&'a i8 as Mul<i8>> - <&'a isize as Mul<isize>> - and 49 others + <&'a u8 as Mul<u8>> + <&u8 as Mul<&u8>> + <u8 as Mul<&u8>> + <u8 as Mul> error[E0277]: cannot multiply `f64` by `&str` --> $DIR/not-suggest-float-literal.rs:32:7 @@ -132,15 +97,10 @@ LL | x * "foo" | = help: the trait `Mul<&str>` is not implemented for `f64` = help: the following other types implement trait `Mul<Rhs>`: - <&'a f32 as Mul<f32>> <&'a f64 as Mul<f64>> - <&'a i128 as Mul<i128>> - <&'a i16 as Mul<i16>> - <&'a i32 as Mul<i32>> - <&'a i64 as Mul<i64>> - <&'a i8 as Mul<i8>> - <&'a isize as Mul<isize>> - and 49 others + <&f64 as Mul<&f64>> + <f64 as Mul<&f64>> + <f64 as Mul> error[E0277]: cannot multiply `f64` by `{integer}` --> $DIR/not-suggest-float-literal.rs:37:7 @@ -150,15 +110,10 @@ LL | x * y | = help: the trait `Mul<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Mul<Rhs>`: - <&'a f32 as Mul<f32>> <&'a f64 as Mul<f64>> - <&'a i128 as Mul<i128>> - <&'a i16 as Mul<i16>> - <&'a i32 as Mul<i32>> - <&'a i64 as Mul<i64>> - <&'a i8 as Mul<i8>> - <&'a isize as Mul<isize>> - and 49 others + <&f64 as Mul<&f64>> + <f64 as Mul<&f64>> + <f64 as Mul> error[E0277]: cannot divide `u8` by `{float}` --> $DIR/not-suggest-float-literal.rs:41:7 @@ -168,15 +123,11 @@ LL | x / 100.0 | = help: the trait `Div<{float}>` is not implemented for `u8` = help: the following other types implement trait `Div<Rhs>`: - <&'a f32 as Div<f32>> - <&'a f64 as Div<f64>> - <&'a i128 as Div<i128>> - <&'a i16 as Div<i16>> - <&'a i32 as Div<i32>> - <&'a i64 as Div<i64>> - <&'a i8 as Div<i8>> - <&'a isize as Div<isize>> - and 54 others + <&'a u8 as Div<u8>> + <&u8 as Div<&u8>> + <u8 as Div<&u8>> + <u8 as Div<NonZeroU8>> + <u8 as Div> error[E0277]: cannot divide `f64` by `&str` --> $DIR/not-suggest-float-literal.rs:45:7 @@ -186,15 +137,10 @@ LL | x / "foo" | = help: the trait `Div<&str>` is not implemented for `f64` = help: the following other types implement trait `Div<Rhs>`: - <&'a f32 as Div<f32>> <&'a f64 as Div<f64>> - <&'a i128 as Div<i128>> - <&'a i16 as Div<i16>> - <&'a i32 as Div<i32>> - <&'a i64 as Div<i64>> - <&'a i8 as Div<i8>> - <&'a isize as Div<isize>> - and 54 others + <&f64 as Div<&f64>> + <f64 as Div<&f64>> + <f64 as Div> error[E0277]: cannot divide `f64` by `{integer}` --> $DIR/not-suggest-float-literal.rs:50:7 @@ -204,15 +150,10 @@ LL | x / y | = help: the trait `Div<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Div<Rhs>`: - <&'a f32 as Div<f32>> <&'a f64 as Div<f64>> - <&'a i128 as Div<i128>> - <&'a i16 as Div<i16>> - <&'a i32 as Div<i32>> - <&'a i64 as Div<i64>> - <&'a i8 as Div<i8>> - <&'a isize as Div<isize>> - and 54 others + <&f64 as Div<&f64>> + <f64 as Div<&f64>> + <f64 as Div> error: aborting due to 12 previous errors diff --git a/src/test/ui/numbers-arithmetic/suggest-float-literal.stderr b/src/test/ui/numbers-arithmetic/suggest-float-literal.stderr index 988379e58..03779d356 100644 --- a/src/test/ui/numbers-arithmetic/suggest-float-literal.stderr +++ b/src/test/ui/numbers-arithmetic/suggest-float-literal.stderr @@ -7,14 +7,9 @@ LL | x + 100 = help: the trait `Add<{integer}>` is not implemented for `f32` = help: the following other types implement trait `Add<Rhs>`: <&'a f32 as Add<f32>> - <&'a f64 as Add<f64>> - <&'a i128 as Add<i128>> - <&'a i16 as Add<i16>> - <&'a i32 as Add<i32>> - <&'a i64 as Add<i64>> - <&'a i8 as Add<i8>> - <&'a isize as Add<isize>> - and 48 others + <&f32 as Add<&f32>> + <f32 as Add<&f32>> + <f32 as Add> help: consider using a floating-point literal by writing it with `.0` | LL | x + 100.0 @@ -28,15 +23,10 @@ LL | x + 100 | = help: the trait `Add<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Add<Rhs>`: - <&'a f32 as Add<f32>> <&'a f64 as Add<f64>> - <&'a i128 as Add<i128>> - <&'a i16 as Add<i16>> - <&'a i32 as Add<i32>> - <&'a i64 as Add<i64>> - <&'a i8 as Add<i8>> - <&'a isize as Add<isize>> - and 48 others + <&f64 as Add<&f64>> + <f64 as Add<&f64>> + <f64 as Add> help: consider using a floating-point literal by writing it with `.0` | LL | x + 100.0 @@ -51,14 +41,9 @@ LL | x - 100 = help: the trait `Sub<{integer}>` is not implemented for `f32` = help: the following other types implement trait `Sub<Rhs>`: <&'a f32 as Sub<f32>> - <&'a f64 as Sub<f64>> - <&'a i128 as Sub<i128>> - <&'a i16 as Sub<i16>> - <&'a i32 as Sub<i32>> - <&'a i64 as Sub<i64>> - <&'a i8 as Sub<i8>> - <&'a isize as Sub<isize>> - and 48 others + <&f32 as Sub<&f32>> + <f32 as Sub<&f32>> + <f32 as Sub> help: consider using a floating-point literal by writing it with `.0` | LL | x - 100.0 @@ -72,15 +57,10 @@ LL | x - 100 | = help: the trait `Sub<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Sub<Rhs>`: - <&'a f32 as Sub<f32>> <&'a f64 as Sub<f64>> - <&'a i128 as Sub<i128>> - <&'a i16 as Sub<i16>> - <&'a i32 as Sub<i32>> - <&'a i64 as Sub<i64>> - <&'a i8 as Sub<i8>> - <&'a isize as Sub<isize>> - and 48 others + <&f64 as Sub<&f64>> + <f64 as Sub<&f64>> + <f64 as Sub> help: consider using a floating-point literal by writing it with `.0` | LL | x - 100.0 @@ -95,14 +75,9 @@ LL | x * 100 = help: the trait `Mul<{integer}>` is not implemented for `f32` = help: the following other types implement trait `Mul<Rhs>`: <&'a f32 as Mul<f32>> - <&'a f64 as Mul<f64>> - <&'a i128 as Mul<i128>> - <&'a i16 as Mul<i16>> - <&'a i32 as Mul<i32>> - <&'a i64 as Mul<i64>> - <&'a i8 as Mul<i8>> - <&'a isize as Mul<isize>> - and 49 others + <&f32 as Mul<&f32>> + <f32 as Mul<&f32>> + <f32 as Mul> help: consider using a floating-point literal by writing it with `.0` | LL | x * 100.0 @@ -116,15 +91,10 @@ LL | x * 100 | = help: the trait `Mul<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Mul<Rhs>`: - <&'a f32 as Mul<f32>> <&'a f64 as Mul<f64>> - <&'a i128 as Mul<i128>> - <&'a i16 as Mul<i16>> - <&'a i32 as Mul<i32>> - <&'a i64 as Mul<i64>> - <&'a i8 as Mul<i8>> - <&'a isize as Mul<isize>> - and 49 others + <&f64 as Mul<&f64>> + <f64 as Mul<&f64>> + <f64 as Mul> help: consider using a floating-point literal by writing it with `.0` | LL | x * 100.0 @@ -139,14 +109,9 @@ LL | x / 100 = help: the trait `Div<{integer}>` is not implemented for `f32` = help: the following other types implement trait `Div<Rhs>`: <&'a f32 as Div<f32>> - <&'a f64 as Div<f64>> - <&'a i128 as Div<i128>> - <&'a i16 as Div<i16>> - <&'a i32 as Div<i32>> - <&'a i64 as Div<i64>> - <&'a i8 as Div<i8>> - <&'a isize as Div<isize>> - and 54 others + <&f32 as Div<&f32>> + <f32 as Div<&f32>> + <f32 as Div> help: consider using a floating-point literal by writing it with `.0` | LL | x / 100.0 @@ -160,15 +125,10 @@ LL | x / 100 | = help: the trait `Div<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Div<Rhs>`: - <&'a f32 as Div<f32>> <&'a f64 as Div<f64>> - <&'a i128 as Div<i128>> - <&'a i16 as Div<i16>> - <&'a i32 as Div<i32>> - <&'a i64 as Div<i64>> - <&'a i8 as Div<i8>> - <&'a isize as Div<isize>> - and 54 others + <&f64 as Div<&f64>> + <f64 as Div<&f64>> + <f64 as Div> help: consider using a floating-point literal by writing it with `.0` | LL | x / 100.0 diff --git a/src/test/ui/object-safety/object-safety-supertrait-mentions-GAT.stderr b/src/test/ui/object-safety/object-safety-supertrait-mentions-GAT.stderr index c1aaad31e..f05b0cd65 100644 --- a/src/test/ui/object-safety/object-safety-supertrait-mentions-GAT.stderr +++ b/src/test/ui/object-safety/object-safety-supertrait-mentions-GAT.stderr @@ -3,10 +3,10 @@ error[E0311]: the parameter type `Self` may not live long enough = help: consider adding an explicit lifetime bound `Self: 'a`... = note: ...so that the type `Self` will meet its required lifetime bounds... note: ...that is required by this bound - --> $DIR/object-safety-supertrait-mentions-GAT.rs:9:39 + --> $DIR/object-safety-supertrait-mentions-GAT.rs:6:15 | -LL | trait SuperTrait<T>: for<'a> GatTrait<Gat<'a> = T> { - | ^^^^^^^^^^^ +LL | Self: 'a; + | ^^ error: associated item referring to unboxed trait object for its own trait --> $DIR/object-safety-supertrait-mentions-GAT.rs:10:20 diff --git a/src/test/ui/on-unimplemented/issue-104140.rs b/src/test/ui/on-unimplemented/issue-104140.rs new file mode 100644 index 000000000..ade3f7270 --- /dev/null +++ b/src/test/ui/on-unimplemented/issue-104140.rs @@ -0,0 +1,8 @@ +#![feature(rustc_attrs)] + +trait Foo {} + +#[rustc_on_unimplemented] //~ ERROR malformed `rustc_on_unimplemented` attribute input +impl Foo for u32 {} + +fn main() {} diff --git a/src/test/ui/on-unimplemented/issue-104140.stderr b/src/test/ui/on-unimplemented/issue-104140.stderr new file mode 100644 index 000000000..ddb1f50f0 --- /dev/null +++ b/src/test/ui/on-unimplemented/issue-104140.stderr @@ -0,0 +1,15 @@ +error: malformed `rustc_on_unimplemented` attribute input + --> $DIR/issue-104140.rs:5:1 + | +LL | #[rustc_on_unimplemented] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[rustc_on_unimplemented = "message"] + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +LL | #[rustc_on_unimplemented(/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...")] + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: aborting due to previous error + diff --git a/src/test/ui/or-patterns/or-patterns-syntactic-fail-2018.stderr b/src/test/ui/or-patterns/or-patterns-syntactic-fail-2018.stderr index 001c68a97..acc2099bb 100644 --- a/src/test/ui/or-patterns/or-patterns-syntactic-fail-2018.stderr +++ b/src/test/ui/or-patterns/or-patterns-syntactic-fail-2018.stderr @@ -6,6 +6,12 @@ LL | macro_rules! accept_pat { ... LL | accept_pat!(p | q); | ^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$p:pat` + --> $DIR/or-patterns-syntactic-fail-2018.rs:9:6 + | +LL | ($p:pat) => {}; + | ^^^^^^ error: no rules expected the token `|` --> $DIR/or-patterns-syntactic-fail-2018.rs:13:13 @@ -15,6 +21,12 @@ LL | macro_rules! accept_pat { ... LL | accept_pat!(|p| q); | ^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$p:pat` + --> $DIR/or-patterns-syntactic-fail-2018.rs:9:6 + | +LL | ($p:pat) => {}; + | ^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/or-patterns/or-patterns-syntactic-pass.rs b/src/test/ui/or-patterns/or-patterns-syntactic-pass.rs index dda5c0bb5..92750bec8 100644 --- a/src/test/ui/or-patterns/or-patterns-syntactic-pass.rs +++ b/src/test/ui/or-patterns/or-patterns-syntactic-pass.rs @@ -21,27 +21,27 @@ accept_pat!([p | q]); #[cfg(FALSE)] fn or_patterns() { // Top level of `let`: - let (A | B); + let (| A | B); let (A | B); let (A | B): u8; let (A | B) = 0; let (A | B): u8 = 0; // Top level of `for`: - for A | B in 0 {} + for | A | B in 0 {} for A | B in 0 {} // Top level of `while`: - while let A | B = 0 {} + while let | A | B = 0 {} while let A | B = 0 {} // Top level of `if`: - if let A | B = 0 {} + if let | A | B = 0 {} if let A | B = 0 {} // Top level of `match` arms: match 0 { - A | B => {} + | A | B => {} A | B => {} } diff --git a/src/test/ui/overloaded/overloaded-calls-nontuple.rs b/src/test/ui/overloaded/overloaded-calls-nontuple.rs index 07d44ff82..32a3b93e0 100644 --- a/src/test/ui/overloaded/overloaded-calls-nontuple.rs +++ b/src/test/ui/overloaded/overloaded-calls-nontuple.rs @@ -8,22 +8,23 @@ struct S { } impl FnMut<isize> for S { + //~^ ERROR type parameter to bare `FnMut` trait must be a tuple extern "rust-call" fn call_mut(&mut self, z: isize) -> isize { + //~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument self.x + self.y + z } - //~^^^ ERROR functions with the "rust-call" ABI must take a single non-self argument } impl FnOnce<isize> for S { + //~^ ERROR type parameter to bare `FnOnce` trait must be a tuple type Output = isize; - extern "rust-call" fn call_once(mut self, z: isize) -> isize { self.call_mut(z) } - //~^ ERROR functions with the "rust-call" ABI must take a single non-self argument + extern "rust-call" fn call_once(mut self, z: isize) -> isize { + //~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument + self.call_mut(z) + } } fn main() { - let mut s = S { - x: 1, - y: 2, - }; - drop(s(3)) //~ ERROR cannot use call notation + let mut s = S { x: 1, y: 2 }; + drop(s(3)) } diff --git a/src/test/ui/overloaded/overloaded-calls-nontuple.stderr b/src/test/ui/overloaded/overloaded-calls-nontuple.stderr index 8f299bc94..794535aeb 100644 --- a/src/test/ui/overloaded/overloaded-calls-nontuple.stderr +++ b/src/test/ui/overloaded/overloaded-calls-nontuple.stderr @@ -1,21 +1,40 @@ -error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple - --> $DIR/overloaded-calls-nontuple.rs:11:5 +error[E0059]: type parameter to bare `FnMut` trait must be a tuple + --> $DIR/overloaded-calls-nontuple.rs:10:6 | -LL | extern "rust-call" fn call_mut(&mut self, z: isize) -> isize { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | impl FnMut<isize> for S { + | ^^^^^^^^^^^^ the trait `Tuple` is not implemented for `isize` + | +note: required by a bound in `FnMut` + --> $SRC_DIR/core/src/ops/function.rs:LL:COL + | +LL | pub trait FnMut<Args: Tuple>: FnOnce<Args> { + | ^^^^^ required by this bound in `FnMut` + +error[E0059]: type parameter to bare `FnOnce` trait must be a tuple + --> $DIR/overloaded-calls-nontuple.rs:18:6 + | +LL | impl FnOnce<isize> for S { + | ^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `isize` + | +note: required by a bound in `FnOnce` + --> $SRC_DIR/core/src/ops/function.rs:LL:COL + | +LL | pub trait FnOnce<Args: Tuple> { + | ^^^^^ required by this bound in `FnOnce` -error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple - --> $DIR/overloaded-calls-nontuple.rs:19:5 +error[E0277]: functions with the "rust-call" ABI must take a single non-self tuple argument + --> $DIR/overloaded-calls-nontuple.rs:12:5 | -LL | extern "rust-call" fn call_once(mut self, z: isize) -> isize { self.call_mut(z) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "rust-call" fn call_mut(&mut self, z: isize) -> isize { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `isize` -error[E0059]: cannot use call notation; the first type parameter for the function trait is neither a tuple nor unit - --> $DIR/overloaded-calls-nontuple.rs:28:10 +error[E0277]: functions with the "rust-call" ABI must take a single non-self tuple argument + --> $DIR/overloaded-calls-nontuple.rs:21:5 | -LL | drop(s(3)) - | ^^^^ +LL | extern "rust-call" fn call_once(mut self, z: isize) -> isize { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `isize` -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0059`. +Some errors have detailed explanations: E0059, E0277. +For more information about an error, try `rustc --explain E0059`. diff --git a/src/test/ui/panic-handler/panic-handler-std.stderr b/src/test/ui/panic-handler/panic-handler-std.stderr index e4069b196..7c7feffe7 100644 --- a/src/test/ui/panic-handler/panic-handler-std.stderr +++ b/src/test/ui/panic-handler/panic-handler-std.stderr @@ -8,12 +8,6 @@ LL | fn panic(info: PanicInfo) -> ! { = note: first definition in `std` loaded from SYSROOT/libstd-*.rlib = note: second definition in the local crate (`panic_handler_std`) -error: argument should be `&PanicInfo` - --> $DIR/panic-handler-std.rs:8:16 - | -LL | fn panic(info: PanicInfo) -> ! { - | ^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0152`. diff --git a/src/test/ui/parser/bad-lit-suffixes.rs b/src/test/ui/parser/bad-lit-suffixes.rs index 9724533c4..8cb9ef7e0 100644 --- a/src/test/ui/parser/bad-lit-suffixes.rs +++ b/src/test/ui/parser/bad-lit-suffixes.rs @@ -1,3 +1,5 @@ +#![feature(rustc_attrs)] + extern "C"suffix //~ ERROR suffixes on string literals are invalid fn foo() {} @@ -24,3 +26,19 @@ fn main() { 1.0suffix; //~ ERROR invalid suffix `suffix` for float literal 1.0e10suffix; //~ ERROR invalid suffix `suffix` for float literal } + +#[rustc_dummy = "string"suffix] +//~^ ERROR unexpected expression: `"string"suffix` +fn f() {} + +#[must_use = "string"suffix] +//~^ ERROR unexpected expression: `"string"suffix` +fn g() {} + +#[link(name = "string"suffix)] +//~^ ERROR suffixes on string literals are invalid +extern "C" {} + +#[rustc_layout_scalar_valid_range_start(0suffix)] +//~^ ERROR invalid suffix `suffix` for number literal +struct S; diff --git a/src/test/ui/parser/bad-lit-suffixes.stderr b/src/test/ui/parser/bad-lit-suffixes.stderr index f74eef324..756f99ab1 100644 --- a/src/test/ui/parser/bad-lit-suffixes.stderr +++ b/src/test/ui/parser/bad-lit-suffixes.stderr @@ -1,53 +1,79 @@ error: suffixes on string literals are invalid - --> $DIR/bad-lit-suffixes.rs:2:5 + --> $DIR/bad-lit-suffixes.rs:4:5 | LL | "C"suffix | ^^^^^^^^^ invalid suffix `suffix` error: suffixes on string literals are invalid - --> $DIR/bad-lit-suffixes.rs:6:5 + --> $DIR/bad-lit-suffixes.rs:8:5 | LL | "C"suffix | ^^^^^^^^^ invalid suffix `suffix` +error: unexpected expression: `"string"suffix` + --> $DIR/bad-lit-suffixes.rs:30:17 + | +LL | #[rustc_dummy = "string"suffix] + | ^^^^^^^^^^^^^^ + +error: unexpected expression: `"string"suffix` + --> $DIR/bad-lit-suffixes.rs:34:14 + | +LL | #[must_use = "string"suffix] + | ^^^^^^^^^^^^^^ + +error: suffixes on string literals are invalid + --> $DIR/bad-lit-suffixes.rs:38:15 + | +LL | #[link(name = "string"suffix)] + | ^^^^^^^^^^^^^^ invalid suffix `suffix` + +error: invalid suffix `suffix` for number literal + --> $DIR/bad-lit-suffixes.rs:42:41 + | +LL | #[rustc_layout_scalar_valid_range_start(0suffix)] + | ^^^^^^^ invalid suffix `suffix` + | + = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) + error: suffixes on string literals are invalid - --> $DIR/bad-lit-suffixes.rs:10:5 + --> $DIR/bad-lit-suffixes.rs:12:5 | LL | ""suffix; | ^^^^^^^^ invalid suffix `suffix` error: suffixes on byte string literals are invalid - --> $DIR/bad-lit-suffixes.rs:11:5 + --> $DIR/bad-lit-suffixes.rs:13:5 | LL | b""suffix; | ^^^^^^^^^ invalid suffix `suffix` error: suffixes on string literals are invalid - --> $DIR/bad-lit-suffixes.rs:12:5 + --> $DIR/bad-lit-suffixes.rs:14:5 | LL | r#""#suffix; | ^^^^^^^^^^^ invalid suffix `suffix` error: suffixes on byte string literals are invalid - --> $DIR/bad-lit-suffixes.rs:13:5 + --> $DIR/bad-lit-suffixes.rs:15:5 | LL | br#""#suffix; | ^^^^^^^^^^^^ invalid suffix `suffix` error: suffixes on char literals are invalid - --> $DIR/bad-lit-suffixes.rs:14:5 + --> $DIR/bad-lit-suffixes.rs:16:5 | LL | 'a'suffix; | ^^^^^^^^^ invalid suffix `suffix` error: suffixes on byte literals are invalid - --> $DIR/bad-lit-suffixes.rs:15:5 + --> $DIR/bad-lit-suffixes.rs:17:5 | LL | b'a'suffix; | ^^^^^^^^^^ invalid suffix `suffix` error: invalid width `1024` for integer literal - --> $DIR/bad-lit-suffixes.rs:17:5 + --> $DIR/bad-lit-suffixes.rs:19:5 | LL | 1234u1024; | ^^^^^^^^^ @@ -55,7 +81,7 @@ LL | 1234u1024; = help: valid widths are 8, 16, 32, 64 and 128 error: invalid width `1024` for integer literal - --> $DIR/bad-lit-suffixes.rs:18:5 + --> $DIR/bad-lit-suffixes.rs:20:5 | LL | 1234i1024; | ^^^^^^^^^ @@ -63,7 +89,7 @@ LL | 1234i1024; = help: valid widths are 8, 16, 32, 64 and 128 error: invalid width `1024` for float literal - --> $DIR/bad-lit-suffixes.rs:19:5 + --> $DIR/bad-lit-suffixes.rs:21:5 | LL | 1234f1024; | ^^^^^^^^^ @@ -71,7 +97,7 @@ LL | 1234f1024; = help: valid widths are 32 and 64 error: invalid width `1024` for float literal - --> $DIR/bad-lit-suffixes.rs:20:5 + --> $DIR/bad-lit-suffixes.rs:22:5 | LL | 1234.5f1024; | ^^^^^^^^^^^ @@ -79,7 +105,7 @@ LL | 1234.5f1024; = help: valid widths are 32 and 64 error: invalid suffix `suffix` for number literal - --> $DIR/bad-lit-suffixes.rs:22:5 + --> $DIR/bad-lit-suffixes.rs:24:5 | LL | 1234suffix; | ^^^^^^^^^^ invalid suffix `suffix` @@ -87,7 +113,7 @@ LL | 1234suffix; = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) error: invalid suffix `suffix` for number literal - --> $DIR/bad-lit-suffixes.rs:23:5 + --> $DIR/bad-lit-suffixes.rs:25:5 | LL | 0b101suffix; | ^^^^^^^^^^^ invalid suffix `suffix` @@ -95,7 +121,7 @@ LL | 0b101suffix; = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) error: invalid suffix `suffix` for float literal - --> $DIR/bad-lit-suffixes.rs:24:5 + --> $DIR/bad-lit-suffixes.rs:26:5 | LL | 1.0suffix; | ^^^^^^^^^ invalid suffix `suffix` @@ -103,12 +129,12 @@ LL | 1.0suffix; = help: valid suffixes are `f32` and `f64` error: invalid suffix `suffix` for float literal - --> $DIR/bad-lit-suffixes.rs:25:5 + --> $DIR/bad-lit-suffixes.rs:27:5 | LL | 1.0e10suffix; | ^^^^^^^^^^^^ invalid suffix `suffix` | = help: valid suffixes are `f32` and `f64` -error: aborting due to 16 previous errors +error: aborting due to 20 previous errors diff --git a/src/test/ui/parser/byte-literals.rs b/src/test/ui/parser/byte-literals.rs index 05a510b24..896dc1a1a 100644 --- a/src/test/ui/parser/byte-literals.rs +++ b/src/test/ui/parser/byte-literals.rs @@ -7,6 +7,6 @@ pub fn main() { b'\x0Z'; //~ ERROR invalid character in numeric character escape: `Z` b' '; //~ ERROR byte constant must be escaped b'''; //~ ERROR byte constant must be escaped - b'é'; //~ ERROR non-ASCII character in byte constant + b'é'; //~ ERROR non-ASCII character in byte literal b'a //~ ERROR unterminated byte constant [E0763] } diff --git a/src/test/ui/parser/byte-literals.stderr b/src/test/ui/parser/byte-literals.stderr index c3d000616..efa55ae05 100644 --- a/src/test/ui/parser/byte-literals.stderr +++ b/src/test/ui/parser/byte-literals.stderr @@ -32,11 +32,11 @@ error: byte constant must be escaped: `'` LL | b'''; | ^ help: escape the character: `\'` -error: non-ASCII character in byte constant +error: non-ASCII character in byte literal --> $DIR/byte-literals.rs:10:7 | LL | b'é'; - | ^ byte constant must be ASCII + | ^ must be ASCII | help: if you meant to use the unicode code point for 'é', use a \xHH escape | diff --git a/src/test/ui/parser/byte-string-literals.rs b/src/test/ui/parser/byte-string-literals.rs index b1f11024a..30a4f50c4 100644 --- a/src/test/ui/parser/byte-string-literals.rs +++ b/src/test/ui/parser/byte-string-literals.rs @@ -3,7 +3,7 @@ static FOO: &'static [u8] = b"\f"; //~ ERROR unknown byte escape pub fn main() { b"\f"; //~ ERROR unknown byte escape b"\x0Z"; //~ ERROR invalid character in numeric character escape: `Z` - b"é"; //~ ERROR non-ASCII character in byte constant - br##"é"##; //~ ERROR raw byte string must be ASCII + b"é"; //~ ERROR non-ASCII character in byte string literal + br##"é"##; //~ ERROR non-ASCII character in raw byte string literal b"a //~ ERROR unterminated double quote byte string } diff --git a/src/test/ui/parser/byte-string-literals.stderr b/src/test/ui/parser/byte-string-literals.stderr index 3b8b3692e..5b96cc3d1 100644 --- a/src/test/ui/parser/byte-string-literals.stderr +++ b/src/test/ui/parser/byte-string-literals.stderr @@ -20,18 +20,18 @@ error: invalid character in numeric character escape: `Z` LL | b"\x0Z"; | ^ invalid character in numeric character escape -error: non-ASCII character in byte constant +error: non-ASCII character in byte string literal --> $DIR/byte-string-literals.rs:6:7 | LL | b"é"; - | ^ byte constant must be ASCII + | ^ must be ASCII | help: if you meant to use the unicode code point for 'é', use a \xHH escape | LL | b"\xE9"; | ~~~~ -error: raw byte string must be ASCII +error: non-ASCII character in raw byte string literal --> $DIR/byte-string-literals.rs:7:10 | LL | br##"é"##; diff --git a/src/test/ui/parser/expr-as-stmt.fixed b/src/test/ui/parser/expr-as-stmt.fixed index 36709eea1..b06f62794 100644 --- a/src/test/ui/parser/expr-as-stmt.fixed +++ b/src/test/ui/parser/expr-as-stmt.fixed @@ -64,4 +64,16 @@ fn asteroids() -> impl FnOnce() -> bool { { foo(); } || { true } //~ ERROR E0308 } +// https://github.com/rust-lang/rust/issues/105179 +fn r#match() -> i32 { + (match () { () => 1 }) + match () { () => 1 } //~ ERROR expected expression, found `+` + //~^ ERROR mismatched types +} + +// https://github.com/rust-lang/rust/issues/102171 +fn r#unsafe() -> i32 { + (unsafe { 1 }) + unsafe { 1 } //~ ERROR expected expression, found `+` + //~^ ERROR mismatched types +} + fn main() {} diff --git a/src/test/ui/parser/expr-as-stmt.rs b/src/test/ui/parser/expr-as-stmt.rs index 92bb972b2..b39d2b886 100644 --- a/src/test/ui/parser/expr-as-stmt.rs +++ b/src/test/ui/parser/expr-as-stmt.rs @@ -64,4 +64,16 @@ fn asteroids() -> impl FnOnce() -> bool { { foo() } || { true } //~ ERROR E0308 } +// https://github.com/rust-lang/rust/issues/105179 +fn r#match() -> i32 { + match () { () => 1 } + match () { () => 1 } //~ ERROR expected expression, found `+` + //~^ ERROR mismatched types +} + +// https://github.com/rust-lang/rust/issues/102171 +fn r#unsafe() -> i32 { + unsafe { 1 } + unsafe { 1 } //~ ERROR expected expression, found `+` + //~^ ERROR mismatched types +} + fn main() {} diff --git a/src/test/ui/parser/expr-as-stmt.stderr b/src/test/ui/parser/expr-as-stmt.stderr index 6da4ac340..18c8b0b7c 100644 --- a/src/test/ui/parser/expr-as-stmt.stderr +++ b/src/test/ui/parser/expr-as-stmt.stderr @@ -55,6 +55,28 @@ help: parentheses are required to parse this as an expression LL | ({ true }) | { true } | + + +error: expected expression, found `+` + --> $DIR/expr-as-stmt.rs:69:26 + | +LL | match () { () => 1 } + match () { () => 1 } + | ^ expected expression + | +help: parentheses are required to parse this as an expression + | +LL | (match () { () => 1 }) + match () { () => 1 } + | + + + +error: expected expression, found `+` + --> $DIR/expr-as-stmt.rs:75:18 + | +LL | unsafe { 1 } + unsafe { 1 } + | ^ expected expression + | +help: parentheses are required to parse this as an expression + | +LL | (unsafe { 1 }) + unsafe { 1 } + | + + + error[E0308]: mismatched types --> $DIR/expr-as-stmt.rs:64:7 | @@ -201,7 +223,26 @@ help: parentheses are required to parse this as an expression LL | ({ true }) || { true } | + + -error: aborting due to 18 previous errors +error[E0308]: mismatched types + --> $DIR/expr-as-stmt.rs:69:5 + | +LL | match () { () => 1 } + match () { () => 1 } + | ^^^^^^^^^^^^^^^^^^^^- help: consider using a semicolon here + | | + | expected `()`, found integer + +error[E0308]: mismatched types + --> $DIR/expr-as-stmt.rs:75:14 + | +LL | unsafe { 1 } + unsafe { 1 } + | ^ expected `()`, found integer + | +help: you might have meant to return this value + | +LL | unsafe { return 1; } + unsafe { 1 } + | ++++++ + + +error: aborting due to 22 previous errors Some errors have detailed explanations: E0308, E0600, E0614. For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/parser/issue-101477-enum.stderr b/src/test/ui/parser/issue-101477-enum.stderr index bffc881bd..1edca391e 100644 --- a/src/test/ui/parser/issue-101477-enum.stderr +++ b/src/test/ui/parser/issue-101477-enum.stderr @@ -3,6 +3,8 @@ error: unexpected `==` | LL | B == 2 | ^^ help: try using `=` instead + | + = help: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }` error: expected item, found `==` --> $DIR/issue-101477-enum.rs:6:7 diff --git a/src/test/ui/parser/issue-102806.rs b/src/test/ui/parser/issue-102806.rs new file mode 100644 index 000000000..ba297bdc9 --- /dev/null +++ b/src/test/ui/parser/issue-102806.rs @@ -0,0 +1,25 @@ +#![allow(dead_code)] + +#[derive(Default)] +struct V3 { + x: f32, + y: f32, + z: f32, +} + +fn pz(v: V3) { + let _ = V3 { z: 0.0, ...v}; + //~^ ERROR expected `..` + + let _ = V3 { z: 0.0, ...Default::default() }; + //~^ ERROR expected `..` + + let _ = V3 { z: 0.0, ... }; + //~^ expected identifier + //~| ERROR missing fields `x` and `y` in initializer of `V3` + + let V3 { z: val, ... } = v; + //~^ ERROR expected field pattern +} + +fn main() {} diff --git a/src/test/ui/parser/issue-102806.stderr b/src/test/ui/parser/issue-102806.stderr new file mode 100644 index 000000000..6872b8bc0 --- /dev/null +++ b/src/test/ui/parser/issue-102806.stderr @@ -0,0 +1,45 @@ +error: expected `..`, found `...` + --> $DIR/issue-102806.rs:11:26 + | +LL | let _ = V3 { z: 0.0, ...v}; + | ^^^ + | +help: use `..` to fill in the rest of the fields + | +LL | let _ = V3 { z: 0.0, ..v}; + | ~~ + +error: expected `..`, found `...` + --> $DIR/issue-102806.rs:14:26 + | +LL | let _ = V3 { z: 0.0, ...Default::default() }; + | ^^^ + | +help: use `..` to fill in the rest of the fields + | +LL | let _ = V3 { z: 0.0, ..Default::default() }; + | ~~ + +error: expected identifier, found `...` + --> $DIR/issue-102806.rs:17:26 + | +LL | let _ = V3 { z: 0.0, ... }; + | -- ^^^ expected identifier + | | + | while parsing this struct + +error: expected field pattern, found `...` + --> $DIR/issue-102806.rs:21:22 + | +LL | let V3 { z: val, ... } = v; + | ^^^ help: to omit remaining fields, use one fewer `.`: `..` + +error[E0063]: missing fields `x` and `y` in initializer of `V3` + --> $DIR/issue-102806.rs:17:13 + | +LL | let _ = V3 { z: 0.0, ... }; + | ^^ missing `x` and `y` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0063`. diff --git a/src/test/ui/parser/issue-103381.fixed b/src/test/ui/parser/issue-103381.fixed new file mode 100644 index 000000000..6a9fb9910 --- /dev/null +++ b/src/test/ui/parser/issue-103381.fixed @@ -0,0 +1,59 @@ +// run-rustfix + +#![feature(let_chains)] +#![allow(unused_variables)] +#![allow(dead_code)] +#![allow(irrefutable_let_patterns)] + +fn err_some(b: bool, x: Option<u32>) { + if b && let Some(x) = x {} + //~^ ERROR unexpected `if` in the condition expression +} + +fn err_none(b: bool, x: Option<u32>) { + if b && let None = x {} + //~^ ERROR unexpected `if` in the condition expression +} + +fn err_bool_1() { + if true && true { true } else { false }; + //~^ ERROR unexpected `if` in the condition expression +} + +fn err_bool_2() { + if true && false { true } else { false }; + //~^ ERROR unexpected `if` in the condition expression +} + +fn should_ok_1() { + if true && if let x = 1 { true } else { true } {} +} + +fn should_ok_2() { + if true && if let 1 = 1 { true } else { true } {} +} + +fn should_ok_3() { + if true && if true { true } else { false } {} +} + +fn shoule_match_ok() { + #[cfg(feature = "full")] + { + let a = 1; + let b = 2; + if match a { + 1 if b == 1 => true, + _ => false, + } && if a > 1 { true } else { false } + { + true + } + } +} + +fn should_ok_in_nested() { + if true && if true { true } else { false } { true } else { false }; +} + +fn main() {} diff --git a/src/test/ui/parser/issue-103381.rs b/src/test/ui/parser/issue-103381.rs new file mode 100644 index 000000000..bf79e1010 --- /dev/null +++ b/src/test/ui/parser/issue-103381.rs @@ -0,0 +1,59 @@ +// run-rustfix + +#![feature(let_chains)] +#![allow(unused_variables)] +#![allow(dead_code)] +#![allow(irrefutable_let_patterns)] + +fn err_some(b: bool, x: Option<u32>) { + if b && if let Some(x) = x {} + //~^ ERROR unexpected `if` in the condition expression +} + +fn err_none(b: bool, x: Option<u32>) { + if b && if let None = x {} + //~^ ERROR unexpected `if` in the condition expression +} + +fn err_bool_1() { + if true && if true { true } else { false }; + //~^ ERROR unexpected `if` in the condition expression +} + +fn err_bool_2() { + if true && if false { true } else { false }; + //~^ ERROR unexpected `if` in the condition expression +} + +fn should_ok_1() { + if true && if let x = 1 { true } else { true } {} +} + +fn should_ok_2() { + if true && if let 1 = 1 { true } else { true } {} +} + +fn should_ok_3() { + if true && if true { true } else { false } {} +} + +fn shoule_match_ok() { + #[cfg(feature = "full")] + { + let a = 1; + let b = 2; + if match a { + 1 if b == 1 => true, + _ => false, + } && if a > 1 { true } else { false } + { + true + } + } +} + +fn should_ok_in_nested() { + if true && if true { true } else { false } { true } else { false }; +} + +fn main() {} diff --git a/src/test/ui/parser/issue-103381.stderr b/src/test/ui/parser/issue-103381.stderr new file mode 100644 index 000000000..85fcc18e7 --- /dev/null +++ b/src/test/ui/parser/issue-103381.stderr @@ -0,0 +1,50 @@ +error: unexpected `if` in the condition expression + --> $DIR/issue-103381.rs:9:12 + | +LL | if b && if let Some(x) = x {} + | ^^^^ + | +help: remove the `if` + | +LL - if b && if let Some(x) = x {} +LL + if b && let Some(x) = x {} + | + +error: unexpected `if` in the condition expression + --> $DIR/issue-103381.rs:14:12 + | +LL | if b && if let None = x {} + | ^^^^ + | +help: remove the `if` + | +LL - if b && if let None = x {} +LL + if b && let None = x {} + | + +error: unexpected `if` in the condition expression + --> $DIR/issue-103381.rs:19:15 + | +LL | if true && if true { true } else { false }; + | ^^^^ + | +help: remove the `if` + | +LL - if true && if true { true } else { false }; +LL + if true && true { true } else { false }; + | + +error: unexpected `if` in the condition expression + --> $DIR/issue-103381.rs:24:15 + | +LL | if true && if false { true } else { false }; + | ^^^^ + | +help: remove the `if` + | +LL - if true && if false { true } else { false }; +LL + if true && false { true } else { false }; + | + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/parser/issue-103451.rs b/src/test/ui/parser/issue-103451.rs new file mode 100644 index 000000000..1fdb00148 --- /dev/null +++ b/src/test/ui/parser/issue-103451.rs @@ -0,0 +1,5 @@ +// error-pattern: this file contains an unclosed delimiter +// error-pattern: expected value, found struct `R` +struct R { } +struct S { + x: [u8; R diff --git a/src/test/ui/parser/issue-103451.stderr b/src/test/ui/parser/issue-103451.stderr new file mode 100644 index 000000000..eb3c92fb4 --- /dev/null +++ b/src/test/ui/parser/issue-103451.stderr @@ -0,0 +1,32 @@ +error: this file contains an unclosed delimiter + --> $DIR/issue-103451.rs:5:15 + | +LL | struct S { + | - unclosed delimiter +LL | x: [u8; R + | - ^ + | | + | unclosed delimiter + +error: this file contains an unclosed delimiter + --> $DIR/issue-103451.rs:5:15 + | +LL | struct S { + | - unclosed delimiter +LL | x: [u8; R + | - ^ + | | + | unclosed delimiter + +error[E0423]: expected value, found struct `R` + --> $DIR/issue-103451.rs:5:13 + | +LL | struct R { } + | ------------ `R` defined here +LL | struct S { +LL | x: [u8; R + | ^ help: use struct literal syntax instead: `R {}` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0423`. diff --git a/src/test/ui/parser/issue-103748-ICE-wrong-braces.rs b/src/test/ui/parser/issue-103748-ICE-wrong-braces.rs new file mode 100644 index 000000000..8012cb652 --- /dev/null +++ b/src/test/ui/parser/issue-103748-ICE-wrong-braces.rs @@ -0,0 +1,8 @@ +#![crate_type = "lib"] + +struct Apple((Apple, Option(Banana ? Citron))); +//~^ ERROR invalid `?` in type +//~| ERROR expected one of `)` or `,`, found `Citron` +//~| ERROR cannot find type `Citron` in this scope [E0412] +//~| ERROR parenthesized type parameters may only be used with a `Fn` trait [E0214] +//~| ERROR recursive type `Apple` has infinite size [E0072] diff --git a/src/test/ui/parser/issue-103748-ICE-wrong-braces.stderr b/src/test/ui/parser/issue-103748-ICE-wrong-braces.stderr new file mode 100644 index 000000000..b0d8b03ae --- /dev/null +++ b/src/test/ui/parser/issue-103748-ICE-wrong-braces.stderr @@ -0,0 +1,51 @@ +error: invalid `?` in type + --> $DIR/issue-103748-ICE-wrong-braces.rs:3:36 + | +LL | struct Apple((Apple, Option(Banana ? Citron))); + | ^ `?` is only allowed on expressions, not types + | +help: if you meant to express that the type might not contain a value, use the `Option` wrapper type + | +LL | struct Apple((Apple, Option(Option<Banana > Citron))); + | +++++++ ~ + +error: expected one of `)` or `,`, found `Citron` + --> $DIR/issue-103748-ICE-wrong-braces.rs:3:38 + | +LL | struct Apple((Apple, Option(Banana ? Citron))); + | -^^^^^^ expected one of `)` or `,` + | | + | help: missing `,` + +error[E0412]: cannot find type `Citron` in this scope + --> $DIR/issue-103748-ICE-wrong-braces.rs:3:38 + | +LL | struct Apple((Apple, Option(Banana ? Citron))); + | ^^^^^^ not found in this scope + +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-103748-ICE-wrong-braces.rs:3:22 + | +LL | struct Apple((Apple, Option(Banana ? Citron))); + | ^^^^^^^^^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses + | +help: use angle brackets instead + | +LL | struct Apple((Apple, Option<Banana ? Citron>)); + | ~ ~ + +error[E0072]: recursive type `Apple` has infinite size + --> $DIR/issue-103748-ICE-wrong-braces.rs:3:1 + | +LL | struct Apple((Apple, Option(Banana ? Citron))); + | ^^^^^^^^^^^^ ----- recursive without indirection + | +help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle + | +LL | struct Apple((Box<Apple>, Option(Banana ? Citron))); + | ++++ + + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0072, E0214, E0412. +For more information about an error, try `rustc --explain E0072`. diff --git a/src/test/ui/parser/issue-103869.rs b/src/test/ui/parser/issue-103869.rs new file mode 100644 index 000000000..28c442bdd --- /dev/null +++ b/src/test/ui/parser/issue-103869.rs @@ -0,0 +1,9 @@ +enum VecOrMap{ + vec: Vec<usize>, + //~^ ERROR expected one of `(`, `,`, `=`, `{`, or `}`, found `:` + //~| HELP: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }` + //~| ERROR expected item, found `:` + map: HashMap<String,usize> +} + +fn main() {} diff --git a/src/test/ui/parser/issue-103869.stderr b/src/test/ui/parser/issue-103869.stderr new file mode 100644 index 000000000..0b8cd919a --- /dev/null +++ b/src/test/ui/parser/issue-103869.stderr @@ -0,0 +1,16 @@ +error: expected one of `(`, `,`, `=`, `{`, or `}`, found `:` + --> $DIR/issue-103869.rs:2:8 + | +LL | vec: Vec<usize>, + | ^ expected one of `(`, `,`, `=`, `{`, or `}` + | + = help: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }` + +error: expected item, found `:` + --> $DIR/issue-103869.rs:2:8 + | +LL | vec: Vec<usize>, + | ^ expected item + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/parser/issue-104620.rs b/src/test/ui/parser/issue-104620.rs new file mode 100644 index 000000000..f49476c44 --- /dev/null +++ b/src/test/ui/parser/issue-104620.rs @@ -0,0 +1,4 @@ +#![feature(rustc_attrs)] + +#![rustc_dummy=5z] //~ ERROR unexpected expression: `5z` +fn main() {} diff --git a/src/test/ui/parser/issue-104620.stderr b/src/test/ui/parser/issue-104620.stderr new file mode 100644 index 000000000..d06a6b255 --- /dev/null +++ b/src/test/ui/parser/issue-104620.stderr @@ -0,0 +1,8 @@ +error: unexpected expression: `5z` + --> $DIR/issue-104620.rs:3:16 + | +LL | #![rustc_dummy=5z] + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issues/issue-104088.rs b/src/test/ui/parser/issues/issue-104088.rs new file mode 100644 index 000000000..5f794fe2d --- /dev/null +++ b/src/test/ui/parser/issues/issue-104088.rs @@ -0,0 +1,26 @@ +fn test() { + if let 123 = 123 { println!("yes"); } +} + +fn test_2() { + let 1x = 123; + //~^ ERROR expected identifier, found number literal +} + +fn test_3() { + let 2x: i32 = 123; + //~^ ERROR expected identifier, found number literal +} + +fn test_4() { + if let 2e1 = 123 { + //~^ ERROR mismatched types + } +} + +fn test_5() { + let 23name = 123; + //~^ ERROR expected identifier, found number literal +} + +fn main() {} diff --git a/src/test/ui/parser/issues/issue-104088.stderr b/src/test/ui/parser/issues/issue-104088.stderr new file mode 100644 index 000000000..ff4b4bdb6 --- /dev/null +++ b/src/test/ui/parser/issues/issue-104088.stderr @@ -0,0 +1,29 @@ +error: expected identifier, found number literal + --> $DIR/issue-104088.rs:6:9 + | +LL | let 1x = 123; + | ^^ identifiers cannot start with a number + +error: expected identifier, found number literal + --> $DIR/issue-104088.rs:11:9 + | +LL | let 2x: i32 = 123; + | ^^ identifiers cannot start with a number + +error: expected identifier, found number literal + --> $DIR/issue-104088.rs:22:9 + | +LL | let 23name = 123; + | ^^^^^^ identifiers cannot start with a number + +error[E0308]: mismatched types + --> $DIR/issue-104088.rs:16:12 + | +LL | if let 2e1 = 123 { + | ^^^ --- this expression has type `{integer}` + | | + | expected integer, found floating-point number + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/parser/item-kw-case-mismatch.fixed b/src/test/ui/parser/item-kw-case-mismatch.fixed new file mode 100644 index 000000000..1794268f2 --- /dev/null +++ b/src/test/ui/parser/item-kw-case-mismatch.fixed @@ -0,0 +1,34 @@ +// run-rustfix +// edition:2018 +#![allow(unused_imports)] + +fn main() {} + +use std::ptr::read; //~ ERROR keyword `use` is written in a wrong case +use std::ptr::write; //~ ERROR keyword `use` is written in a wrong case + +async fn _a() {} +//~^ ERROR keyword `fn` is written in a wrong case + +fn _b() {} +//~^ ERROR keyword `fn` is written in a wrong case + +async fn _c() {} +//~^ ERROR keyword `async` is written in a wrong case +//~| ERROR keyword `fn` is written in a wrong case + +async fn _d() {} +//~^ ERROR keyword `async` is written in a wrong case + +const unsafe fn _e() {} +//~^ ERROR keyword `const` is written in a wrong case +//~| ERROR keyword `unsafe` is written in a wrong case +//~| ERROR keyword `fn` is written in a wrong case + +unsafe extern fn _f() {} +//~^ ERROR keyword `unsafe` is written in a wrong case +//~| ERROR keyword `extern` is written in a wrong case + +extern "C" fn _g() {} +//~^ ERROR keyword `extern` is written in a wrong case +//~| ERROR keyword `fn` is written in a wrong case diff --git a/src/test/ui/parser/item-kw-case-mismatch.rs b/src/test/ui/parser/item-kw-case-mismatch.rs new file mode 100644 index 000000000..ac8390efd --- /dev/null +++ b/src/test/ui/parser/item-kw-case-mismatch.rs @@ -0,0 +1,34 @@ +// run-rustfix +// edition:2018 +#![allow(unused_imports)] + +fn main() {} + +Use std::ptr::read; //~ ERROR keyword `use` is written in a wrong case +USE std::ptr::write; //~ ERROR keyword `use` is written in a wrong case + +async Fn _a() {} +//~^ ERROR keyword `fn` is written in a wrong case + +Fn _b() {} +//~^ ERROR keyword `fn` is written in a wrong case + +aSYNC fN _c() {} +//~^ ERROR keyword `async` is written in a wrong case +//~| ERROR keyword `fn` is written in a wrong case + +Async fn _d() {} +//~^ ERROR keyword `async` is written in a wrong case + +CONST UNSAFE FN _e() {} +//~^ ERROR keyword `const` is written in a wrong case +//~| ERROR keyword `unsafe` is written in a wrong case +//~| ERROR keyword `fn` is written in a wrong case + +unSAFE EXTern fn _f() {} +//~^ ERROR keyword `unsafe` is written in a wrong case +//~| ERROR keyword `extern` is written in a wrong case + +EXTERN "C" FN _g() {} +//~^ ERROR keyword `extern` is written in a wrong case +//~| ERROR keyword `fn` is written in a wrong case diff --git a/src/test/ui/parser/item-kw-case-mismatch.stderr b/src/test/ui/parser/item-kw-case-mismatch.stderr new file mode 100644 index 000000000..e66dae825 --- /dev/null +++ b/src/test/ui/parser/item-kw-case-mismatch.stderr @@ -0,0 +1,86 @@ +error: keyword `use` is written in a wrong case + --> $DIR/item-kw-case-mismatch.rs:7:1 + | +LL | Use std::ptr::read; + | ^^^ help: write it in the correct case (notice the capitalization): `use` + +error: keyword `use` is written in a wrong case + --> $DIR/item-kw-case-mismatch.rs:8:1 + | +LL | USE std::ptr::write; + | ^^^ help: write it in the correct case: `use` + +error: keyword `fn` is written in a wrong case + --> $DIR/item-kw-case-mismatch.rs:10:7 + | +LL | async Fn _a() {} + | ^^ help: write it in the correct case (notice the capitalization): `fn` + +error: keyword `fn` is written in a wrong case + --> $DIR/item-kw-case-mismatch.rs:13:1 + | +LL | Fn _b() {} + | ^^ help: write it in the correct case (notice the capitalization): `fn` + +error: keyword `async` is written in a wrong case + --> $DIR/item-kw-case-mismatch.rs:16:1 + | +LL | aSYNC fN _c() {} + | ^^^^^ help: write it in the correct case: `async` + +error: keyword `fn` is written in a wrong case + --> $DIR/item-kw-case-mismatch.rs:16:7 + | +LL | aSYNC fN _c() {} + | ^^ help: write it in the correct case: `fn` + +error: keyword `async` is written in a wrong case + --> $DIR/item-kw-case-mismatch.rs:20:1 + | +LL | Async fn _d() {} + | ^^^^^ help: write it in the correct case: `async` + +error: keyword `const` is written in a wrong case + --> $DIR/item-kw-case-mismatch.rs:23:1 + | +LL | CONST UNSAFE FN _e() {} + | ^^^^^ help: write it in the correct case: `const` + +error: keyword `unsafe` is written in a wrong case + --> $DIR/item-kw-case-mismatch.rs:23:7 + | +LL | CONST UNSAFE FN _e() {} + | ^^^^^^ help: write it in the correct case: `unsafe` + +error: keyword `fn` is written in a wrong case + --> $DIR/item-kw-case-mismatch.rs:23:14 + | +LL | CONST UNSAFE FN _e() {} + | ^^ help: write it in the correct case: `fn` + +error: keyword `unsafe` is written in a wrong case + --> $DIR/item-kw-case-mismatch.rs:28:1 + | +LL | unSAFE EXTern fn _f() {} + | ^^^^^^ help: write it in the correct case: `unsafe` + +error: keyword `extern` is written in a wrong case + --> $DIR/item-kw-case-mismatch.rs:28:8 + | +LL | unSAFE EXTern fn _f() {} + | ^^^^^^ help: write it in the correct case: `extern` + +error: keyword `extern` is written in a wrong case + --> $DIR/item-kw-case-mismatch.rs:32:1 + | +LL | EXTERN "C" FN _g() {} + | ^^^^^^ help: write it in the correct case: `extern` + +error: keyword `fn` is written in a wrong case + --> $DIR/item-kw-case-mismatch.rs:32:12 + | +LL | EXTERN "C" FN _g() {} + | ^^ help: write it in the correct case: `fn` + +error: aborting due to 14 previous errors + diff --git a/src/test/ui/parser/kw-in-trait-bounds.stderr b/src/test/ui/parser/kw-in-trait-bounds.stderr index 28196c7ce..546ad84ee 100644 --- a/src/test/ui/parser/kw-in-trait-bounds.stderr +++ b/src/test/ui/parser/kw-in-trait-bounds.stderr @@ -94,8 +94,8 @@ LL | fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn()) | ::: $SRC_DIR/core/src/ops/function.rs:LL:COL | -LL | pub trait Fn<Args>: FnMut<Args> { - | ------------------------------- similarly named trait `Fn` defined here +LL | pub trait Fn<Args: Tuple>: FnMut<Args> { + | -------------------------------------- similarly named trait `Fn` defined here error[E0405]: cannot find trait `r#fn` in this scope --> $DIR/kw-in-trait-bounds.rs:17:4 @@ -105,8 +105,8 @@ LL | G: fn(), | ::: $SRC_DIR/core/src/ops/function.rs:LL:COL | -LL | pub trait Fn<Args>: FnMut<Args> { - | ------------------------------- similarly named trait `Fn` defined here +LL | pub trait Fn<Args: Tuple>: FnMut<Args> { + | -------------------------------------- similarly named trait `Fn` defined here error[E0405]: cannot find trait `r#fn` in this scope --> $DIR/kw-in-trait-bounds.rs:3:27 @@ -116,8 +116,8 @@ LL | fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn()) | ::: $SRC_DIR/core/src/ops/function.rs:LL:COL | -LL | pub trait Fn<Args>: FnMut<Args> { - | ------------------------------- similarly named trait `Fn` defined here +LL | pub trait Fn<Args: Tuple>: FnMut<Args> { + | -------------------------------------- similarly named trait `Fn` defined here error[E0405]: cannot find trait `r#fn` in this scope --> $DIR/kw-in-trait-bounds.rs:3:41 @@ -127,8 +127,8 @@ LL | fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn()) | ::: $SRC_DIR/core/src/ops/function.rs:LL:COL | -LL | pub trait Fn<Args>: FnMut<Args> { - | ------------------------------- similarly named trait `Fn` defined here +LL | pub trait Fn<Args: Tuple>: FnMut<Args> { + | -------------------------------------- similarly named trait `Fn` defined here error[E0405]: cannot find trait `r#struct` in this scope --> $DIR/kw-in-trait-bounds.rs:24:10 diff --git a/src/test/ui/parser/macro/issue-37113.stderr b/src/test/ui/parser/macro/issue-37113.stderr index b1f8674fb..da9e743a0 100644 --- a/src/test/ui/parser/macro/issue-37113.stderr +++ b/src/test/ui/parser/macro/issue-37113.stderr @@ -9,6 +9,7 @@ LL | $( $t, )* LL | test_macro!(String,); | -------------------- in this macro invocation | + = help: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }` = note: this error originates in the macro `test_macro` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/parser/macro/macro-doc-comments-1.stderr b/src/test/ui/parser/macro/macro-doc-comments-1.stderr index 0ebf3d52b..eaeb62d2c 100644 --- a/src/test/ui/parser/macro/macro-doc-comments-1.stderr +++ b/src/test/ui/parser/macro/macro-doc-comments-1.stderr @@ -9,6 +9,12 @@ LL | //! Inner | | | no rules expected this token in macro call | inner doc comments expand to `#![doc = "..."]`, which is what this macro attempted to match + | +note: while trying to match `[` + --> $DIR/macro-doc-comments-1.rs:2:7 + | +LL | (#[$outer:meta]) => () + | ^ error: aborting due to previous error diff --git a/src/test/ui/parser/macro/macro-doc-comments-2.stderr b/src/test/ui/parser/macro/macro-doc-comments-2.stderr index 346d86586..1dcd95f6f 100644 --- a/src/test/ui/parser/macro/macro-doc-comments-2.stderr +++ b/src/test/ui/parser/macro/macro-doc-comments-2.stderr @@ -9,6 +9,12 @@ LL | /// Outer | | | no rules expected this token in macro call | outer doc comments expand to `#[doc = "..."]`, which is what this macro attempted to match + | +note: while trying to match `!` + --> $DIR/macro-doc-comments-2.rs:2:7 + | +LL | (#![$inner:meta]) => () + | ^ error: aborting due to previous error diff --git a/src/test/ui/parser/raw/raw-byte-string-literals.rs b/src/test/ui/parser/raw/raw-byte-string-literals.rs index 163c8ac66..1b859fee5 100644 --- a/src/test/ui/parser/raw/raw-byte-string-literals.rs +++ b/src/test/ui/parser/raw/raw-byte-string-literals.rs @@ -2,6 +2,6 @@ pub fn main() { br"a
"; //~ ERROR bare CR not allowed in raw string - br"é"; //~ ERROR raw byte string must be ASCII + br"é"; //~ ERROR non-ASCII character in raw byte string literal br##~"a"~##; //~ ERROR only `#` is allowed in raw string delimitation } diff --git a/src/test/ui/parser/raw/raw-byte-string-literals.stderr b/src/test/ui/parser/raw/raw-byte-string-literals.stderr index cfc877104..a2f27d1ed 100644 --- a/src/test/ui/parser/raw/raw-byte-string-literals.stderr +++ b/src/test/ui/parser/raw/raw-byte-string-literals.stderr @@ -4,7 +4,7 @@ error: bare CR not allowed in raw string LL | br"a
"; | ^ -error: raw byte string must be ASCII +error: non-ASCII character in raw byte string literal --> $DIR/raw-byte-string-literals.rs:5:8 | LL | br"é"; diff --git a/src/test/ui/parser/recover-fn-ptr-with-generics.rs b/src/test/ui/parser/recover-fn-ptr-with-generics.rs new file mode 100644 index 000000000..31de418be --- /dev/null +++ b/src/test/ui/parser/recover-fn-ptr-with-generics.rs @@ -0,0 +1,31 @@ +fn main() { + type Predicate = fn<'a>(&'a str) -> bool; + //~^ ERROR function pointer types may not have generic parameters + + type Identity = fn<T>(T) -> T; + //~^ ERROR function pointer types may not have generic parameters + //~| ERROR cannot find type `T` in this scope + //~| ERROR cannot find type `T` in this scope + + let _: fn<const N: usize, 'e, Q, 'f>(); + //~^ ERROR function pointer types may not have generic parameters + + let _: for<'outer> fn<'inner>(); + //~^ ERROR function pointer types may not have generic parameters + + let _: for<> fn<'r>(); + //~^ ERROR function pointer types may not have generic parameters + + type Hmm = fn<>(); + //~^ ERROR function pointer types may not have generic parameters + + let _: extern fn<'a: 'static>(); + //~^ ERROR function pointer types may not have generic parameters + //~| ERROR lifetime bounds cannot be used in this context + + let _: for<'any> extern "C" fn<'u>(); + //~^ ERROR function pointer types may not have generic parameters + + type QuiteBroken = fn<const>(); + //~^ ERROR expected identifier, found `>` +} diff --git a/src/test/ui/parser/recover-fn-ptr-with-generics.stderr b/src/test/ui/parser/recover-fn-ptr-with-generics.stderr new file mode 100644 index 000000000..1da9c1857 --- /dev/null +++ b/src/test/ui/parser/recover-fn-ptr-with-generics.stderr @@ -0,0 +1,111 @@ +error: function pointer types may not have generic parameters + --> $DIR/recover-fn-ptr-with-generics.rs:2:24 + | +LL | type Predicate = fn<'a>(&'a str) -> bool; + | ^^^^ + | +help: consider moving the lifetime parameter to a `for` parameter list + | +LL - type Predicate = fn<'a>(&'a str) -> bool; +LL + type Predicate = for<'a> fn(&'a str) -> bool; + | + +error: function pointer types may not have generic parameters + --> $DIR/recover-fn-ptr-with-generics.rs:5:23 + | +LL | type Identity = fn<T>(T) -> T; + | ^^^ + +error: function pointer types may not have generic parameters + --> $DIR/recover-fn-ptr-with-generics.rs:10:14 + | +LL | let _: fn<const N: usize, 'e, Q, 'f>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: consider moving the lifetime parameters to a `for` parameter list + | +LL - let _: fn<const N: usize, 'e, Q, 'f>(); +LL + let _: for<'e, 'f> fn(); + | + +error: function pointer types may not have generic parameters + --> $DIR/recover-fn-ptr-with-generics.rs:13:26 + | +LL | let _: for<'outer> fn<'inner>(); + | ^^^^^^^^ + | +help: consider moving the lifetime parameter to the `for` parameter list + | +LL - let _: for<'outer> fn<'inner>(); +LL + let _: for<'outer, 'inner> fn(); + | + +error: function pointer types may not have generic parameters + --> $DIR/recover-fn-ptr-with-generics.rs:16:20 + | +LL | let _: for<> fn<'r>(); + | ^^^^ + | +help: consider moving the lifetime parameter to the `for` parameter list + | +LL - let _: for<> fn<'r>(); +LL + let _: for<'r> fn(); + | + +error: function pointer types may not have generic parameters + --> $DIR/recover-fn-ptr-with-generics.rs:19:18 + | +LL | type Hmm = fn<>(); + | ^^ + +error: function pointer types may not have generic parameters + --> $DIR/recover-fn-ptr-with-generics.rs:22:21 + | +LL | let _: extern fn<'a: 'static>(); + | ^^^^^^^^^^^^^ + | +help: consider moving the lifetime parameter to a `for` parameter list + | +LL - let _: extern fn<'a: 'static>(); +LL + let _: for<'a> extern fn(); + | + +error: function pointer types may not have generic parameters + --> $DIR/recover-fn-ptr-with-generics.rs:26:35 + | +LL | let _: for<'any> extern "C" fn<'u>(); + | ^^^^ + | +help: consider moving the lifetime parameter to the `for` parameter list + | +LL - let _: for<'any> extern "C" fn<'u>(); +LL + let _: for<'any, 'u> extern "C" fn(); + | + +error: expected identifier, found `>` + --> $DIR/recover-fn-ptr-with-generics.rs:29:32 + | +LL | type QuiteBroken = fn<const>(); + | ^ expected identifier + +error: lifetime bounds cannot be used in this context + --> $DIR/recover-fn-ptr-with-generics.rs:22:26 + | +LL | let _: extern fn<'a: 'static>(); + | ^^^^^^^ + +error[E0412]: cannot find type `T` in this scope + --> $DIR/recover-fn-ptr-with-generics.rs:5:27 + | +LL | type Identity = fn<T>(T) -> T; + | ^ not found in this scope + +error[E0412]: cannot find type `T` in this scope + --> $DIR/recover-fn-ptr-with-generics.rs:5:33 + | +LL | type Identity = fn<T>(T) -> T; + | ^ not found in this scope + +error: aborting due to 12 previous errors + +For more information about this error, try `rustc --explain E0412`. diff --git a/src/test/ui/parser/recover-from-bad-variant.stderr b/src/test/ui/parser/recover-from-bad-variant.stderr index 483312c16..04968bbdf 100644 --- a/src/test/ui/parser/recover-from-bad-variant.stderr +++ b/src/test/ui/parser/recover-from-bad-variant.stderr @@ -14,14 +14,11 @@ LL - let x = Enum::Foo(a: 3, b: 4); LL + let x = Enum::Foo(3, 4); | -error[E0532]: expected tuple struct or tuple variant, found struct variant `Enum::Foo` +error[E0164]: expected tuple struct or tuple variant, found struct variant `Enum::Foo` --> $DIR/recover-from-bad-variant.rs:10:9 | -LL | Foo { a: usize, b: usize }, - | -------------------------- `Enum::Foo` defined here -... LL | Enum::Foo(a, b) => {} - | ^^^^^^^^^^^^^^^ help: use struct pattern syntax instead: `Enum::Foo { a, b }` + | ^^^^^^^^^^^^^^^ not a tuple struct or tuple variant error[E0769]: tuple variant `Enum::Bar` written as struct variant --> $DIR/recover-from-bad-variant.rs:12:9 @@ -36,5 +33,5 @@ LL | Enum::Bar(a, b) => {} error: aborting due to 3 previous errors -Some errors have detailed explanations: E0532, E0769. -For more information about an error, try `rustc --explain E0532`. +Some errors have detailed explanations: E0164, E0769. +For more information about an error, try `rustc --explain E0164`. diff --git a/src/test/ui/slowparse-bstring.rs b/src/test/ui/parser/slowparse-bstring.rs index f3a6a6683..f3a6a6683 100644 --- a/src/test/ui/slowparse-bstring.rs +++ b/src/test/ui/parser/slowparse-bstring.rs diff --git a/src/test/ui/slowparse-string.rs b/src/test/ui/parser/slowparse-string.rs index 6ebc61dae..6ebc61dae 100644 --- a/src/test/ui/slowparse-string.rs +++ b/src/test/ui/parser/slowparse-string.rs diff --git a/src/test/ui/parser/struct-literal-variant-in-if.stderr b/src/test/ui/parser/struct-literal-variant-in-if.stderr index 4cffbe433..9f0c0074d 100644 --- a/src/test/ui/parser/struct-literal-variant-in-if.stderr +++ b/src/test/ui/parser/struct-literal-variant-in-if.stderr @@ -42,16 +42,11 @@ help: surround the struct literal with parentheses LL | if x == (E::K { field: "" }) {} | + + -error[E0423]: expected value, found struct variant `E::V` +error[E0533]: expected value, found struct variant `E::V` --> $DIR/struct-literal-variant-in-if.rs:10:13 | LL | if x == E::V { field } {} | ^^^^ not a value - | -help: surround the struct literal with parentheses - | -LL | if x == (E::V { field }) {} - | + + error[E0308]: mismatched types --> $DIR/struct-literal-variant-in-if.rs:10:20 @@ -72,5 +67,5 @@ LL | let y: usize = (); error: aborting due to 7 previous errors -Some errors have detailed explanations: E0308, E0423. +Some errors have detailed explanations: E0308, E0533. For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/parser/underscore-suffix-for-string.rs b/src/test/ui/parser/underscore-suffix-for-string.rs index 2e0ebe2cf..bd260752e 100644 --- a/src/test/ui/parser/underscore-suffix-for-string.rs +++ b/src/test/ui/parser/underscore-suffix-for-string.rs @@ -1,8 +1,17 @@ -// check-pass +macro_rules! sink { + ($tt:tt) => {()} +} fn main() { let _ = "Foo"_; - //~^ WARNING underscore literal suffix is not allowed - //~| WARNING this was previously accepted - //~| NOTE issue #42326 + //~^ ERROR underscore literal suffix is not allowed + + // This is ok, because `__` is a valid identifier and the macro consumes it + // before proper parsing happens. + let _ = sink!("Foo"__); + + // This is not ok, even as an input to a macro, because the `_` suffix is + // never allowed. + sink!("Foo"_); + //~^ ERROR underscore literal suffix is not allowed } diff --git a/src/test/ui/parser/underscore-suffix-for-string.stderr b/src/test/ui/parser/underscore-suffix-for-string.stderr index 00c7657f1..2fe2c130e 100644 --- a/src/test/ui/parser/underscore-suffix-for-string.stderr +++ b/src/test/ui/parser/underscore-suffix-for-string.stderr @@ -1,11 +1,14 @@ -warning: underscore literal suffix is not allowed - --> $DIR/underscore-suffix-for-string.rs:4:18 +error: underscore literal suffix is not allowed + --> $DIR/underscore-suffix-for-string.rs:6:18 | LL | let _ = "Foo"_; | ^ + +error: underscore literal suffix is not allowed + --> $DIR/underscore-suffix-for-string.rs:15:16 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: see issue #42326 <https://github.com/rust-lang/rust/issues/42326> for more information +LL | sink!("Foo"_); + | ^ -warning: 1 warning emitted +error: aborting due to 2 previous errors diff --git a/src/test/ui/parser/unicode-control-codepoints.rs b/src/test/ui/parser/unicode-control-codepoints.rs index 5af0b585a..df099bb62 100644 --- a/src/test/ui/parser/unicode-control-codepoints.rs +++ b/src/test/ui/parser/unicode-control-codepoints.rs @@ -14,15 +14,15 @@ fn main() { println!("{:?}", r##"/* } if isAdmin begin admins only "##); //~^ ERROR unicode codepoint changing visible direction of text present in literal println!("{:?}", b"/* } if isAdmin begin admins only "); - //~^ ERROR non-ASCII character in byte constant - //~| ERROR non-ASCII character in byte constant - //~| ERROR non-ASCII character in byte constant - //~| ERROR non-ASCII character in byte constant + //~^ ERROR non-ASCII character in byte string literal + //~| ERROR non-ASCII character in byte string literal + //~| ERROR non-ASCII character in byte string literal + //~| ERROR non-ASCII character in byte string literal println!("{:?}", br##"/* } if isAdmin begin admins only "##); - //~^ ERROR raw byte string must be ASCII - //~| ERROR raw byte string must be ASCII - //~| ERROR raw byte string must be ASCII - //~| ERROR raw byte string must be ASCII + //~^ ERROR non-ASCII character in raw byte string literal + //~| ERROR non-ASCII character in raw byte string literal + //~| ERROR non-ASCII character in raw byte string literal + //~| ERROR non-ASCII character in raw byte string literal println!("{:?}", ''); //~^ ERROR unicode codepoint changing visible direction of text present in literal } diff --git a/src/test/ui/parser/unicode-control-codepoints.stderr b/src/test/ui/parser/unicode-control-codepoints.stderr index 44548c72f..fc071a941 100644 --- a/src/test/ui/parser/unicode-control-codepoints.stderr +++ b/src/test/ui/parser/unicode-control-codepoints.stderr @@ -14,69 +14,69 @@ LL | println!("{:?}", b"us\u{202B}e\u{202A}r"); | = help: unicode escape sequences cannot be used as a byte or in a byte string -error: non-ASCII character in byte constant +error: non-ASCII character in byte string literal --> $DIR/unicode-control-codepoints.rs:16:26 | LL | println!("{:?}", b"/* } if isAdmin begin admins only "); - | ^ byte constant must be ASCII but is '\u{202e}' + | ^ must be ASCII but is '\u{202e}' | help: if you meant to use the UTF-8 encoding of '\u{202e}', use \xHH escapes | LL | println!("{:?}", b"/*\xE2\x80\xAE } if isAdmin begin admins only "); | ~~~~~~~~~~~~ -error: non-ASCII character in byte constant +error: non-ASCII character in byte string literal --> $DIR/unicode-control-codepoints.rs:16:30 | LL | println!("{:?}", b"/* } if isAdmin begin admins only "); - | ^ byte constant must be ASCII but is '\u{2066}' + | ^ must be ASCII but is '\u{2066}' | help: if you meant to use the UTF-8 encoding of '\u{2066}', use \xHH escapes | LL | println!("{:?}", b"/* } \xE2\x81\xA6if isAdmin begin admins only "); | ~~~~~~~~~~~~ -error: non-ASCII character in byte constant +error: non-ASCII character in byte string literal --> $DIR/unicode-control-codepoints.rs:16:41 | LL | println!("{:?}", b"/* } if isAdmin begin admins only "); - | ^ byte constant must be ASCII but is '\u{2069}' + | ^ must be ASCII but is '\u{2069}' | help: if you meant to use the UTF-8 encoding of '\u{2069}', use \xHH escapes | LL | println!("{:?}", b"/* } if isAdmin\xE2\x81\xA9 begin admins only "); | ~~~~~~~~~~~~ -error: non-ASCII character in byte constant +error: non-ASCII character in byte string literal --> $DIR/unicode-control-codepoints.rs:16:43 | LL | println!("{:?}", b"/* } if isAdmin begin admins only "); - | ^ byte constant must be ASCII but is '\u{2066}' + | ^ must be ASCII but is '\u{2066}' | help: if you meant to use the UTF-8 encoding of '\u{2066}', use \xHH escapes | LL | println!("{:?}", b"/* } if isAdmin \xE2\x81\xA6 begin admins only "); | ~~~~~~~~~~~~ -error: raw byte string must be ASCII +error: non-ASCII character in raw byte string literal --> $DIR/unicode-control-codepoints.rs:21:29 | LL | println!("{:?}", br##"/* } if isAdmin begin admins only "##); | ^ must be ASCII but is '\u{202e}' -error: raw byte string must be ASCII +error: non-ASCII character in raw byte string literal --> $DIR/unicode-control-codepoints.rs:21:33 | LL | println!("{:?}", br##"/* } if isAdmin begin admins only "##); | ^ must be ASCII but is '\u{2066}' -error: raw byte string must be ASCII +error: non-ASCII character in raw byte string literal --> $DIR/unicode-control-codepoints.rs:21:44 | LL | println!("{:?}", br##"/* } if isAdmin begin admins only "##); | ^ must be ASCII but is '\u{2069}' -error: raw byte string must be ASCII +error: non-ASCII character in raw byte string literal --> $DIR/unicode-control-codepoints.rs:21:46 | LL | println!("{:?}", br##"/* } if isAdmin begin admins only "##); diff --git a/src/test/ui/parser/use-colon-as-mod-sep.rs b/src/test/ui/parser/use-colon-as-mod-sep.rs new file mode 100644 index 000000000..e1e8756b0 --- /dev/null +++ b/src/test/ui/parser/use-colon-as-mod-sep.rs @@ -0,0 +1,11 @@ +// Recover from using a colon as a path separator. + +use std::process:Command; +//~^ ERROR expected `::`, found `:` +use std:fs::File; +//~^ ERROR expected `::`, found `:` +use std:collections:HashMap; +//~^ ERROR expected `::`, found `:` +//~| ERROR expected `::`, found `:` + +fn main() { } diff --git a/src/test/ui/parser/use-colon-as-mod-sep.stderr b/src/test/ui/parser/use-colon-as-mod-sep.stderr new file mode 100644 index 000000000..e825dfed1 --- /dev/null +++ b/src/test/ui/parser/use-colon-as-mod-sep.stderr @@ -0,0 +1,28 @@ +error: expected `::`, found `:` + --> $DIR/use-colon-as-mod-sep.rs:3:17 + | +LL | use std::process:Command; + | ^ help: use double colon + | + = note: import paths are delimited using `::` + +error: expected `::`, found `:` + --> $DIR/use-colon-as-mod-sep.rs:5:8 + | +LL | use std:fs::File; + | ^ help: use double colon + +error: expected `::`, found `:` + --> $DIR/use-colon-as-mod-sep.rs:7:8 + | +LL | use std:collections:HashMap; + | ^ help: use double colon + +error: expected `::`, found `:` + --> $DIR/use-colon-as-mod-sep.rs:7:20 + | +LL | use std:collections:HashMap; + | ^ help: use double colon + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr b/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr index fad84dda0..c8b45fd24 100644 --- a/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr +++ b/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr @@ -16,6 +16,11 @@ LL | Some(_z @ ref _y) => {} | | value borrowed here after move | value moved into `_z` here | move occurs because `_z` has type `X` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | Some(ref _z @ ref _y) => {} + | +++ error: cannot move out of value because it is borrowed --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:26:14 @@ -35,6 +40,11 @@ LL | Some(_z @ ref mut _y) => {} | | value borrowed here after move | value moved into `_z` here | move occurs because `_z` has type `X` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | Some(ref _z @ ref mut _y) => {} + | +++ error[E0382]: borrow of moved value --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:12:14 @@ -45,7 +55,7 @@ LL | Some(ref _y @ _z) => {} | value borrowed here after move | = note: move occurs because value has type `X`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving `x.0` +help: borrow this binding in the pattern to avoid moving the value | LL | Some(ref _y @ ref _z) => {} | +++ @@ -59,7 +69,7 @@ LL | Some(ref mut _y @ _z) => {} | value borrowed here after move | = note: move occurs because value has type `X`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving `x.0` +help: borrow this binding in the pattern to avoid moving the value | LL | Some(ref mut _y @ ref _z) => {} | +++ diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr index a227cc583..324897151 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr @@ -6,6 +6,11 @@ LL | let a @ b = U; | | | | | value moved here | value used here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ ref b = U; + | +++ +++ error[E0382]: use of partially moved value --> $DIR/borrowck-move-and-move.rs:13:9 @@ -16,6 +21,10 @@ LL | let a @ (b, c) = (U, U); | value used here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ (b, ref c) = (U, U); + | +++ +++ error[E0382]: use of partially moved value --> $DIR/borrowck-move-and-move.rs:15:9 @@ -26,6 +35,10 @@ LL | let a @ (b, c) = (u(), u()); | value used here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ (b, ref c) = (u(), u()); + | +++ +++ error[E0382]: use of moved value --> $DIR/borrowck-move-and-move.rs:18:16 @@ -36,6 +49,11 @@ LL | a @ Ok(b) | a @ Err(b) => {} | - ^ value used here after move | | | value moved here + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref a @ Ok(b) | a @ Err(b) => {} + | +++ error[E0382]: use of moved value --> $DIR/borrowck-move-and-move.rs:18:29 @@ -46,6 +64,11 @@ LL | a @ Ok(b) | a @ Err(b) => {} | - ^ value used here after move | | | value moved here + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | a @ Ok(b) | ref a @ Err(b) => {} + | +++ error[E0382]: use of partially moved value --> $DIR/borrowck-move-and-move.rs:25:9 @@ -56,6 +79,10 @@ LL | xs @ [a, .., b] => {} | value used here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref xs @ [a, .., ref b] => {} + | +++ +++ error[E0382]: use of partially moved value --> $DIR/borrowck-move-and-move.rs:29:9 @@ -66,6 +93,10 @@ LL | xs @ [_, ys @ .., _] => {} | value used here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref xs @ [_, ref ys @ .., _] => {} + | +++ +++ error[E0382]: use of moved value --> $DIR/borrowck-move-and-move.rs:22:12 diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr index 002c7609f..f27df32cc 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr @@ -79,6 +79,10 @@ LL | let ref a @ box b = Box::new(NC); | value borrowed here after move | = note: move occurs because value has type `NC`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ box ref b = Box::new(NC); + | +++ error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable --> $DIR/borrowck-pat-at-and-box.rs:38:9 diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse-promotion.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse-promotion.stderr index be4e81c61..d6474f1b4 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse-promotion.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse-promotion.stderr @@ -7,6 +7,11 @@ LL | let a @ ref b = U; | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ ref b = U; + | +++ error: aborting due to previous error diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr index a9e66de08..389e86e64 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr @@ -7,6 +7,11 @@ LL | let a @ ref b = U; | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ ref b = U; + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:9 @@ -18,6 +23,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ (mut b @ ref mut c, d @ ref e) = (U, U); + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:14 @@ -28,6 +38,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); | | value borrowed here after move | value moved into `b` here | move occurs because `b` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let a @ (ref mut b @ ref mut c, d @ ref e) = (U, U); + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:33 @@ -38,6 +53,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); | | value borrowed here after move | value moved into `d` here | move occurs because `d` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let a @ (mut b @ ref mut c, ref d @ ref e) = (U, U); + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:29:9 @@ -49,6 +69,11 @@ LL | let a @ [ref mut b, ref c] = [U, U]; | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ [ref mut b, ref c] = [U, U]; + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:31:9 @@ -59,6 +84,11 @@ LL | let a @ ref b = u(); | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ ref b = u(); + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:9 @@ -70,6 +100,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:14 @@ -80,6 +115,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | | value borrowed here after move | value moved into `b` here | move occurs because `b` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let a @ (ref mut b @ ref mut c, d @ ref e) = (u(), u()); + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:33 @@ -90,6 +130,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | | value borrowed here after move | value moved into `d` here | move occurs because `d` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let a @ (mut b @ ref mut c, ref d @ ref e) = (u(), u()); + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:38:9 @@ -101,6 +146,11 @@ LL | let a @ [ref mut b, ref c] = [u(), u()]; | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ [ref mut b, ref c] = [u(), u()]; + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:42:9 @@ -111,6 +161,11 @@ LL | a @ Some(ref b) => {} | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `Option<U>` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref a @ Some(ref b) => {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:47:9 @@ -122,6 +177,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `Option<(U, U)>` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref a @ Some((mut b @ ref mut c, d @ ref e)) => {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:47:19 @@ -132,6 +192,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | | value borrowed here after move | value moved into `b` here | move occurs because `b` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | a @ Some((ref mut b @ ref mut c, d @ ref e)) => {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:47:38 @@ -142,6 +207,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | | value borrowed here after move | value moved into `d` here | move occurs because `d` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | a @ Some((mut b @ ref mut c, ref d @ ref e)) => {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:55:9 @@ -153,6 +223,11 @@ LL | mut a @ Some([ref b, ref mut c]) => {} | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `Option<[U; 2]>` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref mut a @ Some([ref b, ref mut c]) => {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:61:9 @@ -163,6 +238,11 @@ LL | a @ Some(ref b) => {} | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `Option<U>` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref a @ Some(ref b) => {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:9 @@ -174,6 +254,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `Option<(U, U)>` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref a @ Some((mut b @ ref mut c, d @ ref e)) => {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:19 @@ -184,6 +269,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | | value borrowed here after move | value moved into `b` here | move occurs because `b` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | a @ Some((ref mut b @ ref mut c, d @ ref e)) => {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:38 @@ -194,6 +284,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | | value borrowed here after move | value moved into `d` here | move occurs because `d` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | a @ Some((mut b @ ref mut c, ref d @ ref e)) => {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:75:9 @@ -205,6 +300,11 @@ LL | mut a @ Some([ref b, ref mut c]) => {} | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `Option<[U; 2]>` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref mut a @ Some([ref b, ref mut c]) => {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:11:11 @@ -215,6 +315,11 @@ LL | fn f1(a @ ref b: U) {} | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | fn f1(ref a @ ref b: U) {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:11 @@ -226,6 +331,11 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | fn f2(ref mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:20 @@ -236,6 +346,11 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} | | value borrowed here after move | value moved into `b` here | move occurs because `b` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | fn f2(mut a @ (ref b @ ref c, mut d @ ref e): (U, U)) {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:31 @@ -246,6 +361,11 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} | | value borrowed here after move | value moved into `d` here | move occurs because `d` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | fn f2(mut a @ (b @ ref c, ref mut d @ ref e): (U, U)) {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:19:11 @@ -257,6 +377,11 @@ LL | fn f3(a @ [ref mut b, ref c]: [U; 2]) {} | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | fn f3(ref a @ [ref mut b, ref c]: [U; 2]) {} + | +++ error[E0382]: use of partially moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:9 @@ -267,6 +392,10 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); | value used here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ (mut b @ ref mut c, ref d @ ref e) = (U, U); + | +++ +++ error[E0382]: use of partially moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:9 @@ -277,6 +406,10 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | value used here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ (mut b @ ref mut c, ref d @ ref e) = (u(), u()); + | +++ +++ error[E0382]: use of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:47:38 @@ -285,6 +418,11 @@ LL | match Some((U, U)) { | ------------ move occurs because value has type `Option<(U, U)>`, which does not implement the `Copy` trait LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | - value moved here ^ value used here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref a @ Some((mut b @ ref mut c, d @ ref e)) => {} + | +++ error[E0382]: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:55:30 @@ -305,6 +443,11 @@ LL | a @ Some(ref b) => {} | - ^^^^^ value borrowed here after move | | | value moved here + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref a @ Some(ref b) => {} + | +++ error[E0382]: use of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:38 @@ -313,6 +456,11 @@ LL | match Some((u(), u())) { | ---------------- move occurs because value has type `Option<(U, U)>`, which does not implement the `Copy` trait LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | - value moved here ^ value used here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref a @ Some((mut b @ ref mut c, d @ ref e)) => {} + | +++ error[E0382]: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:75:30 diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr index b2f22fe86..770bb8953 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr @@ -242,6 +242,10 @@ LL | let ref mut a @ [b, mut c] = [U, U]; | value borrowed here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref mut a @ [b, ref mut c] = [U, U]; + | +++ error[E0382]: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:33:9 @@ -251,6 +255,11 @@ LL | let ref a @ b = u(); | | | | | value moved here | value borrowed here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ ref b = u(); + | +++ error[E0382]: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:36:18 @@ -261,6 +270,10 @@ LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); | value borrowed here after move | = note: move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ (ref b @ ref mut c, ref d @ e) = (u(), u()); + | +++ error[E0382]: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:36:33 @@ -271,6 +284,10 @@ LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); | value borrowed here after move | = note: move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ (ref b @ mut c, ref d @ ref e) = (u(), u()); + | +++ error[E0382]: borrow of partially moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:42:9 @@ -281,6 +298,10 @@ LL | let ref mut a @ [b, mut c] = [u(), u()]; | value borrowed here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref mut a @ [b, ref mut c] = [u(), u()]; + | +++ error[E0382]: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:69:23 @@ -291,7 +312,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed here after move | = note: move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value +help: borrow this binding in the pattern to avoid moving the value | LL | ref a @ Some((ref b @ ref mut c, ref d @ e)) => {} | +++ @@ -305,7 +326,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed here after move | = note: move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value +help: borrow this binding in the pattern to avoid moving the value | LL | ref a @ Some((ref b @ mut c, ref d @ ref e)) => {} | +++ diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr index 384a57b2e..ad4ce7952 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr @@ -97,6 +97,11 @@ LL | let a @ (ref mut b, ref mut c) = (U, U); | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ (ref mut b, ref mut c) = (U, U); + | +++ error: borrow of moved value --> $DIR/borrowck-pat-ref-mut-twice.rs:67:9 @@ -109,6 +114,11 @@ LL | let a @ (b, [c, d]) = &mut val; // Same as ^-- | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `&mut (U, [U; 2])` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ (b, [c, d]) = &mut val; // Same as ^-- + | +++ error: borrow of moved value --> $DIR/borrowck-pat-ref-mut-twice.rs:70:9 @@ -119,6 +129,11 @@ LL | let a @ &mut ref mut b = &mut U; | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `&mut U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ &mut ref mut b = &mut U; + | +++ error: borrow of moved value --> $DIR/borrowck-pat-ref-mut-twice.rs:72:9 @@ -130,6 +145,11 @@ LL | let a @ &mut (ref mut b, ref mut c) = &mut (U, U); | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `&mut (U, U)` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ &mut (ref mut b, ref mut c) = &mut (U, U); + | +++ error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:76:9 diff --git a/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr b/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr index cd3234952..e0e623fa5 100644 --- a/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr +++ b/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr @@ -7,6 +7,10 @@ LL | let a @ NC(b, c @ NC(d, e)) = NC(C, NC(C, C)); | value used here after partial move | = note: partial move occurs because value has type `NC<C, C>`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ NC(b, ref c @ NC(d, e)) = NC(C, NC(C, C)); + | +++ +++ error: aborting due to previous error diff --git a/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr b/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr index 840a513d6..638bdd6db 100644 --- a/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr +++ b/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr @@ -34,6 +34,11 @@ LL | Ok(ref a @ b) | Err(b @ ref a) => { | | value borrowed here after move | value moved into `b` here | move occurs because `b` has type `NotCopy` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | Ok(ref a @ b) | Err(ref b @ ref a) => { + | +++ error: cannot move out of value because it is borrowed --> $DIR/default-binding-modes-both-sides-independent.rs:42:9 @@ -52,6 +57,11 @@ LL | let ref mut a @ b = NotCopy; | | | | | value moved here | value borrowed here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref mut a @ ref b = NotCopy; + | +++ error: aborting due to 6 previous errors diff --git a/src/test/ui/issues/issue-52240.rs b/src/test/ui/pattern/issue-52240.rs index 5def55778..5def55778 100644 --- a/src/test/ui/issues/issue-52240.rs +++ b/src/test/ui/pattern/issue-52240.rs diff --git a/src/test/ui/issues/issue-52240.stderr b/src/test/ui/pattern/issue-52240.stderr index 69b663b17..69b663b17 100644 --- a/src/test/ui/issues/issue-52240.stderr +++ b/src/test/ui/pattern/issue-52240.stderr diff --git a/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr b/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr index bac2db6ce..bb7b81836 100644 --- a/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr +++ b/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr @@ -129,6 +129,10 @@ LL | drop(tup.1); | ^^^^^ value used here after move | = note: move occurs because `tup.1` has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let (ref _x0, ref _x1, ref _x2, ..) = tup; + | +++ error[E0382]: borrow of moved value: `tup.1` --> $DIR/borrowck-move-ref-pattern.rs:29:20 diff --git a/src/test/ui/pattern/non-structural-match-types.stderr b/src/test/ui/pattern/non-structural-match-types.stderr index 45e162649..dea7c4695 100644 --- a/src/test/ui/pattern/non-structural-match-types.stderr +++ b/src/test/ui/pattern/non-structural-match-types.stderr @@ -4,7 +4,7 @@ error: `[closure@$DIR/non-structural-match-types.rs:9:17: 9:19]` cannot be used LL | const { || {} } => {}, | ^^^^^^^^^^^^^^^ -error: `impl Future<Output = ()>` cannot be used in patterns +error: `[async block@$DIR/non-structural-match-types.rs:12:17: 12:25]` cannot be used in patterns --> $DIR/non-structural-match-types.rs:12:9 | LL | const { async {} } => {}, diff --git a/src/test/ui/pattern/pattern-binding-disambiguation.rs b/src/test/ui/pattern/pattern-binding-disambiguation.rs index 2e80ea345..ce1d8c6c0 100644 --- a/src/test/ui/pattern/pattern-binding-disambiguation.rs +++ b/src/test/ui/pattern/pattern-binding-disambiguation.rs @@ -33,7 +33,7 @@ fn main() { TupleVariant => {} //~ ERROR match bindings cannot shadow tuple variants } match doesnt_matter { - BracedVariant => {} //~ ERROR match bindings cannot shadow struct variants + BracedVariant => {} // OK, `BracedVariant` is a fresh binding } match CONST { CONST => {} // OK, `CONST` is a const pattern @@ -50,7 +50,7 @@ fn main() { let BracedStruct = doesnt_matter; // OK, `BracedStruct` is a fresh binding let UnitVariant = UnitVariant; // OK, `UnitVariant` is a unit variant pattern let TupleVariant = doesnt_matter; //~ ERROR let bindings cannot shadow tuple variants - let BracedVariant = doesnt_matter; //~ ERROR let bindings cannot shadow struct variants + let BracedVariant = doesnt_matter; // OK, `BracedVariant` is a fresh binding let CONST = CONST; // OK, `CONST` is a const pattern let STATIC = doesnt_matter; //~ ERROR let bindings cannot shadow statics let function = doesnt_matter; // OK, `function` is a fresh binding diff --git a/src/test/ui/pattern/pattern-binding-disambiguation.stderr b/src/test/ui/pattern/pattern-binding-disambiguation.stderr index 1529e538b..d54467b3c 100644 --- a/src/test/ui/pattern/pattern-binding-disambiguation.stderr +++ b/src/test/ui/pattern/pattern-binding-disambiguation.stderr @@ -22,15 +22,6 @@ LL | TupleVariant => {} | cannot be named the same as a tuple variant | help: try specify the pattern arguments: `TupleVariant(..)` -error[E0530]: match bindings cannot shadow struct variants - --> $DIR/pattern-binding-disambiguation.rs:36:9 - | -LL | use E::*; - | ---- the struct variant `BracedVariant` is imported here -... -LL | BracedVariant => {} - | ^^^^^^^^^^^^^ cannot be named the same as a struct variant - error[E0530]: match bindings cannot shadow statics --> $DIR/pattern-binding-disambiguation.rs:42:9 | @@ -58,15 +49,6 @@ LL | use E::*; LL | let TupleVariant = doesnt_matter; | ^^^^^^^^^^^^ cannot be named the same as a tuple variant -error[E0530]: let bindings cannot shadow struct variants - --> $DIR/pattern-binding-disambiguation.rs:53:9 - | -LL | use E::*; - | ---- the struct variant `BracedVariant` is imported here -... -LL | let BracedVariant = doesnt_matter; - | ^^^^^^^^^^^^^ cannot be named the same as a struct variant - error[E0530]: let bindings cannot shadow statics --> $DIR/pattern-binding-disambiguation.rs:55:9 | @@ -76,6 +58,6 @@ LL | static STATIC: () = (); LL | let STATIC = doesnt_matter; | ^^^^^^ cannot be named the same as a static -error: aborting due to 8 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0530`. diff --git a/src/test/ui/pattern/usefulness/const-partial_eq-fallback-ice.rs b/src/test/ui/pattern/usefulness/const-partial_eq-fallback-ice.rs new file mode 100644 index 000000000..02599d7c0 --- /dev/null +++ b/src/test/ui/pattern/usefulness/const-partial_eq-fallback-ice.rs @@ -0,0 +1,18 @@ +#![allow(warnings)] + +struct MyType; + +impl PartialEq<usize> for MyType { + fn eq(&self, y: &usize) -> bool { + true + } +} + +const CONSTANT: &&MyType = &&MyType; + +fn main() { + if let CONSTANT = &&MyType { + //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` + println!("did match!"); + } +} diff --git a/src/test/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr b/src/test/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr new file mode 100644 index 000000000..358421cd6 --- /dev/null +++ b/src/test/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr @@ -0,0 +1,8 @@ +error: to use a constant of type `MyType` in a pattern, `MyType` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/const-partial_eq-fallback-ice.rs:14:12 + | +LL | if let CONSTANT = &&MyType { + | ^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/pattern/usefulness/uninhabited.rs b/src/test/ui/pattern/usefulness/uninhabited.rs index 77cd0f400..5622808d4 100644 --- a/src/test/ui/pattern/usefulness/uninhabited.rs +++ b/src/test/ui/pattern/usefulness/uninhabited.rs @@ -2,7 +2,7 @@ // aux-build:empty.rs // // This tests plays with matching and uninhabited types. This also serves as a test for the -// `tcx.is_ty_uninhabited_from()` function. +// `Ty::is_inhabited_from` function. #![feature(never_type)] #![feature(never_type_fallback)] #![feature(exhaustive_patterns)] diff --git a/src/test/ui/pin-macro/lifetime_errors_on_promotion_misusage.stderr b/src/test/ui/pin-macro/lifetime_errors_on_promotion_misusage.stderr index 4971263af..fc1be052f 100644 --- a/src/test/ui/pin-macro/lifetime_errors_on_promotion_misusage.stderr +++ b/src/test/ui/pin-macro/lifetime_errors_on_promotion_misusage.stderr @@ -4,7 +4,7 @@ error[E0716]: temporary value dropped while borrowed LL | let phantom_pinned = identity(pin!(PhantomPinned)); | ^^^^^^^^^^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | creates a temporary which is freed while still in use + | creates a temporary value which is freed while still in use LL | LL | stuff(phantom_pinned) | -------------- borrow later used here @@ -18,7 +18,7 @@ error[E0716]: temporary value dropped while borrowed LL | let phantom_pinned = { | -------------- borrow later stored here LL | let phantom_pinned = pin!(PhantomPinned); - | ^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use ... LL | }; | - temporary value is freed at the end of this statement diff --git a/src/test/ui/issues/auxiliary/issue-75907.rs b/src/test/ui/privacy/auxiliary/issue-75907.rs index 389c9c351..389c9c351 100644 --- a/src/test/ui/issues/auxiliary/issue-75907.rs +++ b/src/test/ui/privacy/auxiliary/issue-75907.rs diff --git a/src/test/ui/privacy/effective_visibilities.rs b/src/test/ui/privacy/effective_visibilities.rs index 1d806a1d1..ff20e20d3 100644 --- a/src/test/ui/privacy/effective_visibilities.rs +++ b/src/test/ui/privacy/effective_visibilities.rs @@ -6,7 +6,7 @@ mod outer { //~ ERROR Direct: pub(crate), Reexported: pub(crate), Reachable: pub pub mod inner1 { //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub #[rustc_effective_visibility] - extern "C" {} //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub + extern "C" {} //~ ERROR not in the table #[rustc_effective_visibility] pub trait PubTrait { //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub @@ -17,12 +17,13 @@ mod outer { //~ ERROR Direct: pub(crate), Reexported: pub(crate), Reachable: pub } #[rustc_effective_visibility] - struct PrivStruct; //~ ERROR not in the table + struct PrivStruct; //~ ERROR Direct: pub(self), Reexported: pub(self), Reachable: pub(self), ReachableThroughImplTrait: pub(self) + //~| ERROR Direct: pub(self), Reexported: pub(self), Reachable: pub(self), ReachableThroughImplTrait: pub(self) #[rustc_effective_visibility] pub union PubUnion { //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub #[rustc_effective_visibility] - a: u8, //~ ERROR not in the table + a: u8, //~ ERROR Direct: pub(self), Reexported: pub(self), Reachable: pub(self), ReachableThroughImplTrait: pub(self) #[rustc_effective_visibility] pub b: u8, //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub } @@ -31,6 +32,7 @@ mod outer { //~ ERROR Direct: pub(crate), Reexported: pub(crate), Reachable: pub pub enum Enum { //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub #[rustc_effective_visibility] A( //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub + //~| ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub #[rustc_effective_visibility] PubUnion, //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub ), @@ -38,13 +40,13 @@ mod outer { //~ ERROR Direct: pub(crate), Reexported: pub(crate), Reachable: pub } #[rustc_effective_visibility] - macro_rules! none_macro { //~ Direct: pub(crate), Reexported: pub(crate), Reachable: pub(crate), ReachableThroughImplTrait: pub(crate) + macro_rules! none_macro { //~ ERROR not in the table () => {}; } #[macro_export] #[rustc_effective_visibility] - macro_rules! public_macro { //~ Direct: pub, Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub + macro_rules! public_macro { //~ ERROR Direct: pub(self), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub () => {}; } @@ -70,6 +72,5 @@ mod half_public_import { #[rustc_effective_visibility] pub use half_public_import::HalfPublicImport; //~ ERROR Direct: pub, Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - //~^ ERROR Direct: pub, Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub fn main() {} diff --git a/src/test/ui/privacy/effective_visibilities.stderr b/src/test/ui/privacy/effective_visibilities.stderr index 1c6201600..046b6095f 100644 --- a/src/test/ui/privacy/effective_visibilities.stderr +++ b/src/test/ui/privacy/effective_visibilities.stderr @@ -10,7 +10,7 @@ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImpl LL | pub mod inner1 { | ^^^^^^^^^^^^^^ -error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub +error: not in the table --> $DIR/effective_visibilities.rs:9:9 | LL | extern "C" {} @@ -22,98 +22,104 @@ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImpl LL | pub trait PubTrait { | ^^^^^^^^^^^^^^^^^^ -error: not in the table +error: Direct: pub(self), Reexported: pub(self), Reachable: pub(self), ReachableThroughImplTrait: pub(self) + --> $DIR/effective_visibilities.rs:20:9 + | +LL | struct PrivStruct; + | ^^^^^^^^^^^^^^^^^ + +error: Direct: pub(self), Reexported: pub(self), Reachable: pub(self), ReachableThroughImplTrait: pub(self) --> $DIR/effective_visibilities.rs:20:9 | LL | struct PrivStruct; | ^^^^^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:23:9 + --> $DIR/effective_visibilities.rs:24:9 | LL | pub union PubUnion { | ^^^^^^^^^^^^^^^^^^ -error: not in the table - --> $DIR/effective_visibilities.rs:25:13 +error: Direct: pub(self), Reexported: pub(self), Reachable: pub(self), ReachableThroughImplTrait: pub(self) + --> $DIR/effective_visibilities.rs:26:13 | LL | a: u8, | ^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:27:13 + --> $DIR/effective_visibilities.rs:28:13 | LL | pub b: u8, | ^^^^^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:31:9 + --> $DIR/effective_visibilities.rs:32:9 | LL | pub enum Enum { | ^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:33:13 + --> $DIR/effective_visibilities.rs:34:13 + | +LL | A( + | ^ + +error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub + --> $DIR/effective_visibilities.rs:34:13 | LL | A( | ^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:35:17 + --> $DIR/effective_visibilities.rs:37:17 | LL | PubUnion, | ^^^^^^^^ -error: Direct: pub(crate), Reexported: pub(crate), Reachable: pub(crate), ReachableThroughImplTrait: pub(crate) - --> $DIR/effective_visibilities.rs:41:5 +error: not in the table + --> $DIR/effective_visibilities.rs:43:5 | LL | macro_rules! none_macro { | ^^^^^^^^^^^^^^^^^^^^^^^ -error: Direct: pub, Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:47:5 +error: Direct: pub(self), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub + --> $DIR/effective_visibilities.rs:49:5 | LL | macro_rules! public_macro { | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub(crate), Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:52:5 + --> $DIR/effective_visibilities.rs:54:5 | LL | pub struct ReachableStruct { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub(crate), Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:54:9 + --> $DIR/effective_visibilities.rs:56:9 | LL | pub a: u8, | ^^^^^^^^^ error: Direct: pub, Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:59:9 + --> $DIR/effective_visibilities.rs:61:9 | LL | pub use outer::inner1; | ^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:65:5 + --> $DIR/effective_visibilities.rs:67:5 | LL | pub type HalfPublicImport = u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub(crate), Reachable: pub(crate), ReachableThroughImplTrait: pub(crate) - --> $DIR/effective_visibilities.rs:68:5 + --> $DIR/effective_visibilities.rs:70:5 | LL | pub(crate) const HalfPublicImport: u8 = 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Direct: pub, Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:72:9 - | -LL | pub use half_public_import::HalfPublicImport; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: Direct: pub, Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:72:9 + --> $DIR/effective_visibilities.rs:74:9 | LL | pub use half_public_import::HalfPublicImport; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -130,5 +136,5 @@ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImpl LL | type B; | ^^^^^^ -error: aborting due to 22 previous errors +error: aborting due to 23 previous errors diff --git a/src/test/ui/privacy/effective_visibilities_glob.rs b/src/test/ui/privacy/effective_visibilities_glob.rs new file mode 100644 index 000000000..eb9dcd6cd --- /dev/null +++ b/src/test/ui/privacy/effective_visibilities_glob.rs @@ -0,0 +1,21 @@ +// Effective visibility tracking for imports is fine-grained, so `S2` is not fully exported +// even if its parent import (`m::*`) is fully exported as a `use` item. + +#![feature(rustc_attrs)] + +mod m { + #[rustc_effective_visibility] + pub struct S1 {} //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub + #[rustc_effective_visibility] + pub struct S2 {} //~ ERROR Direct: pub(crate), Reexported: pub(crate), Reachable: pub(crate), ReachableThroughImplTrait: pub(crate) +} + +mod glob { + #[rustc_effective_visibility] + pub use crate::m::*; //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub +} + +#[rustc_effective_visibility] +pub use glob::S1; //~ ERROR Direct: pub, Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub + +fn main() {} diff --git a/src/test/ui/privacy/effective_visibilities_glob.stderr b/src/test/ui/privacy/effective_visibilities_glob.stderr new file mode 100644 index 000000000..0496cd5df --- /dev/null +++ b/src/test/ui/privacy/effective_visibilities_glob.stderr @@ -0,0 +1,26 @@ +error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub + --> $DIR/effective_visibilities_glob.rs:8:5 + | +LL | pub struct S1 {} + | ^^^^^^^^^^^^^ + +error: Direct: pub(crate), Reexported: pub(crate), Reachable: pub(crate), ReachableThroughImplTrait: pub(crate) + --> $DIR/effective_visibilities_glob.rs:10:5 + | +LL | pub struct S2 {} + | ^^^^^^^^^^^^^ + +error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub + --> $DIR/effective_visibilities_glob.rs:15:13 + | +LL | pub use crate::m::*; + | ^^^^^^^^ + +error: Direct: pub, Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub + --> $DIR/effective_visibilities_glob.rs:19:9 + | +LL | pub use glob::S1; + | ^^^^^^^^ + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/privacy/effective_visibilities_invariants.rs b/src/test/ui/privacy/effective_visibilities_invariants.rs new file mode 100644 index 000000000..af5a2bed6 --- /dev/null +++ b/src/test/ui/privacy/effective_visibilities_invariants.rs @@ -0,0 +1,12 @@ +// Invariant checking doesn't ICE in some cases with errors (issue #104249). + +#![feature(staged_api)] //~ ERROR module has missing stability attribute + +pub mod m {} //~ ERROR module has missing stability attribute + +pub mod m { //~ ERROR the name `m` is defined multiple times + mod inner {} + type Inner = u8; +} + +fn main() {} diff --git a/src/test/ui/privacy/effective_visibilities_invariants.stderr b/src/test/ui/privacy/effective_visibilities_invariants.stderr new file mode 100644 index 000000000..fd205f405 --- /dev/null +++ b/src/test/ui/privacy/effective_visibilities_invariants.stderr @@ -0,0 +1,32 @@ +error[E0428]: the name `m` is defined multiple times + --> $DIR/effective_visibilities_invariants.rs:7:1 + | +LL | pub mod m {} + | --------- previous definition of the module `m` here +LL | +LL | pub mod m { + | ^^^^^^^^^ `m` redefined here + | + = note: `m` must be defined only once in the type namespace of this module + +error: module has missing stability attribute + --> $DIR/effective_visibilities_invariants.rs:3:1 + | +LL | / #![feature(staged_api)] +LL | | +LL | | pub mod m {} +LL | | +... | +LL | | +LL | | fn main() {} + | |____________^ + +error: module has missing stability attribute + --> $DIR/effective_visibilities_invariants.rs:5:1 + | +LL | pub mod m {} + | ^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0428`. diff --git a/src/test/ui/issues/issue-75906.rs b/src/test/ui/privacy/issue-75906.rs index 710039d79..710039d79 100644 --- a/src/test/ui/issues/issue-75906.rs +++ b/src/test/ui/privacy/issue-75906.rs diff --git a/src/test/ui/issues/issue-75906.stderr b/src/test/ui/privacy/issue-75906.stderr index 4c6a68646..4c6a68646 100644 --- a/src/test/ui/issues/issue-75906.stderr +++ b/src/test/ui/privacy/issue-75906.stderr diff --git a/src/test/ui/issues/issue-75907.rs b/src/test/ui/privacy/issue-75907.rs index 6da99cf64..6da99cf64 100644 --- a/src/test/ui/issues/issue-75907.rs +++ b/src/test/ui/privacy/issue-75907.rs diff --git a/src/test/ui/issues/issue-75907.stderr b/src/test/ui/privacy/issue-75907.stderr index 2f89e31a3..2f89e31a3 100644 --- a/src/test/ui/issues/issue-75907.stderr +++ b/src/test/ui/privacy/issue-75907.stderr diff --git a/src/test/ui/issues/issue-75907_b.rs b/src/test/ui/privacy/issue-75907_b.rs index fdfc5907c..fdfc5907c 100644 --- a/src/test/ui/issues/issue-75907_b.rs +++ b/src/test/ui/privacy/issue-75907_b.rs diff --git a/src/test/ui/issues/issue-75907_b.stderr b/src/test/ui/privacy/issue-75907_b.stderr index b82d08473..b82d08473 100644 --- a/src/test/ui/issues/issue-75907_b.stderr +++ b/src/test/ui/privacy/issue-75907_b.stderr diff --git a/src/test/ui/proc-macro/amputate-span.stderr b/src/test/ui/proc-macro/amputate-span.stderr index 9553ba3da..ab4670411 100644 --- a/src/test/ui/proc-macro/amputate-span.stderr +++ b/src/test/ui/proc-macro/amputate-span.stderr @@ -2,7 +2,7 @@ error[E0433]: failed to resolve: use of undeclared type `Command` --> $DIR/amputate-span.rs:49:5 | LL | Command::new("git"); - | ^^^^^^^ not found in this scope + | ^^^^^^^ use of undeclared type `Command` | help: consider importing this struct | @@ -13,7 +13,7 @@ error[E0433]: failed to resolve: use of undeclared type `Command` --> $DIR/amputate-span.rs:63:9 | LL | Command::new("git"); - | ^^^^^^^ not found in this scope + | ^^^^^^^ use of undeclared type `Command` | help: consider importing this struct | diff --git a/src/test/ui/proc-macro/auxiliary/issue-104884.rs b/src/test/ui/proc-macro/auxiliary/issue-104884.rs new file mode 100644 index 000000000..0de59d005 --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/issue-104884.rs @@ -0,0 +1,23 @@ +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(AddImpl)] + +pub fn derive(input: TokenStream) -> TokenStream { + "use std::cmp::Ordering; + + impl<T> Ord for PriorityQueue<T> { + fn cmp(&self, other: &Self) -> Ordering { + self.0.cmp(&self.height) + } + } + " + .parse() + .unwrap() +} diff --git a/src/test/ui/proc-macro/expand-expr.rs b/src/test/ui/proc-macro/expand-expr.rs index d1146d970..901b3a951 100644 --- a/src/test/ui/proc-macro/expand-expr.rs +++ b/src/test/ui/proc-macro/expand-expr.rs @@ -1,5 +1,5 @@ // aux-build:expand-expr.rs - +#![feature(concat_bytes)] extern crate expand_expr; use expand_expr::{ @@ -23,6 +23,11 @@ expand_expr_is!( concat!("contents: ", include_str!("auxiliary/included-file.txt")) ); +expand_expr_is!( + b"contents: Included file contents\n", + concat_bytes!(b"contents: ", include_bytes!("auxiliary/included-file.txt")) +); + // Correct value is checked for multiple sources. check_expand_expr_file!(file!()); @@ -118,4 +123,10 @@ expand_expr_fail!(echo_pm!(arbitrary_expression() + "etc")); const _: u32 = recursive_expand!(); //~ ERROR: recursion limit reached while expanding `recursive_expand!` -fn main() {} +fn main() { + // https://github.com/rust-lang/rust/issues/104414 + match b"Included file contents\n" { + include_bytes!("auxiliary/included-file.txt") => (), + _ => panic!("include_bytes! in pattern"), + } +} diff --git a/src/test/ui/proc-macro/expand-expr.stderr b/src/test/ui/proc-macro/expand-expr.stderr index 8dc2d0cfc..c6c4695fd 100644 --- a/src/test/ui/proc-macro/expand-expr.stderr +++ b/src/test/ui/proc-macro/expand-expr.stderr @@ -1,29 +1,29 @@ error: expected one of `.`, `?`, or an operator, found `;` - --> $DIR/expand-expr.rs:101:27 + --> $DIR/expand-expr.rs:106:27 | LL | expand_expr_fail!("string"; hello); | ^ expected one of `.`, `?`, or an operator error: expected expression, found `$` - --> $DIR/expand-expr.rs:104:19 + --> $DIR/expand-expr.rs:109:19 | LL | expand_expr_fail!($); | ^ expected expression error: expected expression, found `$` - --> $DIR/expand-expr.rs:33:23 + --> $DIR/expand-expr.rs:38:23 | LL | ($($t:tt)*) => { $($t)* }; | ^^^^ expected expression error: expected expression, found `$` - --> $DIR/expand-expr.rs:106:28 + --> $DIR/expand-expr.rs:111:28 | LL | expand_expr_fail!(echo_pm!($)); | ^ expected expression error: macro expansion ignores token `hello` and any following - --> $DIR/expand-expr.rs:110:47 + --> $DIR/expand-expr.rs:115:47 | LL | expand_expr_is!("string", echo_tts!("string"; hello)); | --------------------^^^^^-- help: you might be missing a semicolon here: `;` @@ -33,7 +33,7 @@ LL | expand_expr_is!("string", echo_tts!("string"; hello)); = note: the usage of `echo_tts!` is likely invalid in expression context error: macro expansion ignores token `;` and any following - --> $DIR/expand-expr.rs:111:44 + --> $DIR/expand-expr.rs:116:44 | LL | expand_expr_is!("string", echo_pm!("string"; hello)); | -----------------^-------- help: you might be missing a semicolon here: `;` @@ -43,7 +43,7 @@ LL | expand_expr_is!("string", echo_pm!("string"; hello)); = note: the usage of `echo_pm!` is likely invalid in expression context error: recursion limit reached while expanding `recursive_expand!` - --> $DIR/expand-expr.rs:119:16 + --> $DIR/expand-expr.rs:124:16 | LL | const _: u32 = recursive_expand!(); | ^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/proc-macro/issue-104884-trait-impl-sugg-err.rs b/src/test/ui/proc-macro/issue-104884-trait-impl-sugg-err.rs new file mode 100644 index 000000000..a0d619c45 --- /dev/null +++ b/src/test/ui/proc-macro/issue-104884-trait-impl-sugg-err.rs @@ -0,0 +1,20 @@ +// aux-build:issue-104884.rs + +use std::collections::BinaryHeap; + +#[macro_use] +extern crate issue_104884; + +#[derive(PartialEq, Eq, PartialOrd, Ord)] +struct PriorityQueueEntry<T> { + value: T, +} + +#[derive(PartialOrd, AddImpl)] +//~^ ERROR can't compare `PriorityQueue<T>` with `PriorityQueue<T>` +//~| ERROR the trait bound `PriorityQueue<T>: Eq` is not satisfied +//~| ERROR can't compare `T` with `T` + +struct PriorityQueue<T>(BinaryHeap<PriorityQueueEntry<T>>); + +fn main() {} diff --git a/src/test/ui/proc-macro/issue-104884-trait-impl-sugg-err.stderr b/src/test/ui/proc-macro/issue-104884-trait-impl-sugg-err.stderr new file mode 100644 index 000000000..ac49e04e3 --- /dev/null +++ b/src/test/ui/proc-macro/issue-104884-trait-impl-sugg-err.stderr @@ -0,0 +1,48 @@ +error[E0277]: can't compare `PriorityQueue<T>` with `PriorityQueue<T>` + --> $DIR/issue-104884-trait-impl-sugg-err.rs:13:10 + | +LL | #[derive(PartialOrd, AddImpl)] + | ^^^^^^^^^^ no implementation for `PriorityQueue<T> == PriorityQueue<T>` + | + = help: the trait `PartialEq` is not implemented for `PriorityQueue<T>` +note: required by a bound in `PartialOrd` + --> $SRC_DIR/core/src/cmp.rs:LL:COL + | +LL | pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> { + | ^^^^^^^^^^^^^^ required by this bound in `PartialOrd` + = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `PriorityQueue<T>: Eq` is not satisfied + --> $DIR/issue-104884-trait-impl-sugg-err.rs:13:22 + | +LL | #[derive(PartialOrd, AddImpl)] + | ^^^^^^^ the trait `Eq` is not implemented for `PriorityQueue<T>` + | +note: required by a bound in `Ord` + --> $SRC_DIR/core/src/cmp.rs:LL:COL + | +LL | pub trait Ord: Eq + PartialOrd<Self> { + | ^^ required by this bound in `Ord` + = note: this error originates in the derive macro `AddImpl` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `T` with `T` + --> $DIR/issue-104884-trait-impl-sugg-err.rs:13:22 + | +LL | #[derive(PartialOrd, AddImpl)] + | ^^^^^^^ no implementation for `T < T` and `T > T` + | +note: required for `PriorityQueue<T>` to implement `PartialOrd` + --> $DIR/issue-104884-trait-impl-sugg-err.rs:13:10 + | +LL | #[derive(PartialOrd, AddImpl)] + | ^^^^^^^^^^ +note: required by a bound in `Ord` + --> $SRC_DIR/core/src/cmp.rs:LL:COL + | +LL | pub trait Ord: Eq + PartialOrd<Self> { + | ^^^^^^^^^^^^^^^^ required by this bound in `Ord` + = note: this error originates in the derive macro `AddImpl` which comes from the expansion of the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/qualified/qualified-path-params.stderr b/src/test/ui/qualified/qualified-path-params.stderr index 82cc6e19f..a49ed6c8f 100644 --- a/src/test/ui/qualified/qualified-path-params.stderr +++ b/src/test/ui/qualified/qualified-path-params.stderr @@ -2,7 +2,7 @@ error[E0533]: expected unit struct, unit variant or constant, found associated f --> $DIR/qualified-path-params.rs:20:9 | LL | <S as Tr>::A::f::<u8> => {} - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^ not a unit struct, unit variant or constant error[E0029]: only `char` and numeric types are allowed in range patterns --> $DIR/qualified-path-params.rs:22:15 diff --git a/src/test/ui/query-system/fn-sig-cycle-arity.rs b/src/test/ui/query-system/fn-sig-cycle-arity.rs new file mode 100644 index 000000000..7a9b8469c --- /dev/null +++ b/src/test/ui/query-system/fn-sig-cycle-arity.rs @@ -0,0 +1,8 @@ +trait Dancer { + fn dance(&self) -> _ { + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types + self.dance() + } +} + +fn main() {} diff --git a/src/test/ui/query-system/fn-sig-cycle-arity.stderr b/src/test/ui/query-system/fn-sig-cycle-arity.stderr new file mode 100644 index 000000000..67e0c2545 --- /dev/null +++ b/src/test/ui/query-system/fn-sig-cycle-arity.stderr @@ -0,0 +1,9 @@ +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types + --> $DIR/fn-sig-cycle-arity.rs:2:24 + | +LL | fn dance(&self) -> _ { + | ^ not allowed in type signatures + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0121`. diff --git a/src/test/ui/range/issue-54505-no-std.rs b/src/test/ui/range/issue-54505-no-std.rs index ab1a025b5..9f378b483 100644 --- a/src/test/ui/range/issue-54505-no-std.rs +++ b/src/test/ui/range/issue-54505-no-std.rs @@ -1,5 +1,3 @@ -// error-pattern: `#[panic_handler]` function required, but not found - // Regression test for #54505 - range borrowing suggestion had // incorrect syntax (missing parentheses). @@ -18,6 +16,10 @@ extern "C" fn eh_personality() {} #[lang = "eh_catch_typeinfo"] static EH_CATCH_TYPEINFO: u8 = 0; +#[panic_handler] +fn panic_handler() {} +//~^ ERROR return type should be `!` +//~| ERROR function should have one argument // take a reference to any built-in range fn take_range(_r: &impl RangeBounds<i8>) {} diff --git a/src/test/ui/range/issue-54505-no-std.stderr b/src/test/ui/range/issue-54505-no-std.stderr index c4e36b0b1..9fb0e54a8 100644 --- a/src/test/ui/range/issue-54505-no-std.stderr +++ b/src/test/ui/range/issue-54505-no-std.stderr @@ -1,7 +1,17 @@ -error: `#[panic_handler]` function required, but not found +error: return type should be `!` + --> $DIR/issue-54505-no-std.rs:20:20 + | +LL | fn panic_handler() {} + | ^ + +error: function should have one argument + --> $DIR/issue-54505-no-std.rs:20:1 + | +LL | fn panic_handler() {} + | ^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/issue-54505-no-std.rs:27:16 + --> $DIR/issue-54505-no-std.rs:29:16 | LL | take_range(0..1); | ---------- ^^^^ @@ -13,13 +23,13 @@ LL | take_range(0..1); = note: expected reference `&_` found struct `Range<{integer}>` note: function defined here - --> $DIR/issue-54505-no-std.rs:23:4 + --> $DIR/issue-54505-no-std.rs:25:4 | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- error[E0308]: mismatched types - --> $DIR/issue-54505-no-std.rs:32:16 + --> $DIR/issue-54505-no-std.rs:34:16 | LL | take_range(1..); | ---------- ^^^ @@ -31,13 +41,13 @@ LL | take_range(1..); = note: expected reference `&_` found struct `RangeFrom<{integer}>` note: function defined here - --> $DIR/issue-54505-no-std.rs:23:4 + --> $DIR/issue-54505-no-std.rs:25:4 | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- error[E0308]: mismatched types - --> $DIR/issue-54505-no-std.rs:37:16 + --> $DIR/issue-54505-no-std.rs:39:16 | LL | take_range(..); | ---------- ^^ @@ -49,13 +59,13 @@ LL | take_range(..); = note: expected reference `&_` found struct `RangeFull` note: function defined here - --> $DIR/issue-54505-no-std.rs:23:4 + --> $DIR/issue-54505-no-std.rs:25:4 | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- error[E0308]: mismatched types - --> $DIR/issue-54505-no-std.rs:42:16 + --> $DIR/issue-54505-no-std.rs:44:16 | LL | take_range(0..=1); | ---------- ^^^^^ @@ -67,13 +77,13 @@ LL | take_range(0..=1); = note: expected reference `&_` found struct `RangeInclusive<{integer}>` note: function defined here - --> $DIR/issue-54505-no-std.rs:23:4 + --> $DIR/issue-54505-no-std.rs:25:4 | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- error[E0308]: mismatched types - --> $DIR/issue-54505-no-std.rs:47:16 + --> $DIR/issue-54505-no-std.rs:49:16 | LL | take_range(..5); | ---------- ^^^ @@ -85,13 +95,13 @@ LL | take_range(..5); = note: expected reference `&_` found struct `RangeTo<{integer}>` note: function defined here - --> $DIR/issue-54505-no-std.rs:23:4 + --> $DIR/issue-54505-no-std.rs:25:4 | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- error[E0308]: mismatched types - --> $DIR/issue-54505-no-std.rs:52:16 + --> $DIR/issue-54505-no-std.rs:54:16 | LL | take_range(..=42); | ---------- ^^^^^ @@ -103,11 +113,11 @@ LL | take_range(..=42); = note: expected reference `&_` found struct `RangeToInclusive<{integer}>` note: function defined here - --> $DIR/issue-54505-no-std.rs:23:4 + --> $DIR/issue-54505-no-std.rs:25:4 | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- -error: aborting due to 7 previous errors +error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/raw-ref-op/raw-ref-temp-deref.rs b/src/test/ui/raw-ref-op/raw-ref-temp-deref.rs index a814003ae..2e075a1b9 100644 --- a/src/test/ui/raw-ref-op/raw-ref-temp-deref.rs +++ b/src/test/ui/raw-ref-op/raw-ref-temp-deref.rs @@ -18,7 +18,7 @@ fn main() { let index_deref_ref = &raw const SLICE_REF[1]; let x = 0; - let ascribe_ref = &raw const (x: i32); - let ascribe_deref = &raw const (*ARRAY_REF: [i32; 2]); - let ascribe_index_deref = &raw const (ARRAY_REF[0]: i32); + let ascribe_ref = &raw const type_ascribe!(x, i32); + let ascribe_deref = &raw const type_ascribe!(*ARRAY_REF, [i32; 2]); + let ascribe_index_deref = &raw const type_ascribe!(ARRAY_REF[0], i32); } diff --git a/src/test/ui/raw-ref-op/raw-ref-temp.rs b/src/test/ui/raw-ref-op/raw-ref-temp.rs index 32df56468..10e47cb34 100644 --- a/src/test/ui/raw-ref-op/raw-ref-temp.rs +++ b/src/test/ui/raw-ref-op/raw-ref-temp.rs @@ -8,24 +8,24 @@ const PAIR: (i32, i64) = (1, 2); const ARRAY: [i32; 2] = [1, 2]; fn main() { - let ref_expr = &raw const 2; //~ ERROR cannot take address - let mut_ref_expr = &raw mut 3; //~ ERROR cannot take address - let ref_const = &raw const FOUR; //~ ERROR cannot take address - let mut_ref_const = &raw mut FOUR; //~ ERROR cannot take address - - let field_ref_expr = &raw const (1, 2).0; //~ ERROR cannot take address - let mut_field_ref_expr = &raw mut (1, 2).0; //~ ERROR cannot take address - let field_ref = &raw const PAIR.0; //~ ERROR cannot take address - let mut_field_ref = &raw mut PAIR.0; //~ ERROR cannot take address - - let index_ref_expr = &raw const [1, 2][0]; //~ ERROR cannot take address - let mut_index_ref_expr = &raw mut [1, 2][0]; //~ ERROR cannot take address - let index_ref = &raw const ARRAY[0]; //~ ERROR cannot take address - let mut_index_ref = &raw mut ARRAY[1]; //~ ERROR cannot take address - - let ref_ascribe = &raw const (2: i32); //~ ERROR cannot take address - let mut_ref_ascribe = &raw mut (3: i32); //~ ERROR cannot take address - - let ascribe_field_ref = &raw const (PAIR.0: i32); //~ ERROR cannot take address - let ascribe_index_ref = &raw mut (ARRAY[0]: i32); //~ ERROR cannot take address + let ref_expr = &raw const 2; //~ ERROR cannot take address + let mut_ref_expr = &raw mut 3; //~ ERROR cannot take address + let ref_const = &raw const FOUR; //~ ERROR cannot take address + let mut_ref_const = &raw mut FOUR; //~ ERROR cannot take address + + let field_ref_expr = &raw const (1, 2).0; //~ ERROR cannot take address + let mut_field_ref_expr = &raw mut (1, 2).0; //~ ERROR cannot take address + let field_ref = &raw const PAIR.0; //~ ERROR cannot take address + let mut_field_ref = &raw mut PAIR.0; //~ ERROR cannot take address + + let index_ref_expr = &raw const [1, 2][0]; //~ ERROR cannot take address + let mut_index_ref_expr = &raw mut [1, 2][0]; //~ ERROR cannot take address + let index_ref = &raw const ARRAY[0]; //~ ERROR cannot take address + let mut_index_ref = &raw mut ARRAY[1]; //~ ERROR cannot take address + + let ref_ascribe = &raw const type_ascribe!(2, i32); //~ ERROR cannot take address + let mut_ref_ascribe = &raw mut type_ascribe!(3, i32); //~ ERROR cannot take address + + let ascribe_field_ref = &raw const type_ascribe!(PAIR.0, i32); //~ ERROR cannot take address + let ascribe_index_ref = &raw mut type_ascribe!(ARRAY[0], i32); //~ ERROR cannot take address } diff --git a/src/test/ui/raw-ref-op/raw-ref-temp.stderr b/src/test/ui/raw-ref-op/raw-ref-temp.stderr index 80dea76d5..b96661625 100644 --- a/src/test/ui/raw-ref-op/raw-ref-temp.stderr +++ b/src/test/ui/raw-ref-op/raw-ref-temp.stderr @@ -73,26 +73,26 @@ LL | let mut_index_ref = &raw mut ARRAY[1]; error[E0745]: cannot take address of a temporary --> $DIR/raw-ref-temp.rs:26:34 | -LL | let ref_ascribe = &raw const (2: i32); - | ^^^^^^^^ temporary value +LL | let ref_ascribe = &raw const type_ascribe!(2, i32); + | ^^^^^^^^^^^^^^^^^^^^^ temporary value error[E0745]: cannot take address of a temporary --> $DIR/raw-ref-temp.rs:27:36 | -LL | let mut_ref_ascribe = &raw mut (3: i32); - | ^^^^^^^^ temporary value +LL | let mut_ref_ascribe = &raw mut type_ascribe!(3, i32); + | ^^^^^^^^^^^^^^^^^^^^^ temporary value error[E0745]: cannot take address of a temporary --> $DIR/raw-ref-temp.rs:29:40 | -LL | let ascribe_field_ref = &raw const (PAIR.0: i32); - | ^^^^^^^^^^^^^ temporary value +LL | let ascribe_field_ref = &raw const type_ascribe!(PAIR.0, i32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value error[E0745]: cannot take address of a temporary --> $DIR/raw-ref-temp.rs:30:38 | -LL | let ascribe_index_ref = &raw mut (ARRAY[0]: i32); - | ^^^^^^^^^^^^^^^ temporary value +LL | let ascribe_index_ref = &raw mut type_ascribe!(ARRAY[0], i32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value error: aborting due to 16 previous errors diff --git a/src/test/ui/reachable/expr_type.rs b/src/test/ui/reachable/expr_type.rs index 8d32397b5..1ceb2f859 100644 --- a/src/test/ui/reachable/expr_type.rs +++ b/src/test/ui/reachable/expr_type.rs @@ -6,7 +6,7 @@ fn a() { // the cast is unreachable: - let x = {return}: !; //~ ERROR unreachable + let x = type_ascribe!({return}, !); //~ ERROR unreachable } fn main() { } diff --git a/src/test/ui/reachable/expr_type.stderr b/src/test/ui/reachable/expr_type.stderr index c56c64be7..3cb4a32e0 100644 --- a/src/test/ui/reachable/expr_type.stderr +++ b/src/test/ui/reachable/expr_type.stderr @@ -1,10 +1,10 @@ error: unreachable expression --> $DIR/expr_type.rs:9:13 | -LL | let x = {return}: !; - | ^------^^^^ - | || - | |any code following this expression is unreachable +LL | let x = type_ascribe!({return}, !); + | ^^^^^^^^^^^^^^^------^^^^^ + | | | + | | any code following this expression is unreachable | unreachable expression | note: the lint level is defined here diff --git a/src/test/ui/recursion/issue-83150.rs b/src/test/ui/recursion/issue-83150.rs index e647f0ff4..38353d161 100644 --- a/src/test/ui/recursion/issue-83150.rs +++ b/src/test/ui/recursion/issue-83150.rs @@ -1,6 +1,7 @@ // build-fail // compile-flags: -Copt-level=0 -//~^^ ERROR overflow evaluating the requirement +// normalize-stderr-test: "long-type-\d+" -> "long-type-hash" +//~^^^ ERROR overflow evaluating the requirement fn main() { let mut iter = 0u8..1; diff --git a/src/test/ui/recursion/issue-83150.stderr b/src/test/ui/recursion/issue-83150.stderr index 3e0229717..dde8ad1b6 100644 --- a/src/test/ui/recursion/issue-83150.stderr +++ b/src/test/ui/recursion/issue-83150.stderr @@ -1,5 +1,5 @@ warning: function cannot return without recursing - --> $DIR/issue-83150.rs:10:1 + --> $DIR/issue-83150.rs:11:1 | LL | fn func<T: Iterator<Item = u8>>(iter: &mut T) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing @@ -9,10 +9,11 @@ LL | func(&mut iter.map(|x| x + 1)) = help: a `loop` may express intention better if this is on purpose = note: `#[warn(unconditional_recursion)]` on by default -error[E0275]: overflow evaluating the requirement `Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut std::ops::Range<u8>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>: Iterator` +error[E0275]: overflow evaluating the requirement `Map<&mut Map<&mut Map<&mut Map<..., ...>, ...>, ...>, ...>: Iterator` | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_83150`) - = note: required for `&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut std::ops::Range<u8>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>` to implement `Iterator` + = note: required for `&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<..., ...>, ...>, ...>, ...>, ...>, ...>, ...>` to implement `Iterator` + = note: the full type name has been written to '$TEST_BUILD_DIR/recursion/issue-83150/issue-83150.long-type-hash.txt' error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/recursion/recursion.stderr b/src/test/ui/recursion/recursion.stderr index d2844d0e6..cf0809537 100644 --- a/src/test/ui/recursion/recursion.stderr +++ b/src/test/ui/recursion/recursion.stderr @@ -1,4 +1,4 @@ -error: reached the recursion limit while instantiating `test::<Cons<Cons<Cons<Cons<Cons<...>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` +error: reached the recursion limit while instantiating `test::<Cons<Cons<Cons<Cons<Cons<...>>>>>>` --> $DIR/recursion.rs:18:11 | LL | _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})} diff --git a/src/test/ui/regions/issue-102374.rs b/src/test/ui/regions/issue-102374.rs index e0a116421..fd71248d9 100644 --- a/src/test/ui/regions/issue-102374.rs +++ b/src/test/ui/regions/issue-102374.rs @@ -1,3 +1,4 @@ +// normalize-stderr-test: "long-type-\d+" -> "long-type-hash" use std::cell::Cell; #[rustfmt::skip] diff --git a/src/test/ui/regions/issue-102374.stderr b/src/test/ui/regions/issue-102374.stderr index 31b855c36..157850693 100644 --- a/src/test/ui/regions/issue-102374.stderr +++ b/src/test/ui/regions/issue-102374.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-102374.rs:16:5 + --> $DIR/issue-102374.rs:17:5 | LL | ) -> i32 { | --- expected `i32` because of return type @@ -7,7 +7,8 @@ LL | f | ^ expected `i32`, found fn pointer | = note: expected type `i32` - found fn pointer `for<'z1, 'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, 'm, 'n, 'o, 'p, 'q, 'r, 's, 't, 'u, 'v, 'w, 'x, 'y, 'z, 'z0> fn(Cell<(&'z1 i32, &'a i32, &'b i32, &'c i32, &'d i32, &'e i32, &'f i32, &'g i32, &'h i32, &'i i32, &'j i32, &'k i32, &'l i32, &'m i32, &'n i32, &'o i32, &'p i32, &'q i32, &'r i32, &'s i32, &'t i32, &'u i32, &'v i32, &'w i32, &'x i32, &'y i32, &'z i32, &'z0 i32)>)` + found fn pointer `for<'z1, 'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, 'm, 'n, 'o, 'p, 'q, 'r, 's, 't, 'u, 'v, 'w, 'x, 'y, 'z, 'z0> fn(Cell<...>)` + the full type name has been written to '$TEST_BUILD_DIR/regions/issue-102374/issue-102374.long-type-hash.txt' error: aborting due to previous error diff --git a/src/test/ui/issues/issue-11612.rs b/src/test/ui/regions/issue-11612.rs index 9f7f1cc6f..9f7f1cc6f 100644 --- a/src/test/ui/issues/issue-11612.rs +++ b/src/test/ui/regions/issue-11612.rs diff --git a/src/test/ui/regions/regions-free-region-ordering-caller1.stderr b/src/test/ui/regions/regions-free-region-ordering-caller1.stderr index 8042b1740..8ef7e2253 100644 --- a/src/test/ui/regions/regions-free-region-ordering-caller1.stderr +++ b/src/test/ui/regions/regions-free-region-ordering-caller1.stderr @@ -5,7 +5,7 @@ LL | fn call1<'a>(x: &'a usize) { | -- lifetime `'a` defined here ... LL | let z: &'a & usize = &(&y); - | ----------- ^^^^ creates a temporary which is freed while still in use + | ----------- ^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'a` ... diff --git a/src/test/ui/regions/regions-var-type-out-of-scope.stderr b/src/test/ui/regions/regions-var-type-out-of-scope.stderr index 476e82f04..c32bbe0ee 100644 --- a/src/test/ui/regions/regions-var-type-out-of-scope.stderr +++ b/src/test/ui/regions/regions-var-type-out-of-scope.stderr @@ -4,7 +4,7 @@ error[E0716]: temporary value dropped while borrowed LL | x = &id(3); | ^^^^^- temporary value is freed at the end of this statement | | - | creates a temporary which is freed while still in use + | creates a temporary value which is freed while still in use LL | assert_eq!(*x, 3); | ----------------- borrow later used here | diff --git a/src/test/ui/align-with-extern-c-fn.rs b/src/test/ui/repr/align-with-extern-c-fn.rs index 9e490e27a..9e490e27a 100644 --- a/src/test/ui/align-with-extern-c-fn.rs +++ b/src/test/ui/repr/align-with-extern-c-fn.rs diff --git a/src/test/ui/aligned_enum_cast.rs b/src/test/ui/repr/aligned_enum_cast.rs index 1ddf12717..1ddf12717 100644 --- a/src/test/ui/aligned_enum_cast.rs +++ b/src/test/ui/repr/aligned_enum_cast.rs diff --git a/src/test/ui/repr_c_int_align.rs b/src/test/ui/repr/repr_c_int_align.rs index fdd14fc2d..fdd14fc2d 100644 --- a/src/test/ui/repr_c_int_align.rs +++ b/src/test/ui/repr/repr_c_int_align.rs diff --git a/src/test/ui/resolve/bad-module.stderr b/src/test/ui/resolve/bad-module.stderr index 581a66198..558760c67 100644 --- a/src/test/ui/resolve/bad-module.stderr +++ b/src/test/ui/resolve/bad-module.stderr @@ -1,15 +1,15 @@ -error[E0433]: failed to resolve: use of undeclared crate or module `thing` - --> $DIR/bad-module.rs:2:15 - | -LL | let foo = thing::len(Vec::new()); - | ^^^^^ use of undeclared crate or module `thing` - error[E0433]: failed to resolve: use of undeclared crate or module `foo` --> $DIR/bad-module.rs:5:15 | LL | let foo = foo::bar::baz(); | ^^^ use of undeclared crate or module `foo` +error[E0433]: failed to resolve: use of undeclared crate or module `thing` + --> $DIR/bad-module.rs:2:15 + | +LL | let foo = thing::len(Vec::new()); + | ^^^^^ use of undeclared crate or module `thing` + error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/blind-item-local-shadow.rs b/src/test/ui/resolve/blind-item-local-shadow.rs index 942aeb6fd..942aeb6fd 100644 --- a/src/test/ui/blind-item-local-shadow.rs +++ b/src/test/ui/resolve/blind-item-local-shadow.rs diff --git a/src/test/ui/resolve/issue-101749-2.rs b/src/test/ui/resolve/issue-101749-2.rs new file mode 100644 index 000000000..4d3d46944 --- /dev/null +++ b/src/test/ui/resolve/issue-101749-2.rs @@ -0,0 +1,16 @@ +struct Rectangle { + width: i32, + height: i32, +} +impl Rectangle { + fn new(width: i32, height: i32) -> Self { + Self { width, height } + } +} + +fn main() { + let rect = Rectangle::new(3, 4); + // `area` is not implemented for `Rectangle`, so this should not suggest + let _ = rect::area(); + //~^ ERROR failed to resolve: use of undeclared crate or module `rect` +} diff --git a/src/test/ui/resolve/issue-101749-2.stderr b/src/test/ui/resolve/issue-101749-2.stderr new file mode 100644 index 000000000..370d4b145 --- /dev/null +++ b/src/test/ui/resolve/issue-101749-2.stderr @@ -0,0 +1,9 @@ +error[E0433]: failed to resolve: use of undeclared crate or module `rect` + --> $DIR/issue-101749-2.rs:14:13 + | +LL | let _ = rect::area(); + | ^^^^ use of undeclared crate or module `rect` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/resolve/issue-101749.fixed b/src/test/ui/resolve/issue-101749.fixed new file mode 100644 index 000000000..3e5544296 --- /dev/null +++ b/src/test/ui/resolve/issue-101749.fixed @@ -0,0 +1,19 @@ +// run-rustfix +struct Rectangle { + width: i32, + height: i32, +} +impl Rectangle { + fn new(width: i32, height: i32) -> Self { + Self { width, height } + } + fn area(&self) -> i32 { + self.height * self.width + } +} + +fn main() { + let rect = Rectangle::new(3, 4); + let _ = rect.area(); + //~^ ERROR failed to resolve: use of undeclared crate or module `rect` +} diff --git a/src/test/ui/resolve/issue-101749.rs b/src/test/ui/resolve/issue-101749.rs new file mode 100644 index 000000000..fd67ccab6 --- /dev/null +++ b/src/test/ui/resolve/issue-101749.rs @@ -0,0 +1,19 @@ +// run-rustfix +struct Rectangle { + width: i32, + height: i32, +} +impl Rectangle { + fn new(width: i32, height: i32) -> Self { + Self { width, height } + } + fn area(&self) -> i32 { + self.height * self.width + } +} + +fn main() { + let rect = Rectangle::new(3, 4); + let _ = rect::area(); + //~^ ERROR failed to resolve: use of undeclared crate or module `rect` +} diff --git a/src/test/ui/resolve/issue-101749.stderr b/src/test/ui/resolve/issue-101749.stderr new file mode 100644 index 000000000..dd29d7fc0 --- /dev/null +++ b/src/test/ui/resolve/issue-101749.stderr @@ -0,0 +1,14 @@ +error[E0433]: failed to resolve: use of undeclared crate or module `rect` + --> $DIR/issue-101749.rs:17:13 + | +LL | let _ = rect::area(); + | ^^^^ use of undeclared crate or module `rect` + | +help: you may have meant to call an instance method + | +LL | let _ = rect.area(); + | ~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/resolve/issue-103474.rs b/src/test/ui/resolve/issue-103474.rs new file mode 100644 index 000000000..14f2259e1 --- /dev/null +++ b/src/test/ui/resolve/issue-103474.rs @@ -0,0 +1,28 @@ +struct S {} +impl S { + fn first(&self) {} + + fn second(&self) { + first() + //~^ ERROR cannot find function `first` in this scope + } + + fn third(&self) { + no_method_err() + //~^ ERROR cannot find function `no_method_err` in this scope + } +} + +// https://github.com/rust-lang/rust/pull/103531#discussion_r1004728080 +struct Foo { + i: i32, +} + +impl Foo { + fn needs_self() { + this.i + //~^ ERROR cannot find value `this` in this scope + } +} + +fn main() {} diff --git a/src/test/ui/resolve/issue-103474.stderr b/src/test/ui/resolve/issue-103474.stderr new file mode 100644 index 000000000..415d23155 --- /dev/null +++ b/src/test/ui/resolve/issue-103474.stderr @@ -0,0 +1,35 @@ +error[E0425]: cannot find value `this` in this scope + --> $DIR/issue-103474.rs:23:9 + | +LL | this.i + | ^^^^ not found in this scope + | +help: you might have meant to use `self` here instead + | +LL | self.i + | ~~~~ +help: if you meant to use `self`, you are also missing a `self` receiver argument + | +LL | fn needs_self(&self) { + | +++++ + +error[E0425]: cannot find function `first` in this scope + --> $DIR/issue-103474.rs:6:9 + | +LL | first() + | ^^^^^ not found in this scope + | +help: consider using the associated function + | +LL | self.first() + | +++++ + +error[E0425]: cannot find function `no_method_err` in this scope + --> $DIR/issue-103474.rs:11:9 + | +LL | no_method_err() + | ^^^^^^^^^^^^^ not found in this scope + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/resolve/issue-105069.rs b/src/test/ui/resolve/issue-105069.rs new file mode 100644 index 000000000..73455cf77 --- /dev/null +++ b/src/test/ui/resolve/issue-105069.rs @@ -0,0 +1,11 @@ +use self::A::*; +use V; //~ ERROR `V` is ambiguous +use self::B::*; +enum A { + V +} +enum B { + V +} + +fn main() {} diff --git a/src/test/ui/resolve/issue-105069.stderr b/src/test/ui/resolve/issue-105069.stderr new file mode 100644 index 000000000..1e6c9c6e2 --- /dev/null +++ b/src/test/ui/resolve/issue-105069.stderr @@ -0,0 +1,21 @@ +error[E0659]: `V` is ambiguous + --> $DIR/issue-105069.rs:2:5 + | +LL | use V; + | ^ ambiguous name + | + = note: ambiguous because of multiple potential import sources +note: `V` could refer to the variant imported here + --> $DIR/issue-105069.rs:1:5 + | +LL | use self::A::*; + | ^^^^^^^^^^ +note: `V` could also refer to the variant imported here + --> $DIR/issue-105069.rs:3:5 + | +LL | use self::B::*; + | ^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0659`. diff --git a/src/test/ui/resolve/issue-18252.rs b/src/test/ui/resolve/issue-18252.rs index af0a3cbcb..f6ebe2920 100644 --- a/src/test/ui/resolve/issue-18252.rs +++ b/src/test/ui/resolve/issue-18252.rs @@ -4,5 +4,5 @@ enum Foo { fn main() { let f = Foo::Variant(42); - //~^ ERROR expected function, tuple struct or tuple variant, found struct variant `Foo::Variant` + //~^ ERROR expected value, found struct variant `Foo::Variant` } diff --git a/src/test/ui/resolve/issue-18252.stderr b/src/test/ui/resolve/issue-18252.stderr index 13e7a5973..d9006c0a6 100644 --- a/src/test/ui/resolve/issue-18252.stderr +++ b/src/test/ui/resolve/issue-18252.stderr @@ -1,12 +1,9 @@ -error[E0423]: expected function, tuple struct or tuple variant, found struct variant `Foo::Variant` +error[E0533]: expected value, found struct variant `Foo::Variant` --> $DIR/issue-18252.rs:6:13 | -LL | Variant { x: usize } - | -------------------- `Foo::Variant` defined here -... LL | let f = Foo::Variant(42); - | ^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `Foo::Variant { x: val }` + | ^^^^^^^^^^^^ not a value error: aborting due to previous error -For more information about this error, try `rustc --explain E0423`. +For more information about this error, try `rustc --explain E0533`. diff --git a/src/test/ui/resolve/issue-19452.stderr b/src/test/ui/resolve/issue-19452.stderr index 8df84067e..eff89241f 100644 --- a/src/test/ui/resolve/issue-19452.stderr +++ b/src/test/ui/resolve/issue-19452.stderr @@ -1,23 +1,15 @@ -error[E0423]: expected value, found struct variant `Homura::Madoka` +error[E0533]: expected value, found struct variant `Homura::Madoka` --> $DIR/issue-19452.rs:10:18 | -LL | Madoka { age: u32 } - | ------------------- `Homura::Madoka` defined here -... LL | let homura = Homura::Madoka; - | ^^^^^^^^^^^^^^ help: use struct literal syntax instead: `Homura::Madoka { age: val }` + | ^^^^^^^^^^^^^^ not a value -error[E0423]: expected value, found struct variant `issue_19452_aux::Homura::Madoka` +error[E0533]: expected value, found struct variant `issue_19452_aux::Homura::Madoka` --> $DIR/issue-19452.rs:13:18 | LL | let homura = issue_19452_aux::Homura::Madoka; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `issue_19452_aux::Homura::Madoka { /* fields */ }` - | - ::: $DIR/auxiliary/issue-19452-aux.rs:2:5 - | -LL | Madoka { age: u32 } - | ------ `issue_19452_aux::Homura::Madoka` defined here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a value error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0423`. +For more information about this error, try `rustc --explain E0533`. diff --git a/src/test/ui/resolve/issue-2356.stderr b/src/test/ui/resolve/issue-2356.stderr index e7c53ff44..36f3da7c9 100644 --- a/src/test/ui/resolve/issue-2356.stderr +++ b/src/test/ui/resolve/issue-2356.stderr @@ -85,7 +85,7 @@ LL | static_method(); help: consider using the associated function | LL | Self::static_method(); - | ~~~~~~~~~~~~~~~~~~~ + | ++++++ error[E0425]: cannot find function `purr` in this scope --> $DIR/issue-2356.rs:54:9 @@ -114,7 +114,7 @@ LL | grow_older(); help: consider using the associated function | LL | Self::grow_older(); - | ~~~~~~~~~~~~~~~~ + | ++++++ error[E0425]: cannot find function `shave` in this scope --> $DIR/issue-2356.rs:74:5 diff --git a/src/test/ui/resolve/issue-24968.stderr b/src/test/ui/resolve/issue-24968.stderr index 7e539d258..82f5a1d5b 100644 --- a/src/test/ui/resolve/issue-24968.stderr +++ b/src/test/ui/resolve/issue-24968.stderr @@ -1,15 +1,3 @@ -error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions - --> $DIR/issue-24968.rs:21:19 - | -LL | const FOO2: u32 = Self::bar(); - | ^^^^ `Self` is only available in impls, traits, and type definitions - -error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions - --> $DIR/issue-24968.rs:27:22 - | -LL | static FOO_S2: u32 = Self::bar(); - | ^^^^ `Self` is only available in impls, traits, and type definitions - error[E0411]: cannot find type `Self` in this scope --> $DIR/issue-24968.rs:3:11 | @@ -51,6 +39,18 @@ LL | static FOO_S: Self = 0; | | | `Self` not allowed in a static item +error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions + --> $DIR/issue-24968.rs:21:19 + | +LL | const FOO2: u32 = Self::bar(); + | ^^^^ `Self` is only available in impls, traits, and type definitions + +error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions + --> $DIR/issue-24968.rs:27:22 + | +LL | static FOO_S2: u32 = Self::bar(); + | ^^^^ `Self` is only available in impls, traits, and type definitions + error: aborting due to 7 previous errors Some errors have detailed explanations: E0411, E0433. diff --git a/src/test/ui/issues/issue-35675.rs b/src/test/ui/resolve/issue-35675.rs index 683761667..683761667 100644 --- a/src/test/ui/issues/issue-35675.rs +++ b/src/test/ui/resolve/issue-35675.rs diff --git a/src/test/ui/issues/issue-35675.stderr b/src/test/ui/resolve/issue-35675.stderr index 4a06196d5..4a06196d5 100644 --- a/src/test/ui/issues/issue-35675.stderr +++ b/src/test/ui/resolve/issue-35675.stderr diff --git a/src/test/ui/resolve/issue-50599.rs b/src/test/ui/resolve/issue-50599.rs index 78a20cf8e..72238a591 100644 --- a/src/test/ui/resolve/issue-50599.rs +++ b/src/test/ui/resolve/issue-50599.rs @@ -2,5 +2,5 @@ fn main() { const N: u32 = 1_000; const M: usize = (f64::from(N) * std::f64::LOG10_2) as usize; //~ ERROR cannot find value let mut digits = [0u32; M]; - //~^ ERROR evaluation of constant value failed + //~^ constant } diff --git a/src/test/ui/resolve/issue-50599.stderr b/src/test/ui/resolve/issue-50599.stderr index 910deddd8..b07482c83 100644 --- a/src/test/ui/resolve/issue-50599.stderr +++ b/src/test/ui/resolve/issue-50599.stderr @@ -16,13 +16,12 @@ LL - const M: usize = (f64::from(N) * std::f64::LOG10_2) as usize; LL + const M: usize = (f64::from(N) * LOG10_2) as usize; | -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/issue-50599.rs:4:29 | LL | let mut digits = [0u32; M]; - | ^ referenced constant has errors + | ^ -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0080, E0425. -For more information about an error, try `rustc --explain E0080`. +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/issues/issue-5927.rs b/src/test/ui/resolve/issue-5927.rs index 14f95827b..14f95827b 100644 --- a/src/test/ui/issues/issue-5927.rs +++ b/src/test/ui/resolve/issue-5927.rs diff --git a/src/test/ui/issues/issue-5927.stderr b/src/test/ui/resolve/issue-5927.stderr index d6cd6853d..d6cd6853d 100644 --- a/src/test/ui/issues/issue-5927.stderr +++ b/src/test/ui/resolve/issue-5927.stderr diff --git a/src/test/ui/issues/issue-60057.rs b/src/test/ui/resolve/issue-60057.rs index b52343ada..b52343ada 100644 --- a/src/test/ui/issues/issue-60057.rs +++ b/src/test/ui/resolve/issue-60057.rs diff --git a/src/test/ui/issues/issue-60057.stderr b/src/test/ui/resolve/issue-60057.stderr index 4d915fcd9..4d915fcd9 100644 --- a/src/test/ui/issues/issue-60057.stderr +++ b/src/test/ui/resolve/issue-60057.stderr diff --git a/src/test/ui/resolve/issue-73427.stderr b/src/test/ui/resolve/issue-73427.stderr index d31c5e477..4af5f29d8 100644 --- a/src/test/ui/resolve/issue-73427.stderr +++ b/src/test/ui/resolve/issue-73427.stderr @@ -17,16 +17,12 @@ LL | | } | |_^ help: you might have meant to use one of the following enum variants | -LL | (A::Struct {}).foo(); - | ~~~~~~~~~~~~~~ LL | (A::Tuple()).foo(); | ~~~~~~~~~~~~ LL | A::Unit.foo(); | ~~~~~~~ -help: alternatively, the following enum variants are also available +help: alternatively, the following enum variant is available | -LL | (A::StructWithFields { /* fields */ }).foo(); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LL | (A::TupleWithFields(/* fields */)).foo(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -34,7 +30,7 @@ error[E0423]: expected value, found enum `B` --> $DIR/issue-73427.rs:35:5 | LL | B.foo(); - | ^ + | ^ help: the following enum variant is available: `(B::TupleWithFields(/* fields */))` | note: the enum is defined here --> $DIR/issue-73427.rs:9:1 @@ -44,12 +40,6 @@ LL | | StructWithFields { x: () }, LL | | TupleWithFields(()), LL | | } | |_^ -help: the following enum variants are available - | -LL | (B::StructWithFields { /* fields */ }).foo(); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -LL | (B::TupleWithFields(/* fields */)).foo(); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0423]: expected value, found enum `C` --> $DIR/issue-73427.rs:37:5 @@ -70,10 +60,8 @@ help: you might have meant to use the following enum variant | LL | C::Unit.foo(); | ~~~~~~~ -help: alternatively, the following enum variants are also available +help: alternatively, the following enum variant is available | -LL | (C::StructWithFields { /* fields */ }).foo(); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LL | (C::TupleWithFields(/* fields */)).foo(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -130,7 +118,7 @@ error[E0532]: expected tuple struct or tuple variant, found enum `A` LL | if let A(3) = x { } | ^ | - = help: you might have meant to match against one of the enum's non-tuple variants + = help: you might have meant to match against the enum's non-tuple variant note: the enum is defined here --> $DIR/issue-73427.rs:1:1 | @@ -155,7 +143,7 @@ error[E0423]: expected function, tuple struct or tuple variant, found enum `A` LL | let x = A(3); | ^ | - = help: you might have meant to construct one of the enum's non-tuple variants + = help: you might have meant to construct the enum's non-tuple variant note: the enum is defined here --> $DIR/issue-73427.rs:1:1 | diff --git a/src/test/ui/resolve/missing-in-namespace.stderr b/src/test/ui/resolve/missing-in-namespace.stderr index 3d49b2e5d..fc925ba3b 100644 --- a/src/test/ui/resolve/missing-in-namespace.stderr +++ b/src/test/ui/resolve/missing-in-namespace.stderr @@ -1,8 +1,8 @@ error[E0433]: failed to resolve: could not find `hahmap` in `std` - --> $DIR/missing-in-namespace.rs:2:29 + --> $DIR/missing-in-namespace.rs:2:21 | LL | let _map = std::hahmap::HashMap::new(); - | ^^^^^^^ not found in `std::hahmap` + | ^^^^^^ could not find `hahmap` in `std` | help: consider importing this struct | diff --git a/src/test/ui/resolve/point-at-type-parameter-shadowing-another-type.stderr b/src/test/ui/resolve/point-at-type-parameter-shadowing-another-type.stderr index eb26cd9ca..5790e425c 100644 --- a/src/test/ui/resolve/point-at-type-parameter-shadowing-another-type.stderr +++ b/src/test/ui/resolve/point-at-type-parameter-shadowing-another-type.stderr @@ -1,16 +1,14 @@ error[E0574]: expected struct, variant or union type, found type parameter `Baz` --> $DIR/point-at-type-parameter-shadowing-another-type.rs:16:13 | -LL | / struct Baz { -LL | | num: usize, -LL | | } - | |_- you might have meant to refer to this struct -LL | -LL | impl<Baz> Foo<Baz> for Bar { - | --- found this type parameter +LL | struct Baz { + | --- you might have meant to refer to this struct ... -LL | Baz { num } => num, - | ^^^ not a struct, variant or union type +LL | impl<Baz> Foo<Baz> for Bar { + | --- found this type parameter +... +LL | Baz { num } => num, + | ^^^ not a struct, variant or union type error: aborting due to previous error diff --git a/src/test/ui/resolve/privacy-enum-ctor.stderr b/src/test/ui/resolve/privacy-enum-ctor.stderr index 82a4211f0..d734fa76b 100644 --- a/src/test/ui/resolve/privacy-enum-ctor.stderr +++ b/src/test/ui/resolve/privacy-enum-ctor.stderr @@ -19,12 +19,10 @@ help: you might have meant to use the following enum variant | LL | m::Z::Unit; | ~~~~~~~~~~ -help: alternatively, the following enum variants are also available +help: alternatively, the following enum variant is available | LL | (m::Z::Fn(/* fields */)); | ~~~~~~~~~~~~~~~~~~~~~~~~ -LL | (m::Z::Struct { /* fields */ }); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0423]: expected value, found enum `Z` --> $DIR/privacy-enum-ctor.rs:25:9 @@ -47,23 +45,10 @@ help: you might have meant to use the following enum variant | LL | m::Z::Unit; | ~~~~~~~~~~ -help: alternatively, the following enum variants are also available +help: alternatively, the following enum variant is available | LL | (m::Z::Fn(/* fields */)); | ~~~~~~~~~~~~~~~~~~~~~~~~ -LL | (m::Z::Struct { /* fields */ }); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -error[E0423]: expected value, found struct variant `Z::Struct` - --> $DIR/privacy-enum-ctor.rs:29:20 - | -LL | / Struct { -LL | | s: u8, -LL | | }, - | |_____________- `Z::Struct` defined here -... -LL | let _: Z = Z::Struct; - | ^^^^^^^^^ help: use struct literal syntax instead: `Z::Struct { s: val }` error[E0423]: expected value, found enum `m::E` --> $DIR/privacy-enum-ctor.rs:41:16 @@ -89,12 +74,10 @@ help: you might have meant to use the following enum variant | LL | let _: E = E::Unit; | ~~~~~~~ -help: alternatively, the following enum variants are also available +help: alternatively, the following enum variant is available | LL | let _: E = (E::Fn(/* fields */)); | ~~~~~~~~~~~~~~~~~~~~~ -LL | let _: E = (E::Struct { /* fields */ }); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ help: a function with a similar name exists | LL | let _: E = m::f; @@ -111,17 +94,6 @@ LL - let _: E = m::E; LL + let _: E = E; | -error[E0423]: expected value, found struct variant `m::E::Struct` - --> $DIR/privacy-enum-ctor.rs:45:16 - | -LL | / Struct { -LL | | s: u8, -LL | | }, - | |_________- `m::E::Struct` defined here -... -LL | let _: E = m::E::Struct; - | ^^^^^^^^^^^^ help: use struct literal syntax instead: `m::E::Struct { s: val }` - error[E0423]: expected value, found enum `E` --> $DIR/privacy-enum-ctor.rs:49:16 | @@ -143,12 +115,10 @@ help: you might have meant to use the following enum variant | LL | let _: E = E::Unit; | ~~~~~~~ -help: alternatively, the following enum variants are also available +help: alternatively, the following enum variant is available | LL | let _: E = (E::Fn(/* fields */)); | ~~~~~~~~~~~~~~~~~~~~~ -LL | let _: E = (E::Struct { /* fields */ }); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ help: consider importing one of these items instead | LL | use std::f32::consts::E; @@ -156,17 +126,6 @@ LL | use std::f32::consts::E; LL | use std::f64::consts::E; | -error[E0423]: expected value, found struct variant `E::Struct` - --> $DIR/privacy-enum-ctor.rs:53:16 - | -LL | / Struct { -LL | | s: u8, -LL | | }, - | |_________- `E::Struct` defined here -... -LL | let _: E = E::Struct; - | ^^^^^^^^^ help: use struct literal syntax instead: `E::Struct { s: val }` - error[E0412]: cannot find type `Z` in this scope --> $DIR/privacy-enum-ctor.rs:57:12 | @@ -203,12 +162,10 @@ help: you might have meant to use the following enum variant | LL | let _: Z = m::Z::Unit; | ~~~~~~~~~~ -help: alternatively, the following enum variants are also available +help: alternatively, the following enum variant is available | LL | let _: Z = (m::Z::Fn(/* fields */)); | ~~~~~~~~~~~~~~~~~~~~~~~~ -LL | let _: Z = (m::Z::Struct { /* fields */ }); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0412]: cannot find type `Z` in this scope --> $DIR/privacy-enum-ctor.rs:61:12 @@ -240,17 +197,6 @@ note: enum `m::Z` exists but is inaccessible LL | pub(in m) enum Z { | ^^^^^^^^^^^^^^^^ not accessible -error[E0423]: expected value, found struct variant `m::n::Z::Struct` - --> $DIR/privacy-enum-ctor.rs:64:16 - | -LL | / Struct { -LL | | s: u8, -LL | | }, - | |_____________- `m::n::Z::Struct` defined here -... -LL | let _: Z = m::n::Z::Struct; - | ^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `m::n::Z::Struct { s: val }` - error[E0412]: cannot find type `Z` in this scope --> $DIR/privacy-enum-ctor.rs:68:12 | @@ -332,6 +278,12 @@ help: use parentheses to construct this tuple variant LL | let _: Z = Z::Fn(/* u8 */); | ++++++++++ +error[E0533]: expected value, found struct variant `Z::Struct` + --> $DIR/privacy-enum-ctor.rs:29:20 + | +LL | let _: Z = Z::Struct; + | ^^^^^^^^^ not a value + error[E0618]: expected function, found enum variant `Z::Unit` --> $DIR/privacy-enum-ctor.rs:31:17 | @@ -367,6 +319,12 @@ help: use parentheses to construct this tuple variant LL | let _: E = m::E::Fn(/* u8 */); | ++++++++++ +error[E0533]: expected value, found struct variant `m::E::Struct` + --> $DIR/privacy-enum-ctor.rs:45:16 + | +LL | let _: E = m::E::Struct; + | ^^^^^^^^^^^^ not a value + error[E0618]: expected function, found enum variant `m::E::Unit` --> $DIR/privacy-enum-ctor.rs:47:16 | @@ -402,6 +360,12 @@ help: use parentheses to construct this tuple variant LL | let _: E = E::Fn(/* u8 */); | ++++++++++ +error[E0533]: expected value, found struct variant `E::Struct` + --> $DIR/privacy-enum-ctor.rs:53:16 + | +LL | let _: E = E::Struct; + | ^^^^^^^^^ not a value + error[E0618]: expected function, found enum variant `E::Unit` --> $DIR/privacy-enum-ctor.rs:55:16 | @@ -419,7 +383,13 @@ LL - let _: E = E::Unit(); LL + let _: E = E::Unit; | +error[E0533]: expected value, found struct variant `m::n::Z::Struct` + --> $DIR/privacy-enum-ctor.rs:64:16 + | +LL | let _: Z = m::n::Z::Struct; + | ^^^^^^^^^^^^^^^ not a value + error: aborting due to 23 previous errors -Some errors have detailed explanations: E0308, E0412, E0423, E0603, E0618. +Some errors have detailed explanations: E0308, E0412, E0423, E0533, E0603, E0618. For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/resolve/resolve-self-in-impl.stderr b/src/test/ui/resolve/resolve-self-in-impl.stderr index 9f9ed6889..b3042d413 100644 --- a/src/test/ui/resolve/resolve-self-in-impl.stderr +++ b/src/test/ui/resolve/resolve-self-in-impl.stderr @@ -1,40 +1,40 @@ error: `Self` is not valid in the self type of an impl block - --> $DIR/resolve-self-in-impl.rs:14:13 + --> $DIR/resolve-self-in-impl.rs:16:6 | -LL | impl Tr for Self {} - | ^^^^ +LL | impl Self {} + | ^^^^ | = note: replace `Self` with a different type error: `Self` is not valid in the self type of an impl block - --> $DIR/resolve-self-in-impl.rs:15:15 + --> $DIR/resolve-self-in-impl.rs:17:8 | -LL | impl Tr for S<Self> {} - | ^^^^ +LL | impl S<Self> {} + | ^^^^ | = note: replace `Self` with a different type error: `Self` is not valid in the self type of an impl block - --> $DIR/resolve-self-in-impl.rs:16:6 + --> $DIR/resolve-self-in-impl.rs:18:7 | -LL | impl Self {} - | ^^^^ +LL | impl (Self, Self) {} + | ^^^^ ^^^^ | = note: replace `Self` with a different type error: `Self` is not valid in the self type of an impl block - --> $DIR/resolve-self-in-impl.rs:17:8 + --> $DIR/resolve-self-in-impl.rs:14:13 | -LL | impl S<Self> {} - | ^^^^ +LL | impl Tr for Self {} + | ^^^^ | = note: replace `Self` with a different type error: `Self` is not valid in the self type of an impl block - --> $DIR/resolve-self-in-impl.rs:18:7 + --> $DIR/resolve-self-in-impl.rs:15:15 | -LL | impl (Self, Self) {} - | ^^^^ ^^^^ +LL | impl Tr for S<Self> {} + | ^^^^ | = note: replace `Self` with a different type diff --git a/src/test/ui/resolve/typo-suggestion-mistyped-in-path.rs b/src/test/ui/resolve/typo-suggestion-mistyped-in-path.rs new file mode 100644 index 000000000..3ce17a14f --- /dev/null +++ b/src/test/ui/resolve/typo-suggestion-mistyped-in-path.rs @@ -0,0 +1,42 @@ +struct Struct; +//~^ NOTE function or associated item `fob` not found for this struct + +impl Struct { + fn foo() { } +} + +mod module { + fn foo() { } + + struct Struct; + + impl Struct { + fn foo() { } + } +} + +trait Trait { + fn foo(); +} + +fn main() { + Struct::fob(); + //~^ ERROR no function or associated item named `fob` found for struct `Struct` in the current scope + //~| NOTE function or associated item not found in `Struct` + + Struc::foo(); + //~^ ERROR failed to resolve: use of undeclared type `Struc` + //~| NOTE use of undeclared type `Struc` + + modul::foo(); + //~^ ERROR failed to resolve: use of undeclared crate or module `modul` + //~| NOTE use of undeclared crate or module `modul` + + module::Struc::foo(); + //~^ ERROR failed to resolve: could not find `Struc` in `module` + //~| NOTE could not find `Struc` in `module` + + Trai::foo(); + //~^ ERROR failed to resolve: use of undeclared type `Trai` + //~| NOTE use of undeclared type `Trai` +} diff --git a/src/test/ui/resolve/typo-suggestion-mistyped-in-path.stderr b/src/test/ui/resolve/typo-suggestion-mistyped-in-path.stderr new file mode 100644 index 000000000..89b69e140 --- /dev/null +++ b/src/test/ui/resolve/typo-suggestion-mistyped-in-path.stderr @@ -0,0 +1,54 @@ +error[E0433]: failed to resolve: could not find `Struc` in `module` + --> $DIR/typo-suggestion-mistyped-in-path.rs:35:13 + | +LL | module::Struc::foo(); + | ^^^^^ + | | + | could not find `Struc` in `module` + | help: a struct with a similar name exists: `Struct` + +error[E0599]: no function or associated item named `fob` found for struct `Struct` in the current scope + --> $DIR/typo-suggestion-mistyped-in-path.rs:23:13 + | +LL | struct Struct; + | ------------- function or associated item `fob` not found for this struct +... +LL | Struct::fob(); + | ^^^ + | | + | function or associated item not found in `Struct` + | help: there is an associated function with a similar name: `foo` + +error[E0433]: failed to resolve: use of undeclared type `Struc` + --> $DIR/typo-suggestion-mistyped-in-path.rs:27:5 + | +LL | Struc::foo(); + | ^^^^^ + | | + | use of undeclared type `Struc` + | help: a struct with a similar name exists: `Struct` + +error[E0433]: failed to resolve: use of undeclared crate or module `modul` + --> $DIR/typo-suggestion-mistyped-in-path.rs:31:5 + | +LL | modul::foo(); + | ^^^^^ use of undeclared crate or module `modul` + | +help: there is a crate or module with a similar name + | +LL | module::foo(); + | ~~~~~~ + +error[E0433]: failed to resolve: use of undeclared type `Trai` + --> $DIR/typo-suggestion-mistyped-in-path.rs:39:5 + | +LL | Trai::foo(); + | ^^^^ + | | + | use of undeclared type `Trai` + | help: a trait with a similar name exists: `Trait` + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0433, E0599. +For more information about an error, try `rustc --explain E0433`. diff --git a/src/test/ui/resolve/use_suggestion.stderr b/src/test/ui/resolve/use_suggestion.stderr index 4fff179b1..54ad85383 100644 --- a/src/test/ui/resolve/use_suggestion.stderr +++ b/src/test/ui/resolve/use_suggestion.stderr @@ -1,14 +1,8 @@ -error[E0433]: failed to resolve: use of undeclared type `GooMap` - --> $DIR/use_suggestion.rs:3:14 - | -LL | let x2 = GooMap::new(); - | ^^^^^^ use of undeclared type `GooMap` - error[E0433]: failed to resolve: use of undeclared type `HashMap` --> $DIR/use_suggestion.rs:2:14 | LL | let x1 = HashMap::new(); - | ^^^^^^^ not found in this scope + | ^^^^^^^ use of undeclared type `HashMap` | help: consider importing this struct | @@ -32,6 +26,12 @@ error[E0412]: cannot find type `GooMap` in this scope LL | let y2: GooMap; | ^^^^^^ not found in this scope +error[E0433]: failed to resolve: use of undeclared type `GooMap` + --> $DIR/use_suggestion.rs:3:14 + | +LL | let x2 = GooMap::new(); + | ^^^^^^ use of undeclared type `GooMap` + error: aborting due to 4 previous errors Some errors have detailed explanations: E0412, E0433. diff --git a/src/test/ui/return/issue-86188-return-not-in-fn-body.stderr b/src/test/ui/return/issue-86188-return-not-in-fn-body.stderr index d7eeb3a72..4f938670e 100644 --- a/src/test/ui/return/issue-86188-return-not-in-fn-body.stderr +++ b/src/test/ui/return/issue-86188-return-not-in-fn-body.stderr @@ -35,17 +35,17 @@ LL | | } error[E0572]: return statement outside of function body --> $DIR/issue-86188-return-not-in-fn-body.rs:36:10 | -LL | / fn main() { -LL | | -LL | | [(); return || { - | |__________^ +LL | / fn main() { +LL | | +LL | | [(); return || { + | | __________^ LL | || LL | || LL | || let tx; LL | || }]; | ||_____^ the return is part of this body... -LL | | } - | |_- ...not the enclosing function body +LL | | } + | |__- ...not the enclosing function body error: aborting due to 4 previous errors diff --git a/src/test/ui/return/tail-expr-as-potential-return.rs b/src/test/ui/return/tail-expr-as-potential-return.rs index 2c3610fb2..f46e088b8 100644 --- a/src/test/ui/return/tail-expr-as-potential-return.rs +++ b/src/test/ui/return/tail-expr-as-potential-return.rs @@ -12,7 +12,6 @@ // edition:2018 fn main() { - let _ = foo(true); } fn foo(x: bool) -> Result<f64, i32> { @@ -30,3 +29,19 @@ async fn bar(x: bool) -> Result<f64, i32> { } Ok(42.0) } + +trait Identity { + type Out; +} + +impl<T> Identity for T { + type Out = T; +} + +async fn foo2() -> i32 { + if true { + 1i32 //~ ERROR mismatched types + //| HELP you might have meant to return this value + } + 0 +} diff --git a/src/test/ui/return/tail-expr-as-potential-return.stderr b/src/test/ui/return/tail-expr-as-potential-return.stderr index dec1cbc46..9183b4599 100644 --- a/src/test/ui/return/tail-expr-as-potential-return.stderr +++ b/src/test/ui/return/tail-expr-as-potential-return.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/tail-expr-as-potential-return.rs:28:9 + --> $DIR/tail-expr-as-potential-return.rs:27:9 | LL | / if x { LL | | Err(42) @@ -16,7 +16,22 @@ LL | return Err(42); | ++++++ + error[E0308]: mismatched types - --> $DIR/tail-expr-as-potential-return.rs:20:9 + --> $DIR/tail-expr-as-potential-return.rs:43:9 + | +LL | / if true { +LL | | 1i32 + | | ^^^^ expected `()`, found `i32` +LL | | //| HELP you might have meant to return this value +LL | | } + | |_____- expected this to be `()` + | +help: you might have meant to return this value + | +LL | return 1i32; + | ++++++ + + +error[E0308]: mismatched types + --> $DIR/tail-expr-as-potential-return.rs:19:9 | LL | / if x { LL | | Err(42) @@ -32,6 +47,6 @@ help: you might have meant to return this value LL | return Err(42); | ++++++ + -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.rs index 6b7d94603..a8deb8a75 100644 --- a/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.rs +++ b/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.rs @@ -5,7 +5,7 @@ struct Foo { impl PartialEq for Foo { fn eq(&self, _: &Foo) -> bool { - false // ha ha sucker! + false // ha ha! } } diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr index 6ee323146..957795211 100644 --- a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr @@ -1,12 +1,10 @@ error[E0277]: the trait bound `f32: Termination` is not satisfied - --> $DIR/termination-trait-test-wrong-type.rs:6:1 + --> $DIR/termination-trait-test-wrong-type.rs:6:31 | -LL | #[test] - | ------- in this procedural macro expansion -LL | / fn can_parse_zero_as_f32() -> Result<f32, ParseFloatError> { -LL | | "0".parse() -LL | | } - | |_^ the trait `Termination` is not implemented for `f32` +LL | #[test] + | ------- in this procedural macro expansion +LL | fn can_parse_zero_as_f32() -> Result<f32, ParseFloatError> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Termination` is not implemented for `f32` | = note: required for `Result<f32, ParseFloatError>` to implement `Termination` note: required by a bound in `assert_test_result` diff --git a/src/test/ui/rfc-2294-if-let-guard/feature-gate.stderr b/src/test/ui/rfc-2294-if-let-guard/feature-gate.stderr index e017d04a5..96fe11911 100644 --- a/src/test/ui/rfc-2294-if-let-guard/feature-gate.stderr +++ b/src/test/ui/rfc-2294-if-let-guard/feature-gate.stderr @@ -72,6 +72,12 @@ LL | macro_rules! use_expr { ... LL | use_expr!(let 0 = 1); | ^^^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$e:expr` + --> $DIR/feature-gate.rs:61:10 + | +LL | ($e:expr) => { + | ^^^^^^^ error[E0658]: `if let` guards are experimental --> $DIR/feature-gate.rs:7:12 diff --git a/src/test/ui/rfc-2294-if-let-guard/run-pass.rs b/src/test/ui/rfc-2294-if-let-guard/run-pass.rs index 3da57989d..a303a0d1f 100644 --- a/src/test/ui/rfc-2294-if-let-guard/run-pass.rs +++ b/src/test/ui/rfc-2294-if-let-guard/run-pass.rs @@ -30,4 +30,11 @@ fn main() { Some(x) if let Foo::Qux(y) = qux(x) => assert_eq!(y, 84), _ => panic!(), } + + // issue #88015 + #[allow(irrefutable_let_patterns)] + match () { + () | () if let x = 42 => assert_eq!(x, 42), + _ => panic!() + } } diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr index 5611b5f4e..06699b947 100644 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr +++ b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr @@ -7,6 +7,12 @@ LL | let _ = dbg!(a); | ------- value moved here LL | let _ = dbg!(a); | ^ value used here after move + | +help: borrow this binding in the pattern to avoid moving the value + --> $SRC_DIR/std/src/macros.rs:LL:COL + | +LL | ref tmp => { + | +++ error: aborting due to previous error diff --git a/src/test/ui/rfc-2497-if-let-chains/feature-gate.stderr b/src/test/ui/rfc-2497-if-let-chains/feature-gate.stderr index feea1c254..7a43b71fc 100644 --- a/src/test/ui/rfc-2497-if-let-chains/feature-gate.stderr +++ b/src/test/ui/rfc-2497-if-let-chains/feature-gate.stderr @@ -18,6 +18,12 @@ LL | macro_rules! use_expr { ... LL | use_expr!(let 0 = 1); | ^^^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$e:expr` + --> $DIR/feature-gate.rs:50:10 + | +LL | ($e:expr) => { + | ^^^^^^^ error[E0658]: `let` expressions in this position are unstable --> $DIR/feature-gate.rs:14:16 diff --git a/src/test/ui/rfc-2497-if-let-chains/issue-99938.rs b/src/test/ui/rfc-2497-if-let-chains/issue-99938.rs new file mode 100644 index 000000000..bd81ce0b1 --- /dev/null +++ b/src/test/ui/rfc-2497-if-let-chains/issue-99938.rs @@ -0,0 +1,31 @@ +// compile-flags: -Zvalidate-mir -C opt-level=3 +// build-pass +#![feature(let_chains)] +struct TupleIter<T, I: Iterator<Item = T>> { + inner: I, +} + +impl<T, I: Iterator<Item = T>> Iterator for TupleIter<T, I> { + type Item = (T, T, T); + + fn next(&mut self) -> Option<Self::Item> { + let inner = &mut self.inner; + + if let Some(first) = inner.next() + && let Some(second) = inner.next() + && let Some(third) = inner.next() + { + Some((first, second, third)) + } else { + None + } + } +} + +fn main() { + let vec: Vec<u8> = Vec::new(); + let mut tup_iter = TupleIter { + inner: vec.into_iter(), + }; + tup_iter.next(); +} diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr index f515ec198..36a09add4 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr @@ -10,7 +10,7 @@ LL | impl const std::ops::Add for i32 { | = note: define and implement a trait or new type instead -error[E0119]: conflicting implementations of trait `std::ops::Add` for type `Int` +error[E0119]: conflicting implementations of trait `Add` for type `Int` --> $DIR/const-and-non-const-impl.rs:22:1 | LL | impl std::ops::Add for Int { diff --git a/src/test/ui/rfc-2632-const-trait-impl/const_derives/derive-const-gate.rs b/src/test/ui/rfc-2632-const-trait-impl/const_derives/derive-const-gate.rs new file mode 100644 index 000000000..348ca0ab1 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/const_derives/derive-const-gate.rs @@ -0,0 +1,4 @@ +#[derive_const(Default)] //~ ERROR use of unstable library feature +pub struct S; + +fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/const_derives/derive-const-gate.stderr b/src/test/ui/rfc-2632-const-trait-impl/const_derives/derive-const-gate.stderr new file mode 100644 index 000000000..cc9bdd271 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/const_derives/derive-const-gate.stderr @@ -0,0 +1,11 @@ +error[E0658]: use of unstable library feature 'derive_const' + --> $DIR/derive-const-gate.rs:1:3 + | +LL | #[derive_const(Default)] + | ^^^^^^^^^^^^ + | + = help: add `#![feature(derive_const)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs b/src/test/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs new file mode 100644 index 000000000..92843a8a2 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs @@ -0,0 +1,13 @@ +#![feature(derive_const)] + +pub struct A; + +impl Default for A { + fn default() -> A { A } +} + +#[derive_const(Default)] +pub struct S(A); +//~^ cannot call non-const fn + +fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.stderr b/src/test/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.stderr new file mode 100644 index 000000000..d463c774e --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.stderr @@ -0,0 +1,14 @@ +error[E0015]: cannot call non-const fn `<A as Default>::default` in constant functions + --> $DIR/derive-const-non-const-type.rs:10:14 + | +LL | #[derive_const(Default)] + | ------- in this derive macro expansion +LL | pub struct S(A); + | ^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0015`. diff --git a/src/test/ui/rfc-2632-const-trait-impl/const_derives/derive-const-use.rs b/src/test/ui/rfc-2632-const-trait-impl/const_derives/derive-const-use.rs new file mode 100644 index 000000000..d1fbeac85 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/const_derives/derive-const-use.rs @@ -0,0 +1,19 @@ +// check-pass +#![feature(const_trait_impl, const_cmp, const_default_impls, derive_const)] + +pub struct A; + +impl const Default for A { + fn default() -> A { A } +} + +impl const PartialEq for A { + fn eq(&self, _: &A) -> bool { true } +} + +#[derive_const(Default, PartialEq)] +pub struct S((), A); + +const _: () = assert!(S((), A) == S::default()); + +fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/issue-79450.rs b/src/test/ui/rfc-2632-const-trait-impl/issue-79450.rs new file mode 100644 index 000000000..b604c65d7 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/issue-79450.rs @@ -0,0 +1,20 @@ +#![feature(const_fmt_arguments_new)] +#![feature(const_trait_impl)] + +#[const_trait] +trait Tr { + fn req(&self); + + fn prov(&self) { + println!("lul"); //~ ERROR: cannot call non-const fn `_print` in constant functions + self.req(); + } +} + +struct S; + +impl const Tr for S { + fn req(&self) {} +} + +fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/issue-79450.stderr b/src/test/ui/rfc-2632-const-trait-impl/issue-79450.stderr new file mode 100644 index 000000000..082c0333f --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/issue-79450.stderr @@ -0,0 +1,12 @@ +error[E0015]: cannot call non-const fn `_print` in constant functions + --> $DIR/issue-79450.rs:9:9 + | +LL | println!("lul"); + | ^^^^^^^^^^^^^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0015`. diff --git a/src/test/ui/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.rs b/src/test/ui/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.rs new file mode 100644 index 000000000..3ac909924 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.rs @@ -0,0 +1,46 @@ +// Tests that trait bounds on specializing trait impls must be `~const` if the +// same bound is present on the default impl and is `~const` there. + +#![feature(const_trait_impl)] +#![feature(rustc_attrs)] +#![feature(min_specialization)] + +#[rustc_specialization_trait] +trait Specialize {} + +#[const_trait] +trait Foo {} + +#[const_trait] +trait Bar {} + +// bgr360: I was only able to exercise the code path that raises the +// "missing ~const qualifier" error by making this base impl non-const, even +// though that doesn't really make sense to do. As seen below, if the base impl +// is made const, rustc fails earlier with an overlapping impl failure. +impl<T> Bar for T +where + T: ~const Foo, +{} + +impl<T> Bar for T +where + T: Foo, //~ ERROR missing `~const` qualifier + T: Specialize, +{} + +#[const_trait] +trait Baz {} + +impl<T> const Baz for T +where + T: ~const Foo, +{} + +impl<T> const Baz for T //~ ERROR conflicting implementations of trait `Baz` +where + T: Foo, + T: Specialize, +{} + +fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.stderr b/src/test/ui/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.stderr new file mode 100644 index 000000000..4aea19794 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.stderr @@ -0,0 +1,18 @@ +error: missing `~const` qualifier for specialization + --> $DIR/const-default-bound-non-const-specialized-bound.rs:28:8 + | +LL | T: Foo, + | ^^^ + +error[E0119]: conflicting implementations of trait `Baz` + --> $DIR/const-default-bound-non-const-specialized-bound.rs:40:1 + | +LL | impl<T> const Baz for T + | ----------------------- first implementation here +... +LL | impl<T> const Baz for T + | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/rfc-2632-const-trait-impl/specialization/const-default-const-specialized.rs b/src/test/ui/rfc-2632-const-trait-impl/specialization/const-default-const-specialized.rs new file mode 100644 index 000000000..9ddea427c --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/specialization/const-default-const-specialized.rs @@ -0,0 +1,39 @@ +// Tests that a const default trait impl can be specialized by another const +// trait impl and that the specializing impl will be used during const-eval. + +// run-pass + +#![feature(const_trait_impl)] +#![feature(min_specialization)] + +#[const_trait] +trait Value { + fn value() -> u32; +} + +const fn get_value<T: ~const Value>() -> u32 { + T::value() +} + +impl<T> const Value for T { + default fn value() -> u32 { + 0 + } +} + +struct FortyTwo; + +impl const Value for FortyTwo { + fn value() -> u32 { + 42 + } +} + +const ZERO: u32 = get_value::<()>(); + +const FORTY_TWO: u32 = get_value::<FortyTwo>(); + +fn main() { + assert_eq!(ZERO, 0); + assert_eq!(FORTY_TWO, 42); +} diff --git a/src/test/ui/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.rs b/src/test/ui/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.rs new file mode 100644 index 000000000..a3bb9b3f9 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.rs @@ -0,0 +1,26 @@ +// Tests that specializing trait impls must be at least as const as the default impl. + +#![feature(const_trait_impl)] +#![feature(min_specialization)] + +#[const_trait] +trait Value { + fn value() -> u32; +} + +impl<T> const Value for T { + default fn value() -> u32 { + 0 + } +} + +struct FortyTwo; + +impl Value for FortyTwo { //~ ERROR cannot specialize on const impl with non-const impl + fn value() -> u32 { + println!("You can't do that (constly)"); + 42 + } +} + +fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.stderr b/src/test/ui/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.stderr new file mode 100644 index 000000000..247668047 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.stderr @@ -0,0 +1,8 @@ +error: cannot specialize on const impl with non-const impl + --> $DIR/const-default-impl-non-const-specialized-impl.rs:19:1 + | +LL | impl Value for FortyTwo { + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/rfc-2632-const-trait-impl/specialization/default-keyword.rs b/src/test/ui/rfc-2632-const-trait-impl/specialization/default-keyword.rs new file mode 100644 index 000000000..2aac0a2b4 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/specialization/default-keyword.rs @@ -0,0 +1,15 @@ +// check-pass + +#![feature(const_trait_impl)] +#![feature(min_specialization)] + +#[const_trait] +trait Foo { + fn foo(); +} + +impl const Foo for u32 { + default fn foo() {} +} + +fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/specialization/issue-95186-specialize-on-tilde-const.rs b/src/test/ui/rfc-2632-const-trait-impl/specialization/issue-95186-specialize-on-tilde-const.rs new file mode 100644 index 000000000..9c2c2cf16 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/specialization/issue-95186-specialize-on-tilde-const.rs @@ -0,0 +1,37 @@ +// Tests that `~const` trait bounds can be used to specialize const trait impls. + +// check-pass + +#![feature(const_trait_impl)] +#![feature(rustc_attrs)] +#![feature(min_specialization)] + +#[const_trait] +#[rustc_specialization_trait] +trait Specialize {} + +#[const_trait] +trait Foo {} + +impl<T> const Foo for T {} + +impl<T> const Foo for T +where + T: ~const Specialize, +{} + +#[const_trait] +trait Bar {} + +impl<T> const Bar for T +where + T: ~const Foo, +{} + +impl<T> const Bar for T +where + T: ~const Foo, + T: ~const Specialize, +{} + +fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/specialization/issue-95187-same-trait-bound-different-constness.rs b/src/test/ui/rfc-2632-const-trait-impl/specialization/issue-95187-same-trait-bound-different-constness.rs new file mode 100644 index 000000000..1e6b1c651 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/specialization/issue-95187-same-trait-bound-different-constness.rs @@ -0,0 +1,45 @@ +// Tests that `T: ~const Foo` in a specializing impl is treated as equivalent to +// `T: Foo` in the default impl for the purposes of specialization (i.e., it +// does not think that the user is attempting to specialize on trait `Foo`). + +// check-pass + +#![feature(rustc_attrs)] +#![feature(min_specialization)] +#![feature(const_trait_impl)] + +#[rustc_specialization_trait] +trait Specialize {} + +#[const_trait] +trait Foo {} + +#[const_trait] +trait Bar {} + +impl<T> Bar for T +where + T: Foo, +{} + +impl<T> const Bar for T +where + T: ~const Foo, + T: Specialize, +{} + +#[const_trait] +trait Baz {} + +impl<T> const Baz for T +where + T: Foo, +{} + +impl<T> const Baz for T +where + T: ~const Foo, + T: Specialize, +{} + +fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/specialization/non-const-default-const-specialized.rs b/src/test/ui/rfc-2632-const-trait-impl/specialization/non-const-default-const-specialized.rs new file mode 100644 index 000000000..35aa52fbd --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/specialization/non-const-default-const-specialized.rs @@ -0,0 +1,39 @@ +// Tests that a non-const default impl can be specialized by a const trait impl, +// but that the default impl cannot be used in a const context. + +// run-pass + +#![feature(const_trait_impl)] +#![feature(min_specialization)] + +#[const_trait] +trait Value { + fn value() -> u32; +} + +const fn get_value<T: ~const Value>() -> u32 { + T::value() +} + +impl<T> Value for T { + default fn value() -> u32 { + println!("You can't do that (constly)"); + 0 + } +} + +struct FortyTwo; + +impl const Value for FortyTwo { + fn value() -> u32 { + 42 + } +} + +fn main() { + let zero = get_value::<()>(); + assert_eq!(zero, 0); + + const FORTY_TWO: u32 = get_value::<FortyTwo>(); + assert_eq!(FORTY_TWO, 42); +} diff --git a/src/test/ui/rfc-2632-const-trait-impl/specializing-constness.rs b/src/test/ui/rfc-2632-const-trait-impl/specializing-constness.rs index ff0cd489d..9ab170f09 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/specializing-constness.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/specializing-constness.rs @@ -17,7 +17,9 @@ impl<T: ~const Default> const A for T { } } -impl<T: Default + Sup> A for T { //~ ERROR: cannot specialize +impl<T: Default + Sup> A for T { +//~^ ERROR: cannot specialize +//~| ERROR: missing `~const` qualifier fn a() -> u32 { 3 } diff --git a/src/test/ui/rfc-2632-const-trait-impl/specializing-constness.stderr b/src/test/ui/rfc-2632-const-trait-impl/specializing-constness.stderr index 3296c109c..843fc6ce8 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/specializing-constness.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/specializing-constness.stderr @@ -1,8 +1,14 @@ -error: cannot specialize on trait `Default` +error: cannot specialize on const impl with non-const impl + --> $DIR/specializing-constness.rs:20:1 + | +LL | impl<T: Default + Sup> A for T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: missing `~const` qualifier for specialization --> $DIR/specializing-constness.rs:20:9 | LL | impl<T: Default + Sup> A for T { | ^^^^^^^ -error: aborting due to previous error +error: aborting due to 2 previous errors diff --git a/src/test/ui/rfc1623.rs b/src/test/ui/rfcs/rfc1623-2.rs index c0e13a5f5..c0e13a5f5 100644 --- a/src/test/ui/rfc1623.rs +++ b/src/test/ui/rfcs/rfc1623-2.rs diff --git a/src/test/ui/rfc1623.stderr b/src/test/ui/rfcs/rfc1623-2.stderr index b15a4cb11..d183eaaa6 100644 --- a/src/test/ui/rfc1623.stderr +++ b/src/test/ui/rfcs/rfc1623-2.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/rfc1623.rs:28:8 + --> $DIR/rfc1623-2.rs:28:8 | LL | f: &id, | ^^^ one type is more general than the other @@ -8,7 +8,7 @@ LL | f: &id, found trait `Fn<(&Foo<'_>,)>` error[E0308]: mismatched types - --> $DIR/rfc1623.rs:28:8 + --> $DIR/rfc1623-2.rs:28:8 | LL | f: &id, | ^^^ one type is more general than the other @@ -17,7 +17,7 @@ LL | f: &id, found trait `Fn<(&Foo<'_>,)>` error: implementation of `FnOnce` is not general enough - --> $DIR/rfc1623.rs:28:8 + --> $DIR/rfc1623-2.rs:28:8 | LL | f: &id, | ^^^ implementation of `FnOnce` is not general enough @@ -26,7 +26,7 @@ LL | f: &id, = note: ...but it actually implements `FnOnce<(&'2 Foo<'_>,)>`, for some specific lifetime `'2` error: implementation of `FnOnce` is not general enough - --> $DIR/rfc1623.rs:28:8 + --> $DIR/rfc1623-2.rs:28:8 | LL | f: &id, | ^^^ implementation of `FnOnce` is not general enough diff --git a/src/test/ui/rfc1623-2.rs b/src/test/ui/rfcs/rfc1623-3.rs index 26fa6fdb5..26fa6fdb5 100644 --- a/src/test/ui/rfc1623-2.rs +++ b/src/test/ui/rfcs/rfc1623-3.rs diff --git a/src/test/ui/rfc1623-2.stderr b/src/test/ui/rfcs/rfc1623-3.stderr index 945c6533c..77fc3f041 100644 --- a/src/test/ui/rfc1623-2.stderr +++ b/src/test/ui/rfcs/rfc1623-3.stderr @@ -1,5 +1,5 @@ error[E0106]: missing lifetime specifier - --> $DIR/rfc1623-2.rs:8:42 + --> $DIR/rfc1623-3.rs:8:42 | LL | static NON_ELIDABLE_FN: &fn(&u8, &u8) -> &u8 = | --- --- ^ expected named lifetime parameter @@ -12,7 +12,7 @@ LL | static NON_ELIDABLE_FN: &for<'a> fn(&'a u8, &'a u8) -> &'a u8 = | +++++++ ++ ++ ++ error[E0106]: missing lifetime specifier - --> $DIR/rfc1623-2.rs:10:39 + --> $DIR/rfc1623-3.rs:10:39 | LL | &(non_elidable as fn(&u8, &u8) -> &u8); | --- --- ^ expected named lifetime parameter @@ -24,7 +24,7 @@ LL | &(non_elidable as for<'a> fn(&'a u8, &'a u8) -> &'a u8); | +++++++ ++ ++ ++ error[E0605]: non-primitive cast: `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8 {non_elidable}` as `for<'a, 'b> fn(&'a u8, &'b u8) -> &u8` - --> $DIR/rfc1623-2.rs:10:6 + --> $DIR/rfc1623-3.rs:10:6 | LL | &(non_elidable as fn(&u8, &u8) -> &u8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid cast diff --git a/src/test/ui/sanitize/memory-passing.rs b/src/test/ui/sanitize/memory-passing.rs new file mode 100644 index 000000000..6d9b70ad6 --- /dev/null +++ b/src/test/ui/sanitize/memory-passing.rs @@ -0,0 +1,32 @@ +// needs-sanitizer-support +// needs-sanitizer-memory +// +// revisions: unoptimized optimized +// +// [optimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O +// [unoptimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins +// +// run-pass +// +// This test case intentionally limits the usage of the std, +// since it will be linked with an uninstrumented version of it. + +#![feature(core_intrinsics)] +#![feature(start)] +#![allow(invalid_value)] + +use std::hint::black_box; + +fn calling_black_box_on_zst_ok() { + // It's OK to call black_box on a value of a zero-sized type, even if its + // underlying the memory location is uninitialized. For non-zero-sized types, + // this would be an MSAN error. + let zst = (); + black_box(zst); +} + +#[start] +fn main(_: isize, _: *const *const u8) -> isize { + calling_black_box_on_zst_ok(); + 0 +} diff --git a/src/test/ui/self/class-missing-self.stderr b/src/test/ui/self/class-missing-self.stderr index d501200d7..063c3f013 100644 --- a/src/test/ui/self/class-missing-self.stderr +++ b/src/test/ui/self/class-missing-self.stderr @@ -10,6 +10,10 @@ error[E0425]: cannot find function `sleep` in this scope LL | sleep(); | ^^^^^ not found in this scope | +help: consider using the associated function + | +LL | self.sleep(); + | +++++ help: consider importing this function | LL | use std::thread::sleep; diff --git a/src/test/ui/sized/coinductive-1-gat.rs b/src/test/ui/sized/coinductive-1-gat.rs new file mode 100644 index 000000000..cdf70920f --- /dev/null +++ b/src/test/ui/sized/coinductive-1-gat.rs @@ -0,0 +1,14 @@ +// check-pass +struct Node<C: Trait>(C::Assoc::<Self>); + +trait Trait { + type Assoc<T>; +} + +impl Trait for Vec<()> { + type Assoc<T> = Vec<T>; +} + +fn main() { + let _ = Node::<Vec<()>>(Vec::new()); +} diff --git a/src/test/ui/sized/coinductive-1.rs b/src/test/ui/sized/coinductive-1.rs new file mode 100644 index 000000000..7bcd0f1fd --- /dev/null +++ b/src/test/ui/sized/coinductive-1.rs @@ -0,0 +1,14 @@ +// check-pass +struct Node<C: Trait<Self>>(C::Assoc); + +trait Trait<T> { + type Assoc; +} + +impl<T> Trait<T> for Vec<()> { + type Assoc = Vec<T>; +} + +fn main() { + let _ = Node::<Vec<()>>(Vec::new()); +} diff --git a/src/test/ui/sized/coinductive-2.rs b/src/test/ui/sized/coinductive-2.rs new file mode 100644 index 000000000..212274d2e --- /dev/null +++ b/src/test/ui/sized/coinductive-2.rs @@ -0,0 +1,28 @@ +// run-pass +struct Node<C: CollectionFactory<Self>> { + _children: C::Collection, +} + +trait CollectionFactory<T> { + type Collection; +} + +impl<T> CollectionFactory<T> for Vec<()> { + type Collection = Vec<T>; +} + +trait Collection<T>: Sized { + fn push(&mut self, v: T); +} + +impl<T> Collection<T> for Vec<T> { + fn push(&mut self, v: T) { + self.push(v) + } +} + +fn main() { + let _ = Node::<Vec<()>> { + _children: Vec::new(), + }; +} diff --git a/src/test/ui/sized/recursive-type-1.rs b/src/test/ui/sized/recursive-type-1.rs new file mode 100644 index 000000000..cd6805967 --- /dev/null +++ b/src/test/ui/sized/recursive-type-1.rs @@ -0,0 +1,10 @@ +// check-pass +trait A { type Assoc; } + +impl A for () { + // FIXME: it would be nice for this to at least cause a warning. + type Assoc = Foo<()>; +} +struct Foo<T: A>(T::Assoc); + +fn main() {} diff --git a/src/test/ui/sized/recursive-type-2.rs b/src/test/ui/sized/recursive-type-2.rs new file mode 100644 index 000000000..7d95417a6 --- /dev/null +++ b/src/test/ui/sized/recursive-type-2.rs @@ -0,0 +1,13 @@ +// build-fail +//~^ ERROR cycle detected when computing layout of `Foo<()>` + +trait A { type Assoc: ?Sized; } + +impl A for () { + type Assoc = Foo<()>; +} +struct Foo<T: A>(T::Assoc); + +fn main() { + let x: Foo<()>; +} diff --git a/src/test/ui/sized/recursive-type-2.stderr b/src/test/ui/sized/recursive-type-2.stderr new file mode 100644 index 000000000..d0e6e9db0 --- /dev/null +++ b/src/test/ui/sized/recursive-type-2.stderr @@ -0,0 +1,13 @@ +error[E0391]: cycle detected when computing layout of `Foo<()>` + | + = note: ...which requires computing layout of `<() as A>::Assoc`... + = note: ...which again requires computing layout of `Foo<()>`, completing the cycle +note: cycle used when elaborating drops for `main` + --> $DIR/recursive-type-2.rs:11:1 + | +LL | fn main() { + | ^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/span/borrowck-let-suggestion-suffixes.rs b/src/test/ui/span/borrowck-let-suggestion-suffixes.rs index 6240f103c..18abfb5c3 100644 --- a/src/test/ui/span/borrowck-let-suggestion-suffixes.rs +++ b/src/test/ui/span/borrowck-let-suggestion-suffixes.rs @@ -18,7 +18,7 @@ fn f() { v3.push(&id('x')); // statement 6 //~^ ERROR temporary value dropped while borrowed - //~| NOTE creates a temporary which is freed while still in use + //~| NOTE creates a temporary value which is freed while still in use //~| NOTE temporary value is freed at the end of this statement //~| HELP consider using a `let` binding to create a longer lived value @@ -28,7 +28,7 @@ fn f() { v4.push(&id('y')); //~^ ERROR temporary value dropped while borrowed - //~| NOTE creates a temporary which is freed while still in use + //~| NOTE creates a temporary value which is freed while still in use //~| NOTE temporary value is freed at the end of this statement //~| NOTE consider using a `let` binding to create a longer lived value v4.use_ref(); @@ -39,7 +39,7 @@ fn f() { v5.push(&id('z')); //~^ ERROR temporary value dropped while borrowed - //~| NOTE creates a temporary which is freed while still in use + //~| NOTE creates a temporary value which is freed while still in use //~| NOTE temporary value is freed at the end of this statement //~| HELP consider using a `let` binding to create a longer lived value diff --git a/src/test/ui/span/borrowck-let-suggestion-suffixes.stderr b/src/test/ui/span/borrowck-let-suggestion-suffixes.stderr index a236dab3a..2dc29a78d 100644 --- a/src/test/ui/span/borrowck-let-suggestion-suffixes.stderr +++ b/src/test/ui/span/borrowck-let-suggestion-suffixes.stderr @@ -16,7 +16,7 @@ error[E0716]: temporary value dropped while borrowed LL | v3.push(&id('x')); // statement 6 | ^^^^^^^ - temporary value is freed at the end of this statement | | - | creates a temporary which is freed while still in use + | creates a temporary value which is freed while still in use ... LL | (v1, v2, v3, /* v4 is above. */ v5).use_ref(); | -- borrow later used here @@ -33,7 +33,7 @@ error[E0716]: temporary value dropped while borrowed LL | v4.push(&id('y')); | ^^^^^^^ - temporary value is freed at the end of this statement | | - | creates a temporary which is freed while still in use + | creates a temporary value which is freed while still in use ... LL | v4.use_ref(); | ------------ borrow later used here @@ -46,7 +46,7 @@ error[E0716]: temporary value dropped while borrowed LL | v5.push(&id('z')); | ^^^^^^^ - temporary value is freed at the end of this statement | | - | creates a temporary which is freed while still in use + | creates a temporary value which is freed while still in use ... LL | (v1, v2, v3, /* v4 is above. */ v5).use_ref(); | -- borrow later used here diff --git a/src/test/ui/span/borrowck-ref-into-rvalue.stderr b/src/test/ui/span/borrowck-ref-into-rvalue.stderr index cb5289d24..25e344fed 100644 --- a/src/test/ui/span/borrowck-ref-into-rvalue.stderr +++ b/src/test/ui/span/borrowck-ref-into-rvalue.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/borrowck-ref-into-rvalue.rs:4:11 | LL | match Some("Hello".to_string()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use ... LL | } | - temporary value is freed at the end of this statement diff --git a/src/test/ui/span/issue-11925.rs b/src/test/ui/span/issue-11925.rs index d9c08fbdd..cac9fd5bf 100644 --- a/src/test/ui/span/issue-11925.rs +++ b/src/test/ui/span/issue-11925.rs @@ -1,6 +1,6 @@ -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] -fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f } +fn to_fn_once<A:std::marker::Tuple,F:FnOnce<A>>(f: F) -> F { f } fn main() { let r = { diff --git a/src/test/ui/span/issue-15480.stderr b/src/test/ui/span/issue-15480.stderr index 460ad9ac7..d9cce2254 100644 --- a/src/test/ui/span/issue-15480.stderr +++ b/src/test/ui/span/issue-15480.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/issue-15480.rs:6:10 | LL | &id(3) - | ^^^^^ creates a temporary which is freed while still in use + | ^^^^^ creates a temporary value which is freed while still in use LL | ]; | - temporary value is freed at the end of this statement ... diff --git a/src/test/ui/span/issue-35987.stderr b/src/test/ui/span/issue-35987.stderr index d8fddc800..057d40ac0 100644 --- a/src/test/ui/span/issue-35987.stderr +++ b/src/test/ui/span/issue-35987.stderr @@ -1,6 +1,9 @@ error[E0404]: expected trait, found type parameter `Add` --> $DIR/issue-35987.rs:5:21 | +LL | use std::ops::Add; + | --- you might have meant to refer to this trait +LL | LL | impl<T: Clone, Add> Add for Foo<T> { | --- ^^^ not a trait | | diff --git a/src/test/ui/span/issue-71363.rs b/src/test/ui/span/issue-71363.rs index bbb4a9362..f187d0efa 100644 --- a/src/test/ui/span/issue-71363.rs +++ b/src/test/ui/span/issue-71363.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z simulate-remapped-rust-src-base=/rustc/xyz -Z translate-remapped-path-to-local-path=no -Z ui-testing=no +// compile-flags: -Z simulate-remapped-rust-src-base=/rustc/FAKE_PREFIX -Z translate-remapped-path-to-local-path=no -Z ui-testing=no struct MyError; impl std::error::Error for MyError {} diff --git a/src/test/ui/span/issue-71363.stderr b/src/test/ui/span/issue-71363.stderr index 04e2b46c3..0370e46e6 100644 --- a/src/test/ui/span/issue-71363.stderr +++ b/src/test/ui/span/issue-71363.stderr @@ -7,6 +7,9 @@ error[E0277]: `MyError` doesn't implement `std::fmt::Display` = help: the trait `std::fmt::Display` is not implemented for `MyError` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `std::error::Error` + --> $SRC_DIR/core/src/error.rs:LL:COL + | + = note: required by this bound in `std::error::Error` error[E0277]: `MyError` doesn't implement `Debug` --> $DIR/issue-71363.rs:4:6 @@ -17,6 +20,9 @@ error[E0277]: `MyError` doesn't implement `Debug` = help: the trait `Debug` is not implemented for `MyError` = note: add `#[derive(Debug)]` to `MyError` or manually `impl Debug for MyError` note: required by a bound in `std::error::Error` + --> $SRC_DIR/core/src/error.rs:LL:COL + | + = note: required by this bound in `std::error::Error` help: consider annotating `MyError` with `#[derive(Debug)]` | 3 | #[derive(Debug)] diff --git a/src/test/ui/span/macro-ty-params.rs b/src/test/ui/span/macro-ty-params.rs index 0a93105b6..cf28b0255 100644 --- a/src/test/ui/span/macro-ty-params.rs +++ b/src/test/ui/span/macro-ty-params.rs @@ -9,5 +9,7 @@ macro_rules! foo { () => () } fn main() { foo::<T>!(); //~ ERROR generic arguments in macro path foo::<>!(); //~ ERROR generic arguments in macro path - m!(Default<>); //~ ERROR unexpected generic arguments in path + m!(Default<>); + //~^ ERROR unexpected generic arguments in path + //~^^ ERROR generic arguments in macro path } diff --git a/src/test/ui/span/macro-ty-params.stderr b/src/test/ui/span/macro-ty-params.stderr index 138cd2598..7023ef8cd 100644 --- a/src/test/ui/span/macro-ty-params.stderr +++ b/src/test/ui/span/macro-ty-params.stderr @@ -16,5 +16,11 @@ error: unexpected generic arguments in path LL | m!(Default<>); | ^^ -error: aborting due to 3 previous errors +error: generic arguments in macro path + --> $DIR/macro-ty-params.rs:12:15 + | +LL | m!(Default<>); + | ^^ + +error: aborting due to 4 previous errors diff --git a/src/test/ui/span/multiline-span-simple.stderr b/src/test/ui/span/multiline-span-simple.stderr index c0d9a8634..b44df962a 100644 --- a/src/test/ui/span/multiline-span-simple.stderr +++ b/src/test/ui/span/multiline-span-simple.stderr @@ -6,15 +6,10 @@ LL | foo(1 as u32 + | = help: the trait `Add<()>` is not implemented for `u32` = help: the following other types implement trait `Add<Rhs>`: - <&'a f32 as Add<f32>> - <&'a f64 as Add<f64>> - <&'a i128 as Add<i128>> - <&'a i16 as Add<i16>> - <&'a i32 as Add<i32>> - <&'a i64 as Add<i64>> - <&'a i8 as Add<i8>> - <&'a isize as Add<isize>> - and 48 others + <&'a u32 as Add<u32>> + <&u32 as Add<&u32>> + <u32 as Add<&u32>> + <u32 as Add> error: aborting due to previous error diff --git a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.stderr b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.stderr index ba0c45acf..81e858fa0 100644 --- a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.stderr +++ b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/regions-close-over-borrowed-ref-in-obj.rs:12:27 | LL | let ss: &isize = &id(1); - | ^^^^^ creates a temporary which is freed while still in use + | ^^^^^ creates a temporary value which is freed while still in use ... LL | } | - temporary value is freed at the end of this statement diff --git a/src/test/ui/span/slice-borrow.stderr b/src/test/ui/span/slice-borrow.stderr index 27df25be3..b70bf69d6 100644 --- a/src/test/ui/span/slice-borrow.stderr +++ b/src/test/ui/span/slice-borrow.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/slice-borrow.rs:6:28 | LL | let x: &[isize] = &vec![1, 2, 3, 4, 5]; - | ^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | ^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use ... LL | } | - temporary value is freed at the end of this statement diff --git a/src/test/ui/specialization/issue-43037.stderr b/src/test/ui/specialization/issue-43037.current.stderr index 4249cd894..26db9d7c9 100644 --- a/src/test/ui/specialization/issue-43037.stderr +++ b/src/test/ui/specialization/issue-43037.current.stderr @@ -1,5 +1,5 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`) - --> $DIR/issue-43037.rs:17:6 + --> $DIR/issue-43037.rs:19:6 | LL | impl<T> From<<A<T> as Z>::Assoc> for T {} | ^ type parameter `T` must be used as the type parameter for some local type diff --git a/src/test/ui/coherence/issue-100191.stderr b/src/test/ui/specialization/issue-43037.negative.stderr index 1adb0f1e4..26db9d7c9 100644 --- a/src/test/ui/coherence/issue-100191.stderr +++ b/src/test/ui/specialization/issue-43037.negative.stderr @@ -1,5 +1,5 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`) - --> $DIR/issue-100191.rs:18:6 + --> $DIR/issue-43037.rs:19:6 | LL | impl<T> From<<A<T> as Z>::Assoc> for T {} | ^ type parameter `T` must be used as the type parameter for some local type diff --git a/src/test/ui/specialization/issue-43037.rs b/src/test/ui/specialization/issue-43037.rs index c49119f9c..a1e3f998b 100644 --- a/src/test/ui/specialization/issue-43037.rs +++ b/src/test/ui/specialization/issue-43037.rs @@ -1,4 +1,6 @@ +// revisions: current negative #![feature(specialization)] +#![cfg_attr(negative, feature(with_negative_coherence))] #![allow(incomplete_features)] trait X {} diff --git a/src/test/ui/specialization/issue-45814.stderr b/src/test/ui/specialization/issue-45814.current.stderr index 419345add..5013559b8 100644 --- a/src/test/ui/specialization/issue-45814.stderr +++ b/src/test/ui/specialization/issue-45814.current.stderr @@ -2,7 +2,7 @@ error[E0275]: overflow evaluating the requirement `T: Trait<_>` | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_45814`) note: required for `T` to implement `Trait<_>` - --> $DIR/issue-45814.rs:8:20 + --> $DIR/issue-45814.rs:9:20 | LL | default impl<T, U> Trait<T> for U {} | ^^^^^^^^ ^ diff --git a/src/test/ui/coherence/issue-100191-2.stderr b/src/test/ui/specialization/issue-45814.negative.stderr index d50c220bc..5013559b8 100644 --- a/src/test/ui/coherence/issue-100191-2.stderr +++ b/src/test/ui/specialization/issue-45814.negative.stderr @@ -1,8 +1,8 @@ error[E0275]: overflow evaluating the requirement `T: Trait<_>` | - = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_100191_2`) + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_45814`) note: required for `T` to implement `Trait<_>` - --> $DIR/issue-100191-2.rs:8:20 + --> $DIR/issue-45814.rs:9:20 | LL | default impl<T, U> Trait<T> for U {} | ^^^^^^^^ ^ diff --git a/src/test/ui/specialization/issue-45814.rs b/src/test/ui/specialization/issue-45814.rs index 8ee5d3e2e..fce236390 100644 --- a/src/test/ui/specialization/issue-45814.rs +++ b/src/test/ui/specialization/issue-45814.rs @@ -1,6 +1,7 @@ //~ ERROR overflow evaluating the requirement `T: Trait<_>` - +// revisions: current negative #![feature(specialization)] +#![cfg_attr(negative, feature(with_negative_coherence))] #![allow(incomplete_features)] pub trait Trait<T> {} diff --git a/src/test/ui/specialization/specialization-overlap-negative.stderr b/src/test/ui/specialization/specialization-overlap-negative.stderr index fb3d9723a..1fe4869ff 100644 --- a/src/test/ui/specialization/specialization-overlap-negative.stderr +++ b/src/test/ui/specialization/specialization-overlap-negative.stderr @@ -8,7 +8,7 @@ LL | #![feature(specialization)] = help: consider using `min_specialization` instead, which is more stable and complete = note: `#[warn(incomplete_features)]` on by default -error[E0751]: found both positive and negative implementation of trait `std::marker::Send` for type `TestType<_>`: +error[E0751]: found both positive and negative implementation of trait `Send` for type `TestType<_>`: --> $DIR/specialization-overlap-negative.rs:9:1 | LL | unsafe impl<T: Clone> Send for TestType<T> {} diff --git a/src/test/ui/specialization/specialization-overlap.stderr b/src/test/ui/specialization/specialization-overlap.stderr index 989264467..098bf4a70 100644 --- a/src/test/ui/specialization/specialization-overlap.stderr +++ b/src/test/ui/specialization/specialization-overlap.stderr @@ -8,13 +8,13 @@ LL | #![feature(specialization)] = help: consider using `min_specialization` instead, which is more stable and complete = note: `#[warn(incomplete_features)]` on by default -error[E0119]: conflicting implementations of trait `Foo` for type `std::vec::Vec<_>` +error[E0119]: conflicting implementations of trait `Foo` for type `Vec<_>` --> $DIR/specialization-overlap.rs:5:1 | LL | impl<T: Clone> Foo for T {} | ------------------------ first implementation here LL | impl<T> Foo for Vec<T> {} - | ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `std::vec::Vec<_>` + | ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Vec<_>` error[E0119]: conflicting implementations of trait `Bar` for type `(u8, u8)` --> $DIR/specialization-overlap.rs:9:1 diff --git a/src/test/ui/issues/issue-5216.rs b/src/test/ui/static/issue-5216.rs index 4072a57cb..4072a57cb 100644 --- a/src/test/ui/issues/issue-5216.rs +++ b/src/test/ui/static/issue-5216.rs diff --git a/src/test/ui/issues/issue-5216.stderr b/src/test/ui/static/issue-5216.stderr index 1afff28f0..1afff28f0 100644 --- a/src/test/ui/issues/issue-5216.stderr +++ b/src/test/ui/static/issue-5216.stderr diff --git a/src/test/ui/static/static-drop-scope.stderr b/src/test/ui/static/static-drop-scope.stderr index 112bfc003..cedcb7367 100644 --- a/src/test/ui/static/static-drop-scope.stderr +++ b/src/test/ui/static/static-drop-scope.stderr @@ -13,7 +13,7 @@ LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor); | ------^^^^^^^^- | | | | | | | temporary value is freed at the end of this statement - | | creates a temporary which is freed while still in use + | | creates a temporary value which is freed while still in use | using this value as a static requires that borrow lasts for `'static` error[E0493]: destructor of `WithDtor` cannot be evaluated at compile-time @@ -31,7 +31,7 @@ LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor); | ------^^^^^^^^- | | | | | | | temporary value is freed at the end of this statement - | | creates a temporary which is freed while still in use + | | creates a temporary value which is freed while still in use | using this value as a constant requires that borrow lasts for `'static` error[E0493]: destructor of `(WithDtor, i32)` cannot be evaluated at compile-time diff --git a/src/test/ui/static/static-reference-to-fn-2.stderr b/src/test/ui/static/static-reference-to-fn-2.stderr index ff15884bd..133d8ec2e 100644 --- a/src/test/ui/static/static-reference-to-fn-2.stderr +++ b/src/test/ui/static/static-reference-to-fn-2.stderr @@ -6,7 +6,7 @@ LL | fn state1(self_: &mut StateMachineIter) -> Option<&'static str> { LL | self_.statefn = &id(state2 as StateMachineFunc); | -----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement | | | - | | creates a temporary which is freed while still in use + | | creates a temporary value which is freed while still in use | assignment requires that borrow lasts for `'1` error[E0716]: temporary value dropped while borrowed @@ -17,7 +17,7 @@ LL | fn state2(self_: &mut StateMachineIter) -> Option<(&'static str)> { LL | self_.statefn = &id(state3 as StateMachineFunc); | -----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement | | | - | | creates a temporary which is freed while still in use + | | creates a temporary value which is freed while still in use | assignment requires that borrow lasts for `'1` error[E0716]: temporary value dropped while borrowed @@ -28,7 +28,7 @@ LL | fn state3(self_: &mut StateMachineIter) -> Option<(&'static str)> { LL | self_.statefn = &id(finished as StateMachineFunc); | -----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement | | | - | | creates a temporary which is freed while still in use + | | creates a temporary value which is freed while still in use | assignment requires that borrow lasts for `'1` error[E0515]: cannot return value referencing temporary value diff --git a/src/test/ui/static/static-region-bound.stderr b/src/test/ui/static/static-region-bound.stderr index 15261259e..1a607e3c0 100644 --- a/src/test/ui/static/static-region-bound.stderr +++ b/src/test/ui/static/static-region-bound.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/static-region-bound.rs:10:14 | LL | let x = &id(3); - | ^^^^^ creates a temporary which is freed while still in use + | ^^^^^ creates a temporary value which is freed while still in use LL | f(x); | ---- argument requires that borrow lasts for `'static` LL | } diff --git a/src/test/ui/statics/issue-44373.stderr b/src/test/ui/statics/issue-44373.stderr index 6f92fbb1e..2d29dec88 100644 --- a/src/test/ui/statics/issue-44373.stderr +++ b/src/test/ui/statics/issue-44373.stderr @@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/issue-44373.rs:4:42 | LL | let _val: &'static [&'static u32] = &[&FOO]; - | ----------------------- ^^^^^^ creates a temporary which is freed while still in use + | ----------------------- ^^^^^^ creates a temporary value which is freed while still in use | | | type annotation requires that borrow lasts for `'static` LL | } diff --git a/src/test/ui/stats/hir-stats.rs b/src/test/ui/stats/hir-stats.rs index a24b3ada5..0b89d0b16 100644 --- a/src/test/ui/stats/hir-stats.rs +++ b/src/test/ui/stats/hir-stats.rs @@ -1,6 +1,7 @@ // check-pass // compile-flags: -Zhir-stats // only-x86_64 +// ignore-stage1 FIXME: remove after next bootstrap bump // The aim here is to include at least one of every different type of top-level // AST/HIR node reported by `-Zhir-stats`. diff --git a/src/test/ui/stats/hir-stats.stderr b/src/test/ui/stats/hir-stats.stderr index 1521b692a..15900bef7 100644 --- a/src/test/ui/stats/hir-stats.stderr +++ b/src/test/ui/stats/hir-stats.stderr @@ -2,124 +2,124 @@ ast-stats-1 PRE EXPANSION AST STATS ast-stats-1 Name Accumulated Size Count Item Size ast-stats-1 ---------------------------------------------------------------- ast-stats-1 ExprField 48 ( 0.6%) 1 48 -ast-stats-1 Crate 56 ( 0.7%) 1 56 -ast-stats-1 Attribute 64 ( 0.8%) 2 32 +ast-stats-1 GenericArgs 56 ( 0.8%) 1 56 +ast-stats-1 - AngleBracketed 56 ( 0.8%) 1 +ast-stats-1 Crate 56 ( 0.8%) 1 56 +ast-stats-1 Attribute 64 ( 0.9%) 2 32 ast-stats-1 - Normal 32 ( 0.4%) 1 ast-stats-1 - DocComment 32 ( 0.4%) 1 -ast-stats-1 GenericArgs 64 ( 0.8%) 1 64 -ast-stats-1 - AngleBracketed 64 ( 0.8%) 1 -ast-stats-1 Local 72 ( 0.9%) 1 72 -ast-stats-1 WherePredicate 72 ( 0.9%) 1 72 -ast-stats-1 - BoundPredicate 72 ( 0.9%) 1 -ast-stats-1 Arm 96 ( 1.1%) 2 48 -ast-stats-1 ForeignItem 96 ( 1.1%) 1 96 -ast-stats-1 - Fn 96 ( 1.1%) 1 -ast-stats-1 FieldDef 160 ( 1.9%) 2 80 -ast-stats-1 Stmt 160 ( 1.9%) 5 32 +ast-stats-1 Local 72 ( 1.0%) 1 72 +ast-stats-1 WherePredicate 72 ( 1.0%) 1 72 +ast-stats-1 - BoundPredicate 72 ( 1.0%) 1 +ast-stats-1 Arm 96 ( 1.3%) 2 48 +ast-stats-1 ForeignItem 96 ( 1.3%) 1 96 +ast-stats-1 - Fn 96 ( 1.3%) 1 +ast-stats-1 FieldDef 160 ( 2.2%) 2 80 +ast-stats-1 Stmt 160 ( 2.2%) 5 32 ast-stats-1 - Local 32 ( 0.4%) 1 ast-stats-1 - MacCall 32 ( 0.4%) 1 -ast-stats-1 - Expr 96 ( 1.1%) 3 -ast-stats-1 Param 160 ( 1.9%) 4 40 -ast-stats-1 FnDecl 200 ( 2.4%) 5 40 -ast-stats-1 Variant 240 ( 2.9%) 2 120 -ast-stats-1 Block 288 ( 3.4%) 6 48 -ast-stats-1 GenericBound 352 ( 4.2%) 4 88 -ast-stats-1 - Trait 352 ( 4.2%) 4 -ast-stats-1 AssocItem 416 ( 4.9%) 4 104 -ast-stats-1 - Type 208 ( 2.5%) 2 -ast-stats-1 - Fn 208 ( 2.5%) 2 -ast-stats-1 GenericParam 480 ( 5.7%) 5 96 -ast-stats-1 PathSegment 720 ( 8.6%) 30 24 -ast-stats-1 Expr 832 ( 9.9%) 8 104 -ast-stats-1 - Path 104 ( 1.2%) 1 -ast-stats-1 - Match 104 ( 1.2%) 1 -ast-stats-1 - Struct 104 ( 1.2%) 1 -ast-stats-1 - Lit 208 ( 2.5%) 2 -ast-stats-1 - Block 312 ( 3.7%) 3 -ast-stats-1 Pat 840 (10.0%) 7 120 -ast-stats-1 - Struct 120 ( 1.4%) 1 -ast-stats-1 - Wild 120 ( 1.4%) 1 -ast-stats-1 - Ident 600 ( 7.1%) 5 -ast-stats-1 Ty 1_344 (16.0%) 14 96 -ast-stats-1 - Rptr 96 ( 1.1%) 1 -ast-stats-1 - Ptr 96 ( 1.1%) 1 -ast-stats-1 - ImplicitSelf 192 ( 2.3%) 2 -ast-stats-1 - Path 960 (11.4%) 10 -ast-stats-1 Item 1_656 (19.7%) 9 184 -ast-stats-1 - Trait 184 ( 2.2%) 1 -ast-stats-1 - Enum 184 ( 2.2%) 1 -ast-stats-1 - ForeignMod 184 ( 2.2%) 1 -ast-stats-1 - Impl 184 ( 2.2%) 1 -ast-stats-1 - Fn 368 ( 4.4%) 2 -ast-stats-1 - Use 552 ( 6.6%) 3 +ast-stats-1 - Expr 96 ( 1.3%) 3 +ast-stats-1 Param 160 ( 2.2%) 4 40 +ast-stats-1 FnDecl 200 ( 2.7%) 5 40 +ast-stats-1 Variant 240 ( 3.2%) 2 120 +ast-stats-1 GenericBound 288 ( 3.9%) 4 72 +ast-stats-1 - Trait 288 ( 3.9%) 4 +ast-stats-1 Block 288 ( 3.9%) 6 48 +ast-stats-1 AssocItem 416 ( 5.6%) 4 104 +ast-stats-1 - Type 208 ( 2.8%) 2 +ast-stats-1 - Fn 208 ( 2.8%) 2 +ast-stats-1 GenericParam 480 ( 6.5%) 5 96 +ast-stats-1 Expr 576 ( 7.8%) 8 72 +ast-stats-1 - Path 72 ( 1.0%) 1 +ast-stats-1 - Match 72 ( 1.0%) 1 +ast-stats-1 - Struct 72 ( 1.0%) 1 +ast-stats-1 - Lit 144 ( 1.9%) 2 +ast-stats-1 - Block 216 ( 2.9%) 3 +ast-stats-1 Pat 616 ( 8.3%) 7 88 +ast-stats-1 - Struct 88 ( 1.2%) 1 +ast-stats-1 - Wild 88 ( 1.2%) 1 +ast-stats-1 - Ident 440 ( 5.9%) 5 +ast-stats-1 PathSegment 720 ( 9.7%) 30 24 +ast-stats-1 Ty 896 (12.1%) 14 64 +ast-stats-1 - Rptr 64 ( 0.9%) 1 +ast-stats-1 - Ptr 64 ( 0.9%) 1 +ast-stats-1 - ImplicitSelf 128 ( 1.7%) 2 +ast-stats-1 - Path 640 ( 8.6%) 10 +ast-stats-1 Item 1_656 (22.3%) 9 184 +ast-stats-1 - Trait 184 ( 2.5%) 1 +ast-stats-1 - Enum 184 ( 2.5%) 1 +ast-stats-1 - ForeignMod 184 ( 2.5%) 1 +ast-stats-1 - Impl 184 ( 2.5%) 1 +ast-stats-1 - Fn 368 ( 5.0%) 2 +ast-stats-1 - Use 552 ( 7.4%) 3 ast-stats-1 ---------------------------------------------------------------- -ast-stats-1 Total 8_416 +ast-stats-1 Total 7_416 ast-stats-1 ast-stats-2 POST EXPANSION AST STATS ast-stats-2 Name Accumulated Size Count Item Size ast-stats-2 ---------------------------------------------------------------- -ast-stats-2 ExprField 48 ( 0.5%) 1 48 -ast-stats-2 Crate 56 ( 0.6%) 1 56 -ast-stats-2 GenericArgs 64 ( 0.7%) 1 64 -ast-stats-2 - AngleBracketed 64 ( 0.7%) 1 -ast-stats-2 Local 72 ( 0.8%) 1 72 -ast-stats-2 WherePredicate 72 ( 0.8%) 1 72 -ast-stats-2 - BoundPredicate 72 ( 0.8%) 1 -ast-stats-2 Arm 96 ( 1.0%) 2 48 -ast-stats-2 ForeignItem 96 ( 1.0%) 1 96 -ast-stats-2 - Fn 96 ( 1.0%) 1 -ast-stats-2 InlineAsm 120 ( 1.3%) 1 120 -ast-stats-2 Attribute 128 ( 1.4%) 4 32 -ast-stats-2 - DocComment 32 ( 0.3%) 1 -ast-stats-2 - Normal 96 ( 1.0%) 3 -ast-stats-2 FieldDef 160 ( 1.7%) 2 80 -ast-stats-2 Stmt 160 ( 1.7%) 5 32 -ast-stats-2 - Local 32 ( 0.3%) 1 -ast-stats-2 - Semi 32 ( 0.3%) 1 -ast-stats-2 - Expr 96 ( 1.0%) 3 -ast-stats-2 Param 160 ( 1.7%) 4 40 -ast-stats-2 FnDecl 200 ( 2.2%) 5 40 -ast-stats-2 Variant 240 ( 2.6%) 2 120 -ast-stats-2 Block 288 ( 3.1%) 6 48 -ast-stats-2 GenericBound 352 ( 3.8%) 4 88 -ast-stats-2 - Trait 352 ( 3.8%) 4 -ast-stats-2 AssocItem 416 ( 4.5%) 4 104 -ast-stats-2 - Type 208 ( 2.3%) 2 -ast-stats-2 - Fn 208 ( 2.3%) 2 -ast-stats-2 GenericParam 480 ( 5.2%) 5 96 -ast-stats-2 PathSegment 792 ( 8.7%) 33 24 -ast-stats-2 Pat 840 ( 9.2%) 7 120 -ast-stats-2 - Struct 120 ( 1.3%) 1 -ast-stats-2 - Wild 120 ( 1.3%) 1 -ast-stats-2 - Ident 600 ( 6.6%) 5 -ast-stats-2 Expr 936 (10.2%) 9 104 -ast-stats-2 - Path 104 ( 1.1%) 1 -ast-stats-2 - Match 104 ( 1.1%) 1 -ast-stats-2 - Struct 104 ( 1.1%) 1 -ast-stats-2 - InlineAsm 104 ( 1.1%) 1 -ast-stats-2 - Lit 208 ( 2.3%) 2 -ast-stats-2 - Block 312 ( 3.4%) 3 -ast-stats-2 Ty 1_344 (14.7%) 14 96 -ast-stats-2 - Rptr 96 ( 1.0%) 1 -ast-stats-2 - Ptr 96 ( 1.0%) 1 -ast-stats-2 - ImplicitSelf 192 ( 2.1%) 2 -ast-stats-2 - Path 960 (10.5%) 10 -ast-stats-2 Item 2_024 (22.1%) 11 184 -ast-stats-2 - Trait 184 ( 2.0%) 1 -ast-stats-2 - Enum 184 ( 2.0%) 1 -ast-stats-2 - ExternCrate 184 ( 2.0%) 1 -ast-stats-2 - ForeignMod 184 ( 2.0%) 1 -ast-stats-2 - Impl 184 ( 2.0%) 1 -ast-stats-2 - Fn 368 ( 4.0%) 2 -ast-stats-2 - Use 736 ( 8.0%) 4 +ast-stats-2 ExprField 48 ( 0.6%) 1 48 +ast-stats-2 GenericArgs 56 ( 0.7%) 1 56 +ast-stats-2 - AngleBracketed 56 ( 0.7%) 1 +ast-stats-2 Crate 56 ( 0.7%) 1 56 +ast-stats-2 Local 72 ( 0.9%) 1 72 +ast-stats-2 WherePredicate 72 ( 0.9%) 1 72 +ast-stats-2 - BoundPredicate 72 ( 0.9%) 1 +ast-stats-2 Arm 96 ( 1.2%) 2 48 +ast-stats-2 ForeignItem 96 ( 1.2%) 1 96 +ast-stats-2 - Fn 96 ( 1.2%) 1 +ast-stats-2 InlineAsm 120 ( 1.5%) 1 120 +ast-stats-2 Attribute 128 ( 1.6%) 4 32 +ast-stats-2 - DocComment 32 ( 0.4%) 1 +ast-stats-2 - Normal 96 ( 1.2%) 3 +ast-stats-2 FieldDef 160 ( 2.0%) 2 80 +ast-stats-2 Stmt 160 ( 2.0%) 5 32 +ast-stats-2 - Local 32 ( 0.4%) 1 +ast-stats-2 - Semi 32 ( 0.4%) 1 +ast-stats-2 - Expr 96 ( 1.2%) 3 +ast-stats-2 Param 160 ( 2.0%) 4 40 +ast-stats-2 FnDecl 200 ( 2.5%) 5 40 +ast-stats-2 Variant 240 ( 3.0%) 2 120 +ast-stats-2 GenericBound 288 ( 3.6%) 4 72 +ast-stats-2 - Trait 288 ( 3.6%) 4 +ast-stats-2 Block 288 ( 3.6%) 6 48 +ast-stats-2 AssocItem 416 ( 5.1%) 4 104 +ast-stats-2 - Type 208 ( 2.6%) 2 +ast-stats-2 - Fn 208 ( 2.6%) 2 +ast-stats-2 GenericParam 480 ( 5.9%) 5 96 +ast-stats-2 Pat 616 ( 7.6%) 7 88 +ast-stats-2 - Struct 88 ( 1.1%) 1 +ast-stats-2 - Wild 88 ( 1.1%) 1 +ast-stats-2 - Ident 440 ( 5.4%) 5 +ast-stats-2 Expr 648 ( 8.0%) 9 72 +ast-stats-2 - Path 72 ( 0.9%) 1 +ast-stats-2 - Match 72 ( 0.9%) 1 +ast-stats-2 - Struct 72 ( 0.9%) 1 +ast-stats-2 - InlineAsm 72 ( 0.9%) 1 +ast-stats-2 - Lit 144 ( 1.8%) 2 +ast-stats-2 - Block 216 ( 2.7%) 3 +ast-stats-2 PathSegment 792 ( 9.8%) 33 24 +ast-stats-2 Ty 896 (11.0%) 14 64 +ast-stats-2 - Rptr 64 ( 0.8%) 1 +ast-stats-2 - Ptr 64 ( 0.8%) 1 +ast-stats-2 - ImplicitSelf 128 ( 1.6%) 2 +ast-stats-2 - Path 640 ( 7.9%) 10 +ast-stats-2 Item 2_024 (25.0%) 11 184 +ast-stats-2 - Trait 184 ( 2.3%) 1 +ast-stats-2 - Enum 184 ( 2.3%) 1 +ast-stats-2 - ExternCrate 184 ( 2.3%) 1 +ast-stats-2 - ForeignMod 184 ( 2.3%) 1 +ast-stats-2 - Impl 184 ( 2.3%) 1 +ast-stats-2 - Fn 368 ( 4.5%) 2 +ast-stats-2 - Use 736 ( 9.1%) 4 ast-stats-2 ---------------------------------------------------------------- -ast-stats-2 Total 9_144 +ast-stats-2 Total 8_112 ast-stats-2 hir-stats HIR STATS hir-stats Name Accumulated Size Count Item Size hir-stats ---------------------------------------------------------------- hir-stats ForeignItemRef 24 ( 0.3%) 1 24 -hir-stats Lifetime 32 ( 0.4%) 1 32 +hir-stats Lifetime 24 ( 0.3%) 1 24 hir-stats Mod 32 ( 0.4%) 1 32 hir-stats ExprField 40 ( 0.4%) 1 40 hir-stats TraitItemRef 56 ( 0.6%) 2 28 @@ -128,9 +128,6 @@ hir-stats Param 64 ( 0.7%) 2 32 hir-stats InlineAsm 72 ( 0.8%) 1 72 hir-stats ImplItemRef 72 ( 0.8%) 2 36 hir-stats Body 96 ( 1.1%) 3 32 -hir-stats GenericArg 96 ( 1.1%) 4 24 -hir-stats - Type 24 ( 0.3%) 1 -hir-stats - Lifetime 72 ( 0.8%) 3 hir-stats FieldDef 96 ( 1.1%) 2 48 hir-stats Arm 96 ( 1.1%) 2 48 hir-stats Stmt 96 ( 1.1%) 3 32 @@ -139,40 +136,43 @@ hir-stats - Semi 32 ( 0.4%) 1 hir-stats - Expr 32 ( 0.4%) 1 hir-stats FnDecl 120 ( 1.3%) 3 40 hir-stats Attribute 128 ( 1.4%) 4 32 +hir-stats GenericArg 128 ( 1.4%) 4 32 +hir-stats - Type 32 ( 0.4%) 1 +hir-stats - Lifetime 96 ( 1.1%) 3 hir-stats GenericArgs 144 ( 1.6%) 3 48 -hir-stats Variant 160 ( 1.8%) 2 80 +hir-stats Variant 176 ( 1.9%) 2 88 hir-stats GenericBound 192 ( 2.1%) 4 48 hir-stats - Trait 192 ( 2.1%) 4 hir-stats WherePredicate 192 ( 2.1%) 3 64 hir-stats - BoundPredicate 192 ( 2.1%) 3 hir-stats Block 288 ( 3.2%) 6 48 -hir-stats Pat 360 ( 3.9%) 5 72 +hir-stats Pat 360 ( 4.0%) 5 72 hir-stats - Wild 72 ( 0.8%) 1 hir-stats - Struct 72 ( 0.8%) 1 hir-stats - Binding 216 ( 2.4%) 3 hir-stats GenericParam 400 ( 4.4%) 5 80 -hir-stats Generics 560 ( 6.1%) 10 56 -hir-stats Ty 720 ( 7.9%) 15 48 +hir-stats Generics 560 ( 6.2%) 10 56 +hir-stats Ty 720 ( 8.0%) 15 48 hir-stats - Ptr 48 ( 0.5%) 1 hir-stats - Rptr 48 ( 0.5%) 1 -hir-stats - Path 624 ( 6.8%) 13 -hir-stats Expr 768 ( 8.4%) 12 64 +hir-stats - Path 624 ( 6.9%) 13 +hir-stats Expr 768 ( 8.5%) 12 64 hir-stats - Path 64 ( 0.7%) 1 hir-stats - Struct 64 ( 0.7%) 1 hir-stats - Match 64 ( 0.7%) 1 hir-stats - InlineAsm 64 ( 0.7%) 1 hir-stats - Lit 128 ( 1.4%) 2 hir-stats - Block 384 ( 4.2%) 6 -hir-stats Item 960 (10.5%) 12 80 +hir-stats Item 880 ( 9.7%) 11 80 hir-stats - Trait 80 ( 0.9%) 1 hir-stats - Enum 80 ( 0.9%) 1 hir-stats - ExternCrate 80 ( 0.9%) 1 hir-stats - ForeignMod 80 ( 0.9%) 1 hir-stats - Impl 80 ( 0.9%) 1 hir-stats - Fn 160 ( 1.8%) 2 -hir-stats - Use 400 ( 4.4%) 5 -hir-stats Path 1_280 (14.0%) 32 40 -hir-stats PathSegment 1_920 (21.0%) 40 48 +hir-stats - Use 320 ( 3.5%) 4 +hir-stats Path 1_240 (13.7%) 31 40 +hir-stats PathSegment 1_920 (21.2%) 40 48 hir-stats ---------------------------------------------------------------- -hir-stats Total 9_128 +hir-stats Total 9_048 hir-stats diff --git a/src/test/ui/structs-enums/type-sizes.rs b/src/test/ui/structs-enums/type-sizes.rs index 7a23f1363..63e2f3150 100644 --- a/src/test/ui/structs-enums/type-sizes.rs +++ b/src/test/ui/structs-enums/type-sizes.rs @@ -3,6 +3,7 @@ #![allow(non_camel_case_types)] #![allow(dead_code)] #![feature(never_type)] +#![feature(pointer_is_aligned)] use std::mem::size_of; use std::num::NonZeroU8; @@ -168,6 +169,18 @@ pub enum EnumManyVariant<X> { _F0, _F1, _F2, _F3, _F4, _F5, _F6, _F7, _F8, _F9, _FA, _FB, _FC, _FD, _FE, _FF, } +struct Reorder4 { + a: u32, + b: u8, + ary: [u8; 4], +} + +struct Reorder2 { + a: u16, + b: u8, + ary: [u8; 6], +} + pub fn main() { assert_eq!(size_of::<u8>(), 1 as usize); assert_eq!(size_of::<u32>(), 4 as usize); @@ -249,4 +262,12 @@ pub fn main() { assert_eq!(size_of::<EnumManyVariant<Option<NicheU16>>>(), 4); assert_eq!(size_of::<EnumManyVariant<Option2<NicheU16,u8>>>(), 6); assert_eq!(size_of::<EnumManyVariant<Option<(NicheU16,u8)>>>(), 6); + + + let v = Reorder4 {a: 0, b: 0, ary: [0; 4]}; + assert_eq!(size_of::<Reorder4>(), 12); + assert!((&v.ary).as_ptr().is_aligned_to(4), "[u8; 4] should group with align-4 fields"); + let v = Reorder2 {a: 0, b: 0, ary: [0; 6]}; + assert_eq!(size_of::<Reorder2>(), 10); + assert!((&v.ary).as_ptr().is_aligned_to(2), "[u8; 6] should group with align-2 fields"); } diff --git a/src/test/ui/structs/multi-line-fru-suggestion.rs b/src/test/ui/structs/multi-line-fru-suggestion.rs new file mode 100644 index 000000000..7b2b13914 --- /dev/null +++ b/src/test/ui/structs/multi-line-fru-suggestion.rs @@ -0,0 +1,22 @@ +#[derive(Default)] +struct Inner { + a: u8, + b: u8, +} + +#[derive(Default)] +struct Outer { + inner: Inner, + defaulted: u8, +} + +fn main(){ + Outer { + //~^ ERROR missing field `defaulted` in initializer of `Outer` + inner: Inner { + a: 1, + b: 2, + } + ..Default::default() + }; +} diff --git a/src/test/ui/structs/multi-line-fru-suggestion.stderr b/src/test/ui/structs/multi-line-fru-suggestion.stderr new file mode 100644 index 000000000..8bbd3ace7 --- /dev/null +++ b/src/test/ui/structs/multi-line-fru-suggestion.stderr @@ -0,0 +1,25 @@ +error[E0063]: missing field `defaulted` in initializer of `Outer` + --> $DIR/multi-line-fru-suggestion.rs:14:5 + | +LL | Outer { + | ^^^^^ missing `defaulted` + | +note: this expression may have been misinterpreted as a `..` range expression + --> $DIR/multi-line-fru-suggestion.rs:16:16 + | +LL | inner: Inner { + | ________________^ +LL | | a: 1, +LL | | b: 2, +LL | | } + | |_________^ this expression does not end in a comma... +LL | ..Default::default() + | ^^^^^^^^^^^^^^^^^^^^ ... so this is interpreted as a `..` range expression, instead of functional record update syntax +help: to set the remaining fields from `Default::default()`, separate the last named field with a comma + | +LL | }, + | + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0063`. diff --git a/src/test/ui/structs/struct-fn-in-definition.rs b/src/test/ui/structs/struct-fn-in-definition.rs index 5ae1b727d..7f48f55fe 100644 --- a/src/test/ui/structs/struct-fn-in-definition.rs +++ b/src/test/ui/structs/struct-fn-in-definition.rs @@ -28,6 +28,7 @@ enum E { //~^ ERROR functions are not allowed in enum definitions //~| HELP unlike in C++, Java, and C#, functions are declared in `impl` blocks //~| HELP see https://doc.rust-lang.org/book/ch05-03-method-syntax.html for more information + //~| HELP enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }` } fn main() {} diff --git a/src/test/ui/structs/struct-fn-in-definition.stderr b/src/test/ui/structs/struct-fn-in-definition.stderr index 472365c6e..439c86ec2 100644 --- a/src/test/ui/structs/struct-fn-in-definition.stderr +++ b/src/test/ui/structs/struct-fn-in-definition.stderr @@ -33,6 +33,7 @@ LL | fn foo() {} | = help: unlike in C++, Java, and C#, functions are declared in `impl` blocks = help: see https://doc.rust-lang.org/book/ch05-03-method-syntax.html for more information + = help: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }` error: aborting due to 3 previous errors diff --git a/src/test/ui/structs/struct-record-suggestion.fixed b/src/test/ui/structs/struct-record-suggestion.fixed index 49e38b196..d93a62185 100644 --- a/src/test/ui/structs/struct-record-suggestion.fixed +++ b/src/test/ui/structs/struct-record-suggestion.fixed @@ -7,9 +7,8 @@ struct A { } fn a() { - let q = A { c: 5,..Default::default() }; - //~^ ERROR mismatched types - //~| ERROR missing fields + let q = A { c: 5, ..Default::default() }; + //~^ ERROR missing fields //~| HELP separate the last named field with a comma let r = A { c: 5, ..Default::default() }; assert_eq!(q, r); @@ -21,7 +20,7 @@ struct B { } fn b() { - let q = B { b: 1,..Default::default() }; + let q = B { b: 1, ..Default::default() }; //~^ ERROR mismatched types //~| HELP separate the last named field with a comma let r = B { b: 1 }; diff --git a/src/test/ui/structs/struct-record-suggestion.rs b/src/test/ui/structs/struct-record-suggestion.rs index 901f310c8..f0fd1c94e 100644 --- a/src/test/ui/structs/struct-record-suggestion.rs +++ b/src/test/ui/structs/struct-record-suggestion.rs @@ -8,8 +8,7 @@ struct A { fn a() { let q = A { c: 5..Default::default() }; - //~^ ERROR mismatched types - //~| ERROR missing fields + //~^ ERROR missing fields //~| HELP separate the last named field with a comma let r = A { c: 5, ..Default::default() }; assert_eq!(q, r); diff --git a/src/test/ui/structs/struct-record-suggestion.stderr b/src/test/ui/structs/struct-record-suggestion.stderr index 66e9f021e..f4fd655e6 100644 --- a/src/test/ui/structs/struct-record-suggestion.stderr +++ b/src/test/ui/structs/struct-record-suggestion.stderr @@ -1,37 +1,38 @@ -error[E0308]: mismatched types - --> $DIR/struct-record-suggestion.rs:10:20 - | -LL | let q = A { c: 5..Default::default() }; - | ^^^^^^^^^^^^^^^^^^^^^ expected `u64`, found struct `std::ops::Range` - | - = note: expected type `u64` - found struct `std::ops::Range<{integer}>` - error[E0063]: missing fields `b` and `d` in initializer of `A` --> $DIR/struct-record-suggestion.rs:10:13 | LL | let q = A { c: 5..Default::default() }; | ^ missing `b` and `d` | +note: this expression may have been misinterpreted as a `..` range expression + --> $DIR/struct-record-suggestion.rs:10:20 + | +LL | let q = A { c: 5..Default::default() }; + | ^^^^^^^^^^^^^^^^^^^^^ help: to set the remaining fields from `Default::default()`, separate the last named field with a comma | -LL | let q = A { c: 5,..Default::default() }; +LL | let q = A { c: 5, ..Default::default() }; | + error[E0308]: mismatched types - --> $DIR/struct-record-suggestion.rs:24:20 + --> $DIR/struct-record-suggestion.rs:23:20 | LL | let q = B { b: 1..Default::default() }; | ^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found struct `std::ops::Range` | = note: expected type `u32` found struct `std::ops::Range<{integer}>` +note: this expression may have been misinterpreted as a `..` range expression + --> $DIR/struct-record-suggestion.rs:23:20 + | +LL | let q = B { b: 1..Default::default() }; + | ^^^^^^^^^^^^^^^^^^^^^ help: to set the remaining fields from `Default::default()`, separate the last named field with a comma | -LL | let q = B { b: 1,..Default::default() }; +LL | let q = B { b: 1, ..Default::default() }; | + -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0063, E0308. For more information about an error, try `rustc --explain E0063`. diff --git a/src/test/ui/structs/unresolved-struct-with-fru.rs b/src/test/ui/structs/unresolved-struct-with-fru.rs new file mode 100644 index 000000000..c9fdca457 --- /dev/null +++ b/src/test/ui/structs/unresolved-struct-with-fru.rs @@ -0,0 +1,12 @@ +struct S { + a: u32, +} + +fn main() { + let s1 = S { a: 1 }; + + let _ = || { + let s2 = Oops { a: 2, ..s1 }; + //~^ ERROR cannot find struct, variant or union type `Oops` in this scope + }; +} diff --git a/src/test/ui/structs/unresolved-struct-with-fru.stderr b/src/test/ui/structs/unresolved-struct-with-fru.stderr new file mode 100644 index 000000000..a5796a222 --- /dev/null +++ b/src/test/ui/structs/unresolved-struct-with-fru.stderr @@ -0,0 +1,9 @@ +error[E0422]: cannot find struct, variant or union type `Oops` in this scope + --> $DIR/unresolved-struct-with-fru.rs:9:18 + | +LL | let s2 = Oops { a: 2, ..s1 }; + | ^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0422`. diff --git a/src/test/ui/suggestions/assoc-const-as-fn.rs b/src/test/ui/suggestions/assoc-const-as-fn.rs new file mode 100644 index 000000000..4b4595dd5 --- /dev/null +++ b/src/test/ui/suggestions/assoc-const-as-fn.rs @@ -0,0 +1,18 @@ +unsafe fn pointer(v: usize, w: u32) {} + +pub trait UniformScalar {} +impl UniformScalar for u32 {} + +pub trait GlUniformScalar: UniformScalar { + const FACTORY: unsafe fn(usize, Self) -> (); +} +impl GlUniformScalar for u32 { + const FACTORY: unsafe fn(usize, Self) -> () = pointer; +} + +pub fn foo<T: UniformScalar>(value: T) { + <T as GlUniformScalar>::FACTORY(1, value); + //~^ ERROR the trait bound `T: GlUniformScalar` is not satisfied +} + +fn main() {} diff --git a/src/test/ui/suggestions/assoc-const-as-fn.stderr b/src/test/ui/suggestions/assoc-const-as-fn.stderr new file mode 100644 index 000000000..3b6e947c5 --- /dev/null +++ b/src/test/ui/suggestions/assoc-const-as-fn.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `T: GlUniformScalar` is not satisfied + --> $DIR/assoc-const-as-fn.rs:14:40 + | +LL | <T as GlUniformScalar>::FACTORY(1, value); + | ------------------------------- ^^^^^ the trait `GlUniformScalar` is not implemented for `T` + | | + | required by a bound introduced by this call + | +help: consider further restricting this bound + | +LL | pub fn foo<T: UniformScalar + GlUniformScalar>(value: T) { + | +++++++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/suggestions/assoc_fn_without_self.stderr b/src/test/ui/suggestions/assoc_fn_without_self.stderr index 88920b852..febdd6733 100644 --- a/src/test/ui/suggestions/assoc_fn_without_self.stderr +++ b/src/test/ui/suggestions/assoc_fn_without_self.stderr @@ -7,13 +7,18 @@ LL | foo(); help: consider using the associated function | LL | Self::foo(); - | ~~~~~~~~~ + | ++++++ error[E0425]: cannot find function `bar` in this scope --> $DIR/assoc_fn_without_self.rs:17:9 | LL | bar(); | ^^^ not found in this scope + | +help: consider using the associated function + | +LL | self.bar(); + | +++++ error[E0425]: cannot find function `baz` in this scope --> $DIR/assoc_fn_without_self.rs:18:9 @@ -24,7 +29,7 @@ LL | baz(2, 3); help: consider using the associated function | LL | Self::baz(2, 3); - | ~~~~~~~~~ + | ++++++ error[E0425]: cannot find function `foo` in this scope --> $DIR/assoc_fn_without_self.rs:14:13 diff --git a/src/test/ui/suggestions/borrow-for-loop-head.stderr b/src/test/ui/suggestions/borrow-for-loop-head.stderr index 1059e3d15..0cc8994fe 100644 --- a/src/test/ui/suggestions/borrow-for-loop-head.stderr +++ b/src/test/ui/suggestions/borrow-for-loop-head.stderr @@ -12,6 +12,7 @@ error[E0382]: use of moved value: `a` LL | let a = vec![1, 2, 3]; | - move occurs because `a` has type `Vec<i32>`, which does not implement the `Copy` trait LL | for i in &a { + | ----------- inside of this loop LL | for j in a { | ^ `a` moved due to this implicit call to `.into_iter()`, in previous iteration of loop | diff --git a/src/test/ui/suggestions/core-std-import-order-issue-83564.stderr b/src/test/ui/suggestions/core-std-import-order-issue-83564.stderr index ce85d93b9..e4e1fc591 100644 --- a/src/test/ui/suggestions/core-std-import-order-issue-83564.stderr +++ b/src/test/ui/suggestions/core-std-import-order-issue-83564.stderr @@ -2,7 +2,7 @@ error[E0433]: failed to resolve: use of undeclared type `NonZeroU32` --> $DIR/core-std-import-order-issue-83564.rs:8:14 | LL | let _x = NonZeroU32::new(5).unwrap(); - | ^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^ use of undeclared type `NonZeroU32` | help: consider importing one of these items | diff --git a/src/test/ui/suggestions/crate-or-module-typo.stderr b/src/test/ui/suggestions/crate-or-module-typo.stderr index e8250c9fa..98b88b4fb 100644 --- a/src/test/ui/suggestions/crate-or-module-typo.stderr +++ b/src/test/ui/suggestions/crate-or-module-typo.stderr @@ -20,12 +20,6 @@ help: there is a crate or module with a similar name LL | use bar::bar; | ~~~ -error[E0433]: failed to resolve: use of undeclared crate or module `bar` - --> $DIR/crate-or-module-typo.rs:6:20 - | -LL | pub fn bar() { bar::baz(); } - | ^^^ use of undeclared crate or module `bar` - error[E0433]: failed to resolve: use of undeclared crate or module `st` --> $DIR/crate-or-module-typo.rs:14:10 | @@ -37,6 +31,12 @@ help: there is a crate or module with a similar name LL | bar: std::cell::Cell<bool> | ~~~ +error[E0433]: failed to resolve: use of undeclared crate or module `bar` + --> $DIR/crate-or-module-typo.rs:6:20 + | +LL | pub fn bar() { bar::baz(); } + | ^^^ use of undeclared crate or module `bar` + error: aborting due to 4 previous errors Some errors have detailed explanations: E0432, E0433. diff --git a/src/test/ui/suggestions/dont-suggest-ufcs-for-const.rs b/src/test/ui/suggestions/dont-suggest-ufcs-for-const.rs new file mode 100644 index 000000000..06cf243f1 --- /dev/null +++ b/src/test/ui/suggestions/dont-suggest-ufcs-for-const.rs @@ -0,0 +1,4 @@ +fn main() { + 1_u32.MAX(); + //~^ ERROR no method named `MAX` found for type `u32` in the current scope +} diff --git a/src/test/ui/suggestions/dont-suggest-ufcs-for-const.stderr b/src/test/ui/suggestions/dont-suggest-ufcs-for-const.stderr new file mode 100644 index 000000000..0d9543e0b --- /dev/null +++ b/src/test/ui/suggestions/dont-suggest-ufcs-for-const.stderr @@ -0,0 +1,9 @@ +error[E0599]: no method named `MAX` found for type `u32` in the current scope + --> $DIR/dont-suggest-ufcs-for-const.rs:2:11 + | +LL | 1_u32.MAX(); + | ^^^ method not found in `u32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr b/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr index 77cef485f..34ff59a9b 100644 --- a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr +++ b/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr @@ -78,20 +78,21 @@ LL | impl<P: Deref<Target: Unpin>> Pin<P> { error[E0308]: mismatched types --> $DIR/expected-boxed-future-isnt-pinned.rs:28:5 | -LL | fn zap() -> BoxFuture<'static, i32> { - | ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type LL | / async { LL | | 42 LL | | } - | |_____^ expected struct `Pin`, found opaque type - | - ::: $SRC_DIR/core/src/future/mod.rs:LL:COL - | -LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return> - | ------------------------------- the found opaque type - | - = note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` - found opaque type `impl Future<Output = {integer}>` + | | ^ + | | | + | |_____expected struct `Pin`, found `async` block + | arguments to this function are incorrect + | + = note: expected struct `Pin<Box<dyn Future<Output = i32> + Send>>` + found `async` block `[async block@$DIR/expected-boxed-future-isnt-pinned.rs:28:5: 30:6]` +note: function defined here + --> $SRC_DIR/core/src/future/mod.rs:LL:COL + | +LL | pub const fn identity_future<O, Fut: Future<Output = O>>(f: Fut) -> Fut { + | ^^^^^^^^^^^^^^^ help: you need to pin and box this expression | LL ~ Box::pin(async { diff --git a/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr b/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr index 597dc61c3..d0ddb34d9 100644 --- a/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr +++ b/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr @@ -1,23 +1,3 @@ -error[E0423]: expected value, found struct variant `E::B` - --> $DIR/fn-or-tuple-struct-without-args.rs:36:16 - | -LL | A(usize), - | -------- similarly named tuple variant `A` defined here -LL | B { a: usize }, - | -------------- `E::B` defined here -... -LL | let _: E = E::B; - | ^^^^ - | -help: use struct literal syntax instead - | -LL | let _: E = E::B { a: val }; - | ~~~~~~~~~~~~~~~ -help: a tuple variant with a similar name exists - | -LL | let _: E = E::A; - | ~ - error[E0308]: mismatched types --> $DIR/fn-or-tuple-struct-without-args.rs:29:20 | @@ -144,6 +124,12 @@ help: use parentheses to construct this tuple variant LL | let _: E = E::A(/* usize */); | +++++++++++++ +error[E0533]: expected value, found struct variant `E::B` + --> $DIR/fn-or-tuple-struct-without-args.rs:36:16 + | +LL | let _: E = E::B; + | ^^^^ not a value + error[E0308]: mismatched types --> $DIR/fn-or-tuple-struct-without-args.rs:37:20 | @@ -293,5 +279,5 @@ LL | let _: usize = closure(); error: aborting due to 17 previous errors -Some errors have detailed explanations: E0308, E0423, E0615. +Some errors have detailed explanations: E0308, E0533, E0615. For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/suggestions/if-let-typo.stderr b/src/test/ui/suggestions/if-let-typo.stderr index 3d9ac40ec..02148b7f7 100644 --- a/src/test/ui/suggestions/if-let-typo.stderr +++ b/src/test/ui/suggestions/if-let-typo.stderr @@ -25,12 +25,22 @@ error[E0308]: mismatched types | LL | if Some(x) = foo {} | ^^^^^^^^^^^^^ expected `bool`, found `()` + | +help: consider adding `let` + | +LL | if let Some(x) = foo {} + | +++ error[E0308]: mismatched types --> $DIR/if-let-typo.rs:6:8 | LL | if Some(foo) = bar {} | ^^^^^^^^^^^^^^^ expected `bool`, found `()` + | +help: consider adding `let` + | +LL | if let Some(foo) = bar {} + | +++ error[E0308]: mismatched types --> $DIR/if-let-typo.rs:7:8 @@ -51,6 +61,11 @@ error[E0308]: mismatched types | LL | if Some(3) = foo {} | ^^^^^^^^^^^^^ expected `bool`, found `()` + | +help: consider adding `let` + | +LL | if let Some(3) = foo {} + | +++ error: aborting due to 7 previous errors diff --git a/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.rs b/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.rs index fe291e021..a1a51c481 100644 --- a/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.rs +++ b/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.rs @@ -2,20 +2,67 @@ // gate-test-anonymous_lifetime_in_impl_trait // Verify the behaviour of `feature(anonymous_lifetime_in_impl_trait)`. -fn f(_: impl Iterator<Item = &'_ ()>) {} -//~^ ERROR anonymous lifetimes in `impl Trait` are unstable +mod elided { + fn f(_: impl Iterator<Item = &()>) {} + //~^ ERROR anonymous lifetimes in `impl Trait` are unstable -fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } -//~^ ERROR anonymous lifetimes in `impl Trait` are unstable -//~| ERROR missing lifetime specifier + fn g(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() } + //~^ ERROR anonymous lifetimes in `impl Trait` are unstable + //~| ERROR missing lifetime specifier -// Anonymous lifetimes in async fn are already allowed. -// This is understood as `fn foo<'_1>(_: impl Iterator<Item = &'_1 ()>) {}`. -async fn h(_: impl Iterator<Item = &'_ ()>) {} + // Anonymous lifetimes in async fn are already allowed. + // This is understood as `fn foo<'_1>(_: impl Iterator<Item = &'_1 ()>) {}`. + async fn h(_: impl Iterator<Item = &()>) {} -// Anonymous lifetimes in async fn are already allowed. -// But that lifetime does not participate in resolution. -async fn i(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } -//~^ ERROR missing lifetime specifier + // Anonymous lifetimes in async fn are already allowed. + // But that lifetime does not participate in resolution. + async fn i(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() } + //~^ ERROR missing lifetime specifier +} + +mod underscore { + fn f(_: impl Iterator<Item = &'_ ()>) {} + //~^ ERROR anonymous lifetimes in `impl Trait` are unstable + + fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } + //~^ ERROR anonymous lifetimes in `impl Trait` are unstable + //~| ERROR missing lifetime specifier + + // Anonymous lifetimes in async fn are already allowed. + // This is understood as `fn foo<'_1>(_: impl Iterator<Item = &'_1 ()>) {}`. + async fn h(_: impl Iterator<Item = &'_ ()>) {} + + // Anonymous lifetimes in async fn are already allowed. + // But that lifetime does not participate in resolution. + async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } + //~^ ERROR missing lifetime specifier +} + +mod alone_in_path { + trait Foo<'a> { fn next(&mut self) -> Option<&'a ()>; } + + fn f(_: impl Foo) {} + //~^ ERROR anonymous lifetimes in `impl Trait` are unstable + + fn g(mut x: impl Foo) -> Option<&()> { x.next() } + //~^ ERROR anonymous lifetimes in `impl Trait` are unstable + //~| ERROR missing lifetime specifier +} + +mod in_path { + trait Foo<'a, T> { fn next(&mut self) -> Option<&'a T>; } + + fn f(_: impl Foo<()>) {} + //~^ ERROR anonymous lifetimes in `impl Trait` are unstable + + fn g(mut x: impl Foo<()>) -> Option<&()> { x.next() } + //~^ ERROR anonymous lifetimes in `impl Trait` are unstable + //~| ERROR missing lifetime specifier +} + +// This must not err, as the `&` actually resolves to `'a`. +fn resolved_anonymous<'a, T>(f: impl Fn(&'a str) -> &T) { + f("f") +} fn main() {} diff --git a/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.stderr b/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.stderr index 9833da13f..50806a672 100644 --- a/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.stderr +++ b/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.stderr @@ -1,52 +1,172 @@ error[E0106]: missing lifetime specifier - --> $DIR/impl-trait-missing-lifetime-gated.rs:8:50 + --> $DIR/impl-trait-missing-lifetime-gated.rs:9:54 | -LL | fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } - | ^^ expected named lifetime parameter +LL | fn g(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() } + | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime | -LL | fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() } - | ~~~~~~~ +LL | fn g(mut x: impl Iterator<Item = &()>) -> Option<&'static ()> { x.next() } + | +++++++ error[E0106]: missing lifetime specifier - --> $DIR/impl-trait-missing-lifetime-gated.rs:18:56 + --> $DIR/impl-trait-missing-lifetime-gated.rs:19:60 | -LL | async fn i(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } - | ^^ expected named lifetime parameter +LL | async fn i(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() } + | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime | -LL | async fn i(x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() } - | ~~~~~~~ +LL | async fn i(mut x: impl Iterator<Item = &()>) -> Option<&'static ()> { x.next() } + | +++++++ + +error[E0106]: missing lifetime specifier + --> $DIR/impl-trait-missing-lifetime-gated.rs:27:58 + | +LL | fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } + | ^^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from +help: consider using the `'static` lifetime + | +LL | fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() } + | ~~~~~~~ + +error[E0106]: missing lifetime specifier + --> $DIR/impl-trait-missing-lifetime-gated.rs:37:64 + | +LL | async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } + | ^^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from +help: consider using the `'static` lifetime + | +LL | async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() } + | ~~~~~~~ + +error[E0106]: missing lifetime specifier + --> $DIR/impl-trait-missing-lifetime-gated.rs:47:37 + | +LL | fn g(mut x: impl Foo) -> Option<&()> { x.next() } + | ^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from +help: consider using the `'static` lifetime + | +LL | fn g(mut x: impl Foo) -> Option<&'static ()> { x.next() } + | +++++++ + +error[E0106]: missing lifetime specifier + --> $DIR/impl-trait-missing-lifetime-gated.rs:58:41 + | +LL | fn g(mut x: impl Foo<()>) -> Option<&()> { x.next() } + | ^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from +help: consider using the `'static` lifetime + | +LL | fn g(mut x: impl Foo<()>) -> Option<&'static ()> { x.next() } + | +++++++ + +error[E0658]: anonymous lifetimes in `impl Trait` are unstable + --> $DIR/impl-trait-missing-lifetime-gated.rs:6:35 + | +LL | fn f(_: impl Iterator<Item = &()>) {} + | ^ expected named lifetime parameter + | + = help: add `#![feature(anonymous_lifetime_in_impl_trait)]` to the crate attributes to enable +help: consider introducing a named lifetime parameter + | +LL | fn f<'a>(_: impl Iterator<Item = &'a ()>) {} + | ++++ ++ + +error[E0658]: anonymous lifetimes in `impl Trait` are unstable + --> $DIR/impl-trait-missing-lifetime-gated.rs:9:39 + | +LL | fn g(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() } + | ^ expected named lifetime parameter + | + = help: add `#![feature(anonymous_lifetime_in_impl_trait)]` to the crate attributes to enable +help: consider introducing a named lifetime parameter + | +LL | fn g<'a>(mut x: impl Iterator<Item = &'a ()>) -> Option<&()> { x.next() } + | ++++ ++ + +error[E0658]: anonymous lifetimes in `impl Trait` are unstable + --> $DIR/impl-trait-missing-lifetime-gated.rs:24:35 + | +LL | fn f(_: impl Iterator<Item = &'_ ()>) {} + | ^^ expected named lifetime parameter + | + = help: add `#![feature(anonymous_lifetime_in_impl_trait)]` to the crate attributes to enable +help: consider introducing a named lifetime parameter + | +LL | fn f<'a>(_: impl Iterator<Item = &'a ()>) {} + | ++++ ~~ + +error[E0658]: anonymous lifetimes in `impl Trait` are unstable + --> $DIR/impl-trait-missing-lifetime-gated.rs:27:39 + | +LL | fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } + | ^^ expected named lifetime parameter + | + = help: add `#![feature(anonymous_lifetime_in_impl_trait)]` to the crate attributes to enable +help: consider introducing a named lifetime parameter + | +LL | fn g<'a>(mut x: impl Iterator<Item = &'a ()>) -> Option<&'_ ()> { x.next() } + | ++++ ~~ + +error[E0658]: anonymous lifetimes in `impl Trait` are unstable + --> $DIR/impl-trait-missing-lifetime-gated.rs:44:18 + | +LL | fn f(_: impl Foo) {} + | ^^^ expected named lifetime parameter + | + = help: add `#![feature(anonymous_lifetime_in_impl_trait)]` to the crate attributes to enable +help: consider introducing a named lifetime parameter + | +LL | fn f<'a>(_: impl Foo<'a>) {} + | ++++ ++++ + +error[E0658]: anonymous lifetimes in `impl Trait` are unstable + --> $DIR/impl-trait-missing-lifetime-gated.rs:47:22 + | +LL | fn g(mut x: impl Foo) -> Option<&()> { x.next() } + | ^^^ expected named lifetime parameter + | + = help: add `#![feature(anonymous_lifetime_in_impl_trait)]` to the crate attributes to enable +help: consider introducing a named lifetime parameter + | +LL | fn g<'a>(mut x: impl Foo<'a>) -> Option<&()> { x.next() } + | ++++ ++++ error[E0658]: anonymous lifetimes in `impl Trait` are unstable - --> $DIR/impl-trait-missing-lifetime-gated.rs:5:31 + --> $DIR/impl-trait-missing-lifetime-gated.rs:55:22 | -LL | fn f(_: impl Iterator<Item = &'_ ()>) {} - | ^^ expected named lifetime parameter +LL | fn f(_: impl Foo<()>) {} + | ^ expected named lifetime parameter | = help: add `#![feature(anonymous_lifetime_in_impl_trait)]` to the crate attributes to enable help: consider introducing a named lifetime parameter | -LL | fn f<'a>(_: impl Iterator<Item = &'_'a ()>) {} - | ++++ ++ +LL | fn f<'a>(_: impl Foo<'a, ()>) {} + | ++++ +++ error[E0658]: anonymous lifetimes in `impl Trait` are unstable - --> $DIR/impl-trait-missing-lifetime-gated.rs:8:31 + --> $DIR/impl-trait-missing-lifetime-gated.rs:58:26 | -LL | fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } - | ^^ expected named lifetime parameter +LL | fn g(mut x: impl Foo<()>) -> Option<&()> { x.next() } + | ^ expected named lifetime parameter | = help: add `#![feature(anonymous_lifetime_in_impl_trait)]` to the crate attributes to enable help: consider introducing a named lifetime parameter | -LL | fn g<'a>(x: impl Iterator<Item = &'_'a ()>) -> Option<&'_ ()> { x.next() } - | ++++ ++ +LL | fn g<'a>(mut x: impl Foo<'a, ()>) -> Option<&()> { x.next() } + | ++++ +++ -error: aborting due to 4 previous errors +error: aborting due to 14 previous errors Some errors have detailed explanations: E0106, E0658. For more information about an error, try `rustc --explain E0106`. diff --git a/src/test/ui/suggestions/inner_type2.rs b/src/test/ui/suggestions/inner_type2.rs index c56ea7c03..fac68c053 100644 --- a/src/test/ui/suggestions/inner_type2.rs +++ b/src/test/ui/suggestions/inner_type2.rs @@ -22,5 +22,5 @@ fn main() { let item = std::mem::MaybeUninit::new(Struct { p: 42_u32 }); item.method(); //~^ ERROR no method named `method` found for union `MaybeUninit` in the current scope [E0599] - //~| HELP if this `MaybeUninit::<Struct<u32>>` has been initialized, use one of the `assume_init` methods to access the inner value + //~| HELP if this `MaybeUninit<Struct<u32>>` has been initialized, use one of the `assume_init` methods to access the inner value } diff --git a/src/test/ui/suggestions/inner_type2.stderr b/src/test/ui/suggestions/inner_type2.stderr index eddfd9d63..984366123 100644 --- a/src/test/ui/suggestions/inner_type2.stderr +++ b/src/test/ui/suggestions/inner_type2.stderr @@ -17,7 +17,7 @@ error[E0599]: no method named `method` found for union `MaybeUninit` in the curr LL | item.method(); | ^^^^^^ method not found in `MaybeUninit<Struct<u32>>` | - = help: if this `MaybeUninit::<Struct<u32>>` has been initialized, use one of the `assume_init` methods to access the inner value + = help: if this `MaybeUninit<Struct<u32>>` has been initialized, use one of the `assume_init` methods to access the inner value note: the method `method` exists on the type `Struct<u32>` --> $DIR/inner_type2.rs:6:5 | diff --git a/src/test/ui/suggestions/issue-102354.stderr b/src/test/ui/suggestions/issue-102354.stderr index 4f76c5f2e..08d4b9955 100644 --- a/src/test/ui/suggestions/issue-102354.stderr +++ b/src/test/ui/suggestions/issue-102354.stderr @@ -2,7 +2,10 @@ error[E0599]: no method named `func` found for type `i32` in the current scope --> $DIR/issue-102354.rs:9:7 | LL | x.func(); - | ^^^^ this is an associated function, not a method + | --^^^^-- + | | | + | | this is an associated function, not a method + | help: use associated function syntax instead: `i32::func()` | = note: found the following associated functions; to be used as methods, functions must have a `self` parameter note: the candidate is defined in the trait `Trait` @@ -10,14 +13,6 @@ note: the candidate is defined in the trait `Trait` | LL | fn func() {} | ^^^^^^^^^ -help: use associated function syntax instead - | -LL | i32::func(); - | ~~~~~~~~~ -help: disambiguate the associated function for the candidate - | -LL | <i32 as Trait>::func(x); - | ~~~~~~~~~~~~~~~~~~~~~~~ error: aborting due to previous error diff --git a/src/test/ui/suggestions/issue-104086-suggest-let.rs b/src/test/ui/suggestions/issue-104086-suggest-let.rs new file mode 100644 index 000000000..d22ad27d0 --- /dev/null +++ b/src/test/ui/suggestions/issue-104086-suggest-let.rs @@ -0,0 +1,30 @@ +fn main() { + x = x = x; + //~^ ERROR cannot find value `x` in this scope + //~| ERROR cannot find value `x` in this scope + //~| ERROR cannot find value `x` in this scope + + x = y = y = y; + //~^ ERROR cannot find value `y` in this scope + //~| ERROR cannot find value `y` in this scope + //~| ERROR cannot find value `y` in this scope + //~| ERROR cannot find value `x` in this scope + + x = y = y; + //~^ ERROR cannot find value `x` in this scope + //~| ERROR cannot find value `y` in this scope + //~| ERROR cannot find value `y` in this scope + + x = x = y; + //~^ ERROR cannot find value `x` in this scope + //~| ERROR cannot find value `x` in this scope + //~| ERROR cannot find value `y` in this scope + + x = x; // will suggest add `let` + //~^ ERROR cannot find value `x` in this scope + //~| ERROR cannot find value `x` in this scope + + x = y // will suggest add `let` + //~^ ERROR cannot find value `x` in this scope + //~| ERROR cannot find value `y` in this scope +} diff --git a/src/test/ui/suggestions/issue-104086-suggest-let.stderr b/src/test/ui/suggestions/issue-104086-suggest-let.stderr new file mode 100644 index 000000000..fb4ea3121 --- /dev/null +++ b/src/test/ui/suggestions/issue-104086-suggest-let.stderr @@ -0,0 +1,135 @@ +error[E0425]: cannot find value `x` in this scope + --> $DIR/issue-104086-suggest-let.rs:2:5 + | +LL | x = x = x; + | ^ + | +help: you might have meant to introduce a new binding + | +LL | let x = x = x; + | +++ + +error[E0425]: cannot find value `x` in this scope + --> $DIR/issue-104086-suggest-let.rs:2:9 + | +LL | x = x = x; + | ^ not found in this scope + +error[E0425]: cannot find value `x` in this scope + --> $DIR/issue-104086-suggest-let.rs:2:13 + | +LL | x = x = x; + | ^ not found in this scope + +error[E0425]: cannot find value `x` in this scope + --> $DIR/issue-104086-suggest-let.rs:7:5 + | +LL | x = y = y = y; + | ^ + | +help: you might have meant to introduce a new binding + | +LL | let x = y = y = y; + | +++ + +error[E0425]: cannot find value `y` in this scope + --> $DIR/issue-104086-suggest-let.rs:7:9 + | +LL | x = y = y = y; + | ^ not found in this scope + +error[E0425]: cannot find value `y` in this scope + --> $DIR/issue-104086-suggest-let.rs:7:13 + | +LL | x = y = y = y; + | ^ not found in this scope + +error[E0425]: cannot find value `y` in this scope + --> $DIR/issue-104086-suggest-let.rs:7:17 + | +LL | x = y = y = y; + | ^ not found in this scope + +error[E0425]: cannot find value `x` in this scope + --> $DIR/issue-104086-suggest-let.rs:13:5 + | +LL | x = y = y; + | ^ + | +help: you might have meant to introduce a new binding + | +LL | let x = y = y; + | +++ + +error[E0425]: cannot find value `y` in this scope + --> $DIR/issue-104086-suggest-let.rs:13:9 + | +LL | x = y = y; + | ^ not found in this scope + +error[E0425]: cannot find value `y` in this scope + --> $DIR/issue-104086-suggest-let.rs:13:13 + | +LL | x = y = y; + | ^ not found in this scope + +error[E0425]: cannot find value `x` in this scope + --> $DIR/issue-104086-suggest-let.rs:18:5 + | +LL | x = x = y; + | ^ + | +help: you might have meant to introduce a new binding + | +LL | let x = x = y; + | +++ + +error[E0425]: cannot find value `x` in this scope + --> $DIR/issue-104086-suggest-let.rs:18:9 + | +LL | x = x = y; + | ^ not found in this scope + +error[E0425]: cannot find value `y` in this scope + --> $DIR/issue-104086-suggest-let.rs:18:13 + | +LL | x = x = y; + | ^ not found in this scope + +error[E0425]: cannot find value `x` in this scope + --> $DIR/issue-104086-suggest-let.rs:23:5 + | +LL | x = x; // will suggest add `let` + | ^ + | +help: you might have meant to introduce a new binding + | +LL | let x = x; // will suggest add `let` + | +++ + +error[E0425]: cannot find value `x` in this scope + --> $DIR/issue-104086-suggest-let.rs:23:9 + | +LL | x = x; // will suggest add `let` + | ^ not found in this scope + +error[E0425]: cannot find value `x` in this scope + --> $DIR/issue-104086-suggest-let.rs:27:5 + | +LL | x = y // will suggest add `let` + | ^ + | +help: you might have meant to introduce a new binding + | +LL | let x = y // will suggest add `let` + | +++ + +error[E0425]: cannot find value `y` in this scope + --> $DIR/issue-104086-suggest-let.rs:27:9 + | +LL | x = y // will suggest add `let` + | ^ not found in this scope + +error: aborting due to 17 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/suggestions/issue-104287.rs b/src/test/ui/suggestions/issue-104287.rs new file mode 100644 index 000000000..b7601a548 --- /dev/null +++ b/src/test/ui/suggestions/issue-104287.rs @@ -0,0 +1,9 @@ +// The purpose of this test is not to validate the output of the compiler. +// Instead, it ensures the suggestion is generated without performing an arithmetic overflow. + +fn main() { + let x = not_found; //~ ERROR cannot find value `not_found` in this scope + simd_gt::<()>(x); + //~^ ERROR this associated function takes 0 generic arguments but 1 generic argument was supplied + //~| ERROR cannot find function `simd_gt` in this scope +} diff --git a/src/test/ui/suggestions/issue-104287.stderr b/src/test/ui/suggestions/issue-104287.stderr new file mode 100644 index 000000000..4b302dd65 --- /dev/null +++ b/src/test/ui/suggestions/issue-104287.stderr @@ -0,0 +1,36 @@ +error[E0425]: cannot find value `not_found` in this scope + --> $DIR/issue-104287.rs:5:13 + | +LL | let x = not_found; + | ^^^^^^^^^ not found in this scope + +error[E0107]: this associated function takes 0 generic arguments but 1 generic argument was supplied + --> $DIR/issue-104287.rs:6:5 + | +LL | simd_gt::<()>(x); + | ^^^^^^^------ help: remove these generics + | | + | expected 0 generic arguments + | +note: associated function defined here, with 0 generic parameters + --> $SRC_DIR/core/src/../../portable-simd/crates/core_simd/src/ord.rs:LL:COL + | +LL | fn simd_gt(self, other: Self) -> Self::Mask; + | ^^^^^^^ + +error[E0425]: cannot find function `simd_gt` in this scope + --> $DIR/issue-104287.rs:6:5 + | +LL | simd_gt::<()>(x); + | ^^^^^^^ not found in this scope + | +help: use the `.` operator to call the method `SimdPartialOrd::simd_gt` on `[type error]` + | +LL - simd_gt::<()>(x); +LL + x.simd_gt(); + | + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0107, E0425. +For more information about an error, try `rustc --explain E0107`. diff --git a/src/test/ui/suggestions/issue-84700.stderr b/src/test/ui/suggestions/issue-84700.stderr index b36d8aba3..ac9f5ab0b 100644 --- a/src/test/ui/suggestions/issue-84700.stderr +++ b/src/test/ui/suggestions/issue-84700.stderr @@ -7,15 +7,13 @@ LL | Cow, LL | FarmAnimal::Cow(_) => "moo".to_string(), | ^^^^^^^^^^^^^^^^^^ help: use this syntax instead: `FarmAnimal::Cow` -error[E0532]: expected tuple struct or tuple variant, found struct variant `FarmAnimal::Chicken` +error[E0164]: expected tuple struct or tuple variant, found struct variant `FarmAnimal::Chicken` --> $DIR/issue-84700.rs:17:9 | -LL | Chicken { num_eggs: usize }, - | --------------------------- `FarmAnimal::Chicken` defined here -... LL | FarmAnimal::Chicken(_) => "cluck, cluck!".to_string(), - | ^^^^^^^^^^^^^^^^^^^^^^ help: use struct pattern syntax instead: `FarmAnimal::Chicken { num_eggs }` + | ^^^^^^^^^^^^^^^^^^^^^^ not a tuple struct or tuple variant error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0532`. +Some errors have detailed explanations: E0164, E0532. +For more information about an error, try `rustc --explain E0164`. diff --git a/src/test/ui/suggestions/issue-99240-2.stderr b/src/test/ui/suggestions/issue-99240-2.stderr index 2af60f597..260df8565 100644 --- a/src/test/ui/suggestions/issue-99240-2.stderr +++ b/src/test/ui/suggestions/issue-99240-2.stderr @@ -5,12 +5,12 @@ LL | Unit, | ---- enum variant `Alias::Unit` defined here ... LL | Alias:: - | _____^ - | |_____| + | ______^ + | | _____| | || LL | || Unit(); | ||________^_- call expression requires function - | |_________| + | |________| | | help: `Alias::Unit` is a unit enum variant, and does not take parentheses to be constructed diff --git a/src/test/ui/suggestions/missing-lifetime-specifier.stderr b/src/test/ui/suggestions/missing-lifetime-specifier.stderr index 10fb28c18..997bbb5e9 100644 --- a/src/test/ui/suggestions/missing-lifetime-specifier.stderr +++ b/src/test/ui/suggestions/missing-lifetime-specifier.stderr @@ -166,8 +166,8 @@ LL | pub union Qux<'t, 'k, I> { | ^^^ -- -- help: add missing lifetime argument | -LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'k, i32>>>>> = RefCell::new(HashMap::new()); - | ++++ +LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> = RefCell::new(HashMap::new()); + | +++++++++ error[E0107]: this union takes 2 lifetime arguments but 1 lifetime argument was supplied --> $DIR/missing-lifetime-specifier.rs:39:44 @@ -184,8 +184,8 @@ LL | pub union Qux<'t, 'k, I> { | ^^^ -- -- help: add missing lifetime argument | -LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'k, i32>>>>> = RefCell::new(HashMap::new()); - | ++++ +LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> = RefCell::new(HashMap::new()); + | +++++++++ error[E0107]: this union takes 2 lifetime arguments but 1 lifetime argument was supplied --> $DIR/missing-lifetime-specifier.rs:39:44 @@ -202,8 +202,8 @@ LL | pub union Qux<'t, 'k, I> { | ^^^ -- -- help: add missing lifetime argument | -LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'k, i32>>>>> = RefCell::new(HashMap::new()); - | ++++ +LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> = RefCell::new(HashMap::new()); + | +++++++++ error[E0107]: this union takes 2 lifetime arguments but 1 lifetime argument was supplied --> $DIR/missing-lifetime-specifier.rs:39:44 @@ -256,8 +256,8 @@ LL | trait Tar<'t, 'k, I> {} | ^^^ -- -- help: add missing lifetime argument | -LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'k, i32>>>>> = RefCell::new(HashMap::new()); - | ++++ +LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new()); + | +++++++++ error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied --> $DIR/missing-lifetime-specifier.rs:47:45 @@ -274,8 +274,8 @@ LL | trait Tar<'t, 'k, I> {} | ^^^ -- -- help: add missing lifetime argument | -LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'k, i32>>>>> = RefCell::new(HashMap::new()); - | ++++ +LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new()); + | +++++++++ error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied --> $DIR/missing-lifetime-specifier.rs:47:45 @@ -292,8 +292,8 @@ LL | trait Tar<'t, 'k, I> {} | ^^^ -- -- help: add missing lifetime argument | -LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'k, i32>>>>> = RefCell::new(HashMap::new()); - | ++++ +LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new()); + | +++++++++ error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied --> $DIR/missing-lifetime-specifier.rs:47:45 diff --git a/src/test/ui/suggestions/multibyte-escapes.rs b/src/test/ui/suggestions/multibyte-escapes.rs index fd5d46a4e..c41051862 100644 --- a/src/test/ui/suggestions/multibyte-escapes.rs +++ b/src/test/ui/suggestions/multibyte-escapes.rs @@ -2,17 +2,17 @@ fn main() { b'µ'; - //~^ ERROR: non-ASCII character in byte constant + //~^ ERROR: non-ASCII character in byte literal //~| HELP: if you meant to use the unicode code point for 'µ', use a \xHH escape - //~| NOTE: byte constant must be ASCII + //~| NOTE: must be ASCII b'字'; - //~^ ERROR: non-ASCII character in byte constant + //~^ ERROR: non-ASCII character in byte literal //~| NOTE: this multibyte character does not fit into a single byte - //~| NOTE: byte constant must be ASCII + //~| NOTE: must be ASCII b"字"; - //~^ ERROR: non-ASCII character in byte constant + //~^ ERROR: non-ASCII character in byte string literal //~| HELP: if you meant to use the UTF-8 encoding of '字', use \xHH escapes - //~| NOTE: byte constant must be ASCII + //~| NOTE: must be ASCII } diff --git a/src/test/ui/suggestions/multibyte-escapes.stderr b/src/test/ui/suggestions/multibyte-escapes.stderr index 6e26bc1f0..1e7c43e65 100644 --- a/src/test/ui/suggestions/multibyte-escapes.stderr +++ b/src/test/ui/suggestions/multibyte-escapes.stderr @@ -1,28 +1,28 @@ -error: non-ASCII character in byte constant +error: non-ASCII character in byte literal --> $DIR/multibyte-escapes.rs:4:7 | LL | b'µ'; - | ^ byte constant must be ASCII + | ^ must be ASCII | help: if you meant to use the unicode code point for 'µ', use a \xHH escape | LL | b'\xB5'; | ~~~~ -error: non-ASCII character in byte constant +error: non-ASCII character in byte literal --> $DIR/multibyte-escapes.rs:9:7 | LL | b'字'; | ^^ | | - | byte constant must be ASCII + | must be ASCII | this multibyte character does not fit into a single byte -error: non-ASCII character in byte constant +error: non-ASCII character in byte string literal --> $DIR/multibyte-escapes.rs:14:7 | LL | b"字"; - | ^^ byte constant must be ASCII + | ^^ must be ASCII | help: if you meant to use the UTF-8 encoding of '字', use \xHH escapes | diff --git a/src/test/ui/suggestions/option-to-bool.rs b/src/test/ui/suggestions/option-to-bool.rs new file mode 100644 index 000000000..2a1823b15 --- /dev/null +++ b/src/test/ui/suggestions/option-to-bool.rs @@ -0,0 +1,9 @@ +#![cfg_attr(let_chains, feature(let_chains))] + +fn foo(x: Option<i32>) { + if true && x {} + //~^ ERROR mismatched types + //~| HELP use `Option::is_some` to test if the `Option` has a value +} + +fn main() {} diff --git a/src/test/ui/suggestions/option-to-bool.stderr b/src/test/ui/suggestions/option-to-bool.stderr new file mode 100644 index 000000000..57a934b83 --- /dev/null +++ b/src/test/ui/suggestions/option-to-bool.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/option-to-bool.rs:4:16 + | +LL | if true && x {} + | ^ expected `bool`, found enum `Option` + | + = note: expected type `bool` + found enum `Option<i32>` +help: use `Option::is_some` to test if the `Option` has a value + | +LL | if true && x.is_some() {} + | ++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/suggestions/ref-pattern-binding.fixed b/src/test/ui/suggestions/ref-pattern-binding.fixed new file mode 100644 index 000000000..c36040eec --- /dev/null +++ b/src/test/ui/suggestions/ref-pattern-binding.fixed @@ -0,0 +1,19 @@ +// run-rustfix +#![allow(unused)] + +struct S { + f: String, +} + +fn main() { + let ref _moved @ ref _from = String::from("foo"); //~ ERROR + let ref _moved @ ref _from = String::from("foo"); //~ ERROR + let ref _moved @ ref _from = String::from("foo"); //~ ERROR + //~^ ERROR + let ref _moved @ ref _from = String::from("foo"); // ok + let ref _moved @ S { ref f } = S { f: String::from("foo") }; //~ ERROR + let ref _moved @ S { ref f } = S { f: String::from("foo") }; //~ ERROR + //~^ ERROR + let ref _moved @ S { ref f } = S { f: String::from("foo") }; // ok + let ref _moved @ S { ref f } = S { f: String::from("foo") }; //~ ERROR +} diff --git a/src/test/ui/suggestions/ref-pattern-binding.rs b/src/test/ui/suggestions/ref-pattern-binding.rs new file mode 100644 index 000000000..c0d4feb03 --- /dev/null +++ b/src/test/ui/suggestions/ref-pattern-binding.rs @@ -0,0 +1,19 @@ +// run-rustfix +#![allow(unused)] + +struct S { + f: String, +} + +fn main() { + let _moved @ _from = String::from("foo"); //~ ERROR + let _moved @ ref _from = String::from("foo"); //~ ERROR + let ref _moved @ _from = String::from("foo"); //~ ERROR + //~^ ERROR + let ref _moved @ ref _from = String::from("foo"); // ok + let _moved @ S { f } = S { f: String::from("foo") }; //~ ERROR + let ref _moved @ S { f } = S { f: String::from("foo") }; //~ ERROR + //~^ ERROR + let ref _moved @ S { ref f } = S { f: String::from("foo") }; // ok + let _moved @ S { ref f } = S { f: String::from("foo") }; //~ ERROR +} diff --git a/src/test/ui/suggestions/ref-pattern-binding.stderr b/src/test/ui/suggestions/ref-pattern-binding.stderr new file mode 100644 index 000000000..10447ba70 --- /dev/null +++ b/src/test/ui/suggestions/ref-pattern-binding.stderr @@ -0,0 +1,107 @@ +error: borrow of moved value + --> $DIR/ref-pattern-binding.rs:10:9 + | +LL | let _moved @ ref _from = String::from("foo"); + | ------^^^--------- + | | | + | | value borrowed here after move + | value moved into `_moved` here + | move occurs because `_moved` has type `String` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref _moved @ ref _from = String::from("foo"); + | +++ + +error: cannot move out of value because it is borrowed + --> $DIR/ref-pattern-binding.rs:11:9 + | +LL | let ref _moved @ _from = String::from("foo"); + | ----------^^^----- + | | | + | | value moved into `_from` here + | value borrowed, by `_moved`, here + +error: cannot move out of value because it is borrowed + --> $DIR/ref-pattern-binding.rs:15:9 + | +LL | let ref _moved @ S { f } = S { f: String::from("foo") }; + | ----------^^^^^^^-^^ + | | | + | | value moved into `f` here + | value borrowed, by `_moved`, here + +error: borrow of moved value + --> $DIR/ref-pattern-binding.rs:18:9 + | +LL | let _moved @ S { ref f } = S { f: String::from("foo") }; + | ------^^^^^^^-----^^ + | | | + | | value borrowed here after move + | value moved into `_moved` here + | move occurs because `_moved` has type `S` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref _moved @ S { ref f } = S { f: String::from("foo") }; + | +++ + +error[E0382]: use of moved value + --> $DIR/ref-pattern-binding.rs:9:9 + | +LL | let _moved @ _from = String::from("foo"); + | ^^^^^^ ----- ------------------- move occurs because value has type `String`, which does not implement the `Copy` trait + | | | + | | value moved here + | value used here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref _moved @ ref _from = String::from("foo"); + | +++ +++ + +error[E0382]: borrow of moved value + --> $DIR/ref-pattern-binding.rs:11:9 + | +LL | let ref _moved @ _from = String::from("foo"); + | ^^^^^^^^^^ ----- ------------------- move occurs because value has type `String`, which does not implement the `Copy` trait + | | | + | | value moved here + | value borrowed here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref _moved @ ref _from = String::from("foo"); + | +++ + +error[E0382]: use of partially moved value + --> $DIR/ref-pattern-binding.rs:14:9 + | +LL | let _moved @ S { f } = S { f: String::from("foo") }; + | ^^^^^^ - value partially moved here + | | + | value used here after partial move + | + = note: partial move occurs because value has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref _moved @ S { ref f } = S { f: String::from("foo") }; + | +++ +++ + +error[E0382]: borrow of partially moved value + --> $DIR/ref-pattern-binding.rs:15:9 + | +LL | let ref _moved @ S { f } = S { f: String::from("foo") }; + | ^^^^^^^^^^ - value partially moved here + | | + | value borrowed here after partial move + | + = note: partial move occurs because value has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref _moved @ S { ref f } = S { f: String::from("foo") }; + | +++ + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/suggestions/suggest-assoc-fn-call-deref.fixed b/src/test/ui/suggestions/suggest-assoc-fn-call-deref.fixed new file mode 100644 index 000000000..8d96cf590 --- /dev/null +++ b/src/test/ui/suggestions/suggest-assoc-fn-call-deref.fixed @@ -0,0 +1,15 @@ +// run-rustfix + +#![allow(unused)] + +struct Foo<T>(T); + +impl<T> Foo<T> { + fn test() -> i32 { 1 } +} + +fn main() { + let x = Box::new(Foo(1i32)); + Foo::<i32>::test(); + //~^ ERROR no method named `test` found for struct `Box<Foo<i32>>` in the current scope +} diff --git a/src/test/ui/suggestions/suggest-assoc-fn-call-deref.rs b/src/test/ui/suggestions/suggest-assoc-fn-call-deref.rs new file mode 100644 index 000000000..186901f75 --- /dev/null +++ b/src/test/ui/suggestions/suggest-assoc-fn-call-deref.rs @@ -0,0 +1,15 @@ +// run-rustfix + +#![allow(unused)] + +struct Foo<T>(T); + +impl<T> Foo<T> { + fn test() -> i32 { 1 } +} + +fn main() { + let x = Box::new(Foo(1i32)); + x.test(); + //~^ ERROR no method named `test` found for struct `Box<Foo<i32>>` in the current scope +} diff --git a/src/test/ui/suggestions/suggest-assoc-fn-call-deref.stderr b/src/test/ui/suggestions/suggest-assoc-fn-call-deref.stderr new file mode 100644 index 000000000..00fb96f03 --- /dev/null +++ b/src/test/ui/suggestions/suggest-assoc-fn-call-deref.stderr @@ -0,0 +1,19 @@ +error[E0599]: no method named `test` found for struct `Box<Foo<i32>>` in the current scope + --> $DIR/suggest-assoc-fn-call-deref.rs:13:7 + | +LL | x.test(); + | --^^^^-- + | | | + | | this is an associated function, not a method + | help: use associated function syntax instead: `Foo::<i32>::test()` + | + = note: found the following associated functions; to be used as methods, functions must have a `self` parameter +note: the candidate is defined in an impl for the type `Foo<T>` + --> $DIR/suggest-assoc-fn-call-deref.rs:8:5 + | +LL | fn test() -> i32 { 1 } + | ^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.rs b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.rs new file mode 100644 index 000000000..a39b8711d --- /dev/null +++ b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.rs @@ -0,0 +1,11 @@ +struct GenericAssocMethod<T>(T); + +impl<T> GenericAssocMethod<T> { + fn default_hello() {} +} + +fn main() { + let x = GenericAssocMethod(33); + x.default_hello(); + //~^ ERROR no method named `default_hello` found +} diff --git a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.stderr b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.stderr new file mode 100644 index 000000000..c247e73b3 --- /dev/null +++ b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.stderr @@ -0,0 +1,22 @@ +error[E0599]: no method named `default_hello` found for struct `GenericAssocMethod<{integer}>` in the current scope + --> $DIR/suggest-assoc-fn-call-with-turbofish-placeholder.rs:9:7 + | +LL | struct GenericAssocMethod<T>(T); + | ---------------------------- method `default_hello` not found for this struct +... +LL | x.default_hello(); + | --^^^^^^^^^^^^^-- + | | | + | | this is an associated function, not a method + | help: use associated function syntax instead: `GenericAssocMethod::<_>::default_hello()` + | + = note: found the following associated functions; to be used as methods, functions must have a `self` parameter +note: the candidate is defined in an impl for the type `GenericAssocMethod<T>` + --> $DIR/suggest-assoc-fn-call-with-turbofish-placeholder.rs:4:5 + | +LL | fn default_hello() {} + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-through-deref.stderr b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-through-deref.stderr index 996d57731..7c9f0b6c2 100644 --- a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-through-deref.stderr +++ b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-through-deref.stderr @@ -2,10 +2,10 @@ error[E0599]: no method named `hello` found for struct `RefMut<'_, HasAssocMetho --> $DIR/suggest-assoc-fn-call-with-turbofish-through-deref.rs:11:11 | LL | state.hello(); - | ------^^^^^ + | ------^^^^^-- | | | | | this is an associated function, not a method - | help: use associated function syntax instead: `HasAssocMethod::hello` + | help: use associated function syntax instead: `HasAssocMethod::hello()` | = note: found the following associated functions; to be used as methods, functions must have a `self` parameter note: the candidate is defined in an impl for the type `HasAssocMethod` diff --git a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.fixed b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.fixed new file mode 100644 index 000000000..02dd0715c --- /dev/null +++ b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.fixed @@ -0,0 +1,26 @@ +// run-rustfix + +struct GenericAssocMethod<T>(T); + +impl<T> GenericAssocMethod<T> { + fn default_hello() {} + fn self_ty_hello(_: Self) {} + fn self_ty_ref_hello(_: &Self) {} +} + +fn main() { + // Test for inferred types + let x = GenericAssocMethod(33); + GenericAssocMethod::<_>::self_ty_ref_hello(&x); + //~^ ERROR no method named `self_ty_ref_hello` found + GenericAssocMethod::<_>::self_ty_hello(x); + //~^ ERROR no method named `self_ty_hello` found + // Test for known types + let y = GenericAssocMethod(33i32); + GenericAssocMethod::<i32>::default_hello(); + //~^ ERROR no method named `default_hello` found + GenericAssocMethod::<i32>::self_ty_ref_hello(&y); + //~^ ERROR no method named `self_ty_ref_hello` found + GenericAssocMethod::<i32>::self_ty_hello(y); + //~^ ERROR no method named `self_ty_hello` found +} diff --git a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.rs b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.rs index 2a829db53..1d0ca8e78 100644 --- a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.rs +++ b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.rs @@ -1,11 +1,26 @@ +// run-rustfix + struct GenericAssocMethod<T>(T); impl<T> GenericAssocMethod<T> { fn default_hello() {} + fn self_ty_hello(_: Self) {} + fn self_ty_ref_hello(_: &Self) {} } fn main() { - let x = GenericAssocMethod(33i32); - x.default_hello(); + // Test for inferred types + let x = GenericAssocMethod(33); + x.self_ty_ref_hello(); + //~^ ERROR no method named `self_ty_ref_hello` found + x.self_ty_hello(); + //~^ ERROR no method named `self_ty_hello` found + // Test for known types + let y = GenericAssocMethod(33i32); + y.default_hello(); //~^ ERROR no method named `default_hello` found + y.self_ty_ref_hello(); + //~^ ERROR no method named `self_ty_ref_hello` found + y.self_ty_hello(); + //~^ ERROR no method named `self_ty_hello` found } diff --git a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.stderr b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.stderr index 3fb418b1c..92b03fc77 100644 --- a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.stderr +++ b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.stderr @@ -1,22 +1,98 @@ +error[E0599]: no method named `self_ty_ref_hello` found for struct `GenericAssocMethod<{integer}>` in the current scope + --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:14:7 + | +LL | struct GenericAssocMethod<T>(T); + | ---------------------------- method `self_ty_ref_hello` not found for this struct +... +LL | x.self_ty_ref_hello(); + | --^^^^^^^^^^^^^^^^^-- + | | | + | | this is an associated function, not a method + | help: use associated function syntax instead: `GenericAssocMethod::<_>::self_ty_ref_hello(&x)` + | + = note: found the following associated functions; to be used as methods, functions must have a `self` parameter +note: the candidate is defined in an impl for the type `GenericAssocMethod<T>` + --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:8:5 + | +LL | fn self_ty_ref_hello(_: &Self) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0599]: no method named `self_ty_hello` found for struct `GenericAssocMethod<{integer}>` in the current scope + --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:16:7 + | +LL | struct GenericAssocMethod<T>(T); + | ---------------------------- method `self_ty_hello` not found for this struct +... +LL | x.self_ty_hello(); + | --^^^^^^^^^^^^^-- + | | | + | | this is an associated function, not a method + | help: use associated function syntax instead: `GenericAssocMethod::<_>::self_ty_hello(x)` + | + = note: found the following associated functions; to be used as methods, functions must have a `self` parameter +note: the candidate is defined in an impl for the type `GenericAssocMethod<T>` + --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:7:5 + | +LL | fn self_ty_hello(_: Self) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0599]: no method named `default_hello` found for struct `GenericAssocMethod<i32>` in the current scope - --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:9:7 + --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:20:7 | LL | struct GenericAssocMethod<T>(T); | ---------------------------- method `default_hello` not found for this struct ... -LL | x.default_hello(); - | --^^^^^^^^^^^^^ +LL | y.default_hello(); + | --^^^^^^^^^^^^^-- | | | | | this is an associated function, not a method - | help: use associated function syntax instead: `GenericAssocMethod::<i32>::default_hello` + | help: use associated function syntax instead: `GenericAssocMethod::<i32>::default_hello()` | = note: found the following associated functions; to be used as methods, functions must have a `self` parameter note: the candidate is defined in an impl for the type `GenericAssocMethod<T>` - --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:4:5 + --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:6:5 | LL | fn default_hello() {} | ^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +error[E0599]: no method named `self_ty_ref_hello` found for struct `GenericAssocMethod<i32>` in the current scope + --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:22:7 + | +LL | struct GenericAssocMethod<T>(T); + | ---------------------------- method `self_ty_ref_hello` not found for this struct +... +LL | y.self_ty_ref_hello(); + | --^^^^^^^^^^^^^^^^^-- + | | | + | | this is an associated function, not a method + | help: use associated function syntax instead: `GenericAssocMethod::<i32>::self_ty_ref_hello(&y)` + | + = note: found the following associated functions; to be used as methods, functions must have a `self` parameter +note: the candidate is defined in an impl for the type `GenericAssocMethod<T>` + --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:8:5 + | +LL | fn self_ty_ref_hello(_: &Self) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0599]: no method named `self_ty_hello` found for struct `GenericAssocMethod<i32>` in the current scope + --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:24:7 + | +LL | struct GenericAssocMethod<T>(T); + | ---------------------------- method `self_ty_hello` not found for this struct +... +LL | y.self_ty_hello(); + | --^^^^^^^^^^^^^-- + | | | + | | this is an associated function, not a method + | help: use associated function syntax instead: `GenericAssocMethod::<i32>::self_ty_hello(y)` + | + = note: found the following associated functions; to be used as methods, functions must have a `self` parameter +note: the candidate is defined in an impl for the type `GenericAssocMethod<T>` + --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:7:5 + | +LL | fn self_ty_hello(_: Self) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/suggestions/suggest-remove-refs-3.stderr b/src/test/ui/suggestions/suggest-remove-refs-3.stderr index 4d0732427..31cca323d 100644 --- a/src/test/ui/suggestions/suggest-remove-refs-3.stderr +++ b/src/test/ui/suggestions/suggest-remove-refs-3.stderr @@ -2,8 +2,8 @@ error[E0277]: `&&&&&Enumerate<std::slice::Iter<'_, {integer}>>` is not an iterat --> $DIR/suggest-remove-refs-3.rs:6:19 | LL | for (i, _) in & & & - | ___________________^ - | |___________________| + | ____________________^ + | | ___________________| | || LL | || & &v | ||___________- help: consider removing 5 leading `&`-references diff --git a/src/test/ui/suggestions/suggest-tryinto-edition-change.rs b/src/test/ui/suggestions/suggest-tryinto-edition-change.rs index f03b42bbe..70c4b210d 100644 --- a/src/test/ui/suggestions/suggest-tryinto-edition-change.rs +++ b/src/test/ui/suggestions/suggest-tryinto-edition-change.rs @@ -10,18 +10,19 @@ fn test() { let _i: i16 = TryFrom::try_from(0_i32).unwrap(); //~^ ERROR failed to resolve: use of undeclared type - //~| NOTE not found in this scope + //~| NOTE use of undeclared type //~| NOTE 'std::convert::TryFrom' is included in the prelude starting in Edition 2021 //~| NOTE 'core::convert::TryFrom' is included in the prelude starting in Edition 2021 let _i: i16 = TryInto::try_into(0_i32).unwrap(); //~^ ERROR failed to resolve: use of undeclared type - //~| NOTE not found in this scope + //~| NOTE use of undeclared type //~| NOTE 'std::convert::TryInto' is included in the prelude starting in Edition 2021 //~| NOTE 'core::convert::TryInto' is included in the prelude starting in Edition 2021 let _v: Vec<_> = FromIterator::from_iter(&[1]); //~^ ERROR failed to resolve: use of undeclared type + //~| NOTE use of undeclared type //~| NOTE 'std::iter::FromIterator' is included in the prelude starting in Edition 2021 //~| NOTE 'core::iter::FromIterator' is included in the prelude starting in Edition 2021 } diff --git a/src/test/ui/suggestions/suggest-tryinto-edition-change.stderr b/src/test/ui/suggestions/suggest-tryinto-edition-change.stderr index 86f48716b..3d1f24923 100644 --- a/src/test/ui/suggestions/suggest-tryinto-edition-change.stderr +++ b/src/test/ui/suggestions/suggest-tryinto-edition-change.stderr @@ -2,7 +2,7 @@ error[E0433]: failed to resolve: use of undeclared type `TryFrom` --> $DIR/suggest-tryinto-edition-change.rs:11:19 | LL | let _i: i16 = TryFrom::try_from(0_i32).unwrap(); - | ^^^^^^^ not found in this scope + | ^^^^^^^ use of undeclared type `TryFrom` | = note: 'std::convert::TryFrom' is included in the prelude starting in Edition 2021 = note: 'core::convert::TryFrom' is included in the prelude starting in Edition 2021 @@ -17,7 +17,7 @@ error[E0433]: failed to resolve: use of undeclared type `TryInto` --> $DIR/suggest-tryinto-edition-change.rs:17:19 | LL | let _i: i16 = TryInto::try_into(0_i32).unwrap(); - | ^^^^^^^ not found in this scope + | ^^^^^^^ use of undeclared type `TryInto` | = note: 'std::convert::TryInto' is included in the prelude starting in Edition 2021 = note: 'core::convert::TryInto' is included in the prelude starting in Edition 2021 @@ -32,12 +32,7 @@ error[E0433]: failed to resolve: use of undeclared type `FromIterator` --> $DIR/suggest-tryinto-edition-change.rs:23:22 | LL | let _v: Vec<_> = FromIterator::from_iter(&[1]); - | ^^^^^^^^^^^^ - | - ::: $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL - | -LL | pub trait IntoIterator { - | ---------------------- similarly named trait `IntoIterator` defined here + | ^^^^^^^^^^^^ use of undeclared type `FromIterator` | = note: 'std::iter::FromIterator' is included in the prelude starting in Edition 2021 = note: 'core::iter::FromIterator' is included in the prelude starting in Edition 2021 diff --git a/src/test/ui/suggestions/suggest_print_over_printf.rs b/src/test/ui/suggestions/suggest_print_over_printf.rs new file mode 100644 index 000000000..124ddec50 --- /dev/null +++ b/src/test/ui/suggestions/suggest_print_over_printf.rs @@ -0,0 +1,8 @@ +// Suggest print macro when user erroneously uses printf + +fn main() { + let x = 4; + printf("%d", x); + //~^ ERROR cannot find function `printf` in this scope + //~| HELP you may have meant to use the `print` macro +} diff --git a/src/test/ui/suggestions/suggest_print_over_printf.stderr b/src/test/ui/suggestions/suggest_print_over_printf.stderr new file mode 100644 index 000000000..1214bec16 --- /dev/null +++ b/src/test/ui/suggestions/suggest_print_over_printf.stderr @@ -0,0 +1,14 @@ +error[E0425]: cannot find function `printf` in this scope + --> $DIR/suggest_print_over_printf.rs:5:5 + | +LL | printf("%d", x); + | ^^^^^^ not found in this scope + | +help: you may have meant to use the `print` macro + | +LL | print!("%d", x); + | ~~~~~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/suggestions/try-removing-the-field.rs b/src/test/ui/suggestions/try-removing-the-field.rs index 9d0573ca2..1b7289b22 100644 --- a/src/test/ui/suggestions/try-removing-the-field.rs +++ b/src/test/ui/suggestions/try-removing-the-field.rs @@ -14,4 +14,19 @@ fn use_foo(x: Foo) -> i32 { return foo; } +// issue #105028, suggest removing the field only for shorthand +fn use_match(x: Foo) { + match x { + Foo { foo: unused, .. } => { //~ WARNING unused variable + //~| help: if this is intentional, prefix it with an underscore + } + } + + match x { + Foo { foo, .. } => { //~ WARNING unused variable + //~| help: try removing the field + } + } +} + fn main() {} diff --git a/src/test/ui/suggestions/try-removing-the-field.stderr b/src/test/ui/suggestions/try-removing-the-field.stderr index 448a2c3d2..7a6013d4a 100644 --- a/src/test/ui/suggestions/try-removing-the-field.stderr +++ b/src/test/ui/suggestions/try-removing-the-field.stderr @@ -8,5 +8,19 @@ LL | let Foo { foo, bar, .. } = x; | = note: `#[warn(unused_variables)]` on by default -warning: 1 warning emitted +warning: unused variable: `unused` + --> $DIR/try-removing-the-field.rs:20:20 + | +LL | Foo { foo: unused, .. } => { + | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused` + +warning: unused variable: `foo` + --> $DIR/try-removing-the-field.rs:26:15 + | +LL | Foo { foo, .. } => { + | ^^^- + | | + | help: try removing the field + +warning: 3 warnings emitted diff --git a/src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.rs b/src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.rs new file mode 100644 index 000000000..c1a944562 --- /dev/null +++ b/src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.rs @@ -0,0 +1,6 @@ +fn main() { + let _: f64 = 0..10; //~ ERROR mismatched types + let _: f64 = 1..; //~ ERROR mismatched types + let _: f64 = ..10; //~ ERROR mismatched types + let _: f64 = std::ops::Range { start: 0, end: 1 }; //~ ERROR mismatched types +} diff --git a/src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.stderr b/src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.stderr new file mode 100644 index 000000000..773f1392a --- /dev/null +++ b/src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.stderr @@ -0,0 +1,59 @@ +error[E0308]: mismatched types + --> $DIR/unnecessary_dot_for_floating_point_literal.rs:2:18 + | +LL | let _: f64 = 0..10; + | --- ^^^^^ expected `f64`, found struct `std::ops::Range` + | | + | expected due to this + | + = note: expected type `f64` + found struct `std::ops::Range<{integer}>` +help: remove the unnecessary `.` operator for a floating point literal + | +LL | let _: f64 = 0.10; + | ~ + +error[E0308]: mismatched types + --> $DIR/unnecessary_dot_for_floating_point_literal.rs:3:18 + | +LL | let _: f64 = 1..; + | --- ^^^ expected `f64`, found struct `RangeFrom` + | | + | expected due to this + | + = note: expected type `f64` + found struct `RangeFrom<{integer}>` +help: remove the unnecessary `.` operator for a floating point literal + | +LL | let _: f64 = 1.; + | ~ + +error[E0308]: mismatched types + --> $DIR/unnecessary_dot_for_floating_point_literal.rs:4:18 + | +LL | let _: f64 = ..10; + | --- ^^^^ expected `f64`, found struct `RangeTo` + | | + | expected due to this + | + = note: expected type `f64` + found struct `RangeTo<{integer}>` +help: remove the unnecessary `.` operator and add an integer part for a floating point literal + | +LL | let _: f64 = 0.10; + | ~~ + +error[E0308]: mismatched types + --> $DIR/unnecessary_dot_for_floating_point_literal.rs:5:18 + | +LL | let _: f64 = std::ops::Range { start: 0, end: 1 }; + | --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `f64`, found struct `std::ops::Range` + | | + | expected due to this + | + = note: expected type `f64` + found struct `std::ops::Range<{integer}>` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/target-feature/invalid-attribute.stderr b/src/test/ui/target-feature/invalid-attribute.stderr index 889ced975..a2adfc67f 100644 --- a/src/test/ui/target-feature/invalid-attribute.stderr +++ b/src/test/ui/target-feature/invalid-attribute.stderr @@ -4,36 +4,6 @@ error: malformed `target_feature` attribute input LL | #[target_feature = "+sse2"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[target_feature(enable = "name")]` -error: the feature named `foo` is not valid for this target - --> $DIR/invalid-attribute.rs:19:18 - | -LL | #[target_feature(enable = "foo")] - | ^^^^^^^^^^^^^^ `foo` is not valid for this target - -error: malformed `target_feature` attribute input - --> $DIR/invalid-attribute.rs:22:18 - | -LL | #[target_feature(bar)] - | ^^^ help: must be of the form: `enable = ".."` - -error: malformed `target_feature` attribute input - --> $DIR/invalid-attribute.rs:24:18 - | -LL | #[target_feature(disable = "baz")] - | ^^^^^^^^^^^^^^^ help: must be of the form: `enable = ".."` - -error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions - --> $DIR/invalid-attribute.rs:28:1 - | -LL | #[target_feature(enable = "sse2")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -... -LL | fn bar() {} - | -------- not an `unsafe` function - | - = note: see issue #69098 <https://github.com/rust-lang/rust/issues/69098> for more information - = help: add `#![feature(target_feature_11)]` to the crate attributes to enable - error: attribute should be applied to a function definition --> $DIR/invalid-attribute.rs:34:1 | @@ -92,12 +62,6 @@ LL | LL | trait Baz {} | ------------ not a function definition -error: cannot use `#[inline(always)]` with `#[target_feature]` - --> $DIR/invalid-attribute.rs:67:1 - | -LL | #[inline(always)] - | ^^^^^^^^^^^^^^^^^ - error: attribute should be applied to a function definition --> $DIR/invalid-attribute.rs:85:5 | @@ -119,6 +83,42 @@ LL | LL | || {}; | ----- not a function definition +error: the feature named `foo` is not valid for this target + --> $DIR/invalid-attribute.rs:19:18 + | +LL | #[target_feature(enable = "foo")] + | ^^^^^^^^^^^^^^ `foo` is not valid for this target + +error: malformed `target_feature` attribute input + --> $DIR/invalid-attribute.rs:22:18 + | +LL | #[target_feature(bar)] + | ^^^ help: must be of the form: `enable = ".."` + +error: malformed `target_feature` attribute input + --> $DIR/invalid-attribute.rs:24:18 + | +LL | #[target_feature(disable = "baz")] + | ^^^^^^^^^^^^^^^ help: must be of the form: `enable = ".."` + +error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions + --> $DIR/invalid-attribute.rs:28:1 + | +LL | #[target_feature(enable = "sse2")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn bar() {} + | -------- not an `unsafe` function + | + = note: see issue #69098 <https://github.com/rust-lang/rust/issues/69098> for more information + = help: add `#![feature(target_feature_11)]` to the crate attributes to enable + +error: cannot use `#[inline(always)]` with `#[target_feature]` + --> $DIR/invalid-attribute.rs:67:1 + | +LL | #[inline(always)] + | ^^^^^^^^^^^^^^^^^ + error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions --> $DIR/invalid-attribute.rs:77:5 | diff --git a/src/test/ui/target-feature/tied-features-cli.one.stderr b/src/test/ui/target-feature/tied-features-cli.one.stderr index 0cc901eec..b4b50d981 100644 --- a/src/test/ui/target-feature/tied-features-cli.one.stderr +++ b/src/test/ui/target-feature/tied-features-cli.one.stderr @@ -1,4 +1,4 @@ -error: target features paca, pacg must all be enabled or disabled together +error: the target features paca, pacg must all be either enabled or disabled together error: aborting due to previous error diff --git a/src/test/ui/target-feature/tied-features-cli.three.stderr b/src/test/ui/target-feature/tied-features-cli.three.stderr index 0cc901eec..b4b50d981 100644 --- a/src/test/ui/target-feature/tied-features-cli.three.stderr +++ b/src/test/ui/target-feature/tied-features-cli.three.stderr @@ -1,4 +1,4 @@ -error: target features paca, pacg must all be enabled or disabled together +error: the target features paca, pacg must all be either enabled or disabled together error: aborting due to previous error diff --git a/src/test/ui/target-feature/tied-features-cli.two.stderr b/src/test/ui/target-feature/tied-features-cli.two.stderr index 0cc901eec..b4b50d981 100644 --- a/src/test/ui/target-feature/tied-features-cli.two.stderr +++ b/src/test/ui/target-feature/tied-features-cli.two.stderr @@ -1,4 +1,4 @@ -error: target features paca, pacg must all be enabled or disabled together +error: the target features paca, pacg must all be either enabled or disabled together error: aborting due to previous error diff --git a/src/test/ui/test-attrs/test-thread-capture.run.stdout b/src/test/ui/test-attrs/test-thread-capture.run.stdout index c712a78af..513c8cf2a 100644 --- a/src/test/ui/test-attrs/test-thread-capture.run.stdout +++ b/src/test/ui/test-attrs/test-thread-capture.run.stdout @@ -10,7 +10,7 @@ fee fie foe fum -thread 'main' panicked at 'explicit panic', $DIR/test-thread-capture.rs:32:5 +thread 'thready_fail' panicked at 'explicit panic', $DIR/test-thread-capture.rs:32:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/src/test/ui/test-attrs/test-thread-nocapture.run.stderr b/src/test/ui/test-attrs/test-thread-nocapture.run.stderr index 0a12a0528..8c905d1af 100644 --- a/src/test/ui/test-attrs/test-thread-nocapture.run.stderr +++ b/src/test/ui/test-attrs/test-thread-nocapture.run.stderr @@ -1,2 +1,2 @@ -thread 'main' panicked at 'explicit panic', $DIR/test-thread-nocapture.rs:32:5 +thread 'thready_fail' panicked at 'explicit panic', $DIR/test-thread-nocapture.rs:32:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/src/test/ui/threads-sendsync/mpsc_stress.rs b/src/test/ui/threads-sendsync/mpsc_stress.rs index a889542fe..c2e1912de 100644 --- a/src/test/ui/threads-sendsync/mpsc_stress.rs +++ b/src/test/ui/threads-sendsync/mpsc_stress.rs @@ -64,9 +64,11 @@ fn shared_close_sender_does_not_lose_messages_iter() { #[test] fn shared_close_sender_does_not_lose_messages() { - for _ in 0..10000 { - shared_close_sender_does_not_lose_messages_iter(); - } + with_minimum_timer_resolution(|| { + for _ in 0..10000 { + shared_close_sender_does_not_lose_messages_iter(); + } + }); } @@ -96,17 +98,11 @@ fn concurrent_recv_timeout_and_upgrade_iter() { #[test] fn concurrent_recv_timeout_and_upgrade() { - // FIXME: fix and enable - if true { return } - - // at the moment of writing this test fails like this: - // thread '<unnamed>' panicked at 'assertion failed: `(left == right)` - // left: `4561387584`, - // right: `0`', libstd/sync/mpsc/shared.rs:253:13 - - for _ in 0..10000 { - concurrent_recv_timeout_and_upgrade_iter(); - } + with_minimum_timer_resolution(|| { + for _ in 0..10000 { + concurrent_recv_timeout_and_upgrade_iter(); + } + }); } @@ -159,7 +155,46 @@ fn concurrent_writes_iter() { #[test] fn concurrent_writes() { - for _ in 0..100 { - concurrent_writes_iter(); + with_minimum_timer_resolution(|| { + for _ in 0..100 { + concurrent_writes_iter(); + } + }); +} + +#[cfg(windows)] +pub mod timeapi { + #![allow(non_snake_case)] + use std::ffi::c_uint; + + pub const TIMERR_NOERROR: c_uint = 0; + + #[link(name = "winmm")] + extern "system" { + pub fn timeBeginPeriod(uPeriod: c_uint) -> c_uint; + pub fn timeEndPeriod(uPeriod: c_uint) -> c_uint; + } +} + +/// Window's minimum sleep time can be as much as 16ms. +// This function evaluates the closure with this resolution +// set as low as possible. +/// +/// This takes the above test's duration from 10000*16/1000/60=2.67 minutes to ~16 seconds. +fn with_minimum_timer_resolution(f: impl Fn()) { + #[cfg(windows)] + unsafe { + let ret = timeapi::timeBeginPeriod(1); + assert_eq!(ret, timeapi::TIMERR_NOERROR); + + f(); + + let ret = timeapi::timeEndPeriod(1); + assert_eq!(ret, timeapi::TIMERR_NOERROR); + } + + #[cfg(not(windows))] + { + f(); } } diff --git a/src/test/ui/track-diagnostics/track.rs b/src/test/ui/track-diagnostics/track.rs new file mode 100644 index 000000000..61b9137ea --- /dev/null +++ b/src/test/ui/track-diagnostics/track.rs @@ -0,0 +1,11 @@ +// compile-flags: -Z track-diagnostics +// error-pattern: created at + +// Normalize the emitted location so this doesn't need +// updating everytime someone adds or removes a line. +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC" +// normalize-stderr-test "note: rustc .+ running on .+" -> "note: rustc $$VERSION running on $$TARGET" + +fn main() { + break rust +} diff --git a/src/test/ui/track-diagnostics/track.stderr b/src/test/ui/track-diagnostics/track.stderr new file mode 100644 index 000000000..8256c1f5f --- /dev/null +++ b/src/test/ui/track-diagnostics/track.stderr @@ -0,0 +1,26 @@ +error[E0425]: cannot find value `rust` in this scope + --> $DIR/track.rs:LL:CC + | +LL | break rust + | ^^^^ not found in this scope +-Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:LL:CC + +error[E0268]: `break` outside of a loop or labeled block + --> $DIR/track.rs:LL:CC + | +LL | break rust + | ^^^^^^^^^^ cannot `break` outside of a loop or labeled block +-Ztrack-diagnostics: created at compiler/rustc_passes/src/loops.rs:LL:CC + +error: internal compiler error: It looks like you're trying to break rust; would you like some ICE? + +note: the compiler expectedly panicked. this is a feature. + +note: we would appreciate a joke overview: https://github.com/rust-lang/rust/issues/43162#issuecomment-320764675 + +note: rustc $VERSION running on $TARGET + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0268, E0425. +For more information about an error, try `rustc --explain E0268`. diff --git a/src/test/ui/track-diagnostics/track2.rs b/src/test/ui/track-diagnostics/track2.rs new file mode 100644 index 000000000..dc105c61d --- /dev/null +++ b/src/test/ui/track-diagnostics/track2.rs @@ -0,0 +1,10 @@ +// compile-flags: -Z track-diagnostics +// error-pattern: created at + +// Normalize the emitted location so this doesn't need +// updating everytime someone adds or removes a line. +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC" + +fn main() { + let _moved @ _from = String::from("foo"); +} diff --git a/src/test/ui/track-diagnostics/track2.stderr b/src/test/ui/track-diagnostics/track2.stderr new file mode 100644 index 000000000..fe13e5ef3 --- /dev/null +++ b/src/test/ui/track-diagnostics/track2.stderr @@ -0,0 +1,18 @@ +error[E0382]: use of moved value + --> $DIR/track2.rs:LL:CC + | +LL | let _moved @ _from = String::from("foo"); + | ^^^^^^ ----- ------------------- move occurs because value has type `String`, which does not implement the `Copy` trait + | | | + | | value moved here + | value used here after move +-Ztrack-diagnostics: created at compiler/rustc_borrowck/src/borrowck_errors.rs:LL:CC + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref _moved @ ref _from = String::from("foo"); + | +++ +++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/track-diagnostics/track3.rs b/src/test/ui/track-diagnostics/track3.rs new file mode 100644 index 000000000..069923950 --- /dev/null +++ b/src/test/ui/track-diagnostics/track3.rs @@ -0,0 +1,10 @@ +// compile-flags: -Z track-diagnostics +// error-pattern: created at + +// Normalize the emitted location so this doesn't need +// updating everytime someone adds or removes a line. +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC" + +fn main() { + let _unimported = Blah { field: u8 }; +} diff --git a/src/test/ui/track-diagnostics/track3.stderr b/src/test/ui/track-diagnostics/track3.stderr new file mode 100644 index 000000000..dc468d7e8 --- /dev/null +++ b/src/test/ui/track-diagnostics/track3.stderr @@ -0,0 +1,18 @@ +error[E0422]: cannot find struct, variant or union type `Blah` in this scope + --> $DIR/track3.rs:LL:CC + | +LL | let _unimported = Blah { field: u8 }; + | ^^^^ not found in this scope +-Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:LL:CC + +error[E0423]: expected value, found builtin type `u8` + --> $DIR/track3.rs:LL:CC + | +LL | let _unimported = Blah { field: u8 }; + | ^^ not a value +-Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:LL:CC + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0422, E0423. +For more information about an error, try `rustc --explain E0422`. diff --git a/src/test/ui/track-diagnostics/track4.rs b/src/test/ui/track-diagnostics/track4.rs new file mode 100644 index 000000000..35eec799b --- /dev/null +++ b/src/test/ui/track-diagnostics/track4.rs @@ -0,0 +1,13 @@ +// compile-flags: -Z track-diagnostics +// error-pattern: created at + +// Normalize the emitted location so this doesn't need +// updating everytime someone adds or removes a line. +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC" + +pub onion { + Owo(u8), + Uwu(i8), +} + +fn main() {} diff --git a/src/test/ui/track-diagnostics/track4.stderr b/src/test/ui/track-diagnostics/track4.stderr new file mode 100644 index 000000000..c4668444c --- /dev/null +++ b/src/test/ui/track-diagnostics/track4.stderr @@ -0,0 +1,14 @@ +error: missing `struct` for struct definition + --> $DIR/track4.rs:LL:CC + | +LL | pub onion { + | ^ +-Ztrack-diagnostics: created at compiler/rustc_parse/src/parser/diagnostics.rs:LL:CC + | +help: add `struct` here to parse `onion` as a public struct + | +LL | pub struct onion { + | ++++++ + +error: aborting due to previous error + diff --git a/src/test/ui/track-diagnostics/track5.rs b/src/test/ui/track-diagnostics/track5.rs new file mode 100644 index 000000000..c41d9424e --- /dev/null +++ b/src/test/ui/track-diagnostics/track5.rs @@ -0,0 +1,8 @@ +// compile-flags: -Z track-diagnostics +// error-pattern: created at + +// Normalize the emitted location so this doesn't need +// updating everytime someone adds or removes a line. +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC" + +} diff --git a/src/test/ui/track-diagnostics/track5.stderr b/src/test/ui/track-diagnostics/track5.stderr new file mode 100644 index 000000000..aa54f92b6 --- /dev/null +++ b/src/test/ui/track-diagnostics/track5.stderr @@ -0,0 +1,9 @@ +error: unexpected closing delimiter: `}` + --> $DIR/track5.rs:LL:CC + | +LL | } + | ^ unexpected closing delimiter +-Ztrack-diagnostics: created at compiler/rustc_parse/src/lexer/tokentrees.rs:LL:CC + +error: aborting due to previous error + diff --git a/src/test/ui/track-diagnostics/track6.rs b/src/test/ui/track-diagnostics/track6.rs new file mode 100644 index 000000000..307e31018 --- /dev/null +++ b/src/test/ui/track-diagnostics/track6.rs @@ -0,0 +1,14 @@ +// compile-flags: -Z track-diagnostics +// error-pattern: created at + + + +pub trait Foo { + fn bar(); +} + +impl <T> Foo for T { + default fn bar() {} +} + +fn main() {} diff --git a/src/test/ui/track-diagnostics/track6.stderr b/src/test/ui/track-diagnostics/track6.stderr new file mode 100644 index 000000000..1c7537633 --- /dev/null +++ b/src/test/ui/track-diagnostics/track6.stderr @@ -0,0 +1,13 @@ +error[E0658]: specialization is unstable + --> $DIR/track6.rs:11:5 + | +LL | default fn bar() {} + | ^^^^^^^^^^^^^^^^^^^ +-Ztrack-diagnostics: created at $COMPILER_DIR/rustc_session/src/parse.rs:93:5 + | + = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information + = help: add `#![feature(specialization)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/trait-bounds/impl-bound-with-references-error.rs b/src/test/ui/trait-bounds/impl-bound-with-references-error.rs new file mode 100644 index 000000000..e5d0a1aae --- /dev/null +++ b/src/test/ui/trait-bounds/impl-bound-with-references-error.rs @@ -0,0 +1,20 @@ +// Regression test for #105138. +// This test ensures that the compiler does not add note +// for implementation of trait whose inner type is erroneous. + +pub enum LabelText { + Plain, +} + +impl<T> From<T> for LabelText +//~^ ERROR conflicting implementations of trait `From<LabelText>` for type `LabelText` [E0119] +where + T: Into<Cow<'static, str>>, + //~^ ERROR cannot find type `Cow` in this scope [E0412] +{ + fn from(text: T) -> Self { + LabelText::Plain(text.into()) + } +} + +fn main() {} diff --git a/src/test/ui/trait-bounds/impl-bound-with-references-error.stderr b/src/test/ui/trait-bounds/impl-bound-with-references-error.stderr new file mode 100644 index 000000000..95fd6bd50 --- /dev/null +++ b/src/test/ui/trait-bounds/impl-bound-with-references-error.stderr @@ -0,0 +1,24 @@ +error[E0412]: cannot find type `Cow` in this scope + --> $DIR/impl-bound-with-references-error.rs:12:13 + | +LL | T: Into<Cow<'static, str>>, + | ^^^ not found in this scope + | +help: consider importing this enum + | +LL | use std::borrow::Cow; + | + +error[E0119]: conflicting implementations of trait `From<LabelText>` for type `LabelText` + --> $DIR/impl-bound-with-references-error.rs:9:1 + | +LL | impl<T> From<T> for LabelText + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl<T> From<T> for T; + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0119, E0412. +For more information about an error, try `rustc --explain E0119`. diff --git a/src/test/ui/trait-bounds/impl-missing-where-clause-lifetimes-from-trait.rs b/src/test/ui/trait-bounds/impl-missing-where-clause-lifetimes-from-trait.rs new file mode 100644 index 000000000..dcdbd0228 --- /dev/null +++ b/src/test/ui/trait-bounds/impl-missing-where-clause-lifetimes-from-trait.rs @@ -0,0 +1,38 @@ +trait Trait<T> { + fn foo<'a, K>(self, _: T, _: K) where T: 'a, K: 'a; +} + +impl Trait<()> for () { + fn foo<'a, K>(self, _: (), _: K) where { //~ ERROR E0195 + todo!(); + } +} + +struct State; + +trait Foo<T> { + fn foo<'a>(&self, state: &'a State) -> &'a T + where + T: 'a; +} + +impl<F, T> Foo<T> for F +where + F: Fn(&State) -> &T, +{ + fn foo<'a>(&self, state: &'a State) -> &'a T { //~ ERROR E0195 + self(state) + } +} + +trait Bar { + fn foo<'a>(&'a self) {} +} + +impl Bar for () { + fn foo<'a: 'a>(&'a self) {} //~ ERROR E0195 +} + +fn main() { + ().foo((), ()); +} diff --git a/src/test/ui/trait-bounds/impl-missing-where-clause-lifetimes-from-trait.stderr b/src/test/ui/trait-bounds/impl-missing-where-clause-lifetimes-from-trait.stderr new file mode 100644 index 000000000..e26cb2216 --- /dev/null +++ b/src/test/ui/trait-bounds/impl-missing-where-clause-lifetimes-from-trait.stderr @@ -0,0 +1,36 @@ +error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration + --> $DIR/impl-missing-where-clause-lifetimes-from-trait.rs:6:11 + | +LL | fn foo<'a, K>(self, _: T, _: K) where T: 'a, K: 'a; + | ------- -- -- this bound might be missing in the impl + | | | + | | this bound might be missing in the impl + | lifetimes in impl do not match this method in trait +... +LL | fn foo<'a, K>(self, _: (), _: K) where { + | ^^^^^^^ lifetimes do not match method in trait + +error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration + --> $DIR/impl-missing-where-clause-lifetimes-from-trait.rs:23:11 + | +LL | fn foo<'a>(&self, state: &'a State) -> &'a T + | ---- lifetimes in impl do not match this method in trait +LL | where +LL | T: 'a; + | -- this bound might be missing in the impl +... +LL | fn foo<'a>(&self, state: &'a State) -> &'a T { + | ^^^^ lifetimes do not match method in trait + +error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration + --> $DIR/impl-missing-where-clause-lifetimes-from-trait.rs:33:11 + | +LL | fn foo<'a>(&'a self) {} + | ---- lifetimes in impl do not match this method in trait +... +LL | fn foo<'a: 'a>(&'a self) {} + | ^^^^^^^^ lifetimes do not match method in trait + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0195`. diff --git a/src/test/ui/traits/alias/issue-83613.rs b/src/test/ui/traits/alias/issue-83613.rs index 04320e720..2462e703a 100644 --- a/src/test/ui/traits/alias/issue-83613.rs +++ b/src/test/ui/traits/alias/issue-83613.rs @@ -9,5 +9,4 @@ trait AnotherTrait {} impl<T: Send> AnotherTrait for T {} impl AnotherTrait for OpaqueType {} //~^ ERROR conflicting implementations of trait `AnotherTrait` for type `OpaqueType` -//~| ERROR cannot implement trait on type alias impl trait fn main() {} diff --git a/src/test/ui/traits/alias/issue-83613.stderr b/src/test/ui/traits/alias/issue-83613.stderr index b9d931601..a78294da6 100644 --- a/src/test/ui/traits/alias/issue-83613.stderr +++ b/src/test/ui/traits/alias/issue-83613.stderr @@ -6,18 +6,6 @@ LL | impl<T: Send> AnotherTrait for T {} LL | impl AnotherTrait for OpaqueType {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `OpaqueType` -error: cannot implement trait on type alias impl trait - --> $DIR/issue-83613.rs:10:23 - | -LL | impl AnotherTrait for OpaqueType {} - | ^^^^^^^^^^ - | -note: type alias impl trait defined here - --> $DIR/issue-83613.rs:4:19 - | -LL | type OpaqueType = impl OpaqueTrait; - | ^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/traits/invalid_operator_trait.rs b/src/test/ui/traits/invalid_operator_trait.rs new file mode 100644 index 000000000..7ea3b0d5b --- /dev/null +++ b/src/test/ui/traits/invalid_operator_trait.rs @@ -0,0 +1,23 @@ +#![crate_type = "lib"] +#![feature(lang_items)] +#![feature(no_core)] +#![no_core] + +#[lang="sized"] +pub trait Sized { + // Empty. +} + +#[lang = "add"] +trait Add<RHS=Self> { + type Output; + + fn add<Y>(self, _: RHS) -> Self::Output; + //~^ ERROR `add` must not have any generic parameters +} + +#[allow(unreachable_code)] +fn ice(a: usize) { + let r = loop {}; + r = r + a; +} diff --git a/src/test/ui/traits/invalid_operator_trait.stderr b/src/test/ui/traits/invalid_operator_trait.stderr new file mode 100644 index 000000000..8c6e36959 --- /dev/null +++ b/src/test/ui/traits/invalid_operator_trait.stderr @@ -0,0 +1,8 @@ +error: `add` must not have any generic parameters + --> $DIR/invalid_operator_trait.rs:15:5 + | +LL | fn add<Y>(self, _: RHS) -> Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/traits/issue-102989.rs b/src/test/ui/traits/issue-102989.rs index 62f95272f..216cd78e5 100644 --- a/src/test/ui/traits/issue-102989.rs +++ b/src/test/ui/traits/issue-102989.rs @@ -7,10 +7,8 @@ trait Sized { } //~ ERROR found duplicate lang item `sized` fn ref_Struct(self: &Struct, f: &u32) -> &u32 { //~^ ERROR `self` parameter is only allowed in associated functions //~| ERROR cannot find type `Struct` in this scope - //~| ERROR mismatched types let x = x << 1; - //~^ ERROR the size for values of type `{integer}` cannot be known at compilation time - //~| ERROR cannot find value `x` in this scope + //~^ ERROR cannot find value `x` in this scope } fn main() {} diff --git a/src/test/ui/traits/issue-102989.stderr b/src/test/ui/traits/issue-102989.stderr index efe1a2467..7d0098fe8 100644 --- a/src/test/ui/traits/issue-102989.stderr +++ b/src/test/ui/traits/issue-102989.stderr @@ -13,7 +13,7 @@ LL | fn ref_Struct(self: &Struct, f: &u32) -> &u32 { | ^^^^^^ not found in this scope error[E0425]: cannot find value `x` in this scope - --> $DIR/issue-102989.rs:11:13 + --> $DIR/issue-102989.rs:10:13 | LL | let x = x << 1; | ^ help: a local variable with a similar name exists: `f` @@ -28,32 +28,7 @@ LL | trait Sized { } = note: first definition in `core` loaded from SYSROOT/libcore-*.rlib = note: second definition in the local crate (`issue_102989`) -error[E0277]: the size for values of type `{integer}` cannot be known at compilation time - --> $DIR/issue-102989.rs:11:15 - | -LL | let x = x << 1; - | ^^ doesn't have a size known at compile-time - | - = help: the trait `std::marker::Sized` is not implemented for `{integer}` - -error[E0308]: mismatched types - --> $DIR/issue-102989.rs:7:42 - | -LL | fn ref_Struct(self: &Struct, f: &u32) -> &u32 { - | ---------- ^^^^ expected `&u32`, found `()` - | | - | implicitly returns `()` as its body has no tail or `return` expression - | -note: consider returning one of these bindings - --> $DIR/issue-102989.rs:7:30 - | -LL | fn ref_Struct(self: &Struct, f: &u32) -> &u32 { - | ^ -... -LL | let x = x << 1; - | ^ - -error: aborting due to 6 previous errors +error: aborting due to 4 previous errors -Some errors have detailed explanations: E0152, E0277, E0308, E0412, E0425. +Some errors have detailed explanations: E0152, E0412, E0425. For more information about an error, try `rustc --explain E0152`. diff --git a/src/test/ui/traits/issue-104322.rs b/src/test/ui/traits/issue-104322.rs new file mode 100644 index 000000000..dcc27f1f0 --- /dev/null +++ b/src/test/ui/traits/issue-104322.rs @@ -0,0 +1,80 @@ +// build-pass +// +// Tests that overflows do not occur in certain situations +// related to generic diesel code + +use mini_diesel::*; + +pub trait HandleDelete<K> {} + +pub fn handle_delete<D, R>() +where + R: HasTable, + R::Table: HandleDelete<D> + 'static, +{ +} + +impl<K, T> HandleDelete<K> for T +where + T: Table + HasTable<Table = T> + 'static, + K: 'static, + &'static K: Identifiable<Table = T>, + T::PrimaryKey: EqAll<<&'static K as Identifiable>::Id>, + T::Query: FilterDsl<<T::PrimaryKey as EqAll<<&'static K as Identifiable>::Id>>::Output>, + Filter<T::Query, <T::PrimaryKey as EqAll<<&'static K as Identifiable>::Id>>::Output>: + IntoUpdateTarget<Table = T>, +{ +} + +mod mini_diesel { + pub trait HasTable { + type Table: Table; + } + + pub trait Identifiable: HasTable { + type Id; + } + + pub trait EqAll<Rhs> { + type Output; + } + + pub trait IntoUpdateTarget: HasTable { + type WhereClause; + } + + pub trait Query { + type SqlType; + } + + pub trait AsQuery { + type Query: Query; + } + impl<T: Query> AsQuery for T { + type Query = Self; + } + + pub trait FilterDsl<Predicate> { + type Output; + } + + impl<T, Predicate> FilterDsl<Predicate> for T + where + T: Table, + T::Query: FilterDsl<Predicate>, + { + type Output = Filter<T::Query, Predicate>; + } + + pub trait QuerySource { + type FromClause; + } + + pub trait Table: QuerySource + AsQuery + Sized { + type PrimaryKey; + } + + pub type Filter<Source, Predicate> = <Source as FilterDsl<Predicate>>::Output; +} + +fn main() {} diff --git a/src/test/ui/traits/issue-33140-hack-boundaries.stderr b/src/test/ui/traits/issue-33140-hack-boundaries.stderr index 58286648d..80a502c63 100644 --- a/src/test/ui/traits/issue-33140-hack-boundaries.stderr +++ b/src/test/ui/traits/issue-33140-hack-boundaries.stderr @@ -1,12 +1,12 @@ -error[E0119]: conflicting implementations of trait `Trait1` for type `(dyn std::marker::Send + 'static)` +error[E0119]: conflicting implementations of trait `Trait1` for type `(dyn Send + 'static)` --> $DIR/issue-33140-hack-boundaries.rs:18:1 | LL | impl Trait1 for dyn Send {} | ------------------------ first implementation here LL | impl Trait1 for dyn Send {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + 'static)` + | ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Send + 'static)` -error[E0751]: found both positive and negative implementation of trait `Trait2` for type `(dyn std::marker::Send + 'static)`: +error[E0751]: found both positive and negative implementation of trait `Trait2` for type `(dyn Send + 'static)`: --> $DIR/issue-33140-hack-boundaries.rs:25:1 | LL | impl Trait2 for dyn Send {} @@ -14,21 +14,21 @@ LL | impl Trait2 for dyn Send {} LL | impl !Trait2 for dyn Send {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ negative implementation here -error[E0119]: conflicting implementations of trait `Trait3<(dyn std::marker::Sync + 'static)>` for type `(dyn std::marker::Send + 'static)` +error[E0119]: conflicting implementations of trait `Trait3<(dyn Sync + 'static)>` for type `(dyn Send + 'static)` --> $DIR/issue-33140-hack-boundaries.rs:32:1 | LL | impl Trait3<dyn Sync> for dyn Send {} | ---------------------------------- first implementation here LL | impl Trait3<dyn Sync> for dyn Send {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + 'static)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Send + 'static)` -error[E0119]: conflicting implementations of trait `Trait4a` for type `(dyn std::marker::Send + 'static)` +error[E0119]: conflicting implementations of trait `Trait4a` for type `(dyn Send + 'static)` --> $DIR/issue-33140-hack-boundaries.rs:39:1 | LL | impl<T: ?Sized> Trait4a for T {} | ----------------------------- first implementation here LL | impl Trait4a for dyn Send {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + 'static)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Send + 'static)` error[E0119]: conflicting implementations of trait `Trait4b` for type `()` --> $DIR/issue-33140-hack-boundaries.rs:46:1 @@ -38,42 +38,42 @@ LL | impl Trait4b for () {} LL | impl Trait4b for () {} | ^^^^^^^^^^^^^^^^^^^ conflicting implementation for `()` -error[E0119]: conflicting implementations of trait `Trait4c` for type `(dyn Trait1 + std::marker::Send + 'static)` +error[E0119]: conflicting implementations of trait `Trait4c` for type `(dyn Trait1 + Send + 'static)` --> $DIR/issue-33140-hack-boundaries.rs:53:1 | LL | impl Trait4c for dyn Trait1 + Send {} | ---------------------------------- first implementation here LL | impl Trait4c for dyn Trait1 + Send {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Trait1 + std::marker::Send + 'static)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Trait1 + Send + 'static)` -error[E0119]: conflicting implementations of trait `Trait4d` for type `dyn std::marker::Send` +error[E0119]: conflicting implementations of trait `Trait4d` for type `dyn Send` --> $DIR/issue-33140-hack-boundaries.rs:60:1 | LL | impl<'a> Trait4d for dyn Send + 'a {} | ---------------------------------- first implementation here LL | impl<'a> Trait4d for dyn Send + 'a {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `dyn std::marker::Send` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `dyn Send` -error[E0119]: conflicting implementations of trait `Trait5` for type `(dyn std::marker::Send + 'static)` +error[E0119]: conflicting implementations of trait `Trait5` for type `(dyn Send + 'static)` --> $DIR/issue-33140-hack-boundaries.rs:67:1 | LL | impl Trait5 for dyn Send {} | ------------------------ first implementation here LL | impl Trait5 for dyn Send where u32: Copy {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + 'static)` + | ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Send + 'static)` error: aborting due to 8 previous errors Some errors have detailed explanations: E0119, E0751. For more information about an error, try `rustc --explain E0119`. Future incompatibility report: Future breakage diagnostic: -warning: conflicting implementations of trait `Trait0` for type `(dyn std::marker::Send + 'static)`: (E0119) +warning: conflicting implementations of trait `Trait0` for type `(dyn Send + 'static)`: (E0119) --> $DIR/issue-33140-hack-boundaries.rs:10:1 | LL | impl Trait0 for dyn Send {} | ------------------------ first implementation here LL | impl Trait0 for dyn Send {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + 'static)` + | ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Send + 'static)` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> diff --git a/src/test/ui/traits/issue-33140.stderr b/src/test/ui/traits/issue-33140.stderr index 392c56a28..d31281f72 100644 --- a/src/test/ui/traits/issue-33140.stderr +++ b/src/test/ui/traits/issue-33140.stderr @@ -1,20 +1,20 @@ -error[E0119]: conflicting implementations of trait `Trait` for type `(dyn std::marker::Send + std::marker::Sync + 'static)` +error[E0119]: conflicting implementations of trait `Trait` for type `(dyn Send + Sync + 'static)` --> $DIR/issue-33140.rs:9:1 | LL | impl Trait for dyn Send + Sync { | ------------------------------ first implementation here ... LL | impl Trait for dyn Sync + Send { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Send + Sync + 'static)` -error[E0119]: conflicting implementations of trait `Trait2` for type `(dyn std::marker::Send + std::marker::Sync + 'static)` +error[E0119]: conflicting implementations of trait `Trait2` for type `(dyn Send + Sync + 'static)` --> $DIR/issue-33140.rs:22:1 | LL | impl Trait2 for dyn Send + Sync { | ------------------------------- first implementation here ... LL | impl Trait2 for dyn Sync + Send + Sync { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Send + Sync + 'static)` error[E0592]: duplicate definitions with name `abc` --> $DIR/issue-33140.rs:29:5 diff --git a/src/test/ui/issues/issue-7013.rs b/src/test/ui/traits/issue-7013.rs index 1fb01303c..1fb01303c 100644 --- a/src/test/ui/issues/issue-7013.rs +++ b/src/test/ui/traits/issue-7013.rs diff --git a/src/test/ui/issues/issue-7013.stderr b/src/test/ui/traits/issue-7013.stderr index 4575f4dba..4575f4dba 100644 --- a/src/test/ui/issues/issue-7013.stderr +++ b/src/test/ui/traits/issue-7013.stderr diff --git a/src/test/ui/traits/issue-77982.stderr b/src/test/ui/traits/issue-77982.stderr index e210f11b3..b6a045855 100644 --- a/src/test/ui/traits/issue-77982.stderr +++ b/src/test/ui/traits/issue-77982.stderr @@ -46,12 +46,7 @@ LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect( | | | required by a bound introduced by this call | - = note: multiple `impl`s satisfying `u32: From<_>` found in the following crates: `core`, `std`: - - impl From<Ipv4Addr> for u32; - - impl From<NonZeroU32> for u32; - - impl From<bool> for u32; - - impl From<char> for u32; - and 3 more + = note: cannot satisfy `u32: From<_>` help: try using a fully qualified path to specify the expected types | LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(<u32 as Into<T>>::into(0u32))).collect(); diff --git a/src/test/ui/traits/issue-79458.stderr b/src/test/ui/traits/issue-79458.stderr index cf2e4edf9..08f7bbbf0 100644 --- a/src/test/ui/traits/issue-79458.stderr +++ b/src/test/ui/traits/issue-79458.stderr @@ -7,10 +7,7 @@ LL | struct Foo<'a, T> { LL | bar: &'a mut T | ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `&mut T` | - = help: the following other types implement trait `Clone`: - &T - *const T - *mut T + = help: the trait `Clone` is implemented for `&T` = note: `Clone` is implemented for `&T`, but not for `&mut T` = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/traits/issue-82830.rs b/src/test/ui/traits/issue-82830.rs index c8289b2e3..37bae2e90 100644 --- a/src/test/ui/traits/issue-82830.rs +++ b/src/test/ui/traits/issue-82830.rs @@ -1,10 +1,12 @@ +// check-pass + trait A<Y, N> { type B; } type MaybeBox<T> = <T as A<T, Box<T>>>::B; struct P { - t: MaybeBox<P>, //~ ERROR: overflow evaluating the requirement `P: Sized` + t: MaybeBox<P>, } impl<Y, N> A<Y, N> for P { diff --git a/src/test/ui/traits/issue-82830.stderr b/src/test/ui/traits/issue-82830.stderr deleted file mode 100644 index 6a597a402..000000000 --- a/src/test/ui/traits/issue-82830.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0275]: overflow evaluating the requirement `P: Sized` - --> $DIR/issue-82830.rs:7:8 - | -LL | t: MaybeBox<P>, - | ^^^^^^^^^^^ - | -note: required for `P` to implement `A<P, Box<P>>` - --> $DIR/issue-82830.rs:10:12 - | -LL | impl<Y, N> A<Y, N> for P { - | ^^^^^^^ ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/traits/issue-91949-hangs-on-recursion.rs b/src/test/ui/traits/issue-91949-hangs-on-recursion.rs index 499a64f28..6474b2b38 100644 --- a/src/test/ui/traits/issue-91949-hangs-on-recursion.rs +++ b/src/test/ui/traits/issue-91949-hangs-on-recursion.rs @@ -2,6 +2,7 @@ // compile-flags: -Zinline-mir=no // error-pattern: overflow evaluating the requirement `(): Sized` // error-pattern: function cannot return without recursing +// normalize-stderr-test: "long-type-\d+" -> "long-type-hash" // Regression test for #91949. // This hanged *forever* on 1.56, fixed by #90423. diff --git a/src/test/ui/traits/issue-91949-hangs-on-recursion.stderr b/src/test/ui/traits/issue-91949-hangs-on-recursion.stderr index 61b6d4b08..1f18c5daf 100644 --- a/src/test/ui/traits/issue-91949-hangs-on-recursion.stderr +++ b/src/test/ui/traits/issue-91949-hangs-on-recursion.stderr @@ -1,5 +1,5 @@ warning: function cannot return without recursing - --> $DIR/issue-91949-hangs-on-recursion.rs:22:1 + --> $DIR/issue-91949-hangs-on-recursion.rs:23:1 | LL | / fn recurse<T>(elements: T) -> Vec<char> LL | | where @@ -17,7 +17,8 @@ error[E0275]: overflow evaluating the requirement `(): Sized` = help: consider increasing the recursion limit by adding a `#![recursion_limit = "512"]` attribute to your crate (`issue_91949_hangs_on_recursion`) = note: required for `std::iter::Empty<()>` to implement `Iterator` = note: 171 redundant requirements hidden - = note: required for `IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), std::iter::Empty<()>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>` to implement `Iterator` + = note: required for `IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<..., ...>>, ...>>, ...>>` to implement `Iterator` + = note: the full type name has been written to '$TEST_BUILD_DIR/traits/issue-91949-hangs-on-recursion/issue-91949-hangs-on-recursion.long-type-hash.txt' error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/traits/item-privacy.stderr b/src/test/ui/traits/item-privacy.stderr index 7f78b37ba..f137a298a 100644 --- a/src/test/ui/traits/item-privacy.stderr +++ b/src/test/ui/traits/item-privacy.stderr @@ -162,9 +162,12 @@ error[E0223]: ambiguous associated type LL | let _: S::C; | ^^^^ help: use fully-qualified syntax: `<S as Trait>::C` -error: associated type `A` is private +error[E0624]: associated type `A` is private --> $DIR/item-privacy.rs:119:12 | +LL | type A = u8; + | ------ associated type defined here +... LL | let _: T::A; | ^^^^ private associated type diff --git a/src/test/ui/traits/negative-impls/eager-mono.rs b/src/test/ui/traits/negative-impls/eager-mono.rs new file mode 100644 index 000000000..ce770376c --- /dev/null +++ b/src/test/ui/traits/negative-impls/eager-mono.rs @@ -0,0 +1,12 @@ +// build-pass +// compile-flags:-C link-dead-code=y + +#![feature(negative_impls)] + +trait Foo { + fn foo() {} +} + +impl !Foo for () {} + +fn main() {} diff --git a/src/test/ui/traits/negative-impls/pin-unsound-issue-66544-clone.stderr b/src/test/ui/traits/negative-impls/pin-unsound-issue-66544-clone.stderr index d7039e3db..a87acb1fb 100644 --- a/src/test/ui/traits/negative-impls/pin-unsound-issue-66544-clone.stderr +++ b/src/test/ui/traits/negative-impls/pin-unsound-issue-66544-clone.stderr @@ -1,4 +1,4 @@ -error[E0751]: found both positive and negative implementation of trait `std::clone::Clone` for type `&mut MyType<'_>`: +error[E0751]: found both positive and negative implementation of trait `Clone` for type `&mut MyType<'_>`: --> $DIR/pin-unsound-issue-66544-clone.rs:7:1 | LL | impl<'a> Clone for &'a mut MyType<'a> { diff --git a/src/test/ui/traits/negative-impls/pin-unsound-issue-66544-derefmut.stderr b/src/test/ui/traits/negative-impls/pin-unsound-issue-66544-derefmut.stderr index a0b62a8ba..9185e8f84 100644 --- a/src/test/ui/traits/negative-impls/pin-unsound-issue-66544-derefmut.stderr +++ b/src/test/ui/traits/negative-impls/pin-unsound-issue-66544-derefmut.stderr @@ -1,4 +1,4 @@ -error[E0751]: found both positive and negative implementation of trait `std::ops::DerefMut` for type `&MyType<'_>`: +error[E0751]: found both positive and negative implementation of trait `DerefMut` for type `&MyType<'_>`: --> $DIR/pin-unsound-issue-66544-derefmut.rs:12:1 | LL | impl<'a> DerefMut for &'a MyType<'a> { diff --git a/src/test/ui/traits/object/issue-33140-traitobject-crate.stderr b/src/test/ui/traits/object/issue-33140-traitobject-crate.stderr index 0af4df2ae..525401f9d 100644 --- a/src/test/ui/traits/object/issue-33140-traitobject-crate.stderr +++ b/src/test/ui/traits/object/issue-33140-traitobject-crate.stderr @@ -1,10 +1,10 @@ -warning: conflicting implementations of trait `Trait` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) +warning: conflicting implementations of trait `Trait` for type `(dyn Send + Sync + 'static)`: (E0119) --> $DIR/issue-33140-traitobject-crate.rs:86:1 | LL | unsafe impl Trait for dyn (::std::marker::Send) + Sync { } | ------------------------------------------------------ first implementation here LL | unsafe impl Trait for dyn (::std::marker::Send) + Send + Sync { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Send + Sync + 'static)` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> @@ -14,26 +14,26 @@ note: the lint level is defined here LL | #![warn(order_dependent_trait_objects)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: conflicting implementations of trait `Trait` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) +warning: conflicting implementations of trait `Trait` for type `(dyn Send + Sync + 'static)`: (E0119) --> $DIR/issue-33140-traitobject-crate.rs:89:1 | LL | unsafe impl Trait for dyn (::std::marker::Send) + Send + Sync { } | ------------------------------------------------------------- first implementation here ... LL | unsafe impl Trait for dyn (::std::marker::Sync) + Send { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Send + Sync + 'static)` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> -warning: conflicting implementations of trait `Trait` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) +warning: conflicting implementations of trait `Trait` for type `(dyn Send + Sync + 'static)`: (E0119) --> $DIR/issue-33140-traitobject-crate.rs:93:1 | LL | unsafe impl Trait for dyn (::std::marker::Sync) + Send { } | ------------------------------------------------------ first implementation here ... LL | unsafe impl Trait for dyn (::std::marker::Sync) + Send + Sync { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Send + Sync + 'static)` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> @@ -41,13 +41,13 @@ LL | unsafe impl Trait for dyn (::std::marker::Sync) + Send + Sync { } warning: 3 warnings emitted Future incompatibility report: Future breakage diagnostic: -warning: conflicting implementations of trait `Trait` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) +warning: conflicting implementations of trait `Trait` for type `(dyn Send + Sync + 'static)`: (E0119) --> $DIR/issue-33140-traitobject-crate.rs:86:1 | LL | unsafe impl Trait for dyn (::std::marker::Send) + Sync { } | ------------------------------------------------------ first implementation here LL | unsafe impl Trait for dyn (::std::marker::Send) + Send + Sync { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Send + Sync + 'static)` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> @@ -58,14 +58,14 @@ LL | #![warn(order_dependent_trait_objects)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -warning: conflicting implementations of trait `Trait` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) +warning: conflicting implementations of trait `Trait` for type `(dyn Send + Sync + 'static)`: (E0119) --> $DIR/issue-33140-traitobject-crate.rs:89:1 | LL | unsafe impl Trait for dyn (::std::marker::Send) + Send + Sync { } | ------------------------------------------------------------- first implementation here ... LL | unsafe impl Trait for dyn (::std::marker::Sync) + Send { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Send + Sync + 'static)` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> @@ -76,14 +76,14 @@ LL | #![warn(order_dependent_trait_objects)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -warning: conflicting implementations of trait `Trait` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) +warning: conflicting implementations of trait `Trait` for type `(dyn Send + Sync + 'static)`: (E0119) --> $DIR/issue-33140-traitobject-crate.rs:93:1 | LL | unsafe impl Trait for dyn (::std::marker::Sync) + Send { } | ------------------------------------------------------ first implementation here ... LL | unsafe impl Trait for dyn (::std::marker::Sync) + Send + Sync { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Send + Sync + 'static)` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> diff --git a/src/test/ui/traits/overlap-not-permitted-for-builtin-trait.stderr b/src/test/ui/traits/overlap-not-permitted-for-builtin-trait.stderr index 910c5e29d..e24ed695d 100644 --- a/src/test/ui/traits/overlap-not-permitted-for-builtin-trait.stderr +++ b/src/test/ui/traits/overlap-not-permitted-for-builtin-trait.stderr @@ -1,4 +1,4 @@ -error[E0119]: conflicting implementations of trait `std::marker::Send` for type `MyStruct` +error[E0119]: conflicting implementations of trait `Send` for type `MyStruct` --> $DIR/overlap-not-permitted-for-builtin-trait.rs:7:1 | LL | impl !Send for MyStruct {} diff --git a/src/test/ui/traits/suggest-fully-qualified-closure.rs b/src/test/ui/traits/suggest-fully-qualified-closure.rs new file mode 100644 index 000000000..c077921c0 --- /dev/null +++ b/src/test/ui/traits/suggest-fully-qualified-closure.rs @@ -0,0 +1,24 @@ +// check-fail +// known-bug: #103705 +// normalize-stderr-test "\[closure@.*\]" -> "[closure@]" +// normalize-stderr-test "\+* ~" -> "+++ ~" + +// The output of this currently suggests writing a closure in the qualified path. + +trait MyTrait<T> { + fn lol<F:FnOnce()>(&self, f:F) -> u16; +} + +struct Qqq; + +impl MyTrait<u32> for Qqq{ + fn lol<F:FnOnce()>(&self, _f:F) -> u16 { 5 } +} +impl MyTrait<u64> for Qqq{ + fn lol<F:FnOnce()>(&self, _f:F) -> u16 { 6 } +} + +fn main() { + let q = Qqq; + q.lol(||()); +} diff --git a/src/test/ui/traits/suggest-fully-qualified-closure.stderr b/src/test/ui/traits/suggest-fully-qualified-closure.stderr new file mode 100644 index 000000000..3df623c14 --- /dev/null +++ b/src/test/ui/traits/suggest-fully-qualified-closure.stderr @@ -0,0 +1,34 @@ +error[E0282]: type annotations needed + --> $DIR/suggest-fully-qualified-closure.rs:23:7 + | +LL | q.lol(||()); + | ^^^ + | +help: try using a fully qualified path to specify the expected types + | +LL | <Qqq as MyTrait<T>>::lol::<[closure@]>(&q, ||()); + | +++ ~ + +error[E0283]: type annotations needed + --> $DIR/suggest-fully-qualified-closure.rs:23:7 + | +LL | q.lol(||()); + | ^^^ + | +note: multiple `impl`s satisfying `Qqq: MyTrait<_>` found + --> $DIR/suggest-fully-qualified-closure.rs:14:1 + | +LL | impl MyTrait<u32> for Qqq{ + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl MyTrait<u64> for Qqq{ + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <Qqq as MyTrait<T>>::lol::<[closure@]>(&q, ||()); + | +++ ~ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0282, E0283. +For more information about an error, try `rustc --explain E0282`. diff --git a/src/test/ui/traits/trait-upcasting/basic.rs b/src/test/ui/traits/trait-upcasting/basic.rs index 484a222bc..570ec5160 100644 --- a/src/test/ui/traits/trait-upcasting/basic.rs +++ b/src/test/ui/traits/trait-upcasting/basic.rs @@ -1,7 +1,6 @@ // run-pass #![feature(trait_upcasting)] -#![allow(incomplete_features)] trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync { fn a(&self) -> i32 { diff --git a/src/test/ui/traits/trait-upcasting/correct-supertrait-substitution.rs b/src/test/ui/traits/trait-upcasting/correct-supertrait-substitution.rs index 8d0a9ef0a..eae5cf8d5 100644 --- a/src/test/ui/traits/trait-upcasting/correct-supertrait-substitution.rs +++ b/src/test/ui/traits/trait-upcasting/correct-supertrait-substitution.rs @@ -1,6 +1,5 @@ // run-pass #![feature(trait_upcasting)] -#![allow(incomplete_features)] trait Foo<T: Default + ToString>: Bar<i32> + Bar<T> {} trait Bar<T: Default + ToString> { diff --git a/src/test/ui/traits/trait-upcasting/diamond.rs b/src/test/ui/traits/trait-upcasting/diamond.rs index e4e23c1a2..a4f81c464 100644 --- a/src/test/ui/traits/trait-upcasting/diamond.rs +++ b/src/test/ui/traits/trait-upcasting/diamond.rs @@ -1,7 +1,6 @@ // run-pass #![feature(trait_upcasting)] -#![allow(incomplete_features)] trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync { fn a(&self) -> i32 { diff --git a/src/test/ui/traits/trait-upcasting/invalid-upcast.rs b/src/test/ui/traits/trait-upcasting/invalid-upcast.rs index 240224504..e634bbd5a 100644 --- a/src/test/ui/traits/trait-upcasting/invalid-upcast.rs +++ b/src/test/ui/traits/trait-upcasting/invalid-upcast.rs @@ -1,5 +1,4 @@ #![feature(trait_upcasting)] -#![allow(incomplete_features)] trait Foo { fn a(&self) -> i32 { diff --git a/src/test/ui/traits/trait-upcasting/invalid-upcast.stderr b/src/test/ui/traits/trait-upcasting/invalid-upcast.stderr index b4530ed0c..3aa21ee3d 100644 --- a/src/test/ui/traits/trait-upcasting/invalid-upcast.stderr +++ b/src/test/ui/traits/trait-upcasting/invalid-upcast.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:54:35 + --> $DIR/invalid-upcast.rs:53:35 | LL | let _: &dyn std::fmt::Debug = baz; | -------------------- ^^^ expected trait `Debug`, found trait `Baz` @@ -10,7 +10,7 @@ LL | let _: &dyn std::fmt::Debug = baz; found reference `&dyn Baz` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:56:24 + --> $DIR/invalid-upcast.rs:55:24 | LL | let _: &dyn Send = baz; | --------- ^^^ expected trait `Send`, found trait `Baz` @@ -21,7 +21,7 @@ LL | let _: &dyn Send = baz; found reference `&dyn Baz` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:58:24 + --> $DIR/invalid-upcast.rs:57:24 | LL | let _: &dyn Sync = baz; | --------- ^^^ expected trait `Sync`, found trait `Baz` @@ -32,7 +32,7 @@ LL | let _: &dyn Sync = baz; found reference `&dyn Baz` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:61:25 + --> $DIR/invalid-upcast.rs:60:25 | LL | let bar: &dyn Bar = baz; | -------- ^^^ expected trait `Bar`, found trait `Baz` @@ -43,7 +43,7 @@ LL | let bar: &dyn Bar = baz; found reference `&dyn Baz` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:63:35 + --> $DIR/invalid-upcast.rs:62:35 | LL | let _: &dyn std::fmt::Debug = bar; | -------------------- ^^^ expected trait `Debug`, found trait `Bar` @@ -54,7 +54,7 @@ LL | let _: &dyn std::fmt::Debug = bar; found reference `&dyn Bar` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:65:24 + --> $DIR/invalid-upcast.rs:64:24 | LL | let _: &dyn Send = bar; | --------- ^^^ expected trait `Send`, found trait `Bar` @@ -65,7 +65,7 @@ LL | let _: &dyn Send = bar; found reference `&dyn Bar` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:67:24 + --> $DIR/invalid-upcast.rs:66:24 | LL | let _: &dyn Sync = bar; | --------- ^^^ expected trait `Sync`, found trait `Bar` @@ -76,7 +76,7 @@ LL | let _: &dyn Sync = bar; found reference `&dyn Bar` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:70:25 + --> $DIR/invalid-upcast.rs:69:25 | LL | let foo: &dyn Foo = baz; | -------- ^^^ expected trait `Foo`, found trait `Baz` @@ -87,7 +87,7 @@ LL | let foo: &dyn Foo = baz; found reference `&dyn Baz` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:72:35 + --> $DIR/invalid-upcast.rs:71:35 | LL | let _: &dyn std::fmt::Debug = foo; | -------------------- ^^^ expected trait `Debug`, found trait `Foo` @@ -98,7 +98,7 @@ LL | let _: &dyn std::fmt::Debug = foo; found reference `&dyn Foo` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:74:24 + --> $DIR/invalid-upcast.rs:73:24 | LL | let _: &dyn Send = foo; | --------- ^^^ expected trait `Send`, found trait `Foo` @@ -109,7 +109,7 @@ LL | let _: &dyn Send = foo; found reference `&dyn Foo` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:76:24 + --> $DIR/invalid-upcast.rs:75:24 | LL | let _: &dyn Sync = foo; | --------- ^^^ expected trait `Sync`, found trait `Foo` @@ -120,7 +120,7 @@ LL | let _: &dyn Sync = foo; found reference `&dyn Foo` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:79:25 + --> $DIR/invalid-upcast.rs:78:25 | LL | let foo: &dyn Foo = bar; | -------- ^^^ expected trait `Foo`, found trait `Bar` @@ -131,7 +131,7 @@ LL | let foo: &dyn Foo = bar; found reference `&dyn Bar` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:81:35 + --> $DIR/invalid-upcast.rs:80:35 | LL | let _: &dyn std::fmt::Debug = foo; | -------------------- ^^^ expected trait `Debug`, found trait `Foo` @@ -142,7 +142,7 @@ LL | let _: &dyn std::fmt::Debug = foo; found reference `&dyn Foo` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:83:24 + --> $DIR/invalid-upcast.rs:82:24 | LL | let _: &dyn Send = foo; | --------- ^^^ expected trait `Send`, found trait `Foo` @@ -153,7 +153,7 @@ LL | let _: &dyn Send = foo; found reference `&dyn Foo` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:85:24 + --> $DIR/invalid-upcast.rs:84:24 | LL | let _: &dyn Sync = foo; | --------- ^^^ expected trait `Sync`, found trait `Foo` diff --git a/src/test/ui/traits/trait-upcasting/issue-11515-upcast-fn_mut-fn.rs b/src/test/ui/traits/trait-upcasting/issue-11515-upcast-fn_mut-fn.rs index 6d8800254..b672963ae 100644 --- a/src/test/ui/traits/trait-upcasting/issue-11515-upcast-fn_mut-fn.rs +++ b/src/test/ui/traits/trait-upcasting/issue-11515-upcast-fn_mut-fn.rs @@ -1,6 +1,5 @@ // run-pass #![feature(trait_upcasting)] -#![allow(incomplete_features)] struct Test { func: Box<dyn FnMut() + 'static>, diff --git a/src/test/ui/traits/trait-upcasting/lifetime.rs b/src/test/ui/traits/trait-upcasting/lifetime.rs index f029a6f08..9825158c2 100644 --- a/src/test/ui/traits/trait-upcasting/lifetime.rs +++ b/src/test/ui/traits/trait-upcasting/lifetime.rs @@ -1,7 +1,6 @@ // run-pass #![feature(trait_upcasting)] -#![allow(incomplete_features)] trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync { fn a(&self) -> i32 { diff --git a/src/test/ui/traits/trait-upcasting/migrate-lint-deny.rs b/src/test/ui/traits/trait-upcasting/migrate-lint-deny.rs index c67251018..d62418756 100644 --- a/src/test/ui/traits/trait-upcasting/migrate-lint-deny.rs +++ b/src/test/ui/traits/trait-upcasting/migrate-lint-deny.rs @@ -7,7 +7,11 @@ use core::ops::Deref; // issue 89190 trait A {} trait B: A {} + impl<'a> Deref for dyn 'a + B { + //~^ ERROR `(dyn B + 'a)` implements `Deref` with supertrait `A` as target + //~| WARN this was previously accepted by the compiler but is being phased out; + type Target = dyn A; fn deref(&self) -> &Self::Target { todo!() @@ -18,8 +22,6 @@ fn take_a(_: &dyn A) {} fn whoops(b: &dyn B) { take_a(b) - //~^ ERROR `dyn B` implements `Deref` with supertrait `(dyn A + 'static)` as output - //~^^ WARN this was previously accepted by the compiler but is being phased out; } fn main() {} diff --git a/src/test/ui/traits/trait-upcasting/migrate-lint-deny.stderr b/src/test/ui/traits/trait-upcasting/migrate-lint-deny.stderr index 6c359b698..4533b1163 100644 --- a/src/test/ui/traits/trait-upcasting/migrate-lint-deny.stderr +++ b/src/test/ui/traits/trait-upcasting/migrate-lint-deny.stderr @@ -1,8 +1,11 @@ -error: `dyn B` implements `Deref` with supertrait `(dyn A + 'static)` as output - --> $DIR/migrate-lint-deny.rs:20:12 +error: `(dyn B + 'a)` implements `Deref` with supertrait `A` as target + --> $DIR/migrate-lint-deny.rs:11:1 | -LL | take_a(b) - | ^ +LL | impl<'a> Deref for dyn 'a + B { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | type Target = dyn A; + | -------------------- target type is set here | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #89460 <https://github.com/rust-lang/rust/issues/89460> diff --git a/src/test/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.rs b/src/test/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.rs index 6986ad621..2e53a00a9 100644 --- a/src/test/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.rs +++ b/src/test/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.rs @@ -1,12 +1,11 @@ // check-fail #![feature(trait_upcasting)] -#![allow(incomplete_features)] trait Bar<T> { fn bar(&self, _: T) {} } -trait Foo : Bar<i32> + Bar<u32> { +trait Foo: Bar<i32> + Bar<u32> { fn foo(&self, _: ()) {} } diff --git a/src/test/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.stderr b/src/test/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.stderr index 956481351..0ad18be03 100644 --- a/src/test/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.stderr +++ b/src/test/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/multiple-occurrence-ambiguousity.rs:21:26 + --> $DIR/multiple-occurrence-ambiguousity.rs:20:26 | LL | let t: &dyn Bar<_> = s; | ----------- ^ expected trait `Bar`, found trait `Foo` diff --git a/src/test/ui/traits/trait-upcasting/replace-vptr.rs b/src/test/ui/traits/trait-upcasting/replace-vptr.rs index 1164e4361..9ccfc9306 100644 --- a/src/test/ui/traits/trait-upcasting/replace-vptr.rs +++ b/src/test/ui/traits/trait-upcasting/replace-vptr.rs @@ -1,7 +1,6 @@ // run-pass #![feature(trait_upcasting)] -#![allow(incomplete_features)] trait A { fn foo_a(&self); diff --git a/src/test/ui/traits/trait-upcasting/struct.rs b/src/test/ui/traits/trait-upcasting/struct.rs index 0f3cb285b..a3e416969 100644 --- a/src/test/ui/traits/trait-upcasting/struct.rs +++ b/src/test/ui/traits/trait-upcasting/struct.rs @@ -1,7 +1,6 @@ // run-pass #![feature(trait_upcasting)] -#![allow(incomplete_features)] use std::rc::Rc; use std::sync::Arc; diff --git a/src/test/ui/traits/trait-upcasting/subtrait-method.rs b/src/test/ui/traits/trait-upcasting/subtrait-method.rs index 3508e1528..136d15af0 100644 --- a/src/test/ui/traits/trait-upcasting/subtrait-method.rs +++ b/src/test/ui/traits/trait-upcasting/subtrait-method.rs @@ -1,5 +1,4 @@ #![feature(trait_upcasting)] -#![allow(incomplete_features)] trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync { fn a(&self) -> i32 { diff --git a/src/test/ui/traits/trait-upcasting/subtrait-method.stderr b/src/test/ui/traits/trait-upcasting/subtrait-method.stderr index af7a410f6..918159e84 100644 --- a/src/test/ui/traits/trait-upcasting/subtrait-method.stderr +++ b/src/test/ui/traits/trait-upcasting/subtrait-method.stderr @@ -1,64 +1,64 @@ error[E0599]: no method named `c` found for reference `&dyn Bar` in the current scope - --> $DIR/subtrait-method.rs:56:9 + --> $DIR/subtrait-method.rs:55:9 | LL | bar.c(); | ^ help: there is a method with a similar name: `a` | = help: items from traits can only be used if the trait is implemented and in scope note: `Baz` defines an item `c`, perhaps you need to implement it - --> $DIR/subtrait-method.rs:28:1 + --> $DIR/subtrait-method.rs:27:1 | LL | trait Baz: Bar { | ^^^^^^^^^^^^^^ error[E0599]: no method named `b` found for reference `&dyn Foo` in the current scope - --> $DIR/subtrait-method.rs:60:9 + --> $DIR/subtrait-method.rs:59:9 | LL | foo.b(); | ^ help: there is a method with a similar name: `a` | = help: items from traits can only be used if the trait is implemented and in scope note: `Bar` defines an item `b`, perhaps you need to implement it - --> $DIR/subtrait-method.rs:18:1 + --> $DIR/subtrait-method.rs:17:1 | LL | trait Bar: Foo { | ^^^^^^^^^^^^^^ error[E0599]: no method named `c` found for reference `&dyn Foo` in the current scope - --> $DIR/subtrait-method.rs:62:9 + --> $DIR/subtrait-method.rs:61:9 | LL | foo.c(); | ^ help: there is a method with a similar name: `a` | = help: items from traits can only be used if the trait is implemented and in scope note: `Baz` defines an item `c`, perhaps you need to implement it - --> $DIR/subtrait-method.rs:28:1 + --> $DIR/subtrait-method.rs:27:1 | LL | trait Baz: Bar { | ^^^^^^^^^^^^^^ error[E0599]: no method named `b` found for reference `&dyn Foo` in the current scope - --> $DIR/subtrait-method.rs:66:9 + --> $DIR/subtrait-method.rs:65:9 | LL | foo.b(); | ^ help: there is a method with a similar name: `a` | = help: items from traits can only be used if the trait is implemented and in scope note: `Bar` defines an item `b`, perhaps you need to implement it - --> $DIR/subtrait-method.rs:18:1 + --> $DIR/subtrait-method.rs:17:1 | LL | trait Bar: Foo { | ^^^^^^^^^^^^^^ error[E0599]: no method named `c` found for reference `&dyn Foo` in the current scope - --> $DIR/subtrait-method.rs:68:9 + --> $DIR/subtrait-method.rs:67:9 | LL | foo.c(); | ^ help: there is a method with a similar name: `a` | = help: items from traits can only be used if the trait is implemented and in scope note: `Baz` defines an item `c`, perhaps you need to implement it - --> $DIR/subtrait-method.rs:28:1 + --> $DIR/subtrait-method.rs:27:1 | LL | trait Baz: Bar { | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-1.rs b/src/test/ui/traits/trait-upcasting/type-checking-test-1.rs index 79ddedd41..6bc9f4a75 100644 --- a/src/test/ui/traits/trait-upcasting/type-checking-test-1.rs +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-1.rs @@ -1,5 +1,4 @@ #![feature(trait_upcasting)] -#![allow(incomplete_features)] trait Foo: Bar<i32> + Bar<u32> {} trait Bar<T> { diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-1.stderr b/src/test/ui/traits/trait-upcasting/type-checking-test-1.stderr index 398537211..fe269d8e9 100644 --- a/src/test/ui/traits/trait-upcasting/type-checking-test-1.stderr +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-1.stderr @@ -1,5 +1,5 @@ error[E0605]: non-primitive cast: `&dyn Foo` as `&dyn Bar<_>` - --> $DIR/type-checking-test-1.rs:17:13 + --> $DIR/type-checking-test-1.rs:16:13 | LL | let _ = x as &dyn Bar<_>; // Ambiguous | ^^^^^^^^^^^^^^^^ invalid cast @@ -10,7 +10,7 @@ LL | let _ = &x as &dyn Bar<_>; // Ambiguous | + error[E0277]: the trait bound `&dyn Foo: Bar<_>` is not satisfied - --> $DIR/type-checking-test-1.rs:17:13 + --> $DIR/type-checking-test-1.rs:16:13 | LL | let _ = x as &dyn Bar<_>; // Ambiguous | ^ the trait `Bar<_>` is not implemented for `&dyn Foo` diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-2.rs b/src/test/ui/traits/trait-upcasting/type-checking-test-2.rs index 32754c538..36b11dffd 100644 --- a/src/test/ui/traits/trait-upcasting/type-checking-test-2.rs +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-2.rs @@ -1,5 +1,4 @@ #![feature(trait_upcasting)] -#![allow(incomplete_features)] trait Foo<T>: Bar<i32> + Bar<T> {} trait Bar<T> { diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-2.stderr b/src/test/ui/traits/trait-upcasting/type-checking-test-2.stderr index 93c71f54e..ef007d5cb 100644 --- a/src/test/ui/traits/trait-upcasting/type-checking-test-2.stderr +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-2.stderr @@ -1,5 +1,5 @@ error[E0605]: non-primitive cast: `&dyn Foo<i32>` as `&dyn Bar<u32>` - --> $DIR/type-checking-test-2.rs:20:13 + --> $DIR/type-checking-test-2.rs:19:13 | LL | let _ = x as &dyn Bar<u32>; // Error | ^^^^^^^^^^^^^^^^^^ invalid cast @@ -10,7 +10,7 @@ LL | let _ = &x as &dyn Bar<u32>; // Error | + error[E0277]: the trait bound `&dyn Foo<i32>: Bar<u32>` is not satisfied - --> $DIR/type-checking-test-2.rs:20:13 + --> $DIR/type-checking-test-2.rs:19:13 | LL | let _ = x as &dyn Bar<u32>; // Error | ^ the trait `Bar<u32>` is not implemented for `&dyn Foo<i32>` @@ -18,7 +18,7 @@ LL | let _ = x as &dyn Bar<u32>; // Error = note: required for the cast from `&dyn Foo<i32>` to the object type `dyn Bar<u32>` error[E0605]: non-primitive cast: `&dyn Foo<u32>` as `&dyn Bar<_>` - --> $DIR/type-checking-test-2.rs:26:13 + --> $DIR/type-checking-test-2.rs:25:13 | LL | let a = x as &dyn Bar<_>; // Ambiguous | ^^^^^^^^^^^^^^^^ invalid cast @@ -29,7 +29,7 @@ LL | let a = &x as &dyn Bar<_>; // Ambiguous | + error[E0277]: the trait bound `&dyn Foo<u32>: Bar<_>` is not satisfied - --> $DIR/type-checking-test-2.rs:26:13 + --> $DIR/type-checking-test-2.rs:25:13 | LL | let a = x as &dyn Bar<_>; // Ambiguous | ^ the trait `Bar<_>` is not implemented for `&dyn Foo<u32>` diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-3.polonius.stderr b/src/test/ui/traits/trait-upcasting/type-checking-test-3.polonius.stderr index e48ba709a..e6cb6a753 100644 --- a/src/test/ui/traits/trait-upcasting/type-checking-test-3.polonius.stderr +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-3.polonius.stderr @@ -1,22 +1,18 @@ error: lifetime may not live long enough - --> $DIR/type-checking-test-3.rs:13:13 + --> $DIR/type-checking-test-3.rs:11:13 | LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) { | -- lifetime `'a` defined here LL | let _ = x as &dyn Bar<'a>; // Error | ^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` - | - = help: consider replacing `'a` with `'static` error: lifetime may not live long enough - --> $DIR/type-checking-test-3.rs:18:13 + --> $DIR/type-checking-test-3.rs:16:13 | LL | fn test_wrong2<'a>(x: &dyn Foo<'a>) { | -- lifetime `'a` defined here LL | let _ = x as &dyn Bar<'static>; // Error | ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` - | - = help: consider replacing `'a` with `'static` error: aborting due to 2 previous errors diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-3.rs b/src/test/ui/traits/trait-upcasting/type-checking-test-3.rs index b3aa2279a..b2db3a127 100644 --- a/src/test/ui/traits/trait-upcasting/type-checking-test-3.rs +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-3.rs @@ -1,5 +1,4 @@ #![feature(trait_upcasting)] -#![allow(incomplete_features)] trait Foo<'a>: Bar<'a> {} trait Bar<'a> {} @@ -10,12 +9,12 @@ fn test_correct(x: &dyn Foo<'static>) { fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) { let _ = x as &dyn Bar<'a>; // Error - //~^ ERROR lifetime may not live long enough + //~^ ERROR lifetime may not live long enough } fn test_wrong2<'a>(x: &dyn Foo<'a>) { let _ = x as &dyn Bar<'static>; // Error - //~^ ERROR lifetime may not live long enough + //~^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-3.stderr b/src/test/ui/traits/trait-upcasting/type-checking-test-3.stderr index 5ad151b50..e6cb6a753 100644 --- a/src/test/ui/traits/trait-upcasting/type-checking-test-3.stderr +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-3.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/type-checking-test-3.rs:12:13 + --> $DIR/type-checking-test-3.rs:11:13 | LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) { | -- lifetime `'a` defined here @@ -7,7 +7,7 @@ LL | let _ = x as &dyn Bar<'a>; // Error | ^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/type-checking-test-3.rs:17:13 + --> $DIR/type-checking-test-3.rs:16:13 | LL | fn test_wrong2<'a>(x: &dyn Foo<'a>) { | -- lifetime `'a` defined here diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-4.polonius.stderr b/src/test/ui/traits/trait-upcasting/type-checking-test-4.polonius.stderr index a3411f40a..8d506e580 100644 --- a/src/test/ui/traits/trait-upcasting/type-checking-test-4.polonius.stderr +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-4.polonius.stderr @@ -1,33 +1,52 @@ error: lifetime may not live long enough - --> $DIR/type-checking-test-4.rs:17:13 + --> $DIR/type-checking-test-4.rs:15:13 | LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) { | -- lifetime `'a` defined here LL | let _ = x as &dyn Bar<'static, 'a>; // Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` - | - = help: consider replacing `'a` with `'static` error: lifetime may not live long enough - --> $DIR/type-checking-test-4.rs:22:13 + --> $DIR/type-checking-test-4.rs:20:13 | LL | fn test_wrong2<'a>(x: &dyn Foo<'static>, y: &'a u32) { | -- lifetime `'a` defined here LL | let _ = x as &dyn Bar<'a, 'static>; // Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` - | - = help: consider replacing `'a` with `'static` error: lifetime may not live long enough - --> $DIR/type-checking-test-4.rs:29:5 + --> $DIR/type-checking-test-4.rs:26:5 | LL | fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | -- lifetime `'a` defined here -... +LL | let y = x as &dyn Bar<'_, '_>; LL | y.get_b() // ERROR | ^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + +error: lifetime may not live long enough + --> $DIR/type-checking-test-4.rs:31:5 + | +LL | fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { + | -- lifetime `'a` defined here +LL | <_ as Bar>::get_b(x) // ERROR + | ^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + +error: lifetime may not live long enough + --> $DIR/type-checking-test-4.rs:36:5 + | +LL | fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { + | -- lifetime `'a` defined here +LL | <_ as Bar<'_, '_>>::get_b(x) // ERROR + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + +error: lifetime may not live long enough + --> $DIR/type-checking-test-4.rs:44:5 | - = help: consider replacing `'a` with `'static` +LL | fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { + | -- lifetime `'a` defined here +... +LL | z.get_b() // ERROR + | ^^^^^^^^^ returning this value requires that `'a` must outlive `'static` -error: aborting due to 3 previous errors +error: aborting due to 6 previous errors diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-4.rs b/src/test/ui/traits/trait-upcasting/type-checking-test-4.rs index 70ccc87fc..f40c48f0d 100644 --- a/src/test/ui/traits/trait-upcasting/type-checking-test-4.rs +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-4.rs @@ -1,5 +1,4 @@ #![feature(trait_upcasting)] -#![allow(incomplete_features)] trait Foo<'a>: Bar<'a, 'a> {} trait Bar<'a, 'b> { @@ -14,28 +13,28 @@ fn test_correct(x: &dyn Foo<'static>) { fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) { let _ = x as &dyn Bar<'static, 'a>; // Error - //~^ ERROR lifetime may not live long enough + //~^ ERROR lifetime may not live long enough } fn test_wrong2<'a>(x: &dyn Foo<'static>, y: &'a u32) { let _ = x as &dyn Bar<'a, 'static>; // Error - //~^ ERROR lifetime may not live long enough + //~^ ERROR lifetime may not live long enough } fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { let y = x as &dyn Bar<'_, '_>; y.get_b() // ERROR - //~^ ERROR lifetime may not live long enough + //~^ ERROR lifetime may not live long enough } fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { <_ as Bar>::get_b(x) // ERROR - //~^ ERROR lifetime may not live long enough + //~^ ERROR lifetime may not live long enough } fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { <_ as Bar<'_, '_>>::get_b(x) // ERROR - //~^ ERROR lifetime may not live long enough + //~^ ERROR lifetime may not live long enough } fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { @@ -43,7 +42,7 @@ fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { y.get_b(); // ERROR let z = y; z.get_b() // ERROR - //~^ ERROR lifetime may not live long enough + //~^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-4.stderr b/src/test/ui/traits/trait-upcasting/type-checking-test-4.stderr index 436129d0b..8d506e580 100644 --- a/src/test/ui/traits/trait-upcasting/type-checking-test-4.stderr +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-4.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/type-checking-test-4.rs:16:13 + --> $DIR/type-checking-test-4.rs:15:13 | LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) { | -- lifetime `'a` defined here @@ -7,7 +7,7 @@ LL | let _ = x as &dyn Bar<'static, 'a>; // Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/type-checking-test-4.rs:21:13 + --> $DIR/type-checking-test-4.rs:20:13 | LL | fn test_wrong2<'a>(x: &dyn Foo<'static>, y: &'a u32) { | -- lifetime `'a` defined here @@ -15,7 +15,7 @@ LL | let _ = x as &dyn Bar<'a, 'static>; // Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/type-checking-test-4.rs:27:5 + --> $DIR/type-checking-test-4.rs:26:5 | LL | fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | -- lifetime `'a` defined here @@ -24,7 +24,7 @@ LL | y.get_b() // ERROR | ^^^^^^^^^ returning this value requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/type-checking-test-4.rs:32:5 + --> $DIR/type-checking-test-4.rs:31:5 | LL | fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | -- lifetime `'a` defined here @@ -32,7 +32,7 @@ LL | <_ as Bar>::get_b(x) // ERROR | ^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/type-checking-test-4.rs:37:5 + --> $DIR/type-checking-test-4.rs:36:5 | LL | fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | -- lifetime `'a` defined here @@ -40,7 +40,7 @@ LL | <_ as Bar<'_, '_>>::get_b(x) // ERROR | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/type-checking-test-4.rs:45:5 + --> $DIR/type-checking-test-4.rs:44:5 | LL | fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | -- lifetime `'a` defined here diff --git a/src/test/ui/transmutability/arrays/issue-103783-array-length.rs b/src/test/ui/transmutability/arrays/issue-103783-array-length.rs new file mode 100644 index 000000000..cb36e539e --- /dev/null +++ b/src/test/ui/transmutability/arrays/issue-103783-array-length.rs @@ -0,0 +1,24 @@ +#![crate_type = "lib"] +#![feature(transmutability)] +#![allow(dead_code)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + pub struct Context; + + pub fn is_maybe_transmutable<Src, Dst>() + where + Dst: BikeshedIntrinsicFrom< + Src, + Context, + { Assume { alignment: true, lifetimes: true, safety: true, validity: true } }, + >, + { + } +} + +fn test() { + type NaughtyLenArray = [u32; 3.14159]; //~ ERROR mismatched types + type JustUnit = (); + assert::is_maybe_transmutable::<JustUnit, NaughtyLenArray>(); +} diff --git a/src/test/ui/transmutability/arrays/issue-103783-array-length.stderr b/src/test/ui/transmutability/arrays/issue-103783-array-length.stderr new file mode 100644 index 000000000..37774c59e --- /dev/null +++ b/src/test/ui/transmutability/arrays/issue-103783-array-length.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/issue-103783-array-length.rs:21:34 + | +LL | type NaughtyLenArray = [u32; 3.14159]; + | ^^^^^^^ expected `usize`, found floating-point number + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/transmute/transmute-padding-ice.rs b/src/test/ui/transmute/transmute-padding-ice.rs new file mode 100644 index 000000000..a1be7075a --- /dev/null +++ b/src/test/ui/transmute/transmute-padding-ice.rs @@ -0,0 +1,29 @@ +#![crate_type = "lib"] +#![feature(transmutability)] +#![allow(dead_code)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + pub struct Context; + + pub fn is_maybe_transmutable<Src, Dst>() + where + Dst: BikeshedIntrinsicFrom< + Src, + Context, + { Assume { alignment: true, lifetimes: true, safety: true, validity: true } }, + >, + { + } +} + +fn test() { + #[repr(C, align(2))] + struct A(u8, u8); + + #[repr(C)] + struct B(u8, u8); + + assert::is_maybe_transmutable::<B, A>(); + //~^ ERROR cannot be safely transmuted +} diff --git a/src/test/ui/transmute/transmute-padding-ice.stderr b/src/test/ui/transmute/transmute-padding-ice.stderr new file mode 100644 index 000000000..c9233890f --- /dev/null +++ b/src/test/ui/transmute/transmute-padding-ice.stderr @@ -0,0 +1,24 @@ +error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`. + --> $DIR/transmute-padding-ice.rs:27:40 + | +LL | assert::is_maybe_transmutable::<B, A>(); + | ^ `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`. + | + = help: the trait `BikeshedIntrinsicFrom<B, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `A` +note: required by a bound in `is_maybe_transmutable` + --> $DIR/transmute-padding-ice.rs:11:14 + | +LL | pub fn is_maybe_transmutable<Src, Dst>() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom< + | ______________^ +LL | | Src, +LL | | Context, +LL | | { Assume { alignment: true, lifetimes: true, safety: true, validity: true } }, +LL | | >, + | |_________^ required by this bound in `is_maybe_transmutable` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/try-block/try-block-maybe-bad-lifetime.stderr b/src/test/ui/try-block/try-block-maybe-bad-lifetime.stderr index c9f2a3ed9..f738b03ee 100644 --- a/src/test/ui/try-block/try-block-maybe-bad-lifetime.stderr +++ b/src/test/ui/try-block/try-block-maybe-bad-lifetime.stderr @@ -23,6 +23,10 @@ LL | println!("{}", x); | ^ value borrowed here after move | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider cloning the value if the performance cost is acceptable + | +LL | ::std::mem::drop(x.clone()); + | ++++++++ error[E0506]: cannot assign to `i` because it is borrowed --> $DIR/try-block-maybe-bad-lifetime.rs:40:9 diff --git a/src/test/ui/try-trait/bad-interconversion.stderr b/src/test/ui/try-trait/bad-interconversion.stderr index 419a86bf3..a49630adb 100644 --- a/src/test/ui/try-trait/bad-interconversion.stderr +++ b/src/test/ui/try-trait/bad-interconversion.stderr @@ -8,15 +8,8 @@ LL | Ok(Err(123_i32)?) | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the following other types implement trait `From<T>`: - <f32 as From<i16>> - <f32 as From<i8>> - <f32 as From<u16>> - <f32 as From<u8>> - <f64 as From<f32>> - <f64 as From<i16>> - <f64 as From<i32>> - <f64 as From<i8>> - and 68 others + <u8 as From<NonZeroU8>> + <u8 as From<bool>> = note: required for `Result<u64, u8>` to implement `FromResidual<Result<Infallible, i32>>` error[E0277]: the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result` diff --git a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-Self-issue-58006.stderr b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-Self-issue-58006.stderr index 15d15f2f4..6870b9d7d 100644 --- a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-Self-issue-58006.stderr +++ b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-Self-issue-58006.stderr @@ -2,7 +2,7 @@ error[E0533]: expected unit struct, unit variant or constant, found tuple varian --> $DIR/incorrect-variant-form-through-Self-issue-58006.rs:8:13 | LL | Self::A => (), - | ^^^^^^^ + | ^^^^^^^ not a unit struct, unit variant or constant error: aborting due to previous error diff --git a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.rs b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.rs index e4abb96b4..5ed7988e4 100644 --- a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.rs +++ b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.rs @@ -6,7 +6,7 @@ type Alias = Enum; fn main() { Alias::Braced; - //~^ ERROR expected unit struct, unit variant or constant, found struct variant `Alias::Braced` [E0533] + //~^ ERROR expected value, found struct variant `Alias::Braced` [E0533] let Alias::Braced = panic!(); //~^ ERROR expected unit struct, unit variant or constant, found struct variant `Alias::Braced` [E0533] let Alias::Braced(..) = panic!(); diff --git a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.stderr b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.stderr index 8f3180a86..c9ac99ede 100644 --- a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.stderr +++ b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.stderr @@ -1,20 +1,20 @@ -error[E0533]: expected unit struct, unit variant or constant, found struct variant `Alias::Braced` +error[E0533]: expected value, found struct variant `Alias::Braced` --> $DIR/incorrect-variant-form-through-alias-caught.rs:8:5 | LL | Alias::Braced; - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ not a value error[E0533]: expected unit struct, unit variant or constant, found struct variant `Alias::Braced` --> $DIR/incorrect-variant-form-through-alias-caught.rs:10:9 | LL | let Alias::Braced = panic!(); - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ not a unit struct, unit variant or constant error[E0164]: expected tuple struct or tuple variant, found struct variant `Alias::Braced` --> $DIR/incorrect-variant-form-through-alias-caught.rs:12:9 | LL | let Alias::Braced(..) = panic!(); - | ^^^^^^^^^^^^^^^^^ not a tuple variant or struct + | ^^^^^^^^^^^^^^^^^ not a tuple struct or tuple variant error[E0618]: expected function, found enum variant `Alias::Unit` --> $DIR/incorrect-variant-form-through-alias-caught.rs:15:5 @@ -37,7 +37,7 @@ error[E0164]: expected tuple struct or tuple variant, found unit variant `Alias: --> $DIR/incorrect-variant-form-through-alias-caught.rs:17:9 | LL | let Alias::Unit() = panic!(); - | ^^^^^^^^^^^^^ not a tuple variant or struct + | ^^^^^^^^^^^^^ not a tuple struct or tuple variant error: aborting due to 5 previous errors diff --git a/src/test/ui/type-alias-enum-variants/self-in-enum-definition.stderr b/src/test/ui/type-alias-enum-variants/self-in-enum-definition.stderr index 4775e6882..576fc6a4f 100644 --- a/src/test/ui/type-alias-enum-variants/self-in-enum-definition.stderr +++ b/src/test/ui/type-alias-enum-variants/self-in-enum-definition.stderr @@ -14,6 +14,46 @@ note: ...which requires const-evaluating + checking `Alpha::V3::{constant#0}`... | LL | V3 = Self::V1 {} as u8 + 2, | ^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires caching mir of `Alpha::V3::{constant#0}` for CTFE... + --> $DIR/self-in-enum-definition.rs:5:10 + | +LL | V3 = Self::V1 {} as u8 + 2, + | ^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires elaborating drops for `Alpha::V3::{constant#0}`... + --> $DIR/self-in-enum-definition.rs:5:10 + | +LL | V3 = Self::V1 {} as u8 + 2, + | ^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires borrow-checking `Alpha::V3::{constant#0}`... + --> $DIR/self-in-enum-definition.rs:5:10 + | +LL | V3 = Self::V1 {} as u8 + 2, + | ^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires processing MIR for `Alpha::V3::{constant#0}`... + --> $DIR/self-in-enum-definition.rs:5:10 + | +LL | V3 = Self::V1 {} as u8 + 2, + | ^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires const checking `Alpha::V3::{constant#0}`... + --> $DIR/self-in-enum-definition.rs:5:10 + | +LL | V3 = Self::V1 {} as u8 + 2, + | ^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires preparing `Alpha::V3::{constant#0}` for borrow checking... + --> $DIR/self-in-enum-definition.rs:5:10 + | +LL | V3 = Self::V1 {} as u8 + 2, + | ^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires unsafety-checking `Alpha::V3::{constant#0}`... + --> $DIR/self-in-enum-definition.rs:5:10 + | +LL | V3 = Self::V1 {} as u8 + 2, + | ^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires building MIR for `Alpha::V3::{constant#0}`... + --> $DIR/self-in-enum-definition.rs:5:10 + | +LL | V3 = Self::V1 {} as u8 + 2, + | ^^^^^^^^^^^^^^^^^^^^^ = note: ...which requires computing layout of `Alpha`... = note: ...which again requires simplifying constant for the type system `Alpha::V3::{constant#0}`, completing the cycle note: cycle used when collecting item types in top-level module diff --git a/src/test/ui/type-alias-impl-trait/coherence.rs b/src/test/ui/type-alias-impl-trait/coherence.rs index 98ac215ad..077a31494 100644 --- a/src/test/ui/type-alias-impl-trait/coherence.rs +++ b/src/test/ui/type-alias-impl-trait/coherence.rs @@ -12,6 +12,6 @@ fn use_alias<T>(val: T) -> AliasOfForeignType<T> { } impl<T> foreign_crate::ForeignTrait for AliasOfForeignType<T> {} -//~^ ERROR cannot implement trait on type alias impl trait +//~^ ERROR only traits defined in the current crate can be implemented for arbitrary types fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/coherence.stderr b/src/test/ui/type-alias-impl-trait/coherence.stderr index 3ce25d94f..c923eb08a 100644 --- a/src/test/ui/type-alias-impl-trait/coherence.stderr +++ b/src/test/ui/type-alias-impl-trait/coherence.stderr @@ -1,14 +1,14 @@ -error: cannot implement trait on type alias impl trait - --> $DIR/coherence.rs:14:41 +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence.rs:14:1 | LL | impl<T> foreign_crate::ForeignTrait for AliasOfForeignType<T> {} - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------- + | | | + | | `AliasOfForeignType<T>` is not defined in the current crate + | impl doesn't use only types from inside the current crate | -note: type alias impl trait defined here - --> $DIR/coherence.rs:9:30 - | -LL | type AliasOfForeignType<T> = impl LocalTrait; - | ^^^^^^^^^^^^^^^ + = note: define and implement a trait or new type instead error: aborting due to previous error +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/type-alias-impl-trait/coherence_generalization.rs b/src/test/ui/type-alias-impl-trait/coherence_generalization.rs new file mode 100644 index 000000000..5c9ad9498 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/coherence_generalization.rs @@ -0,0 +1,13 @@ +// check-pass + +#![feature(type_alias_impl_trait)] +trait Trait {} +type Opaque<T> = impl Sized; +fn foo<T>() -> Opaque<T> { + () +} + +impl<T, V> Trait for (T, V, V, u32) {} +impl<U, V> Trait for (Opaque<U>, V, i32, V) {} + +fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/impl_trait_for_generic_tait.rs b/src/test/ui/type-alias-impl-trait/impl_trait_for_generic_tait.rs new file mode 100644 index 000000000..0efbd1c2b --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/impl_trait_for_generic_tait.rs @@ -0,0 +1,23 @@ +// check-pass + +#![feature(type_alias_impl_trait)] +trait Foo { + type Assoc; +} + +impl Foo for i32 { + type Assoc = u32; +} +type ImplTrait = impl Sized; +fn constrain() -> ImplTrait { + 1u64 +} +impl Foo for i64 { + type Assoc = ImplTrait; +} + +trait Bar<T> {} + +impl<T: Foo> Bar<<T as Foo>::Assoc> for T {} + +fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/impl_trait_for_same_tait.rs b/src/test/ui/type-alias-impl-trait/impl_trait_for_same_tait.rs new file mode 100644 index 000000000..3f1a9d12b --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/impl_trait_for_same_tait.rs @@ -0,0 +1,33 @@ +#![feature(type_alias_impl_trait)] + +trait Foo {} +impl Foo for () {} +impl Foo for i32 {} + +type Bar<T: Foo> = impl std::fmt::Debug; +fn defining_use<T: Foo>() -> Bar<T> { + 42 +} + +trait Bop {} + +impl Bop for Bar<()> {} + +// If the hidden type is the same, this is effectively a second impl for the same type. +impl Bop for Bar<i32> {} +//~^ ERROR conflicting implementations + +type Barr = impl std::fmt::Debug; +fn defining_use2() -> Barr { + 42 +} + +// Even completely different opaque types must conflict. +impl Bop for Barr {} +//~^ ERROR conflicting implementations + +// And obviously the hidden type must conflict, too. +impl Bop for i32 {} +//~^ ERROR conflicting implementations + +fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/impl_trait_for_same_tait.stderr b/src/test/ui/type-alias-impl-trait/impl_trait_for_same_tait.stderr new file mode 100644 index 000000000..aaf75cc3d --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/impl_trait_for_same_tait.stderr @@ -0,0 +1,30 @@ +error[E0119]: conflicting implementations of trait `Bop` for type `Bar<()>` + --> $DIR/impl_trait_for_same_tait.rs:17:1 + | +LL | impl Bop for Bar<()> {} + | -------------------- first implementation here +... +LL | impl Bop for Bar<i32> {} + | ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Bar<()>` + +error[E0119]: conflicting implementations of trait `Bop` for type `Bar<()>` + --> $DIR/impl_trait_for_same_tait.rs:26:1 + | +LL | impl Bop for Bar<()> {} + | -------------------- first implementation here +... +LL | impl Bop for Barr {} + | ^^^^^^^^^^^^^^^^^ conflicting implementation for `Bar<()>` + +error[E0119]: conflicting implementations of trait `Bop` for type `Bar<()>` + --> $DIR/impl_trait_for_same_tait.rs:30:1 + | +LL | impl Bop for Bar<()> {} + | -------------------- first implementation here +... +LL | impl Bop for i32 {} + | ^^^^^^^^^^^^^^^^ conflicting implementation for `Bar<()>` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/type-alias-impl-trait/impl_trait_for_tait.rs b/src/test/ui/type-alias-impl-trait/impl_trait_for_tait.rs new file mode 100644 index 000000000..9f32c5d88 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/impl_trait_for_tait.rs @@ -0,0 +1,21 @@ +// compile-flags: --crate-type=lib +// check-pass + +#![feature(type_alias_impl_trait)] +type Alias = impl Sized; + +fn constrain() -> Alias { + 1i32 +} + +trait HideIt { + type Assoc; +} + +impl HideIt for () { + type Assoc = Alias; +} + +pub trait Yay {} + +impl Yay for <() as HideIt>::Assoc {} diff --git a/src/test/ui/type-alias-impl-trait/impl_trait_for_tait_bound.rs b/src/test/ui/type-alias-impl-trait/impl_trait_for_tait_bound.rs new file mode 100644 index 000000000..8ec20acef --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/impl_trait_for_tait_bound.rs @@ -0,0 +1,19 @@ +#![feature(type_alias_impl_trait)] + +use std::fmt::Debug; + +type Foo = impl Debug; +pub trait Yay { } +impl Yay for Foo { } + +fn foo() { + is_yay::<u32>(); //~ ERROR: the trait bound `u32: Yay` is not satisfied + is_debug::<u32>(); // OK + is_yay::<Foo>(); // OK + is_debug::<Foo>(); // OK +} + +fn is_yay<T: Yay>() { } +fn is_debug<T: Debug>() { } + +fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/impl_trait_for_tait_bound.stderr b/src/test/ui/type-alias-impl-trait/impl_trait_for_tait_bound.stderr new file mode 100644 index 000000000..1c83105a1 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/impl_trait_for_tait_bound.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `u32: Yay` is not satisfied + --> $DIR/impl_trait_for_tait_bound.rs:10:14 + | +LL | is_yay::<u32>(); + | ^^^ the trait `Yay` is not implemented for `u32` + | + = help: the trait `Yay` is implemented for `Foo` +note: required by a bound in `is_yay` + --> $DIR/impl_trait_for_tait_bound.rs:16:14 + | +LL | fn is_yay<T: Yay>() { } + | ^^^ required by this bound in `is_yay` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/impl_trait_for_tait_bound2.rs b/src/test/ui/type-alias-impl-trait/impl_trait_for_tait_bound2.rs new file mode 100644 index 000000000..a4b8c2d19 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/impl_trait_for_tait_bound2.rs @@ -0,0 +1,16 @@ +#![feature(type_alias_impl_trait)] + +use std::fmt::Debug; + +type Foo = impl Debug; + +pub trait Yay { } +impl Yay for u32 { } + +fn foo() { + is_yay::<Foo>(); //~ ERROR: the trait bound `Foo: Yay` is not satisfied +} + +fn is_yay<T: Yay>() { } + +fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/impl_trait_for_tait_bound2.stderr b/src/test/ui/type-alias-impl-trait/impl_trait_for_tait_bound2.stderr new file mode 100644 index 000000000..a6440f02c --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/impl_trait_for_tait_bound2.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `Foo: Yay` is not satisfied + --> $DIR/impl_trait_for_tait_bound2.rs:11:14 + | +LL | is_yay::<Foo>(); + | ^^^ the trait `Yay` is not implemented for `Foo` + | + = help: the trait `Yay` is implemented for `u32` +note: required by a bound in `is_yay` + --> $DIR/impl_trait_for_tait_bound2.rs:14:14 + | +LL | fn is_yay<T: Yay>() { } + | ^^^ required by this bound in `is_yay` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/imply_bounds_from_bounds.rs b/src/test/ui/type-alias-impl-trait/imply_bounds_from_bounds.rs new file mode 100644 index 000000000..ee9bce15d --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/imply_bounds_from_bounds.rs @@ -0,0 +1,25 @@ +// check-pass + +#![feature(type_alias_impl_trait)] + +trait Callable { + type Output; + fn call() -> Self::Output; +} + +impl<'a> Callable for &'a () { + type Output = impl Sized; + fn call() -> Self::Output {} +} + +fn test<'a>() -> impl Sized { + <&'a () as Callable>::call() +} + +fn want_static<T: 'static>(_: T) {} + +fn test2<'a>() { + want_static(<&'a () as Callable>::call()); +} + +fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs b/src/test/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs new file mode 100644 index 000000000..ae21a9134 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs @@ -0,0 +1,38 @@ +#![feature(type_alias_impl_trait)] + +trait Callable { + type Output; + fn call(x: Self) -> Self::Output; +} + +trait PlusOne { + fn plus_one(&mut self); +} + +impl<'a> PlusOne for &'a mut i32 { + fn plus_one(&mut self) { + **self += 1; + } +} + +impl<T: PlusOne> Callable for T { + type Output = impl PlusOne; + fn call(t: T) -> Self::Output { t } +} + +fn test<'a>(y: &'a mut i32) -> impl PlusOne { + <&'a mut i32 as Callable>::call(y) + //~^ ERROR hidden type for `impl PlusOne` captures lifetime that does not appear in bounds +} + +fn main() { + let mut z = 42; + let mut thing = test(&mut z); + let mut thing2 = test(&mut z); + thing.plus_one(); + assert_eq!(z, 43); + thing2.plus_one(); + assert_eq!(z, 44); + thing.plus_one(); + assert_eq!(z, 45); +} diff --git a/src/test/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.stderr b/src/test/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.stderr new file mode 100644 index 000000000..0ed8a703b --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.stderr @@ -0,0 +1,16 @@ +error[E0700]: hidden type for `impl PlusOne` captures lifetime that does not appear in bounds + --> $DIR/imply_bounds_from_bounds_param.rs:24:5 + | +LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne { + | -- hidden type `<&'a mut i32 as Callable>::Output` captures the lifetime `'a` as defined here +LL | <&'a mut i32 as Callable>::call(y) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: to declare that `impl PlusOne` captures `'a`, you can add an explicit `'a` lifetime bound + | +LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne + 'a { + | ++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.rs b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.rs index 067ed7ea1..cad3e0f66 100644 --- a/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.rs +++ b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.rs @@ -1,7 +1,6 @@ +// check-pass // Regression test for issue #57611 // Ensures that we don't ICE -// FIXME: This should compile, but it currently doesn't -// known-bug: unknown #![feature(trait_alias)] #![feature(type_alias_impl_trait)] diff --git a/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr deleted file mode 100644 index 6344f114a..000000000 --- a/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-57611-trait-alias.rs:21:9 - | -LL | |x| x - | ^^^^^ one type is more general than the other - | - = note: expected trait `for<'a> Fn<(&'a X,)>` - found trait `Fn<(&X,)>` -note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-57611-trait-alias.rs:21:9 - | -LL | |x| x - | ^^^ - -error: implementation of `FnOnce` is not general enough - --> $DIR/issue-57611-trait-alias.rs:21:9 - | -LL | |x| x - | ^^^^^ implementation of `FnOnce` is not general enough - | - = note: closure with signature `fn(&'2 X) -> &X` must implement `FnOnce<(&'1 X,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 X,)>`, for some specific lifetime `'2` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/type-alias-impl-trait/issue-65384.rs b/src/test/ui/type-alias-impl-trait/issue-65384.rs index 9a119c4d2..9a9b2269f 100644 --- a/src/test/ui/type-alias-impl-trait/issue-65384.rs +++ b/src/test/ui/type-alias-impl-trait/issue-65384.rs @@ -8,7 +8,7 @@ impl MyTrait for () {} type Bar = impl MyTrait; impl MyTrait for Bar {} -//~^ ERROR: cannot implement trait on type alias impl trait +//~^ ERROR: conflicting implementations of trait `MyTrait` for type `()` fn bazr() -> Bar { } diff --git a/src/test/ui/type-alias-impl-trait/issue-65384.stderr b/src/test/ui/type-alias-impl-trait/issue-65384.stderr index 41bcea27e..f6692ae32 100644 --- a/src/test/ui/type-alias-impl-trait/issue-65384.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-65384.stderr @@ -1,14 +1,12 @@ -error: cannot implement trait on type alias impl trait - --> $DIR/issue-65384.rs:10:18 +error[E0119]: conflicting implementations of trait `MyTrait` for type `()` + --> $DIR/issue-65384.rs:10:1 | +LL | impl MyTrait for () {} + | ------------------- first implementation here +... LL | impl MyTrait for Bar {} - | ^^^ - | -note: type alias impl trait defined here - --> $DIR/issue-65384.rs:8:12 - | -LL | type Bar = impl MyTrait; - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `()` error: aborting due to previous error +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs b/src/test/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs index fb56cc54d..b97e444c6 100644 --- a/src/test/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs +++ b/src/test/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs @@ -1,6 +1,8 @@ // Regression test for issue #76202 // Tests that we don't ICE when we have a trait impl on a TAIT. +// check-pass + #![feature(type_alias_impl_trait)] trait Dummy {} @@ -14,7 +16,12 @@ trait Test { } impl Test for F { - //~^ ERROR cannot implement trait + fn test(self) {} +} + +// Ok because `i32` does not implement `Dummy`, +// so it can't possibly be the hidden type of `F`. +impl Test for i32 { fn test(self) {} } diff --git a/src/test/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.stderr b/src/test/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.stderr deleted file mode 100644 index 2d4a6854a..000000000 --- a/src/test/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: cannot implement trait on type alias impl trait - --> $DIR/issue-76202-trait-impl-for-tait.rs:16:15 - | -LL | impl Test for F { - | ^ - | -note: type alias impl trait defined here - --> $DIR/issue-76202-trait-impl-for-tait.rs:9:10 - | -LL | type F = impl Dummy; - | ^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/type-alias-impl-trait/issue-84660-trait-impl-for-tait.rs b/src/test/ui/type-alias-impl-trait/issue-84660-trait-impl-for-tait.rs index fa25d8f76..2ba4befea 100644 --- a/src/test/ui/type-alias-impl-trait/issue-84660-trait-impl-for-tait.rs +++ b/src/test/ui/type-alias-impl-trait/issue-84660-trait-impl-for-tait.rs @@ -1,6 +1,8 @@ // Regression test for issues #84660 and #86411: both are variations on #76202. // Tests that we don't ICE when we have an opaque type appearing anywhere in an impl header. +// check-pass + #![feature(type_alias_impl_trait)] trait Foo {} @@ -12,7 +14,7 @@ trait TraitArg<T> { fn f(); } -impl TraitArg<Bar> for () { //~ ERROR cannot implement trait +impl TraitArg<Bar> for () { fn f() { println!("ho"); } diff --git a/src/test/ui/type-alias-impl-trait/issue-84660-trait-impl-for-tait.stderr b/src/test/ui/type-alias-impl-trait/issue-84660-trait-impl-for-tait.stderr deleted file mode 100644 index bb70d07be..000000000 --- a/src/test/ui/type-alias-impl-trait/issue-84660-trait-impl-for-tait.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: cannot implement trait on type alias impl trait - --> $DIR/issue-84660-trait-impl-for-tait.rs:15:15 - | -LL | impl TraitArg<Bar> for () { - | ^^^ - | -note: type alias impl trait defined here - --> $DIR/issue-84660-trait-impl-for-tait.rs:8:12 - | -LL | type Bar = impl Foo; - | ^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/type-alias-impl-trait/issue-84660-unsoundness.rs b/src/test/ui/type-alias-impl-trait/issue-84660-unsoundness.rs index f12d1b6d9..48d4b0c96 100644 --- a/src/test/ui/type-alias-impl-trait/issue-84660-unsoundness.rs +++ b/src/test/ui/type-alias-impl-trait/issue-84660-unsoundness.rs @@ -13,14 +13,14 @@ trait Trait<T, In> { fn convert(i: In) -> Self::Out; } -impl<In, Out> Trait<Bar, In> for Out { //~ ERROR cannot implement trait +impl<In, Out> Trait<Bar, In> for Out { type Out = Out; fn convert(_i: In) -> Self::Out { unreachable!(); } } -impl<In, Out> Trait<(), In> for Out { +impl<In, Out> Trait<(), In> for Out { //~ ERROR conflicting implementations of trait `Trait<Bar, _>` type Out = In; fn convert(i: In) -> Self::Out { i diff --git a/src/test/ui/type-alias-impl-trait/issue-84660-unsoundness.stderr b/src/test/ui/type-alias-impl-trait/issue-84660-unsoundness.stderr index f2d600fb4..6a75e1bd2 100644 --- a/src/test/ui/type-alias-impl-trait/issue-84660-unsoundness.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-84660-unsoundness.stderr @@ -1,14 +1,12 @@ -error: cannot implement trait on type alias impl trait - --> $DIR/issue-84660-unsoundness.rs:16:21 +error[E0119]: conflicting implementations of trait `Trait<Bar, _>` + --> $DIR/issue-84660-unsoundness.rs:23:1 | LL | impl<In, Out> Trait<Bar, In> for Out { - | ^^^ - | -note: type alias impl trait defined here - --> $DIR/issue-84660-unsoundness.rs:8:12 - | -LL | type Bar = impl Foo; - | ^^^^^^^^ + | ------------------------------------ first implementation here +... +LL | impl<In, Out> Trait<(), In> for Out { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error: aborting due to previous error +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/type-alias-impl-trait/missing_lifetime_bound.rs b/src/test/ui/type-alias-impl-trait/missing_lifetime_bound.rs index 428194058..01d1f5db1 100644 --- a/src/test/ui/type-alias-impl-trait/missing_lifetime_bound.rs +++ b/src/test/ui/type-alias-impl-trait/missing_lifetime_bound.rs @@ -2,6 +2,6 @@ type Opaque<'a, T> = impl Sized; fn defining<'a, T>(x: &'a i32) -> Opaque<T> { x } -//~^ ERROR: non-defining opaque type use in defining scope +//~^ ERROR: hidden type for `Opaque<'a, T>` captures lifetime that does not appear in bounds fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/missing_lifetime_bound.stderr b/src/test/ui/type-alias-impl-trait/missing_lifetime_bound.stderr index df2b3ed19..65a0af0d2 100644 --- a/src/test/ui/type-alias-impl-trait/missing_lifetime_bound.stderr +++ b/src/test/ui/type-alias-impl-trait/missing_lifetime_bound.stderr @@ -1,8 +1,11 @@ -error: non-defining opaque type use in defining scope +error[E0700]: hidden type for `Opaque<'a, T>` captures lifetime that does not appear in bounds --> $DIR/missing_lifetime_bound.rs:4:47 | LL | fn defining<'a, T>(x: &'a i32) -> Opaque<T> { x } - | ^ lifetime `'a` is part of concrete type but not used in parameter list of the `impl Trait` type alias + | -- ^ + | | + | hidden type `&'a i32` captures the lifetime `'a` as defined here error: aborting due to previous error +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference3.rs b/src/test/ui/type-alias-impl-trait/nested-tait-inference3.rs index ebf3a99bb..b0ebdd1bf 100644 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference3.rs +++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference3.rs @@ -4,11 +4,11 @@ use std::fmt::Debug; type FooX = impl Debug; +//~^ ERROR unconstrained opaque type trait Foo<A> { } impl Foo<FooX> for () { } -//~^ cannot implement trait on type alias impl trait fn foo() -> impl Foo<FooX> { () diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference3.stderr b/src/test/ui/type-alias-impl-trait/nested-tait-inference3.stderr index 4a3fb1673..b1d947a9c 100644 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference3.stderr +++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference3.stderr @@ -1,14 +1,10 @@ -error: cannot implement trait on type alias impl trait - --> $DIR/nested-tait-inference3.rs:10:10 - | -LL | impl Foo<FooX> for () { } - | ^^^^ - | -note: type alias impl trait defined here +error: unconstrained opaque type --> $DIR/nested-tait-inference3.rs:6:13 | LL | type FooX = impl Debug; | ^^^^^^^^^^ + | + = note: `FooX` must be used in combination with a concrete type within the same module error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/self-referential-2.stderr b/src/test/ui/type-alias-impl-trait/self-referential-2.stderr index 2b505d307..c2cf70687 100644 --- a/src/test/ui/type-alias-impl-trait/self-referential-2.stderr +++ b/src/test/ui/type-alias-impl-trait/self-referential-2.stderr @@ -7,16 +7,7 @@ LL | 42_i32 | ------ return type was inferred to be `i32` here | = help: the trait `PartialEq<Foo>` is not implemented for `i32` - = help: the following other types implement trait `PartialEq<Rhs>`: - f32 - f64 - i128 - i16 - i32 - i64 - i8 - isize - and 6 others + = help: the trait `PartialEq` is implemented for `i32` error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/self-referential-4.stderr b/src/test/ui/type-alias-impl-trait/self-referential-4.stderr index 27880f792..98c762e3d 100644 --- a/src/test/ui/type-alias-impl-trait/self-referential-4.stderr +++ b/src/test/ui/type-alias-impl-trait/self-referential-4.stderr @@ -7,16 +7,7 @@ LL | i | - return type was inferred to be `&i32` here | = help: the trait `PartialEq<Bar<'b, 'static>>` is not implemented for `&i32` - = help: the following other types implement trait `PartialEq<Rhs>`: - f32 - f64 - i128 - i16 - i32 - i64 - i8 - isize - and 6 others + = help: the trait `PartialEq` is implemented for `i32` error[E0277]: can't compare `&i32` with `Foo<'static, 'b>` --> $DIR/self-referential-4.rs:11:31 @@ -27,16 +18,7 @@ LL | i | - return type was inferred to be `&i32` here | = help: the trait `PartialEq<Foo<'static, 'b>>` is not implemented for `&i32` - = help: the following other types implement trait `PartialEq<Rhs>`: - f32 - f64 - i128 - i16 - i32 - i64 - i8 - isize - and 6 others + = help: the trait `PartialEq` is implemented for `i32` error[E0277]: can't compare `&i32` with `Moo<'static, 'a>` --> $DIR/self-referential-4.rs:17:31 @@ -47,16 +29,7 @@ LL | i | - return type was inferred to be `&i32` here | = help: the trait `PartialEq<Moo<'static, 'a>>` is not implemented for `&i32` - = help: the following other types implement trait `PartialEq<Rhs>`: - f32 - f64 - i128 - i16 - i32 - i64 - i8 - isize - and 6 others + = help: the trait `PartialEq` is implemented for `i32` error: aborting due to 3 previous errors diff --git a/src/test/ui/type-alias-impl-trait/self-referential.stderr b/src/test/ui/type-alias-impl-trait/self-referential.stderr index 97d510f68..aff489d70 100644 --- a/src/test/ui/type-alias-impl-trait/self-referential.stderr +++ b/src/test/ui/type-alias-impl-trait/self-referential.stderr @@ -8,16 +8,7 @@ LL | i | - return type was inferred to be `&i32` here | = help: the trait `PartialEq<Bar<'b, 'a>>` is not implemented for `&i32` - = help: the following other types implement trait `PartialEq<Rhs>`: - f32 - f64 - i128 - i16 - i32 - i64 - i8 - isize - and 6 others + = help: the trait `PartialEq` is implemented for `i32` error[E0277]: can't compare `&i32` with `(i32, &i32)` --> $DIR/self-referential.rs:12:31 @@ -29,16 +20,7 @@ LL | (42, i) | ------- return type was inferred to be `(i32, &i32)` here | = help: the trait `PartialEq<(i32, &i32)>` is not implemented for `&i32` - = help: the following other types implement trait `PartialEq<Rhs>`: - f32 - f64 - i128 - i16 - i32 - i64 - i8 - isize - and 6 others + = help: the trait `PartialEq` is implemented for `i32` error[E0277]: can't compare `&i32` with `(i32, Moo<'b, 'a>::{opaque#0})` --> $DIR/self-referential.rs:19:31 @@ -50,16 +32,7 @@ LL | (42, i) | ------- return type was inferred to be `(i32, &i32)` here | = help: the trait `PartialEq<(i32, Moo<'b, 'a>::{opaque#0})>` is not implemented for `&i32` - = help: the following other types implement trait `PartialEq<Rhs>`: - f32 - f64 - i128 - i16 - i32 - i64 - i8 - isize - and 6 others + = help: the trait `PartialEq` is implemented for `i32` error: aborting due to 3 previous errors diff --git a/src/test/ui/type-alias-impl-trait/self_implication.rs b/src/test/ui/type-alias-impl-trait/self_implication.rs new file mode 100644 index 000000000..4e805ee30 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/self_implication.rs @@ -0,0 +1,38 @@ +// check-pass + +#![feature(type_alias_impl_trait)] +fn foo() { + struct Foo<'a> { + x: &'a mut u8, + } + impl<'a> Foo<'a> { + fn foo(&self) -> impl Sized {} + } + // use site + let mut x = 5; + let y = Foo { x: &mut x }; + let z = y.foo(); + let _a = &x; // invalidate the `&'a mut`in `y` + let _b = z; // this should *not* check that `'a` in the type `Foo<'a>::foo::opaque` is live +} + +fn bar() { + struct Foo<'a> { + x: &'a mut u8, + } + + // desugared + type FooX<'a> = impl Sized; + impl<'a> Foo<'a> { + fn foo(&self) -> FooX<'a> {} + } + + // use site + let mut x = 5; + let y = Foo { x: &mut x }; + let z = y.foo(); + let _a = &x; // invalidate the `&'a mut`in `y` + let _b = z; // this should *not* check that `'a` in the type `Foo<'a>::foo::opaque` is live +} + +fn main() {} diff --git a/src/test/ui/type/issue-103271.rs b/src/test/ui/type/issue-103271.rs new file mode 100644 index 000000000..7cd76286a --- /dev/null +++ b/src/test/ui/type/issue-103271.rs @@ -0,0 +1,18 @@ +fn main() { + let iter_fun = <&[u32]>::iter; + //~^ ERROR no function or associated item named `iter` found for reference `&[u32]` in the current scope [E0599] + //~| function or associated item not found in `&[u32]` + //~| HELP the function `iter` is implemented on `[u32]` + for item in iter_fun(&[1,1]) { + let x: &u32 = item; + assert_eq!(x, &1); + } + let iter_fun2 = <(&[u32])>::iter; + //~^ no function or associated item named `iter` found for reference `&[u32]` in the current scope [E0599] + //~| function or associated item not found in `&[u32]` + //~| HELP the function `iter` is implemented on `[u32]` + for item2 in iter_fun2(&[1,1]) { + let x: &u32 = item2; + assert_eq!(x, &1); + } +} diff --git a/src/test/ui/type/issue-103271.stderr b/src/test/ui/type/issue-103271.stderr new file mode 100644 index 000000000..f4dac51b2 --- /dev/null +++ b/src/test/ui/type/issue-103271.stderr @@ -0,0 +1,25 @@ +error[E0599]: no function or associated item named `iter` found for reference `&[u32]` in the current scope + --> $DIR/issue-103271.rs:2:30 + | +LL | let iter_fun = <&[u32]>::iter; + | ^^^^ function or associated item not found in `&[u32]` + | +help: the function `iter` is implemented on `[u32]` + | +LL | let iter_fun = <[u32]>::iter; + | ~~~~~ + +error[E0599]: no function or associated item named `iter` found for reference `&[u32]` in the current scope + --> $DIR/issue-103271.rs:10:33 + | +LL | let iter_fun2 = <(&[u32])>::iter; + | ^^^^ function or associated item not found in `&[u32]` + | +help: the function `iter` is implemented on `[u32]` + | +LL | let iter_fun2 = <([u32])>::iter; + | ~~~~~ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/type/issue-94187-verbose-type-name.rs b/src/test/ui/type/issue-94187-verbose-type-name.rs index 902ef5ade..3713a32eb 100644 --- a/src/test/ui/type/issue-94187-verbose-type-name.rs +++ b/src/test/ui/type/issue-94187-verbose-type-name.rs @@ -1,13 +1,16 @@ -// Check to insure that the output of `std::any::type_name` does not change based on -Zverbose -// when printing constants +// Check to insure that the output of `std::any::type_name` does not change based on `-Zverbose` // run-pass // edition: 2018 // revisions: normal verbose // [verbose]compile-flags:-Zverbose -struct Wrapper<const VALUE: usize>; +use std::any::type_name; fn main() { - assert_eq!(std::any::type_name::<[u32; 0]>(), "[u32; 0]"); - assert_eq!(std::any::type_name::<Wrapper<0>>(), "issue_94187_verbose_type_name::Wrapper<0>"); + assert_eq!(type_name::<[u32; 0]>(), "[u32; 0]"); + + struct Wrapper<const VALUE: usize>; + assert_eq!(type_name::<Wrapper<0>>(), "issue_94187_verbose_type_name::main::Wrapper<0>"); + + assert_eq!(type_name::<dyn Fn(u32) -> u32>(), "dyn core::ops::function::Fn(u32) -> u32"); } diff --git a/src/test/ui/type/type-ascription-soundness.rs b/src/test/ui/type/type-ascription-soundness.rs index d583fc213..08316cdcd 100644 --- a/src/test/ui/type/type-ascription-soundness.rs +++ b/src/test/ui/type/type-ascription-soundness.rs @@ -4,10 +4,10 @@ fn main() { let arr = &[1u8, 2, 3]; - let ref x = arr: &[u8]; //~ ERROR mismatched types - let ref mut x = arr: &[u8]; //~ ERROR mismatched types - match arr: &[u8] { //~ ERROR mismatched types + let ref x = type_ascribe!(arr, &[u8]); //~ ERROR mismatched types + let ref mut x = type_ascribe!(arr, &[u8]); //~ ERROR mismatched types + match type_ascribe!(arr, &[u8]) { //~ ERROR mismatched types ref x => {} } - let _len = (arr: &[u8]).len(); //~ ERROR mismatched types + let _len = type_ascribe!(arr, &[u8]).len(); //~ ERROR mismatched types } diff --git a/src/test/ui/type/type-ascription-soundness.stderr b/src/test/ui/type/type-ascription-soundness.stderr index 6ed940823..522d5b2e3 100644 --- a/src/test/ui/type/type-ascription-soundness.stderr +++ b/src/test/ui/type/type-ascription-soundness.stderr @@ -1,35 +1,35 @@ error[E0308]: mismatched types - --> $DIR/type-ascription-soundness.rs:7:17 + --> $DIR/type-ascription-soundness.rs:7:31 | -LL | let ref x = arr: &[u8]; - | ^^^ expected slice `[u8]`, found array `[u8; 3]` +LL | let ref x = type_ascribe!(arr, &[u8]); + | ^^^ expected slice `[u8]`, found array `[u8; 3]` | = note: expected reference `&[u8]` found reference `&[u8; 3]` error[E0308]: mismatched types - --> $DIR/type-ascription-soundness.rs:8:21 + --> $DIR/type-ascription-soundness.rs:8:35 | -LL | let ref mut x = arr: &[u8]; - | ^^^ expected slice `[u8]`, found array `[u8; 3]` +LL | let ref mut x = type_ascribe!(arr, &[u8]); + | ^^^ expected slice `[u8]`, found array `[u8; 3]` | = note: expected reference `&[u8]` found reference `&[u8; 3]` error[E0308]: mismatched types - --> $DIR/type-ascription-soundness.rs:9:11 + --> $DIR/type-ascription-soundness.rs:9:25 | -LL | match arr: &[u8] { - | ^^^ expected slice `[u8]`, found array `[u8; 3]` +LL | match type_ascribe!(arr, &[u8]) { + | ^^^ expected slice `[u8]`, found array `[u8; 3]` | = note: expected reference `&[u8]` found reference `&[u8; 3]` error[E0308]: mismatched types - --> $DIR/type-ascription-soundness.rs:12:17 + --> $DIR/type-ascription-soundness.rs:12:30 | -LL | let _len = (arr: &[u8]).len(); - | ^^^ expected slice `[u8]`, found array `[u8; 3]` +LL | let _len = type_ascribe!(arr, &[u8]).len(); + | ^^^ expected slice `[u8]`, found array `[u8; 3]` | = note: expected reference `&[u8]` found reference `&[u8; 3]` diff --git a/src/test/ui/type/type-ascription.rs b/src/test/ui/type/type-ascription.rs index 7adb07442..e4a4c89d0 100644 --- a/src/test/ui/type/type-ascription.rs +++ b/src/test/ui/type/type-ascription.rs @@ -8,32 +8,32 @@ use std::mem; -const C1: u8 = 10: u8; -const C2: [u8; 1: usize] = [1]; +const C1: u8 = type_ascribe!(10, u8); +const C2: [u8; type_ascribe!(1, usize)] = [1]; struct S { a: u8 } fn main() { - assert_eq!(C1.into(): i32, 10); + assert_eq!(type_ascribe!(C1.into(), i32), 10); assert_eq!(C2[0], 1); - let s = S { a: 10: u8 }; + let s = S { a: type_ascribe!(10, u8) }; let arr = &[1u8, 2, 3]; - let mut v = arr.iter().cloned().collect(): Vec<_>; + let mut v = type_ascribe!(arr.iter().cloned().collect(), Vec<_>); v.push(4); assert_eq!(v, [1, 2, 3, 4]); - let a = 1: u8; - let b = a.into(): u16; - assert_eq!(v[a.into(): usize], 2); + let a = type_ascribe!(1, u8); + let b = type_ascribe!(a.into(), u16); + assert_eq!(v[type_ascribe!(a.into(), usize)], 2); assert_eq!(mem::size_of_val(&a), 1); assert_eq!(mem::size_of_val(&b), 2); - assert_eq!(b, 1: u16); + assert_eq!(b, type_ascribe!(1, u16)); let mut v = Vec::new(); - v: Vec<u8> = vec![1, 2, 3]; // Place expression type ascription + type_ascribe!(v, Vec<u8>) = vec![1, 2, 3]; // Place expression type ascription assert_eq!(v, [1u8, 2, 3]); } diff --git a/src/test/ui/type/type-check-defaults.stderr b/src/test/ui/type/type-check-defaults.stderr index cf77c057d..9ba63ffe9 100644 --- a/src/test/ui/type/type-check-defaults.stderr +++ b/src/test/ui/type/type-check-defaults.stderr @@ -66,15 +66,10 @@ LL | trait ProjectionPred<T:Iterator = IntoIter<i32>> where T::Item : Add<u8> {} | = help: the trait `Add<u8>` is not implemented for `i32` = help: the following other types implement trait `Add<Rhs>`: - <&'a f32 as Add<f32>> - <&'a f64 as Add<f64>> - <&'a i128 as Add<i128>> - <&'a i16 as Add<i16>> <&'a i32 as Add<i32>> - <&'a i64 as Add<i64>> - <&'a i8 as Add<i8>> - <&'a isize as Add<isize>> - and 48 others + <&i32 as Add<&i32>> + <i32 as Add<&i32>> + <i32 as Add> error: aborting due to 7 previous errors diff --git a/src/test/ui/type/type-dependent-def-issue-49241.rs b/src/test/ui/type/type-dependent-def-issue-49241.rs index f37f093d9..caf5bade5 100644 --- a/src/test/ui/type/type-dependent-def-issue-49241.rs +++ b/src/test/ui/type/type-dependent-def-issue-49241.rs @@ -2,5 +2,5 @@ fn main() { let v = vec![0]; const l: usize = v.count(); //~ ERROR attempt to use a non-constant value in a constant let s: [u32; l] = v.into_iter().collect(); - //~^ERROR evaluation of constant value failed + //~^ constant } diff --git a/src/test/ui/type/type-dependent-def-issue-49241.stderr b/src/test/ui/type/type-dependent-def-issue-49241.stderr index 02f267c6c..af16a6e8f 100644 --- a/src/test/ui/type/type-dependent-def-issue-49241.stderr +++ b/src/test/ui/type/type-dependent-def-issue-49241.stderr @@ -6,13 +6,12 @@ LL | const l: usize = v.count(); | | | help: consider using `let` instead of `const`: `let l` -error[E0080]: evaluation of constant value failed +note: erroneous constant used --> $DIR/type-dependent-def-issue-49241.rs:4:18 | LL | let s: [u32; l] = v.into_iter().collect(); - | ^ referenced constant has errors + | ^ -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0080, E0435. -For more information about an error, try `rustc --explain E0080`. +For more information about this error, try `rustc --explain E0435`. diff --git a/src/test/ui/type_length_limit.rs b/src/test/ui/type_length_limit.rs index ce6fdf811..b3c127474 100644 --- a/src/test/ui/type_length_limit.rs +++ b/src/test/ui/type_length_limit.rs @@ -7,7 +7,7 @@ // The exact type depends on optimizations, so disable them. #![allow(dead_code)] -#![type_length_limit="4"] +#![type_length_limit="8"] macro_rules! link { ($id:ident, $t:ty) => { @@ -15,14 +15,19 @@ macro_rules! link { } } +link! { A1, B1 } +link! { B1, C1 } +link! { C1, D1 } +link! { D1, E1 } +link! { E1, A } link! { A, B } link! { B, C } link! { C, D } link! { D, E } link! { E, F } -link! { F, G } +link! { F, G<Option<i32>, Option<i32>> } -pub struct G; +pub struct G<T, K>(std::marker::PhantomData::<(T, K)>); fn main() { drop::<Option<A>>(None); diff --git a/src/test/ui/type_length_limit.stderr b/src/test/ui/type_length_limit.stderr index 84ac48b1e..ff4874669 100644 --- a/src/test/ui/type_length_limit.stderr +++ b/src/test/ui/type_length_limit.stderr @@ -1,20 +1,11 @@ -error: reached the type-length limit while instantiating `std::mem::drop::<Option<((((...,....., ...), ..., ...), ..., ...)>>` +error: reached the type-length limit while instantiating `std::mem::drop::<Option<((((..., ..., ...), ..., ...), ..., ...), ..., ...)>>` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub fn drop<T>(_x: T) {} | ^^^^^^^^^^^^^^^^^^^^^ | - = help: consider adding a `#![type_length_limit="8"]` attribute to your crate + = help: consider adding a `#![type_length_limit="10"]` attribute to your crate = note: the full type name has been written to '$TEST_BUILD_DIR/type_length_limit/type_length_limit.long-type.txt' -error: reached the type-length limit while instantiating `<[closure@std::rt::lang_start<()...e<()>>::call_once - shim(vtable)` - --> $SRC_DIR/core/src/ops/function.rs:LL:COL - | -LL | extern "rust-call" fn call_once(self, args: Args) -> Self::Output; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: consider adding a `#![type_length_limit="8"]` attribute to your crate - = note: the full type name has been written to '$TEST_BUILD_DIR/type_length_limit/type_length_limit.long-type.txt' - -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/src/test/ui/typeck/issue-103899.rs b/src/test/ui/typeck/issue-103899.rs new file mode 100644 index 000000000..ac9e4c716 --- /dev/null +++ b/src/test/ui/typeck/issue-103899.rs @@ -0,0 +1,30 @@ +// check-fail +// failure-status: 101 +// dont-check-compiler-stderr +// known-bug: #103899 + +trait BaseWithAssoc { + type Assoc; +} + +trait WrapperWithAssoc { + type BaseAssoc: BaseWithAssoc; +} + +struct Wrapper<B> { + inner: B, +} + +struct ProjectToBase<T: BaseWithAssoc> { + data_type_h: T::Assoc, +} + +struct DoubleProject<L: WrapperWithAssoc> { + buffer: Wrapper<ProjectToBase<L::BaseAssoc>>, +} + +fn trigger<L: WrapperWithAssoc<BaseAssoc = ()>>() -> DoubleProject<L> { + loop {} +} + +fn main() {} diff --git a/src/test/ui/typeck/issue-104510-ice.rs b/src/test/ui/typeck/issue-104510-ice.rs new file mode 100644 index 000000000..157bdf07e --- /dev/null +++ b/src/test/ui/typeck/issue-104510-ice.rs @@ -0,0 +1,16 @@ +// needs-asm-support +// only-x86_64 + +struct W<T: ?Sized>(Oops); +//~^ ERROR cannot find type `Oops` in this scope + +unsafe fn test() { + let j = W(()); + let pointer = &j as *const _; + core::arch::asm!( + "nop", + in("eax") pointer, + ); +} + +fn main() {} diff --git a/src/test/ui/typeck/issue-104510-ice.stderr b/src/test/ui/typeck/issue-104510-ice.stderr new file mode 100644 index 000000000..ddb510ef0 --- /dev/null +++ b/src/test/ui/typeck/issue-104510-ice.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `Oops` in this scope + --> $DIR/issue-104510-ice.rs:4:21 + | +LL | struct W<T: ?Sized>(Oops); + | ^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/src/test/ui/typeck/issue-104513-ice.rs b/src/test/ui/typeck/issue-104513-ice.rs new file mode 100644 index 000000000..bcac0fa1e --- /dev/null +++ b/src/test/ui/typeck/issue-104513-ice.rs @@ -0,0 +1,6 @@ +struct S; +fn f() { + let _: S<impl Oops> = S; //~ ERROR cannot find trait `Oops` in this scope + //~^ ERROR `impl Trait` only allowed in function and inherent method return types +} +fn main() {} diff --git a/src/test/ui/typeck/issue-104513-ice.stderr b/src/test/ui/typeck/issue-104513-ice.stderr new file mode 100644 index 000000000..2b3b1b9ef --- /dev/null +++ b/src/test/ui/typeck/issue-104513-ice.stderr @@ -0,0 +1,18 @@ +error[E0405]: cannot find trait `Oops` in this scope + --> $DIR/issue-104513-ice.rs:3:19 + | +LL | fn f() { + | - help: you might be missing a type parameter: `<Oops>` +LL | let _: S<impl Oops> = S; + | ^^^^ not found in this scope + +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding + --> $DIR/issue-104513-ice.rs:3:14 + | +LL | let _: S<impl Oops> = S; + | ^^^^^^^^^ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0405, E0562. +For more information about an error, try `rustc --explain E0405`. diff --git a/src/test/ui/issues/issue-10969.rs b/src/test/ui/typeck/issue-10969.rs index 0b78fc1bb..0b78fc1bb 100644 --- a/src/test/ui/issues/issue-10969.rs +++ b/src/test/ui/typeck/issue-10969.rs diff --git a/src/test/ui/issues/issue-10969.stderr b/src/test/ui/typeck/issue-10969.stderr index f64b61aae..f64b61aae 100644 --- a/src/test/ui/issues/issue-10969.stderr +++ b/src/test/ui/typeck/issue-10969.stderr diff --git a/src/test/ui/issues/issue-50687-ice-on-borrow.rs b/src/test/ui/typeck/issue-50687-ice-on-borrow.rs index 7a8a12c2a..7a8a12c2a 100644 --- a/src/test/ui/issues/issue-50687-ice-on-borrow.rs +++ b/src/test/ui/typeck/issue-50687-ice-on-borrow.rs diff --git a/src/test/ui/issues/issue-50687-ice-on-borrow.stderr b/src/test/ui/typeck/issue-50687-ice-on-borrow.stderr index e6a0edac4..e6a0edac4 100644 --- a/src/test/ui/issues/issue-50687-ice-on-borrow.stderr +++ b/src/test/ui/typeck/issue-50687-ice-on-borrow.stderr diff --git a/src/test/ui/typeck/issue-81293.stderr b/src/test/ui/typeck/issue-81293.stderr index 9658288ac..6976be711 100644 --- a/src/test/ui/typeck/issue-81293.stderr +++ b/src/test/ui/typeck/issue-81293.stderr @@ -21,15 +21,10 @@ LL | a = c + b * 5; | = help: the trait `Add<u16>` is not implemented for `usize` = help: the following other types implement trait `Add<Rhs>`: - <&'a f32 as Add<f32>> - <&'a f64 as Add<f64>> - <&'a i128 as Add<i128>> - <&'a i16 as Add<i16>> - <&'a i32 as Add<i32>> - <&'a i64 as Add<i64>> - <&'a i8 as Add<i8>> - <&'a isize as Add<isize>> - and 48 others + <&'a usize as Add<usize>> + <&usize as Add<&usize>> + <usize as Add<&usize>> + <usize as Add> error: aborting due to 3 previous errors diff --git a/src/test/ui/typeck/issue-83693.stderr b/src/test/ui/typeck/issue-83693.stderr index 0d8bbf1ce..1e45c2d35 100644 --- a/src/test/ui/typeck/issue-83693.stderr +++ b/src/test/ui/typeck/issue-83693.stderr @@ -6,8 +6,8 @@ LL | impl F { | ::: $SRC_DIR/core/src/ops/function.rs:LL:COL | -LL | pub trait Fn<Args>: FnMut<Args> { - | ------------------------------- similarly named trait `Fn` defined here +LL | pub trait Fn<Args: Tuple>: FnMut<Args> { + | -------------------------------------- similarly named trait `Fn` defined here error[E0412]: cannot find type `TestResult` in this scope --> $DIR/issue-83693.rs:9:22 diff --git a/src/test/ui/typeck/issue-91267.rs b/src/test/ui/typeck/issue-91267.rs index f5a37e9cb..4e39cfab5 100644 --- a/src/test/ui/typeck/issue-91267.rs +++ b/src/test/ui/typeck/issue-91267.rs @@ -1,5 +1,7 @@ +#![feature(type_ascription)] + fn main() { - 0: u8<e<5>=e> + type_ascribe!(0, u8<e<5>=e>) //~^ ERROR: cannot find type `e` in this scope [E0412] //~| ERROR: associated type bindings are not allowed here [E0229] //~| ERROR: mismatched types [E0308] diff --git a/src/test/ui/typeck/issue-91267.stderr b/src/test/ui/typeck/issue-91267.stderr index aac00b9b6..72acd9c67 100644 --- a/src/test/ui/typeck/issue-91267.stderr +++ b/src/test/ui/typeck/issue-91267.stderr @@ -1,25 +1,22 @@ error[E0412]: cannot find type `e` in this scope - --> $DIR/issue-91267.rs:2:16 + --> $DIR/issue-91267.rs:4:30 | -LL | 0: u8<e<5>=e> - | ^ - | | - | not found in this scope - | help: maybe you meant to write an assignment here: `let e` +LL | type_ascribe!(0, u8<e<5>=e>) + | ^ not found in this scope error[E0229]: associated type bindings are not allowed here - --> $DIR/issue-91267.rs:2:11 + --> $DIR/issue-91267.rs:4:25 | -LL | 0: u8<e<5>=e> - | ^^^^^^ associated type not allowed here +LL | type_ascribe!(0, u8<e<5>=e>) + | ^^^^^^ associated type not allowed here error[E0308]: mismatched types - --> $DIR/issue-91267.rs:2:5 + --> $DIR/issue-91267.rs:4:5 | LL | fn main() { | - expected `()` because of default return type -LL | 0: u8<e<5>=e> - | ^^^^^^^^^^^^^ expected `()`, found `u8` +LL | type_ascribe!(0, u8<e<5>=e>) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `u8` error: aborting due to 3 previous errors diff --git a/src/test/ui/typeck/path-to-method-sugg-unresolved-expr.rs b/src/test/ui/typeck/path-to-method-sugg-unresolved-expr.rs new file mode 100644 index 000000000..fb56b3944 --- /dev/null +++ b/src/test/ui/typeck/path-to-method-sugg-unresolved-expr.rs @@ -0,0 +1,4 @@ +fn main() { + let page_size = page_size::get(); + //~^ ERROR failed to resolve: use of undeclared crate or module `page_size` +} diff --git a/src/test/ui/typeck/path-to-method-sugg-unresolved-expr.stderr b/src/test/ui/typeck/path-to-method-sugg-unresolved-expr.stderr new file mode 100644 index 000000000..b01e30be5 --- /dev/null +++ b/src/test/ui/typeck/path-to-method-sugg-unresolved-expr.stderr @@ -0,0 +1,9 @@ +error[E0433]: failed to resolve: use of undeclared crate or module `page_size` + --> $DIR/path-to-method-sugg-unresolved-expr.rs:2:21 + | +LL | let page_size = page_size::get(); + | ^^^^^^^^^ use of undeclared crate or module `page_size` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/issues/issue-29184.rs b/src/test/ui/typeof/issue-29184.rs index c77e364c3..c77e364c3 100644 --- a/src/test/ui/issues/issue-29184.rs +++ b/src/test/ui/typeof/issue-29184.rs diff --git a/src/test/ui/issues/issue-29184.stderr b/src/test/ui/typeof/issue-29184.stderr index 75b6c64f2..75b6c64f2 100644 --- a/src/test/ui/issues/issue-29184.stderr +++ b/src/test/ui/typeof/issue-29184.stderr diff --git a/src/test/ui/issues/issue-42060.rs b/src/test/ui/typeof/issue-42060.rs index 1740b2383..1740b2383 100644 --- a/src/test/ui/issues/issue-42060.rs +++ b/src/test/ui/typeof/issue-42060.rs diff --git a/src/test/ui/issues/issue-42060.stderr b/src/test/ui/typeof/issue-42060.stderr index effcbe4d7..effcbe4d7 100644 --- a/src/test/ui/issues/issue-42060.stderr +++ b/src/test/ui/typeof/issue-42060.stderr diff --git a/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr b/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr index eaab6ff3d..ed56e1cf9 100644 --- a/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr +++ b/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr @@ -8,15 +8,10 @@ LL | <i32 as Add<u32>>::add(1, 2); | = help: the trait `Add<u32>` is not implemented for `i32` = help: the following other types implement trait `Add<Rhs>`: - <&'a f32 as Add<f32>> - <&'a f64 as Add<f64>> - <&'a i128 as Add<i128>> - <&'a i16 as Add<i16>> <&'a i32 as Add<i32>> - <&'a i64 as Add<i64>> - <&'a i8 as Add<i8>> - <&'a isize as Add<isize>> - and 48 others + <&i32 as Add<&i32>> + <i32 as Add<&i32>> + <i32 as Add> error[E0308]: mismatched types --> $DIR/ufcs-qpath-self-mismatch.rs:7:28 @@ -62,15 +57,10 @@ LL | <i32 as Add<u32>>::add(1, 2); | = help: the trait `Add<u32>` is not implemented for `i32` = help: the following other types implement trait `Add<Rhs>`: - <&'a f32 as Add<f32>> - <&'a f64 as Add<f64>> - <&'a i128 as Add<i128>> - <&'a i16 as Add<i16>> <&'a i32 as Add<i32>> - <&'a i64 as Add<i64>> - <&'a i8 as Add<i8>> - <&'a isize as Add<isize>> - and 48 others + <&i32 as Add<&i32>> + <i32 as Add<&i32>> + <i32 as Add> error: aborting due to 4 previous errors diff --git a/src/test/ui/unboxed-closures/non-tupled-arg-mismatch.rs b/src/test/ui/unboxed-closures/non-tupled-arg-mismatch.rs index 925463d6d..d2e486002 100644 --- a/src/test/ui/unboxed-closures/non-tupled-arg-mismatch.rs +++ b/src/test/ui/unboxed-closures/non-tupled-arg-mismatch.rs @@ -1,8 +1,8 @@ #![feature(unboxed_closures)] fn a<F: Fn<usize>>(f: F) {} +//~^ ERROR type parameter to bare `Fn` trait must be a tuple fn main() { a(|_: usize| {}); - //~^ ERROR mismatched types } diff --git a/src/test/ui/unboxed-closures/non-tupled-arg-mismatch.stderr b/src/test/ui/unboxed-closures/non-tupled-arg-mismatch.stderr index 9a24fb8c2..1c18eb0fc 100644 --- a/src/test/ui/unboxed-closures/non-tupled-arg-mismatch.stderr +++ b/src/test/ui/unboxed-closures/non-tupled-arg-mismatch.stderr @@ -1,17 +1,15 @@ -error[E0308]: mismatched types - --> $DIR/non-tupled-arg-mismatch.rs:6:5 - | -LL | a(|_: usize| {}); - | ^ types differ - | - = note: expected trait `Fn<usize>` - found trait `Fn<(usize,)>` -note: required by a bound in `a` +error[E0059]: type parameter to bare `Fn` trait must be a tuple --> $DIR/non-tupled-arg-mismatch.rs:3:9 | LL | fn a<F: Fn<usize>>(f: F) {} - | ^^^^^^^^^ required by this bound in `a` + | ^^^^^^^^^ the trait `Tuple` is not implemented for `usize` + | +note: required by a bound in `Fn` + --> $SRC_DIR/core/src/ops/function.rs:LL:COL + | +LL | pub trait Fn<Args: Tuple>: FnMut<Args> { + | ^^^^^ required by this bound in `Fn` error: aborting due to previous error -For more information about this error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0059`. diff --git a/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.rs b/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.rs index ed8d72114..7377359b6 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.rs @@ -1,12 +1,12 @@ -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] // Tests that we can't move out of an unboxed closure environment // if the upvar is captured by ref or the closure takes self by // reference. -fn to_fn<A,F:Fn<A>>(f: F) -> F { f } -fn to_fn_mut<A,F:FnMut<A>>(f: F) -> F { f } -fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f } +fn to_fn<A:std::marker::Tuple,F:Fn<A>>(f: F) -> F { f } +fn to_fn_mut<A:std::marker::Tuple,F:FnMut<A>>(f: F) -> F { f } +fn to_fn_once<A:std::marker::Tuple,F:FnOnce<A>>(f: F) -> F { f } fn main() { // By-ref cases diff --git a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.rs b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.rs index 57e6d3065..c57312b43 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.rs @@ -2,12 +2,12 @@ // as `mut` through a closure. Also test that we CAN mutate a moved copy, // unless this is a `Fn` closure. Issue #16749. -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] use std::mem; -fn to_fn<A,F:Fn<A>>(f: F) -> F { f } -fn to_fn_mut<A,F:FnMut<A>>(f: F) -> F { f } +fn to_fn<A:std::marker::Tuple,F:Fn<A>>(f: F) -> F { f } +fn to_fn_mut<A:std::marker::Tuple,F:FnMut<A>>(f: F) -> F { f } fn a() { let n = 0; diff --git a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr index d6e74b5b8..26f97b519 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr @@ -28,8 +28,8 @@ LL | n += 1; error[E0594]: cannot assign to `n`, as it is a captured variable in a `Fn` closure --> $DIR/unboxed-closures-mutate-upvar.rs:53:9 | -LL | fn to_fn<A,F:Fn<A>>(f: F) -> F { f } - | - change this to accept `FnMut` instead of `Fn` +LL | fn to_fn<A:std::marker::Tuple,F:Fn<A>>(f: F) -> F { f } + | - change this to accept `FnMut` instead of `Fn` ... LL | let mut f = to_fn(move || { | ----- ------- in this closure diff --git a/src/test/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.rs b/src/test/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.rs index 0e727b11c..7289d9322 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.rs @@ -1,6 +1,6 @@ -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] -fn to_fn_mut<A,F:FnMut<A>>(f: F) -> F { f } +fn to_fn_mut<A:std::marker::Tuple,F:FnMut<A>>(f: F) -> F { f } fn main() { let mut_ = to_fn_mut(|x| x); diff --git a/src/test/ui/underscore-ident-matcher.stderr b/src/test/ui/underscore-ident-matcher.stderr index 241c3d3d8..b0e4d88f6 100644 --- a/src/test/ui/underscore-ident-matcher.stderr +++ b/src/test/ui/underscore-ident-matcher.stderr @@ -6,6 +6,12 @@ LL | macro_rules! identity { ... LL | let identity!(_) = 10; | ^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$i:ident` + --> $DIR/underscore-ident-matcher.rs:2:6 + | +LL | ($i: ident) => ( + | ^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/union/union-move.mirunsafeck.stderr b/src/test/ui/union/union-move.mirunsafeck.stderr index 53050cf53..6381ae874 100644 --- a/src/test/ui/union/union-move.mirunsafeck.stderr +++ b/src/test/ui/union/union-move.mirunsafeck.stderr @@ -8,6 +8,14 @@ LL | move_out(x.f1_nocopy); | ----------- value moved here LL | move_out(x.f2_nocopy); | ^^^^^^^^^^^ value used here after move + | +note: consider changing this parameter type in function `move_out` to borrow instead if owning the value isn't necessary + --> $DIR/union-move.rs:10:19 + | +LL | fn move_out<T>(x: T) {} + | -------- ^ this parameter takes ownership of the value + | | + | in this function error[E0382]: use of moved value: `x` --> $DIR/union-move.rs:45:18 @@ -19,6 +27,14 @@ LL | move_out(x.f2_nocopy); | ----------- value moved here LL | move_out(x.f3_copy); | ^^^^^^^^^ value used here after move + | +note: consider changing this parameter type in function `move_out` to borrow instead if owning the value isn't necessary + --> $DIR/union-move.rs:10:19 + | +LL | fn move_out<T>(x: T) {} + | -------- ^ this parameter takes ownership of the value + | | + | in this function error[E0509]: cannot move out of type `U2`, which implements the `Drop` trait --> $DIR/union-move.rs:52:18 diff --git a/src/test/ui/union/union-move.thirunsafeck.stderr b/src/test/ui/union/union-move.thirunsafeck.stderr index 53050cf53..6381ae874 100644 --- a/src/test/ui/union/union-move.thirunsafeck.stderr +++ b/src/test/ui/union/union-move.thirunsafeck.stderr @@ -8,6 +8,14 @@ LL | move_out(x.f1_nocopy); | ----------- value moved here LL | move_out(x.f2_nocopy); | ^^^^^^^^^^^ value used here after move + | +note: consider changing this parameter type in function `move_out` to borrow instead if owning the value isn't necessary + --> $DIR/union-move.rs:10:19 + | +LL | fn move_out<T>(x: T) {} + | -------- ^ this parameter takes ownership of the value + | | + | in this function error[E0382]: use of moved value: `x` --> $DIR/union-move.rs:45:18 @@ -19,6 +27,14 @@ LL | move_out(x.f2_nocopy); | ----------- value moved here LL | move_out(x.f3_copy); | ^^^^^^^^^ value used here after move + | +note: consider changing this parameter type in function `move_out` to borrow instead if owning the value isn't necessary + --> $DIR/union-move.rs:10:19 + | +LL | fn move_out<T>(x: T) {} + | -------- ^ this parameter takes ownership of the value + | | + | in this function error[E0509]: cannot move out of type `U2`, which implements the `Drop` trait --> $DIR/union-move.rs:52:18 diff --git a/src/test/ui/unop-move-semantics.stderr b/src/test/ui/unop-move-semantics.stderr index 65d866c71..d52a92b88 100644 --- a/src/test/ui/unop-move-semantics.stderr +++ b/src/test/ui/unop-move-semantics.stderr @@ -14,6 +14,10 @@ note: calling this operator moves the left-hand side | LL | fn not(self) -> Self::Output; | ^^^^ +help: consider cloning the value if the performance cost is acceptable + | +LL | !x.clone(); + | ++++++++ help: consider further restricting this bound | LL | fn move_then_borrow<T: Not<Output=T> + Clone + Copy>(x: T) { diff --git a/src/test/ui/unsafe/unsafe-not-inherited.rs b/src/test/ui/unsafe/unsafe-not-inherited.rs new file mode 100644 index 000000000..6d797caa0 --- /dev/null +++ b/src/test/ui/unsafe/unsafe-not-inherited.rs @@ -0,0 +1,26 @@ +#![allow(unused, dead_code)] + +static mut FOO: u64 = 0; + +fn static_mod() { + unsafe {static BAR: u64 = FOO;} + //~^ ERROR: use of mutable static is unsafe + //~| NOTE: use of mutable static + //~| NOTE: mutable statics can be mutated by multiple threads + //~| NOTE: items do not inherit unsafety +} + +unsafe fn unsafe_call() {} +fn foo() { + unsafe { + //~^ NOTE: items do not inherit unsafety + fn bar() { + unsafe_call(); + //~^ ERROR: call to unsafe function + //~| NOTE: call to unsafe function + //~| NOTE: consult the function's documentation + } + } +} + +fn main() {} diff --git a/src/test/ui/unsafe/unsafe-not-inherited.stderr b/src/test/ui/unsafe/unsafe-not-inherited.stderr new file mode 100644 index 000000000..3bc5ca5c9 --- /dev/null +++ b/src/test/ui/unsafe/unsafe-not-inherited.stderr @@ -0,0 +1,24 @@ +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/unsafe-not-inherited.rs:6:31 + | +LL | unsafe {static BAR: u64 = FOO;} + | ------ ^^^ use of mutable static + | | + | items do not inherit unsafety from separate enclosing items + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error[E0133]: call to unsafe function is unsafe and requires unsafe function or block + --> $DIR/unsafe-not-inherited.rs:18:13 + | +LL | unsafe { + | ------ items do not inherit unsafety from separate enclosing items +... +LL | unsafe_call(); + | ^^^^^^^^^^^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/unsized-locals/borrow-after-move.stderr b/src/test/ui/unsized-locals/borrow-after-move.stderr index 28ae1c068..d8bffd4f9 100644 --- a/src/test/ui/unsized-locals/borrow-after-move.stderr +++ b/src/test/ui/unsized-locals/borrow-after-move.stderr @@ -28,6 +28,14 @@ LL | drop_unsized(y); ... LL | println!("{}", &y); | ^^ value borrowed here after move + | +note: consider changing this parameter type in function `drop_unsized` to borrow instead if owning the value isn't necessary + --> $DIR/borrow-after-move.rs:14:31 + | +LL | fn drop_unsized<T: ?Sized>(_: T) {} + | ------------ ^ this parameter takes ownership of the value + | | + | in this function error[E0382]: borrow of moved value: `x` --> $DIR/borrow-after-move.rs:31:24 @@ -66,6 +74,11 @@ LL | x.foo(); | - value moved here LL | println!("{}", &x); | ^^ value borrowed here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | x.clone().foo(); + | ++++++++ error: aborting due to 5 previous errors; 1 warning emitted diff --git a/src/test/ui/unsized-locals/double-move.stderr b/src/test/ui/unsized-locals/double-move.stderr index dfae6cc75..715348181 100644 --- a/src/test/ui/unsized-locals/double-move.stderr +++ b/src/test/ui/unsized-locals/double-move.stderr @@ -16,6 +16,14 @@ LL | drop_unsized(y); | - value moved here LL | drop_unsized(y); | ^ value used here after move + | +note: consider changing this parameter type in function `drop_unsized` to borrow instead if owning the value isn't necessary + --> $DIR/double-move.rs:14:31 + | +LL | fn drop_unsized<T: ?Sized>(_: T) {} + | ------------ ^ this parameter takes ownership of the value + | | + | in this function error[E0382]: use of moved value: `x` --> $DIR/double-move.rs:27:22 diff --git a/src/test/ui/use/use-after-move-based-on-type.stderr b/src/test/ui/use/use-after-move-based-on-type.stderr index 445f14d65..7b4d24549 100644 --- a/src/test/ui/use/use-after-move-based-on-type.stderr +++ b/src/test/ui/use/use-after-move-based-on-type.stderr @@ -9,6 +9,10 @@ LL | println!("{}", x); | ^ value borrowed here after move | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider cloning the value if the performance cost is acceptable + | +LL | let _y = x.clone(); + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/use/use-after-move-implicity-coerced-object.stderr b/src/test/ui/use/use-after-move-implicity-coerced-object.stderr index 26804216d..dfa0c0483 100644 --- a/src/test/ui/use/use-after-move-implicity-coerced-object.stderr +++ b/src/test/ui/use/use-after-move-implicity-coerced-object.stderr @@ -9,6 +9,14 @@ LL | l.push(n); LL | LL | let x = n.to_string(); | ^^^^^^^^^^^^^ value borrowed here after move + | +note: consider changing this parameter type in method `push` to borrow instead if owning the value isn't necessary + --> $DIR/use-after-move-implicity-coerced-object.rs:17:27 + | +LL | fn push(&mut self, n: Box<dyn ToString + 'static>) { + | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ this parameter takes ownership of the value + | | + | in this method error: aborting due to previous error diff --git a/src/test/ui/use/use-crate-self.rs b/src/test/ui/use/use-crate-self.rs new file mode 100644 index 000000000..65ab94814 --- /dev/null +++ b/src/test/ui/use/use-crate-self.rs @@ -0,0 +1,4 @@ +use crate::{self}; + //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` + +fn main() {} diff --git a/src/test/ui/use/use-crate-self.stderr b/src/test/ui/use/use-crate-self.stderr new file mode 100644 index 000000000..dd4036bff --- /dev/null +++ b/src/test/ui/use/use-crate-self.stderr @@ -0,0 +1,8 @@ +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-crate-self.rs:1:13 + | +LL | use crate::{self}; + | ^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/weird-exprs.rs b/src/test/ui/weird-exprs.rs index 4066bcf3b..d65703ef5 100644 --- a/src/test/ui/weird-exprs.rs +++ b/src/test/ui/weird-exprs.rs @@ -8,6 +8,7 @@ #![allow(unreachable_code)] #![allow(unused_braces, unused_must_use, unused_parens)] #![allow(uncommon_codepoints, confusable_idents)] +#![allow(unreachable_patterns)] #![recursion_limit = "256"] @@ -194,6 +195,15 @@ fn bathroom_stall() { assert_eq!(i, 13); } +fn closure_matching() { + let x = |_| Some(1); + let (|x| x) = match x(..) { + |_| Some(2) => |_| Some(3), + |_| _ => unreachable!(), + }; + assert!(matches!(x(..), |_| Some(4))); +} + pub fn main() { strange(); funny(); @@ -216,4 +226,5 @@ pub fn main() { 𝚌𝚘𝚗𝚝𝚒𝚗𝚞𝚎(); function(); bathroom_stall(); + closure_matching(); } diff --git a/src/test/ui/where-clauses/higher-ranked-fn-type.rs b/src/test/ui/where-clauses/higher-ranked-fn-type.rs index ab6edde4e..c19e75eb7 100644 --- a/src/test/ui/where-clauses/higher-ranked-fn-type.rs +++ b/src/test/ui/where-clauses/higher-ranked-fn-type.rs @@ -19,7 +19,7 @@ where { called() //[quiet]~^ ERROR the trait bound `for<'b> fn(&'b ()): Foo` is not satisfied - //[verbose]~^^ ERROR the trait bound `for<'b> fn(&ReLateBound( + //[verbose]~^^ ERROR the trait bound `for<Region( } fn main() {} diff --git a/src/test/ui/where-clauses/higher-ranked-fn-type.verbose.stderr b/src/test/ui/where-clauses/higher-ranked-fn-type.verbose.stderr index 24660ec35..268cef6e2 100644 --- a/src/test/ui/where-clauses/higher-ranked-fn-type.verbose.stderr +++ b/src/test/ui/where-clauses/higher-ranked-fn-type.verbose.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `for<'b> fn(&ReLateBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrNamed(DefId(0:6 ~ higher_ranked_fn_type[1209]::called::'b), 'b) }) ()): Foo` is not satisfied +error[E0277]: the trait bound `for<Region(BrNamed(DefId(0:6 ~ higher_ranked_fn_type[1209]::called::'b), 'b))> fn(&ReLateBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrNamed(DefId(0:6 ~ higher_ranked_fn_type[1209]::called::'b), 'b) }) ()): Foo` is not satisfied --> $DIR/higher-ranked-fn-type.rs:20:5 | LL | called() - | ^^^^^^ the trait `for<'b> Foo` is not implemented for `fn(&ReLateBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrNamed(DefId(0:6 ~ higher_ranked_fn_type[1209]::called::'b), 'b) }) ())` + | ^^^^^^ the trait `for<Region(BrNamed(DefId(0:6 ~ higher_ranked_fn_type[1209]::called::'b), 'b))> Foo` is not implemented for `fn(&ReLateBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrNamed(DefId(0:6 ~ higher_ranked_fn_type[1209]::called::'b), 'b) }) ())` | note: required by a bound in `called` --> $DIR/higher-ranked-fn-type.rs:12:25 |