diff options
Diffstat (limited to 'tests')
649 files changed, 5714 insertions, 2161 deletions
diff --git a/tests/assembly/asm/arm-types.rs b/tests/assembly/asm/arm-types.rs index b22a26ce36f..9520f932779 100644 --- a/tests/assembly/asm/arm-types.rs +++ b/tests/assembly/asm/arm-types.rs @@ -1,6 +1,7 @@ // assembly-output: emit-asm // compile-flags: --target armv7-unknown-linux-gnueabihf // compile-flags: -C target-feature=+neon +// compile-flags: -C opt-level=0 // needs-llvm-components: arm #![feature(no_core, lang_items, rustc_attrs, repr_simd)] diff --git a/tests/assembly/closure-inherit-target-feature.rs b/tests/assembly/closure-inherit-target-feature.rs index 65728a15516..24802603452 100644 --- a/tests/assembly/closure-inherit-target-feature.rs +++ b/tests/assembly/closure-inherit-target-feature.rs @@ -22,6 +22,7 @@ pub unsafe fn sse41_blend_nofeature(x: __m128, y: __m128) -> __m128 { f(x, y) } +#[no_mangle] #[target_feature(enable = "sse4.1")] pub fn sse41_blend_noinline(x: __m128, y: __m128) -> __m128 { let f = { diff --git a/tests/assembly/dwarf5.rs b/tests/assembly/dwarf5.rs index f41e6bd55be..253baafb887 100644 --- a/tests/assembly/dwarf5.rs +++ b/tests/assembly/dwarf5.rs @@ -1,6 +1,6 @@ // Makes sure that `-Z dwarf-version=5` causes `rustc` to emit DWARF version 5. // assembly-output: emit-asm -// compile-flags: -g --target x86_64-unknown-linux-gnu -Z dwarf-version=5 +// compile-flags: -g --target x86_64-unknown-linux-gnu -Z dwarf-version=5 -Copt-level=0 // needs-llvm-components: x86 #![feature(no_core, lang_items)] diff --git a/tests/assembly/libs/issue-115339-zip-arrays.rs b/tests/assembly/libs/issue-115339-zip-arrays.rs new file mode 100644 index 00000000000..26b7b9770bc --- /dev/null +++ b/tests/assembly/libs/issue-115339-zip-arrays.rs @@ -0,0 +1,25 @@ +// assembly-output: emit-asm +// # zen3 previously exhibited odd vectorization +// compile-flags: --crate-type=lib -Ctarget-cpu=znver3 -O +// only-x86_64 +// ignore-sgx + +use std::iter; + +// previously this produced a long chain of +// 56: vpextrb $6, %xmm0, %ecx +// 57: orb %cl, 22(%rsi) +// 58: vpextrb $7, %xmm0, %ecx +// 59: orb %cl, 23(%rsi) +// [...] + +// CHECK-LABEL: zip_arrays: +#[no_mangle] +pub fn zip_arrays(mut a: [u8; 32], b: [u8; 32]) -> [u8; 32] { + // CHECK-NOT: vpextrb + // CHECK-NOT: orb %cl + // CHECK: vorps + iter::zip(&mut a, b).for_each(|(a, b)| *a |= b); + // CHECK: retq + a +} diff --git a/tests/assembly/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs b/tests/assembly/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs new file mode 100644 index 00000000000..fca2c85d5a6 --- /dev/null +++ b/tests/assembly/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs @@ -0,0 +1,406 @@ +// revisions: all strong basic none missing +// assembly-output: emit-asm +// only-windows +// only-msvc +// ignore-64bit 64-bit table based SEH has slightly different behaviors than classic SEH +// [all] compile-flags: -Z stack-protector=all +// [strong] compile-flags: -Z stack-protector=strong +// [basic] compile-flags: -Z stack-protector=basic +// [none] compile-flags: -Z stack-protector=none +// compile-flags: -C opt-level=2 -Z merge-functions=disabled + +#![crate_type = "lib"] + +#![allow(incomplete_features)] + +#![feature(unsized_locals, unsized_fn_params)] + + +// CHECK-LABEL: emptyfn: +#[no_mangle] +pub fn emptyfn() { + // all: __security_check_cookie + // strong-NOT: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +// CHECK-LABEL: array_char +#[no_mangle] +pub fn array_char(f: fn(*const char)) { + let a = ['c'; 1]; + let b = ['d'; 3]; + let c = ['e'; 15]; + + f(&a as *const _); + f(&b as *const _); + f(&c as *const _); + + // Any type of local array variable leads to stack protection with the + // "strong" heuristic. The 'basic' heuristic only adds stack protection to + // functions with local array variables of a byte-sized type, however. Since + // 'char' is 4 bytes in Rust, this function is not protected by the 'basic' + // heuristic + // + // (This test *also* takes the address of the local stack variables. We + // cannot know that this isn't what triggers the `strong` heuristic. + // However, the test strategy of passing the address of a stack array to an + // external function is sufficient to trigger the `basic` heuristic (see + // test `array_u8_large()`). Since the `basic` heuristic only checks for the + // presence of stack-local array variables, we can be confident that this + // test also captures this part of the `strong` heuristic specification.) + + // all: __security_check_cookie + // strong: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +// CHECK-LABEL: array_u8_1 +#[no_mangle] +pub fn array_u8_1(f: fn(*const u8)) { + let a = [0u8; 1]; + f(&a as *const _); + + // The 'strong' heuristic adds stack protection to functions with local + // array variables regardless of their size. + + // all: __security_check_cookie + // strong: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +// CHECK-LABEL: array_u8_small: +#[no_mangle] +pub fn array_u8_small(f: fn(*const u8)) { + let a = [0u8; 2]; + let b = [0u8; 7]; + f(&a as *const _); + f(&b as *const _); + + // Small arrays do not lead to stack protection by the 'basic' heuristic. + + // all: __security_check_cookie + // strong: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +// CHECK-LABEL: array_u8_large: +#[no_mangle] +pub fn array_u8_large(f: fn(*const u8)) { + let a = [0u8; 9]; + f(&a as *const _); + + // Since `a` is a byte array with size greater than 8, the basic heuristic + // will also protect this function. + + // all: __security_check_cookie + // strong: __security_check_cookie + // basic: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +#[derive(Copy, Clone)] +pub struct ByteSizedNewtype(u8); + +// CHECK-LABEL: array_bytesizednewtype_9: +#[no_mangle] +pub fn array_bytesizednewtype_9(f: fn(*const ByteSizedNewtype)) { + let a = [ByteSizedNewtype(0); 9]; + f(&a as *const _); + + // Since `a` is a byte array in the LLVM output, the basic heuristic will + // also protect this function. + + // all: __security_check_cookie + // strong: __security_check_cookie + // basic: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +// CHECK-LABEL: local_var_addr_used_indirectly +#[no_mangle] +pub fn local_var_addr_used_indirectly(f: fn(bool)) { + let a = 5; + let a_addr = &a as *const _ as usize; + f(a_addr & 0x10 == 0); + + // This function takes the address of a local variable taken. Although this + // address is never used as a way to refer to stack memory, the `strong` + // heuristic adds stack smash protection. This is also the case in C++: + // ``` + // cat << EOF | clang++ -O2 -fstack-protector-strong -S -x c++ - -o - | grep stack_chk + // #include <cstdint> + // void f(void (*g)(bool)) { + // int32_t x; + // g((reinterpret_cast<uintptr_t>(&x) & 0x10U) == 0); + // } + // EOF + // ``` + + // all: __security_check_cookie + // strong: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + + +// CHECK-LABEL: local_string_addr_taken +#[no_mangle] +pub fn local_string_addr_taken(f: fn(&String)) { + let x = String::new(); + f(&x); + + // Taking the address of the local variable `x` leads to stack smash + // protection with the `strong` heuristic, but not with the `basic` + // heuristic. It does not matter that the reference is not mut. + // + // An interesting note is that a similar function in C++ *would* be + // protected by the `basic` heuristic, because `std::string` has a char + // array internally as a small object optimization: + // ``` + // cat <<EOF | clang++ -O2 -fstack-protector -S -x c++ - -o - | grep stack_chk + // #include <string> + // void f(void (*g)(const std::string&)) { + // std::string x; + // g(x); + // } + // EOF + // ``` + // + + // all: __security_check_cookie + // strong-NOT: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +pub trait SelfByRef { + fn f(&self) -> i32; +} + +impl SelfByRef for i32 { + fn f(&self) -> i32 { + return self + 1; + } +} + +// CHECK-LABEL: local_var_addr_taken_used_locally_only +#[no_mangle] +pub fn local_var_addr_taken_used_locally_only(factory: fn() -> i32, sink: fn(i32)) { + let x = factory(); + let g = x.f(); + sink(g); + + // Even though the local variable conceptually has its address taken, as + // it's passed by reference to the trait function, the use of the reference + // is easily inlined. There is therefore no stack smash protection even with + // the `strong` heuristic. + + // all: __security_check_cookie + // strong-NOT: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +pub struct Gigastruct { + does: u64, + not: u64, + have: u64, + array: u64, + members: u64 +} + +// CHECK-LABEL: local_large_var_moved +#[no_mangle] +pub fn local_large_var_moved(f: fn(Gigastruct)) { + let x = Gigastruct { does: 0, not: 1, have: 2, array: 3, members: 4 }; + f(x); + + // Even though the local variable conceptually doesn't have its address + // taken, it's so large that the "move" is implemented with a reference to a + // stack-local variable in the ABI. Consequently, this function *is* + // protected by the `strong` heuristic. This is also the case for + // rvalue-references in C++, regardless of struct size: + // ``` + // cat <<EOF | clang++ -O2 -fstack-protector-strong -S -x c++ - -o - | grep stack_chk + // #include <cstdint> + // #include <utility> + // void f(void (*g)(uint64_t&&)) { + // uint64_t x; + // g(std::move(x)); + // } + // EOF + // ``` + + // all: __security_check_cookie + // strong: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +// CHECK-LABEL: local_large_var_cloned +#[no_mangle] +pub fn local_large_var_cloned(f: fn(Gigastruct)) { + f(Gigastruct { does: 0, not: 1, have: 2, array: 3, members: 4 }); + + // A new instance of `Gigastruct` is passed to `f()`, without any apparent + // connection to this stack frame. Still, since instances of `Gigastruct` + // are sufficiently large, it is allocated in the caller stack frame and + // passed as a pointer. As such, this function is *also* protected by the + // `strong` heuristic, just like `local_large_var_moved`. This is also the + // case for pass-by-value of sufficiently large structs in C++: + // ``` + // cat <<EOF | clang++ -O2 -fstack-protector-strong -S -x c++ - -o - | grep stack_chk + // #include <cstdint> + // #include <utility> + // struct Gigastruct { uint64_t a, b, c, d, e; }; + // void f(void (*g)(Gigastruct)) { + // g(Gigastruct{}); + // } + // EOF + // ``` + + + // all: __security_check_cookie + // strong: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + + +extern "C" { + // A call to an external `alloca` function is *not* recognized as an + // `alloca(3)` operation. This function is a compiler built-in, as the + // man page explains. Clang translates it to an LLVM `alloca` + // instruction with a count argument, which is also what the LLVM stack + // protector heuristics looks for. The man page for `alloca(3)` details + // a way to avoid using the compiler built-in: pass a -std=c11 + // argument, *and* don't include <alloca.h>. Though this leads to an + // external alloca() function being called, it doesn't lead to stack + // protection being included. It even fails with a linker error + // "undefined reference to `alloca'". Example: + // ``` + // cat<<EOF | clang -fstack-protector-strong -x c -std=c11 - -o /dev/null + // #include <stdlib.h> + // void * alloca(size_t); + // void f(void (*g)(void*)) { + // void * p = alloca(10); + // g(p); + // } + // int main() { return 0; } + // EOF + // ``` + // The following tests demonstrate that calls to an external `alloca` + // function in Rust also doesn't trigger stack protection. + + fn alloca(size: usize) -> *mut (); +} + +// CHECK-LABEL: alloca_small_compile_time_constant_arg +#[no_mangle] +pub fn alloca_small_compile_time_constant_arg(f: fn(*mut ())) { + f(unsafe { alloca(8) }); + + // all: __security_check_cookie + // strong-NOT: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +// CHECK-LABEL: alloca_large_compile_time_constant_arg +#[no_mangle] +pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) { + f(unsafe { alloca(9) }); + + // all: __security_check_cookie + // strong-NOT: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + + +// CHECK-LABEL: alloca_dynamic_arg +#[no_mangle] +pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) { + f(unsafe { alloca(n) }); + + // all: __security_check_cookie + // strong-NOT: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +// The question then is: in what ways can Rust code generate array-`alloca` +// LLVM instructions? This appears to only be generated by +// rustc_codegen_ssa::traits::Builder::array_alloca() through +// rustc_codegen_ssa::mir::operand::OperandValue::store_unsized(). FWICT +// this is support for the "unsized locals" unstable feature: +// https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html. + + +// CHECK-LABEL: unsized_fn_param +#[no_mangle] +pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) { + let n = if l { 1 } else { 2 }; + f(*Box::<[u8]>::from(&s[0..n])); // slice-copy with Box::from + + // Even though slices are conceptually passed by-value both into this + // function and into `f()`, this is implemented with pass-by-reference + // using a suitably constructed fat-pointer (as if the functions + // accepted &[u8]). This function therefore doesn't need dynamic array + // alloca, and is therefore not protected by the `strong` or `basic` + // heuristics. + + + // We should have a __security_check_cookie call in `all` and `strong` modes but + // LLVM does not support generating stack protectors in functions with funclet + // based EH personalities. + // https://github.com/llvm/llvm-project/blob/37fd3c96b917096d8a550038f6e61cdf0fc4174f/llvm/lib/CodeGen/StackProtector.cpp#L103C1-L109C4 + // all-NOT: __security_check_cookie + // strong-NOT: __security_check_cookie + + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +// CHECK-LABEL: unsized_local +#[no_mangle] +pub fn unsized_local(s: &[u8], l: bool, f: fn(&mut [u8])) { + let n = if l { 1 } else { 2 }; + let mut a: [u8] = *Box::<[u8]>::from(&s[0..n]); // slice-copy with Box::from + f(&mut a); + + // This function allocates a slice as a local variable in its stack + // frame. Since the size is not a compile-time constant, an array + // alloca is required, and the function is protected by both the + // `strong` and `basic` heuristic. + + // We should have a __security_check_cookie call in `all`, `strong` and `basic` modes but + // LLVM does not support generating stack protectors in functions with funclet + // based EH personalities. + // https://github.com/llvm/llvm-project/blob/37fd3c96b917096d8a550038f6e61cdf0fc4174f/llvm/lib/CodeGen/StackProtector.cpp#L103C1-L109C4 + // all-NOT: __security_check_cookie + // strong-NOT: __security_check_cookie + // basic-NOT: __security_check_cookie + + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} diff --git a/tests/assembly/stack-protector/stack-protector-heuristics-effect-windows-64bit.rs b/tests/assembly/stack-protector/stack-protector-heuristics-effect-windows-64bit.rs new file mode 100644 index 00000000000..d9abf554a92 --- /dev/null +++ b/tests/assembly/stack-protector/stack-protector-heuristics-effect-windows-64bit.rs @@ -0,0 +1,414 @@ +// revisions: all strong basic none missing +// assembly-output: emit-asm +// only-windows +// only-msvc +// ignore-32bit 64-bit table based SEH has slightly different behaviors than classic SEH +// [all] compile-flags: -Z stack-protector=all +// [strong] compile-flags: -Z stack-protector=strong +// [basic] compile-flags: -Z stack-protector=basic +// [none] compile-flags: -Z stack-protector=none +// compile-flags: -C opt-level=2 -Z merge-functions=disabled + +#![crate_type = "lib"] + +#![allow(incomplete_features)] + +#![feature(unsized_locals, unsized_fn_params)] + + +// CHECK-LABEL: emptyfn: +#[no_mangle] +pub fn emptyfn() { + // all: __security_check_cookie + // strong-NOT: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +// CHECK-LABEL: array_char +#[no_mangle] +pub fn array_char(f: fn(*const char)) { + let a = ['c'; 1]; + let b = ['d'; 3]; + let c = ['e'; 15]; + + f(&a as *const _); + f(&b as *const _); + f(&c as *const _); + + // Any type of local array variable leads to stack protection with the + // "strong" heuristic. The 'basic' heuristic only adds stack protection to + // functions with local array variables of a byte-sized type, however. Since + // 'char' is 4 bytes in Rust, this function is not protected by the 'basic' + // heuristic + // + // (This test *also* takes the address of the local stack variables. We + // cannot know that this isn't what triggers the `strong` heuristic. + // However, the test strategy of passing the address of a stack array to an + // external function is sufficient to trigger the `basic` heuristic (see + // test `array_u8_large()`). Since the `basic` heuristic only checks for the + // presence of stack-local array variables, we can be confident that this + // test also captures this part of the `strong` heuristic specification.) + + // all: __security_check_cookie + // strong: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +// CHECK-LABEL: array_u8_1 +#[no_mangle] +pub fn array_u8_1(f: fn(*const u8)) { + let a = [0u8; 1]; + f(&a as *const _); + + // The 'strong' heuristic adds stack protection to functions with local + // array variables regardless of their size. + + // all: __security_check_cookie + // strong: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +// CHECK-LABEL: array_u8_small: +#[no_mangle] +pub fn array_u8_small(f: fn(*const u8)) { + let a = [0u8; 2]; + let b = [0u8; 7]; + f(&a as *const _); + f(&b as *const _); + + // Small arrays do not lead to stack protection by the 'basic' heuristic. + + // all: __security_check_cookie + // strong: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +// CHECK-LABEL: array_u8_large: +#[no_mangle] +pub fn array_u8_large(f: fn(*const u8)) { + let a = [0u8; 9]; + f(&a as *const _); + + // Since `a` is a byte array with size greater than 8, the basic heuristic + // will also protect this function. + + // all: __security_check_cookie + // strong: __security_check_cookie + // basic: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +#[derive(Copy, Clone)] +pub struct ByteSizedNewtype(u8); + +// CHECK-LABEL: array_bytesizednewtype_9: +#[no_mangle] +pub fn array_bytesizednewtype_9(f: fn(*const ByteSizedNewtype)) { + let a = [ByteSizedNewtype(0); 9]; + f(&a as *const _); + + // Since `a` is a byte array in the LLVM output, the basic heuristic will + // also protect this function. + + // all: __security_check_cookie + // strong: __security_check_cookie + // basic: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +// CHECK-LABEL: local_var_addr_used_indirectly +#[no_mangle] +pub fn local_var_addr_used_indirectly(f: fn(bool)) { + let a = 5; + let a_addr = &a as *const _ as usize; + f(a_addr & 0x10 == 0); + + // This function takes the address of a local variable taken. Although this + // address is never used as a way to refer to stack memory, the `strong` + // heuristic adds stack smash protection. This is also the case in C++: + // ``` + // cat << EOF | clang++ -O2 -fstack-protector-strong -S -x c++ - -o - | grep stack_chk + // #include <cstdint> + // void f(void (*g)(bool)) { + // int32_t x; + // g((reinterpret_cast<uintptr_t>(&x) & 0x10U) == 0); + // } + // EOF + // ``` + + // all: __security_check_cookie + // strong: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + + +// CHECK-LABEL: local_string_addr_taken +#[no_mangle] +pub fn local_string_addr_taken(f: fn(&String)) { + // CHECK-DAG: .seh_endprologue + let x = String::new(); + f(&x); + + // Taking the address of the local variable `x` leads to stack smash + // protection with the `strong` heuristic, but not with the `basic` + // heuristic. It does not matter that the reference is not mut. + // + // An interesting note is that a similar function in C++ *would* be + // protected by the `basic` heuristic, because `std::string` has a char + // array internally as a small object optimization: + // ``` + // cat <<EOF | clang++ -O2 -fstack-protector -S -x c++ - -o - | grep stack_chk + // #include <string> + // void f(void (*g)(const std::string&)) { + // std::string x; + // g(x); + // } + // EOF + // ``` + // + + // We should have a __security_check_cookie call in `all` and `strong` modes but + // LLVM does not support generating stack protectors in functions with funclet + // based EH personalities. + // https://github.com/llvm/llvm-project/blob/37fd3c96b917096d8a550038f6e61cdf0fc4174f/llvm/lib/CodeGen/StackProtector.cpp#L103C1-L109C4 + // all-NOT: __security_check_cookie + // strong-NOT: __security_check_cookie + + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie + + // CHECK-DAG: .seh_endproc +} + +pub trait SelfByRef { + fn f(&self) -> i32; +} + +impl SelfByRef for i32 { + fn f(&self) -> i32 { + return self + 1; + } +} + +// CHECK-LABEL: local_var_addr_taken_used_locally_only +#[no_mangle] +pub fn local_var_addr_taken_used_locally_only(factory: fn() -> i32, sink: fn(i32)) { + let x = factory(); + let g = x.f(); + sink(g); + + // Even though the local variable conceptually has its address taken, as + // it's passed by reference to the trait function, the use of the reference + // is easily inlined. There is therefore no stack smash protection even with + // the `strong` heuristic. + + // all: __security_check_cookie + // strong-NOT: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +pub struct Gigastruct { + does: u64, + not: u64, + have: u64, + array: u64, + members: u64 +} + +// CHECK-LABEL: local_large_var_moved +#[no_mangle] +pub fn local_large_var_moved(f: fn(Gigastruct)) { + let x = Gigastruct { does: 0, not: 1, have: 2, array: 3, members: 4 }; + f(x); + + // Even though the local variable conceptually doesn't have its address + // taken, it's so large that the "move" is implemented with a reference to a + // stack-local variable in the ABI. Consequently, this function *is* + // protected by the `strong` heuristic. This is also the case for + // rvalue-references in C++, regardless of struct size: + // ``` + // cat <<EOF | clang++ -O2 -fstack-protector-strong -S -x c++ - -o - | grep stack_chk + // #include <cstdint> + // #include <utility> + // void f(void (*g)(uint64_t&&)) { + // uint64_t x; + // g(std::move(x)); + // } + // EOF + // ``` + + // all: __security_check_cookie + // strong: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +// CHECK-LABEL: local_large_var_cloned +#[no_mangle] +pub fn local_large_var_cloned(f: fn(Gigastruct)) { + f(Gigastruct { does: 0, not: 1, have: 2, array: 3, members: 4 }); + + // A new instance of `Gigastruct` is passed to `f()`, without any apparent + // connection to this stack frame. Still, since instances of `Gigastruct` + // are sufficiently large, it is allocated in the caller stack frame and + // passed as a pointer. As such, this function is *also* protected by the + // `strong` heuristic, just like `local_large_var_moved`. This is also the + // case for pass-by-value of sufficiently large structs in C++: + // ``` + // cat <<EOF | clang++ -O2 -fstack-protector-strong -S -x c++ - -o - | grep stack_chk + // #include <cstdint> + // #include <utility> + // struct Gigastruct { uint64_t a, b, c, d, e; }; + // void f(void (*g)(Gigastruct)) { + // g(Gigastruct{}); + // } + // EOF + // ``` + + + // all: __security_check_cookie + // strong: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + + +extern "C" { + // A call to an external `alloca` function is *not* recognized as an + // `alloca(3)` operation. This function is a compiler built-in, as the + // man page explains. Clang translates it to an LLVM `alloca` + // instruction with a count argument, which is also what the LLVM stack + // protector heuristics looks for. The man page for `alloca(3)` details + // a way to avoid using the compiler built-in: pass a -std=c11 + // argument, *and* don't include <alloca.h>. Though this leads to an + // external alloca() function being called, it doesn't lead to stack + // protection being included. It even fails with a linker error + // "undefined reference to `alloca'". Example: + // ``` + // cat<<EOF | clang -fstack-protector-strong -x c -std=c11 - -o /dev/null + // #include <stdlib.h> + // void * alloca(size_t); + // void f(void (*g)(void*)) { + // void * p = alloca(10); + // g(p); + // } + // int main() { return 0; } + // EOF + // ``` + // The following tests demonstrate that calls to an external `alloca` + // function in Rust also doesn't trigger stack protection. + + fn alloca(size: usize) -> *mut (); +} + +// CHECK-LABEL: alloca_small_compile_time_constant_arg +#[no_mangle] +pub fn alloca_small_compile_time_constant_arg(f: fn(*mut ())) { + f(unsafe { alloca(8) }); + + // all: __security_check_cookie + // strong-NOT: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +// CHECK-LABEL: alloca_large_compile_time_constant_arg +#[no_mangle] +pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) { + f(unsafe { alloca(9) }); + + // all: __security_check_cookie + // strong-NOT: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + + +// CHECK-LABEL: alloca_dynamic_arg +#[no_mangle] +pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) { + f(unsafe { alloca(n) }); + + // all: __security_check_cookie + // strong-NOT: __security_check_cookie + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +// The question then is: in what ways can Rust code generate array-`alloca` +// LLVM instructions? This appears to only be generated by +// rustc_codegen_ssa::traits::Builder::array_alloca() through +// rustc_codegen_ssa::mir::operand::OperandValue::store_unsized(). FWICT +// this is support for the "unsized locals" unstable feature: +// https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html. + + +// CHECK-LABEL: unsized_fn_param +#[no_mangle] +pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) { + let n = if l { 1 } else { 2 }; + f(*Box::<[u8]>::from(&s[0..n])); // slice-copy with Box::from + + // Even though slices are conceptually passed by-value both into this + // function and into `f()`, this is implemented with pass-by-reference + // using a suitably constructed fat-pointer (as if the functions + // accepted &[u8]). This function therefore doesn't need dynamic array + // alloca, and is therefore not protected by the `strong` or `basic` + // heuristics. + + + // We should have a __security_check_cookie call in `all` and `strong` modes but + // LLVM does not support generating stack protectors in functions with funclet + // based EH personalities. + // https://github.com/llvm/llvm-project/blob/37fd3c96b917096d8a550038f6e61cdf0fc4174f/llvm/lib/CodeGen/StackProtector.cpp#L103C1-L109C4 + // all-NOT: __security_check_cookie + // strong-NOT: __security_check_cookie + + // basic-NOT: __security_check_cookie + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} + +// CHECK-LABEL: unsized_local +#[no_mangle] +pub fn unsized_local(s: &[u8], l: bool, f: fn(&mut [u8])) { + let n = if l { 1 } else { 2 }; + let mut a: [u8] = *Box::<[u8]>::from(&s[0..n]); // slice-copy with Box::from + f(&mut a); + + // This function allocates a slice as a local variable in its stack + // frame. Since the size is not a compile-time constant, an array + // alloca is required, and the function is protected by both the + // `strong` and `basic` heuristic. + + // We should have a __security_check_cookie call in `all`, `strong` and `basic` modes but + // LLVM does not support generating stack protectors in functions with funclet + // based EH personalities. + // https://github.com/llvm/llvm-project/blob/37fd3c96b917096d8a550038f6e61cdf0fc4174f/llvm/lib/CodeGen/StackProtector.cpp#L103C1-L109C4 + // all-NOT: __security_check_cookie + // strong-NOT: __security_check_cookie + // basic-NOT: __security_check_cookie + + // none-NOT: __security_check_cookie + // missing-NOT: __security_check_cookie +} diff --git a/tests/assembly/stack-protector/stack-protector-heuristics-effect.rs b/tests/assembly/stack-protector/stack-protector-heuristics-effect.rs index e46b902df07..ca566b6e46a 100644 --- a/tests/assembly/stack-protector/stack-protector-heuristics-effect.rs +++ b/tests/assembly/stack-protector/stack-protector-heuristics-effect.rs @@ -1,7 +1,7 @@ // revisions: all strong basic none missing // assembly-output: emit-asm // ignore-macos slightly different policy on stack protection of arrays -// ignore-windows stack check code uses different function names +// ignore-msvc stack check code uses different function names // ignore-nvptx64 stack protector is not supported // ignore-wasm32-bare // [all] compile-flags: -Z stack-protector=all diff --git a/tests/codegen-units/item-collection/asm-sym.rs b/tests/codegen-units/item-collection/asm-sym.rs index 8bafb95bc16..4b05b771a9b 100644 --- a/tests/codegen-units/item-collection/asm-sym.rs +++ b/tests/codegen-units/item-collection/asm-sym.rs @@ -6,15 +6,18 @@ pub unsafe fn f() { //~ MONO_ITEM static f::S @@ asm_sym-cgu.0[External] static S: usize = 1; //~ MONO_ITEM fn f::fun @@ asm_sym-cgu.0[External] + #[inline(never)] fn fun() {} core::arch::asm!("/* {0} {1} */", sym S, sym fun); } //~ MONO_ITEM fn g @@ asm_sym-cgu.0[External] +#[inline(never)] pub unsafe fn g() { //~ MONO_ITEM static g::S @@ asm_sym-cgu.0[Internal] static S: usize = 2; //~ MONO_ITEM fn g::fun @@ asm_sym-cgu.0[Internal] + #[inline(never)] fn fun() {} core::arch::asm!("/* {0} {1} */", sym S, sym fun); } diff --git a/tests/codegen-units/item-collection/auxiliary/cgu_export_trait_method.rs b/tests/codegen-units/item-collection/auxiliary/cgu_export_trait_method.rs index ecea26dc4be..e94dded55cf 100644 --- a/tests/codegen-units/item-collection/auxiliary/cgu_export_trait_method.rs +++ b/tests/codegen-units/item-collection/auxiliary/cgu_export_trait_method.rs @@ -1,3 +1,5 @@ +// compile-flags: -Copt-level=0 + #![crate_type = "lib"] pub trait Trait : Sized { diff --git a/tests/codegen-units/item-collection/cross-crate-trait-method.rs b/tests/codegen-units/item-collection/cross-crate-trait-method.rs index b7216a14318..778b3820f18 100644 --- a/tests/codegen-units/item-collection/cross-crate-trait-method.rs +++ b/tests/codegen-units/item-collection/cross-crate-trait-method.rs @@ -1,4 +1,4 @@ -// compile-flags:-Zprint-mono-items=eager -Zinline-mir=no +// compile-flags:-Zprint-mono-items=eager -Zinline-mir=no -Copt-level=0 #![deny(dead_code)] #![feature(start)] diff --git a/tests/codegen-units/item-collection/items-within-generic-items.rs b/tests/codegen-units/item-collection/items-within-generic-items.rs index d37d7f7d9b2..bb1a3be36c5 100644 --- a/tests/codegen-units/item-collection/items-within-generic-items.rs +++ b/tests/codegen-units/item-collection/items-within-generic-items.rs @@ -1,4 +1,4 @@ -// compile-flags:-Zprint-mono-items=eager +// compile-flags:-Zprint-mono-items=eager -Copt-level=0 #![deny(dead_code)] #![feature(start)] diff --git a/tests/codegen-units/item-collection/unreferenced-const-fn.rs b/tests/codegen-units/item-collection/unreferenced-const-fn.rs index 17b92eae00d..5f59d801504 100644 --- a/tests/codegen-units/item-collection/unreferenced-const-fn.rs +++ b/tests/codegen-units/item-collection/unreferenced-const-fn.rs @@ -4,6 +4,7 @@ #![crate_type = "rlib"] //~ MONO_ITEM fn foo @@ unreferenced_const_fn-cgu.0[External] +#[inline(never)] pub const fn foo(x: u32) -> u32 { x + 0xf00 } diff --git a/tests/codegen/asm-sanitize-llvm.rs b/tests/codegen/asm-sanitize-llvm.rs index 6dcacd08cac..41bed98038e 100644 --- a/tests/codegen/asm-sanitize-llvm.rs +++ b/tests/codegen/asm-sanitize-llvm.rs @@ -1,5 +1,5 @@ // FIXME(nagisa): remove the flags below once all targets support `asm!`. -// compile-flags: --target x86_64-unknown-linux-gnu +// compile-flags: --target x86_64-unknown-linux-gnu -Copt-level=0 // needs-llvm-components: x86 // Verify we sanitize the special tokens for the LLVM inline-assembly, ensuring people won't diff --git a/tests/codegen/async-fn-debug-awaitee-field.rs b/tests/codegen/async-fn-debug-awaitee-field.rs index 690505fd72b..29defe68f8b 100644 --- a/tests/codegen/async-fn-debug-awaitee-field.rs +++ b/tests/codegen/async-fn-debug-awaitee-field.rs @@ -3,7 +3,7 @@ // extensions rely on the field having this name. // ignore-tidy-linelength -// compile-flags: -C debuginfo=2 --edition=2018 +// compile-flags: -C debuginfo=2 --edition=2018 -Copt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/debug-linkage-name.rs b/tests/codegen/debug-linkage-name.rs index 9011a7da51d..9bf4d521fc0 100644 --- a/tests/codegen/debug-linkage-name.rs +++ b/tests/codegen/debug-linkage-name.rs @@ -1,8 +1,8 @@ // Verifies that linkage name is omitted when it is // the same as variable / function name. // -// compile-flags: -C no-prepopulate-passes -// compile-flags: -C debuginfo=2 +// compile-flags: -C no-prepopulate-passes -Copt-level=0 +// compile-flags: -C debuginfo=2 -Copt-level=0 #![crate_type = "lib"] pub mod xyz { diff --git a/tests/codegen/default-requires-uwtable.rs b/tests/codegen/default-requires-uwtable.rs index 5d77d3f14bb..26424f03568 100644 --- a/tests/codegen/default-requires-uwtable.rs +++ b/tests/codegen/default-requires-uwtable.rs @@ -1,5 +1,5 @@ // revisions: WINDOWS ANDROID -// compile-flags: -C panic=abort +// compile-flags: -C panic=abort -Copt-level=0 // [WINDOWS] compile-flags: --target=x86_64-pc-windows-msvc // [WINDOWS] needs-llvm-components: x86 // [ANDROID] compile-flags: --target=armv7-linux-androideabi diff --git a/tests/codegen/drop.rs b/tests/codegen/drop.rs index 3615ef47b53..14b5840e2fe 100644 --- a/tests/codegen/drop.rs +++ b/tests/codegen/drop.rs @@ -7,10 +7,12 @@ struct SomeUniqueName; impl Drop for SomeUniqueName { + #[inline(never)] fn drop(&mut self) { } } +#[inline(never)] pub fn possibly_unwinding() { } diff --git a/tests/codegen/force-frame-pointers.rs b/tests/codegen/force-frame-pointers.rs index 637c4234654..5791ae47937 100644 --- a/tests/codegen/force-frame-pointers.rs +++ b/tests/codegen/force-frame-pointers.rs @@ -1,4 +1,4 @@ -// compile-flags: -C no-prepopulate-passes -C force-frame-pointers=y +// compile-flags: -C no-prepopulate-passes -C force-frame-pointers=y -Copt-level=0 #![crate_type="lib"] diff --git a/tests/codegen/force-unwind-tables.rs b/tests/codegen/force-unwind-tables.rs index 4c0a5602c6d..c904978c9ff 100644 --- a/tests/codegen/force-unwind-tables.rs +++ b/tests/codegen/force-unwind-tables.rs @@ -1,4 +1,4 @@ -// compile-flags: -C no-prepopulate-passes -C force-unwind-tables=y +// compile-flags: -C no-prepopulate-passes -C force-unwind-tables=y -Copt-level=0 #![crate_type="lib"] diff --git a/tests/codegen/inline-function-args-debug-info.rs b/tests/codegen/inline-function-args-debug-info.rs index e3d8caa49d4..ffae99e0f24 100644 --- a/tests/codegen/inline-function-args-debug-info.rs +++ b/tests/codegen/inline-function-args-debug-info.rs @@ -6,6 +6,7 @@ #![crate_type = "lib"] +#[inline(never)] pub fn outer_function(x: usize, y: usize) -> usize { inner_function(x, y) + 1 } @@ -13,8 +14,8 @@ pub fn outer_function(x: usize, y: usize) -> usize { #[inline] fn inner_function(aaaa: usize, bbbb: usize) -> usize { // CHECK: !DILocalVariable(name: "aaaa", arg: 1 - // CHECK-SAME: line: 14 + // CHECK-SAME: line: 15 // CHECK: !DILocalVariable(name: "bbbb", arg: 2 - // CHECK-SAME: line: 14 + // CHECK-SAME: line: 15 aaaa + bbbb } diff --git a/tests/codegen/instrument-mcount.rs b/tests/codegen/instrument-mcount.rs index b26076e7a7b..50823775a41 100644 --- a/tests/codegen/instrument-mcount.rs +++ b/tests/codegen/instrument-mcount.rs @@ -1,5 +1,5 @@ // -// compile-flags: -Z instrument-mcount +// compile-flags: -Z instrument-mcount -Copt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/instrument-xray/basic.rs b/tests/codegen/instrument-xray/basic.rs index d3e49d53174..5da878474f2 100644 --- a/tests/codegen/instrument-xray/basic.rs +++ b/tests/codegen/instrument-xray/basic.rs @@ -1,7 +1,7 @@ // Checks that `-Z instrument-xray` produces expected instrumentation. // // needs-xray -// compile-flags: -Z instrument-xray=always +// compile-flags: -Z instrument-xray=always -Copt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/instrument-xray/options-combine.rs b/tests/codegen/instrument-xray/options-combine.rs index f7e500b65f6..d1e56586279 100644 --- a/tests/codegen/instrument-xray/options-combine.rs +++ b/tests/codegen/instrument-xray/options-combine.rs @@ -1,9 +1,9 @@ // Checks that `-Z instrument-xray` options can be specified multiple times. // // needs-xray -// compile-flags: -Z instrument-xray=skip-exit -// compile-flags: -Z instrument-xray=instruction-threshold=123 -// compile-flags: -Z instrument-xray=instruction-threshold=456 +// compile-flags: -Z instrument-xray=skip-exit -Copt-level=0 +// compile-flags: -Z instrument-xray=instruction-threshold=123 -Copt-level=0 +// compile-flags: -Z instrument-xray=instruction-threshold=456 -Copt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/instrument-xray/options-override.rs b/tests/codegen/instrument-xray/options-override.rs index 00f81837902..b1fc4c966dc 100644 --- a/tests/codegen/instrument-xray/options-override.rs +++ b/tests/codegen/instrument-xray/options-override.rs @@ -1,8 +1,8 @@ // Checks that the last `-Z instrument-xray` option wins. // // needs-xray -// compile-flags: -Z instrument-xray=always -// compile-flags: -Z instrument-xray=never +// compile-flags: -Z instrument-xray=always -Copt-level=0 +// compile-flags: -Z instrument-xray=never -Copt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/panic-unwind-default-uwtable.rs b/tests/codegen/panic-unwind-default-uwtable.rs index 4c85008cf35..b78b159d20d 100644 --- a/tests/codegen/panic-unwind-default-uwtable.rs +++ b/tests/codegen/panic-unwind-default-uwtable.rs @@ -1,4 +1,4 @@ -// compile-flags: -C panic=unwind -C no-prepopulate-passes +// compile-flags: -C panic=unwind -C no-prepopulate-passes -Copt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/personality_lifetimes.rs b/tests/codegen/personality_lifetimes.rs index 47243bece98..b39718a8d08 100644 --- a/tests/codegen/personality_lifetimes.rs +++ b/tests/codegen/personality_lifetimes.rs @@ -9,10 +9,12 @@ struct S; impl Drop for S { + #[inline(never)] fn drop(&mut self) { } } +#[inline(never)] fn might_unwind() { } diff --git a/tests/codegen/sanitizer/cfi-emit-type-metadata-attr-cfi-encoding.rs b/tests/codegen/sanitizer/cfi-emit-type-metadata-attr-cfi-encoding.rs index 084d8bf803c..f16890afad0 100644 --- a/tests/codegen/sanitizer/cfi-emit-type-metadata-attr-cfi-encoding.rs +++ b/tests/codegen/sanitizer/cfi-emit-type-metadata-attr-cfi-encoding.rs @@ -1,7 +1,7 @@ // Verifies that user-defined CFI encoding for types are emitted. // // needs-sanitizer-cfi -// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 #![crate_type="lib"] #![feature(cfi_encoding, extern_types)] diff --git a/tests/codegen/sanitizer/cfi-emit-type-metadata-id-itanium-cxx-abi.rs b/tests/codegen/sanitizer/cfi-emit-type-metadata-id-itanium-cxx-abi.rs index 2d8b13e2080..4ed7c27fc4e 100644 --- a/tests/codegen/sanitizer/cfi-emit-type-metadata-id-itanium-cxx-abi.rs +++ b/tests/codegen/sanitizer/cfi-emit-type-metadata-id-itanium-cxx-abi.rs @@ -1,7 +1,7 @@ // Verifies that type metadata identifiers for functions are emitted correctly. // // needs-sanitizer-cfi -// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 #![crate_type="lib"] #![allow(dead_code)] diff --git a/tests/codegen/sanitizer/cfi-generalize-pointers.rs b/tests/codegen/sanitizer/cfi-generalize-pointers.rs index 677ebdb27ec..17cb42d3e74 100644 --- a/tests/codegen/sanitizer/cfi-generalize-pointers.rs +++ b/tests/codegen/sanitizer/cfi-generalize-pointers.rs @@ -1,7 +1,7 @@ // Verifies that pointer types are generalized. // // needs-sanitizer-cfi -// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers -Copt-level=0 #![crate_type="lib"] diff --git a/tests/codegen/sanitizer/cfi-normalize-integers.rs b/tests/codegen/sanitizer/cfi-normalize-integers.rs index aa3913cb8e7..9663aa54c28 100644 --- a/tests/codegen/sanitizer/cfi-normalize-integers.rs +++ b/tests/codegen/sanitizer/cfi-normalize-integers.rs @@ -1,7 +1,7 @@ // Verifies that integer types are normalized. // // needs-sanitizer-cfi -// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -Copt-level=0 #![crate_type="lib"] diff --git a/tests/codegen/sanitizer/kasan-emits-instrumentation.rs b/tests/codegen/sanitizer/kasan-emits-instrumentation.rs index 783bc47b9d0..29d50d8df24 100644 --- a/tests/codegen/sanitizer/kasan-emits-instrumentation.rs +++ b/tests/codegen/sanitizer/kasan-emits-instrumentation.rs @@ -1,6 +1,6 @@ // Verifies that `-Zsanitizer=kernel-address` emits sanitizer instrumentation. -// compile-flags: -Zsanitizer=kernel-address +// compile-flags: -Zsanitizer=kernel-address -Copt-level=0 // revisions: aarch64 riscv64imac riscv64gc x86_64 //[aarch64] compile-flags: --target aarch64-unknown-none //[aarch64] needs-llvm-components: aarch64 diff --git a/tests/codegen/sanitizer/memtag-attr-check.rs b/tests/codegen/sanitizer/memtag-attr-check.rs index 2fd362656d4..3e5e14e8429 100644 --- a/tests/codegen/sanitizer/memtag-attr-check.rs +++ b/tests/codegen/sanitizer/memtag-attr-check.rs @@ -2,7 +2,7 @@ // applied when enabling the memtag sanitizer. // // needs-sanitizer-memtag -// compile-flags: -Zsanitizer=memtag -Ctarget-feature=+mte +// compile-flags: -Zsanitizer=memtag -Ctarget-feature=+mte -Copt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/no-sanitize.rs b/tests/codegen/sanitizer/no-sanitize.rs index d0b69243453..029cf8e7f5c 100644 --- a/tests/codegen/sanitizer/no-sanitize.rs +++ b/tests/codegen/sanitizer/no-sanitize.rs @@ -2,7 +2,7 @@ // selectively disable sanitizer instrumentation. // // needs-sanitizer-address -// compile-flags: -Zsanitizer=address -Ctarget-feature=-crt-static +// compile-flags: -Zsanitizer=address -Ctarget-feature=-crt-static -Copt-level=0 #![crate_type="lib"] #![feature(no_sanitize)] diff --git a/tests/codegen/sanitizer/safestack-attr-check.rs b/tests/codegen/sanitizer/safestack-attr-check.rs index b73ed00e730..b19e2d13133 100644 --- a/tests/codegen/sanitizer/safestack-attr-check.rs +++ b/tests/codegen/sanitizer/safestack-attr-check.rs @@ -1,7 +1,7 @@ // This tests that the safestack attribute is applied when enabling the safe-stack sanitizer. // // needs-sanitizer-safestack -// compile-flags: -Zsanitizer=safestack +// compile-flags: -Zsanitizer=safestack -Copt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs b/tests/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs index 64be1127786..6ef0f0406d2 100644 --- a/tests/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs +++ b/tests/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs @@ -1,4 +1,4 @@ -// compile-flags: -g -Z src-hash-algorithm=md5 +// compile-flags: -g -Z src-hash-algorithm=md5 -Copt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs b/tests/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs index 54e07152142..ebfa3040aca 100644 --- a/tests/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs +++ b/tests/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs @@ -1,4 +1,4 @@ -// compile-flags: -g -Z src-hash-algorithm=sha1 +// compile-flags: -g -Z src-hash-algorithm=sha1 -Copt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/src-hash-algorithm/src-hash-algorithm-sha256.rs b/tests/codegen/src-hash-algorithm/src-hash-algorithm-sha256.rs index dc7db8e2372..5ec678d55f3 100644 --- a/tests/codegen/src-hash-algorithm/src-hash-algorithm-sha256.rs +++ b/tests/codegen/src-hash-algorithm/src-hash-algorithm-sha256.rs @@ -1,4 +1,4 @@ -// compile-flags: -g -Z src-hash-algorithm=sha256 +// compile-flags: -g -Z src-hash-algorithm=sha256 -Copt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/target-cpu-on-functions.rs b/tests/codegen/target-cpu-on-functions.rs index c043eceb5cd..d5250f22cca 100644 --- a/tests/codegen/target-cpu-on-functions.rs +++ b/tests/codegen/target-cpu-on-functions.rs @@ -15,7 +15,8 @@ pub extern "C" fn exported() { // CHECK-LABEL: ; target_cpu_on_functions::not_exported // CHECK-NEXT: ; Function Attrs: -// CHECK-NEXT: define {{.*}}() {{.*}} #0 +// CHECK-NEXT: define {{.*}}() {{.*}} #1 +#[inline(never)] fn not_exported() {} // CHECK: attributes #0 = {{.*}} "target-cpu"="{{.*}}" diff --git a/tests/codegen/target-feature-inline-closure.rs b/tests/codegen/target-feature-inline-closure.rs index d075706173f..54cb27242d5 100644 --- a/tests/codegen/target-feature-inline-closure.rs +++ b/tests/codegen/target-feature-inline-closure.rs @@ -31,3 +31,7 @@ unsafe fn without_avx(x: __m256) -> __m256 { }; add(x, x) } + +// Don't allow the above CHECK-NOT to accidentally match a commit hash in the +// compiler version. +// CHECK-LABEL: rustc version diff --git a/tests/codegen/tied-features-strength.rs b/tests/codegen/tied-features-strength.rs index 51334c12158..71cea48c4da 100644 --- a/tests/codegen/tied-features-strength.rs +++ b/tests/codegen/tied-features-strength.rs @@ -7,16 +7,16 @@ // are targeting older LLVM versions. Once the min supported version // is LLVM-14 we can remove the optional regex matching for this feature. -// [ENABLE_SVE] compile-flags: -C target-feature=+sve +// [ENABLE_SVE] compile-flags: -C target-feature=+sve -Copt-level=0 // ENABLE_SVE: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)?|(\+sve,?)|(\+neon,?))*}}" } -// [DISABLE_SVE] compile-flags: -C target-feature=-sve +// [DISABLE_SVE] compile-flags: -C target-feature=-sve -Copt-level=0 // DISABLE_SVE: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)?|(-sve,?)|(\+neon,?))*}}" } -// [DISABLE_NEON] compile-flags: -C target-feature=-neon +// [DISABLE_NEON] compile-flags: -C target-feature=-neon -Copt-level=0 // DISABLE_NEON: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)?|(-fp-armv8,?)|(-neon,?))*}}" } -// [ENABLE_NEON] compile-flags: -C target-feature=+neon +// [ENABLE_NEON] compile-flags: -C target-feature=+neon -Copt-level=0 // ENABLE_NEON: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)?|(\+fp-armv8,?)|(\+neon,?))*}}" } diff --git a/tests/codegen/tune-cpu-on-functions.rs b/tests/codegen/tune-cpu-on-functions.rs index ed8dc0e9383..116f0772d25 100644 --- a/tests/codegen/tune-cpu-on-functions.rs +++ b/tests/codegen/tune-cpu-on-functions.rs @@ -3,7 +3,7 @@ // no-prefer-dynamic // -// compile-flags: -C no-prepopulate-passes -C panic=abort -C linker-plugin-lto -Cpasses=name-anon-globals -Z tune-cpu=generic +// compile-flags: -C no-prepopulate-passes -C panic=abort -C linker-plugin-lto -Cpasses=name-anon-globals -Z tune-cpu=generic -Copt-level=0 #![crate_type = "staticlib"] diff --git a/tests/codegen/vec_pop_push_noop.rs b/tests/codegen/vec_pop_push_noop.rs new file mode 100644 index 00000000000..8bc7b68a816 --- /dev/null +++ b/tests/codegen/vec_pop_push_noop.rs @@ -0,0 +1,24 @@ +// compile-flags: -O + +#![crate_type = "lib"] + +#[no_mangle] +// CHECK-LABEL: @noop( +pub fn noop(v: &mut Vec<u8>) { + // CHECK-NOT: reserve_for_push + // CHECK-NOT: call + // CHECK: tail call void @llvm.assume + // CHECK-NOT: reserve_for_push + // CHECK-NOT: call + // CHECK: ret + if let Some(x) = v.pop() { + v.push(x) + } +} + +#[no_mangle] +// CHECK-LABEL: @push_byte( +pub fn push_byte(v: &mut Vec<u8>) { + // CHECK: call {{.*}}reserve_for_push + v.push(3); +} diff --git a/tests/coverage-map/status-quo/issue-84561.cov-map b/tests/coverage-map/status-quo/issue-84561.cov-map index fe098fd396c..01fa7ec573c 100644 --- a/tests/coverage-map/status-quo/issue-84561.cov-map +++ b/tests/coverage-map/status-quo/issue-84561.cov-map @@ -1,11 +1,10 @@ Function name: <issue_84561::Foo as core::cmp::PartialEq>::eq -Raw bytes (14): 0x[01, 01, 00, 02, 01, 04, 0a, 00, 13, 00, 00, 0a, 00, 13] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 04, 0a, 00, 13] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 -Number of file 0 mappings: 2 +Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 4, 10) to (start + 0, 19) -- Code(Zero) at (prev + 0, 10) to (start + 0, 19) Function name: <issue_84561::Foo as core::fmt::Debug>::fmt Raw bytes (29): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 89, 01, 09, 00, 25, 05, 00, 25, 00, 26, 02, 01, 09, 00, 0f, 07, 01, 05, 00, 06] diff --git a/tests/mir-opt/building/custom/consts.statics.built.after.mir b/tests/mir-opt/building/custom/consts.statics.built.after.mir index ea394c5b727..a5cb6ff992e 100644 --- a/tests/mir-opt/building/custom/consts.statics.built.after.mir +++ b/tests/mir-opt/building/custom/consts.statics.built.after.mir @@ -6,16 +6,16 @@ fn statics() -> () { let mut _2: *mut i32; bb0: { - _1 = const {alloc1: &i32}; - _2 = const {alloc2: *mut i32}; + _1 = const {ALLOC0: &i32}; + _2 = const {ALLOC1: *mut i32}; return; } } -alloc2 (static: T, size: 4, align: 4) { +ALLOC1 (static: T, size: 4, align: 4) { 0a 0a 0a 0a │ .... } -alloc1 (static: S, size: 4, align: 4) { +ALLOC0 (static: S, size: 4, align: 4) { 05 05 05 05 │ .... } diff --git a/tests/mir-opt/byte_slice.main.SimplifyCfg-elaborate-drops.after.mir b/tests/mir-opt/byte_slice.main.SimplifyCfg-elaborate-drops.after.mir index 9b17b4b63dd..09a65e6e6a6 100644 --- a/tests/mir-opt/byte_slice.main.SimplifyCfg-elaborate-drops.after.mir +++ b/tests/mir-opt/byte_slice.main.SimplifyCfg-elaborate-drops.after.mir @@ -23,6 +23,6 @@ fn main() -> () { } } -alloc1 (size: 3, align: 1) { +ALLOC0 (size: 3, align: 1) { 66 6f 6f │ foo } diff --git a/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir b/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir index 8c8e6959595..f20bfef8c79 100644 --- a/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir +++ b/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir @@ -8,7 +8,7 @@ fn main() -> () { bb0: { StorageLive(_1); StorageLive(_2); - _2 = const {alloc1: &&[(Option<i32>, &[&str])]}; + _2 = const {ALLOC9: &&[(Option<i32>, &[&str])]}; _1 = (*_2); StorageDead(_2); StorageDead(_1); @@ -17,43 +17,43 @@ fn main() -> () { } } -alloc1 (static: FOO, size: 8, align: 4) { - ╾─alloc19─╼ 03 00 00 00 │ ╾──╼.... +ALLOC9 (static: FOO, size: 8, align: 4) { + ╾ALLOC0╼ 03 00 00 00 │ ╾──╼.... } -alloc19 (size: 48, align: 4) { - 0x00 │ 00 00 00 00 __ __ __ __ ╾─alloc6──╼ 00 00 00 00 │ ....░░░░╾──╼.... - 0x10 │ 00 00 00 00 __ __ __ __ ╾─alloc10─╼ 02 00 00 00 │ ....░░░░╾──╼.... - 0x20 │ 01 00 00 00 2a 00 00 00 ╾─alloc15─╼ 03 00 00 00 │ ....*...╾──╼.... +ALLOC0 (size: 48, align: 4) { + 0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC1╼ 00 00 00 00 │ ....░░░░╾──╼.... + 0x10 │ 00 00 00 00 __ __ __ __ ╾ALLOC2╼ 02 00 00 00 │ ....░░░░╾──╼.... + 0x20 │ 01 00 00 00 2a 00 00 00 ╾ALLOC3╼ 03 00 00 00 │ ....*...╾──╼.... } -alloc6 (size: 0, align: 4) {} +ALLOC1 (size: 0, align: 4) {} -alloc10 (size: 16, align: 4) { - ╾─alloc9──╼ 03 00 00 00 ╾─alloc11─╼ 03 00 00 00 │ ╾──╼....╾──╼.... +ALLOC2 (size: 16, align: 4) { + ╾ALLOC4╼ 03 00 00 00 ╾ALLOC5╼ 03 00 00 00 │ ╾──╼....╾──╼.... } -alloc9 (size: 3, align: 1) { +ALLOC4 (size: 3, align: 1) { 66 6f 6f │ foo } -alloc11 (size: 3, align: 1) { +ALLOC5 (size: 3, align: 1) { 62 61 72 │ bar } -alloc15 (size: 24, align: 4) { - 0x00 │ ╾─alloc14─╼ 03 00 00 00 ╾─alloc16─╼ 03 00 00 00 │ ╾──╼....╾──╼.... - 0x10 │ ╾─alloc17─╼ 04 00 00 00 │ ╾──╼.... +ALLOC3 (size: 24, align: 4) { + 0x00 │ ╾ALLOC6╼ 03 00 00 00 ╾ALLOC7╼ 03 00 00 00 │ ╾──╼....╾──╼.... + 0x10 │ ╾ALLOC8╼ 04 00 00 00 │ ╾──╼.... } -alloc14 (size: 3, align: 1) { +ALLOC6 (size: 3, align: 1) { 6d 65 68 │ meh } -alloc16 (size: 3, align: 1) { +ALLOC7 (size: 3, align: 1) { 6d 6f 70 │ mop } -alloc17 (size: 4, align: 1) { +ALLOC8 (size: 4, align: 1) { 6d c3 b6 70 │ m..p } diff --git a/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir b/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir index e2254703296..263cae2f3ea 100644 --- a/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir +++ b/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir @@ -8,7 +8,7 @@ fn main() -> () { bb0: { StorageLive(_1); StorageLive(_2); - _2 = const {alloc1: &&[(Option<i32>, &[&str])]}; + _2 = const {ALLOC9: &&[(Option<i32>, &[&str])]}; _1 = (*_2); StorageDead(_2); StorageDead(_1); @@ -17,47 +17,47 @@ fn main() -> () { } } -alloc1 (static: FOO, size: 16, align: 8) { - ╾───────alloc19───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ +ALLOC9 (static: FOO, size: 16, align: 8) { + ╾ALLOC0╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ } -alloc19 (size: 72, align: 8) { - 0x00 │ 00 00 00 00 __ __ __ __ ╾───────alloc6────────╼ │ ....░░░░╾──────╼ +ALLOC0 (size: 72, align: 8) { + 0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC1╼ │ ....░░░░╾──────╼ 0x10 │ 00 00 00 00 00 00 00 00 00 00 00 00 __ __ __ __ │ ............░░░░ - 0x20 │ ╾───────alloc10───────╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x30 │ 01 00 00 00 2a 00 00 00 ╾───────alloc15───────╼ │ ....*...╾──────╼ + 0x20 │ ╾ALLOC2╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x30 │ 01 00 00 00 2a 00 00 00 ╾ALLOC3╼ │ ....*...╾──────╼ 0x40 │ 03 00 00 00 00 00 00 00 │ ........ } -alloc6 (size: 0, align: 8) {} +ALLOC1 (size: 0, align: 8) {} -alloc10 (size: 32, align: 8) { - 0x00 │ ╾───────alloc9────────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x10 │ ╾───────alloc11───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ +ALLOC2 (size: 32, align: 8) { + 0x00 │ ╾ALLOC4╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x10 │ ╾ALLOC5╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ } -alloc9 (size: 3, align: 1) { +ALLOC4 (size: 3, align: 1) { 66 6f 6f │ foo } -alloc11 (size: 3, align: 1) { +ALLOC5 (size: 3, align: 1) { 62 61 72 │ bar } -alloc15 (size: 48, align: 8) { - 0x00 │ ╾───────alloc14───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x10 │ ╾───────alloc16───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x20 │ ╾───────alloc17───────╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ +ALLOC3 (size: 48, align: 8) { + 0x00 │ ╾ALLOC6╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x10 │ ╾ALLOC7╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x20 │ ╾ALLOC8╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } -alloc14 (size: 3, align: 1) { +ALLOC6 (size: 3, align: 1) { 6d 65 68 │ meh } -alloc16 (size: 3, align: 1) { +ALLOC7 (size: 3, align: 1) { 6d 6f 70 │ mop } -alloc17 (size: 4, align: 1) { +ALLOC8 (size: 4, align: 1) { 6d c3 b6 70 │ m..p } diff --git a/tests/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir b/tests/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir index c5f6902b4b4..713abb264a7 100644 --- a/tests/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir +++ b/tests/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir @@ -8,7 +8,7 @@ fn main() -> () { bb0: { StorageLive(_1); StorageLive(_2); - _2 = const {alloc1: &&[(Option<i32>, &[&u8])]}; + _2 = const {ALLOC9: &&[(Option<i32>, &[&u8])]}; _1 = (*_2); StorageDead(_2); StorageDead(_1); @@ -17,42 +17,42 @@ fn main() -> () { } } -alloc1 (static: FOO, size: 8, align: 4) { - ╾─alloc23─╼ 03 00 00 00 │ ╾──╼.... +ALLOC9 (static: FOO, size: 8, align: 4) { + ╾ALLOC0╼ 03 00 00 00 │ ╾──╼.... } -alloc23 (size: 48, align: 4) { - 0x00 │ 00 00 00 00 __ __ __ __ ╾─alloc10─╼ 00 00 00 00 │ ....░░░░╾──╼.... - 0x10 │ 00 00 00 00 __ __ __ __ ╾─alloc15─╼ 02 00 00 00 │ ....░░░░╾──╼.... - 0x20 │ 01 00 00 00 2a 00 00 00 ╾─alloc21─╼ 03 00 00 00 │ ....*...╾──╼.... +ALLOC0 (size: 48, align: 4) { + 0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC1╼ 00 00 00 00 │ ....░░░░╾──╼.... + 0x10 │ 00 00 00 00 __ __ __ __ ╾ALLOC2╼ 02 00 00 00 │ ....░░░░╾──╼.... + 0x20 │ 01 00 00 00 2a 00 00 00 ╾ALLOC3╼ 03 00 00 00 │ ....*...╾──╼.... } -alloc10 (size: 0, align: 4) {} +ALLOC1 (size: 0, align: 4) {} -alloc15 (size: 8, align: 4) { - ╾─alloc13─╼ ╾─alloc14─╼ │ ╾──╼╾──╼ +ALLOC2 (size: 8, align: 4) { + ╾ALLOC4╼ ╾ALLOC5╼ │ ╾──╼╾──╼ } -alloc13 (size: 1, align: 1) { +ALLOC4 (size: 1, align: 1) { 05 │ . } -alloc14 (size: 1, align: 1) { +ALLOC5 (size: 1, align: 1) { 06 │ . } -alloc21 (size: 12, align: 4) { - ╾─a18+0x3─╼ ╾─alloc19─╼ ╾─a20+0x2─╼ │ ╾──╼╾──╼╾──╼ +ALLOC3 (size: 12, align: 4) { + ╾ALLOC6+0x3╼ ╾ALLOC7╼ ╾ALLOC8+0x2╼ │ ╾──╼╾──╼╾──╼ } -alloc18 (size: 4, align: 1) { +ALLOC6 (size: 4, align: 1) { 2a 45 15 6f │ *E.o } -alloc19 (size: 1, align: 1) { +ALLOC7 (size: 1, align: 1) { 2a │ * } -alloc20 (size: 4, align: 1) { +ALLOC8 (size: 4, align: 1) { 2a 45 15 6f │ *E.o } diff --git a/tests/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir b/tests/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir index b95b8c78748..e9d61ef120c 100644 --- a/tests/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir +++ b/tests/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir @@ -8,7 +8,7 @@ fn main() -> () { bb0: { StorageLive(_1); StorageLive(_2); - _2 = const {alloc1: &&[(Option<i32>, &[&u8])]}; + _2 = const {ALLOC9: &&[(Option<i32>, &[&u8])]}; _1 = (*_2); StorageDead(_2); StorageDead(_1); @@ -17,45 +17,45 @@ fn main() -> () { } } -alloc1 (static: FOO, size: 16, align: 8) { - ╾───────alloc23───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ +ALLOC9 (static: FOO, size: 16, align: 8) { + ╾ALLOC0╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ } -alloc23 (size: 72, align: 8) { - 0x00 │ 00 00 00 00 __ __ __ __ ╾───────alloc10───────╼ │ ....░░░░╾──────╼ +ALLOC0 (size: 72, align: 8) { + 0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC1╼ │ ....░░░░╾──────╼ 0x10 │ 00 00 00 00 00 00 00 00 00 00 00 00 __ __ __ __ │ ............░░░░ - 0x20 │ ╾───────alloc15───────╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x30 │ 01 00 00 00 2a 00 00 00 ╾───────alloc21───────╼ │ ....*...╾──────╼ + 0x20 │ ╾ALLOC2╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x30 │ 01 00 00 00 2a 00 00 00 ╾ALLOC3╼ │ ....*...╾──────╼ 0x40 │ 03 00 00 00 00 00 00 00 │ ........ } -alloc10 (size: 0, align: 8) {} +ALLOC1 (size: 0, align: 8) {} -alloc15 (size: 16, align: 8) { - ╾───────alloc13───────╼ ╾───────alloc14───────╼ │ ╾──────╼╾──────╼ +ALLOC2 (size: 16, align: 8) { + ╾ALLOC4╼ ╾ALLOC5╼ │ ╾──────╼╾──────╼ } -alloc13 (size: 1, align: 1) { +ALLOC4 (size: 1, align: 1) { 05 │ . } -alloc14 (size: 1, align: 1) { +ALLOC5 (size: 1, align: 1) { 06 │ . } -alloc21 (size: 24, align: 8) { - 0x00 │ ╾─────alloc18+0x3─────╼ ╾───────alloc19───────╼ │ ╾──────╼╾──────╼ - 0x10 │ ╾─────alloc20+0x2─────╼ │ ╾──────╼ +ALLOC3 (size: 24, align: 8) { + 0x00 │ ╾ALLOC6+0x3╼ ╾ALLOC7╼ │ ╾──────╼╾──────╼ + 0x10 │ ╾ALLOC8+0x2╼ │ ╾──────╼ } -alloc18 (size: 4, align: 1) { +ALLOC6 (size: 4, align: 1) { 2a 45 15 6f │ *E.o } -alloc19 (size: 1, align: 1) { +ALLOC7 (size: 1, align: 1) { 2a │ * } -alloc20 (size: 4, align: 1) { +ALLOC8 (size: 4, align: 1) { 2a 45 15 6f │ *E.o } diff --git a/tests/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir b/tests/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir index e172c754001..c18c067c72e 100644 --- a/tests/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir +++ b/tests/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir @@ -8,7 +8,7 @@ fn main() -> () { bb0: { StorageLive(_1); StorageLive(_2); - _2 = const {alloc1: &&Packed}; + _2 = const {ALLOC4: &&Packed}; _1 = (*_2); StorageDead(_2); StorageDead(_1); @@ -17,31 +17,31 @@ fn main() -> () { } } -alloc1 (static: FOO, size: 4, align: 4) { - ╾─alloc12─╼ │ ╾──╼ +ALLOC4 (static: FOO, size: 4, align: 4) { + ╾ALLOC0╼ │ ╾──╼ } -alloc12 (size: 168, align: 1) { +ALLOC0 (size: 168, align: 1) { 0x00 │ ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab │ ................ - 0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾─alloc7──╼ │ ............╾──╼ + 0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾ALLOC1╼ │ ............╾──╼ 0x20 │ 01 ef cd ab 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x30 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x40 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x50 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x60 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x70 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ - 0x80 │ 00 00 00 00 00 00 00 00 00 00 ╾─alloc9──╼ 00 00 │ ..........╾──╼.. - 0x90 │ ╾a10+0x63─╼ 00 00 00 00 00 00 00 00 00 00 00 00 │ ╾──╼............ + 0x80 │ 00 00 00 00 00 00 00 00 00 00 ╾ALLOC2╼ 00 00 │ ..........╾──╼.. + 0x90 │ ╾ALLOC3+0x63╼ 00 00 00 00 00 00 00 00 00 00 00 00 │ ╾──╼............ 0xa0 │ 00 00 00 00 00 00 00 00 │ ........ } -alloc7 (size: 4, align: 4) { +ALLOC1 (size: 4, align: 4) { 2a 00 00 00 │ *... } -alloc9 (fn: main) +ALLOC2 (fn: main) -alloc10 (size: 100, align: 1) { +ALLOC3 (size: 100, align: 1) { 0x00 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x10 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x20 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ diff --git a/tests/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir b/tests/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir index d5feea723e7..6af0e3cbd94 100644 --- a/tests/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir +++ b/tests/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir @@ -8,7 +8,7 @@ fn main() -> () { bb0: { StorageLive(_1); StorageLive(_2); - _2 = const {alloc1: &&Packed}; + _2 = const {ALLOC2: &&Packed}; _1 = (*_2); StorageDead(_2); StorageDead(_1); @@ -17,13 +17,13 @@ fn main() -> () { } } -alloc1 (static: FOO, size: 8, align: 8) { - ╾───────alloc12───────╼ │ ╾──────╼ +ALLOC2 (static: FOO, size: 8, align: 8) { + ╾ALLOC0╼ │ ╾──────╼ } -alloc12 (size: 180, align: 1) { +ALLOC0 (size: 180, align: 1) { 0x00 │ ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab │ ................ - 0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾──alloc7── │ ............╾─── + 0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾──ALLOC3── │ ............╾─── 0x20 │ ──────────╼ 01 ef cd ab 00 00 00 00 00 00 00 00 │ ───╼............ 0x30 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x40 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ @@ -31,18 +31,18 @@ alloc12 (size: 180, align: 1) { 0x60 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x70 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x80 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ╾──── │ ..............╾─ - 0x90 │ ─────alloc9─────╼ 00 00 ╾────alloc10+0x63─────╼ │ ─────╼..╾──────╼ + 0x90 │ ─────ALLOC4─────╼ 00 00 ╾ALLOC1+0x63╼ │ ─────╼..╾──────╼ 0xa0 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0xb0 │ 00 00 00 00 │ .... } -alloc7 (size: 4, align: 4) { +ALLOC3 (size: 4, align: 4) { 2a 00 00 00 │ *... } -alloc9 (fn: main) +ALLOC4 (fn: main) -alloc10 (size: 100, align: 1) { +ALLOC1 (size: 100, align: 1) { 0x00 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x10 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x20 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ diff --git a/tests/mir-opt/const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-elaborate-drops.after.mir b/tests/mir-opt/const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-elaborate-drops.after.mir index 5b8d3ca78e3..960b982242d 100644 --- a/tests/mir-opt/const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-elaborate-drops.after.mir +++ b/tests/mir-opt/const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-elaborate-drops.after.mir @@ -7,7 +7,7 @@ promoted[0] in BAR: &[&i32; 1] = { let mut _3: &i32; bb0: { - _3 = const {alloc1: &i32}; + _3 = const {ALLOC0: &i32}; _2 = &(*_3); _1 = [move _2]; _0 = &_1; @@ -15,6 +15,6 @@ promoted[0] in BAR: &[&i32; 1] = { } } -alloc1 (static: Y, size: 4, align: 4) { +ALLOC0 (static: Y, size: 4, align: 4) { 2a 00 00 00 │ *... } diff --git a/tests/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff b/tests/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff index 14d2d7fc85c..4a93db3fcaa 100644 --- a/tests/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff +++ b/tests/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff @@ -16,7 +16,7 @@ - StorageLive(_3); - StorageLive(_4); - StorageLive(_5); -- _5 = const {alloc1: &i32}; +- _5 = const {ALLOC0: &i32}; - _4 = &(*_5); - _3 = [move _4]; - _2 = &_3; @@ -40,7 +40,7 @@ } - } - -- alloc1 (static: Y, size: 4, align: 4) { +- ALLOC0 (static: Y, size: 4, align: 4) { - 2a 00 00 00 │ *... } diff --git a/tests/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir b/tests/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir index 85355389be5..a9c05442764 100644 --- a/tests/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir +++ b/tests/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir @@ -7,7 +7,7 @@ promoted[0] in FOO: &[&i32; 1] = { let mut _3: *const i32; bb0: { - _3 = const {alloc3: *const i32}; + _3 = const {ALLOC0: *const i32}; _2 = &(*_3); _1 = [move _2]; _0 = &_1; @@ -15,4 +15,4 @@ promoted[0] in FOO: &[&i32; 1] = { } } -alloc3 (extern static: X) +ALLOC0 (extern static: X) diff --git a/tests/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff b/tests/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff index ffdd195eca3..21d21b0eee0 100644 --- a/tests/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff +++ b/tests/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff @@ -18,7 +18,7 @@ - StorageLive(_3); - StorageLive(_4); - StorageLive(_5); -- _5 = const {alloc3: *const i32}; +- _5 = const {ALLOC0: *const i32}; - _4 = &(*_5); - _3 = [move _4]; - _2 = &_3; @@ -42,5 +42,5 @@ } } - -- alloc3 (extern static: X) +- ALLOC0 (extern static: X) diff --git a/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-abort.diff index c2fd7f65f5e..5a958cc7a47 100644 --- a/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-abort.diff @@ -26,7 +26,7 @@ } + } + -+ alloc3 (size: 8, align: 4) { ++ ALLOC0 (size: 8, align: 4) { + 02 00 00 00 00 __ __ __ │ .....░░░ } diff --git a/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-unwind.diff index 21a31f9aba3..ab48186aed9 100644 --- a/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-unwind.diff @@ -26,7 +26,7 @@ } + } + -+ alloc3 (size: 8, align: 4) { ++ ALLOC0 (size: 8, align: 4) { + 02 00 00 00 00 __ __ __ │ .....░░░ } diff --git a/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-abort.diff index c0efc873029..530cfc6539a 100644 --- a/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-abort.diff @@ -31,7 +31,7 @@ } + } + -+ alloc3 (size: 2, align: 1) { ++ ALLOC0 (size: 2, align: 1) { + 03 00 │ .. } diff --git a/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff index 2aee6f164ae..08cf72e47a9 100644 --- a/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff @@ -31,7 +31,7 @@ } + } + -+ alloc3 (size: 2, align: 1) { ++ ALLOC0 (size: 2, align: 1) { + 03 00 │ .. } diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff index d585ae89e82..b30deb2a4d4 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff @@ -39,7 +39,7 @@ } + } + -+ alloc3 (size: 2, align: 1) { ++ ALLOC0 (size: 2, align: 1) { + 00 01 │ .. } diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff index 9fe39090638..47c51196c02 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff @@ -39,7 +39,7 @@ } + } + -+ alloc3 (size: 2, align: 1) { ++ ALLOC0 (size: 2, align: 1) { + 00 01 │ .. } diff --git a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff index 18341ba7db9..6484b4b67af 100644 --- a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff @@ -20,11 +20,11 @@ } + } + -+ alloc8 (size: 2, align: 1) { ++ ALLOC0 (size: 2, align: 1) { + 00 00 │ .. + } + -+ alloc7 (size: 2, align: 1) { ++ ALLOC1 (size: 2, align: 1) { + 00 00 │ .. } diff --git a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff index 50763c10f0c..b02f0407839 100644 --- a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff @@ -20,11 +20,11 @@ } + } + -+ alloc8 (size: 2, align: 1) { ++ ALLOC0 (size: 2, align: 1) { + 00 00 │ .. + } + -+ alloc7 (size: 2, align: 1) { ++ ALLOC1 (size: 2, align: 1) { + 00 00 │ .. } diff --git a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff index 015180db896..c1ef453e9df 100644 --- a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff @@ -25,15 +25,15 @@ } + } + -+ alloc12 (size: 2, align: 1) { ++ ALLOC0 (size: 2, align: 1) { + 01 02 │ .. + } + -+ alloc11 (size: 2, align: 1) { ++ ALLOC1 (size: 2, align: 1) { + 01 02 │ .. + } + -+ alloc8 (size: 2, align: 1) { ++ ALLOC2 (size: 2, align: 1) { + 01 02 │ .. } diff --git a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff index 8e41705c1af..53cdcc18167 100644 --- a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff @@ -25,15 +25,15 @@ } + } + -+ alloc12 (size: 2, align: 1) { ++ ALLOC0 (size: 2, align: 1) { + 01 02 │ .. + } + -+ alloc11 (size: 2, align: 1) { ++ ALLOC1 (size: 2, align: 1) { + 01 02 │ .. + } + -+ alloc8 (size: 2, align: 1) { ++ ALLOC2 (size: 2, align: 1) { + 01 02 │ .. } diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff index 56a127ae31e..c3ace9687e6 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff @@ -27,11 +27,11 @@ } + } + -+ alloc7 (size: 8, align: 4) { ++ ALLOC0 (size: 8, align: 4) { + 2a 00 00 00 63 00 00 00 │ *...c... + } + -+ alloc5 (size: 8, align: 4) { ++ ALLOC1 (size: 8, align: 4) { + 2a 00 00 00 2b 00 00 00 │ *...+... } diff --git a/tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff index ac26f8ef4ae..1f74bdcfd03 100644 --- a/tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff @@ -23,7 +23,7 @@ StorageLive(_2); StorageLive(_3); StorageLive(_4); - _4 = const {alloc1: *mut u32}; + _4 = const {ALLOC0: *mut u32}; _3 = (*_4); _1 = move _3; StorageDead(_3); @@ -39,7 +39,7 @@ } } - alloc1 (static: STATIC, size: 4, align: 4) { + ALLOC0 (static: STATIC, size: 4, align: 4) { 42 42 42 42 │ BBBB } diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-abort.diff index a1b433716c8..85bd2b6e722 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-abort.diff @@ -48,7 +48,7 @@ } + } + -+ alloc7 (size: 8, align: 4) { ++ ALLOC0 (size: 8, align: 4) { + 01 00 00 00 02 00 00 00 │ ........ } diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-unwind.diff index 2dc514194bc..06e96e57a62 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-unwind.diff @@ -48,7 +48,7 @@ } + } + -+ alloc7 (size: 8, align: 4) { ++ ALLOC0 (size: 8, align: 4) { + 01 00 00 00 02 00 00 00 │ ........ } diff --git a/tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff b/tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff index 29c455f35b3..e193c82d2c0 100644 --- a/tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff @@ -16,12 +16,12 @@ StorageLive(_1); StorageLive(_2); StorageLive(_3); - _3 = const {alloc1: &u8}; + _3 = const {ALLOC0: &u8}; - _2 = (*_3); + _2 = const 2_u8; StorageLive(_4); StorageLive(_5); - _5 = const {alloc1: &u8}; + _5 = const {ALLOC0: &u8}; - _4 = (*_5); - _1 = Add(move _2, move _4); + _4 = const 2_u8; @@ -36,7 +36,7 @@ } } - alloc1 (static: FOO, size: 1, align: 1) { + ALLOC0 (static: FOO, size: 1, align: 1) { 02 │ . } diff --git a/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-abort.diff index 6c9de476465..974a42e5078 100644 --- a/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-abort.diff @@ -19,7 +19,7 @@ } + } + -+ alloc5 (size: 8, align: 4) { ++ ALLOC0 (size: 8, align: 4) { + 04 00 00 00 00 __ __ __ │ .....░░░ } diff --git a/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-unwind.diff index 0f079278c43..55dbc700285 100644 --- a/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-unwind.diff @@ -19,7 +19,7 @@ } + } + -+ alloc5 (size: 8, align: 4) { ++ ALLOC0 (size: 8, align: 4) { + 04 00 00 00 00 __ __ __ │ .....░░░ } diff --git a/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-abort.mir b/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-abort.mir index c2488f3944c..f87c26bb004 100644 --- a/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-abort.mir +++ b/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-abort.mir @@ -15,6 +15,6 @@ fn add() -> u32 { } } -alloc5 (size: 8, align: 4) { +ALLOC0 (size: 8, align: 4) { 04 00 00 00 00 __ __ __ │ .....░░░ } diff --git a/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-unwind.mir b/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-unwind.mir index fa0b9c77eaf..33f97591387 100644 --- a/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-unwind.mir +++ b/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-unwind.mir @@ -15,6 +15,6 @@ fn add() -> u32 { } } -alloc5 (size: 8, align: 4) { +ALLOC0 (size: 8, align: 4) { 04 00 00 00 00 __ __ __ │ .....░░░ } diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-abort.diff index 988ef7dd225..f19650d5a83 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-abort.diff @@ -31,15 +31,15 @@ } + } + -+ alloc9 (size: 8, align: 4) { ++ ALLOC0 (size: 8, align: 4) { + 01 00 00 00 02 00 00 00 │ ........ + } + -+ alloc8 (size: 8, align: 4) { ++ ALLOC1 (size: 8, align: 4) { + 01 00 00 00 02 00 00 00 │ ........ + } + -+ alloc6 (size: 8, align: 4) { ++ ALLOC2 (size: 8, align: 4) { + 01 00 00 00 02 00 00 00 │ ........ } diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff index 29844619720..67307c42331 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff @@ -31,15 +31,15 @@ } + } + -+ alloc9 (size: 8, align: 4) { ++ ALLOC0 (size: 8, align: 4) { + 01 00 00 00 02 00 00 00 │ ........ + } + -+ alloc8 (size: 8, align: 4) { ++ ALLOC1 (size: 8, align: 4) { + 01 00 00 00 02 00 00 00 │ ........ + } + -+ alloc6 (size: 8, align: 4) { ++ ALLOC2 (size: 8, align: 4) { + 01 00 00 00 02 00 00 00 │ ........ } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-abort.diff index b9b46f16a8b..9bfd46231c4 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-abort.diff @@ -87,13 +87,13 @@ + _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); -+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc7, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; ++ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(_3, const std::alloc::Global); -+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc10, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); ++ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = A { foo: move _2 }; -+ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc11, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; ++ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; @@ -105,15 +105,15 @@ } + } + -+ alloc11 (size: 8, align: 4) { ++ ALLOC2 (size: 8, align: 4) { + 01 00 00 00 00 00 00 00 │ ........ + } + -+ alloc10 (size: 8, align: 4) { ++ ALLOC1 (size: 8, align: 4) { + 01 00 00 00 00 00 00 00 │ ........ + } + -+ alloc7 (size: 8, align: 4) { ++ ALLOC0 (size: 8, align: 4) { + 01 00 00 00 00 00 00 00 │ ........ } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-unwind.diff index 93b18f23e61..dba50b1428e 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-unwind.diff @@ -87,13 +87,13 @@ + _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); -+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc7, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; ++ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(_3, const std::alloc::Global); -+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc10, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); ++ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = A { foo: move _2 }; -+ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc11, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; ++ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; @@ -109,15 +109,15 @@ } + } + -+ alloc11 (size: 8, align: 4) { ++ ALLOC2 (size: 8, align: 4) { + 01 00 00 00 00 00 00 00 │ ........ + } + -+ alloc10 (size: 8, align: 4) { ++ ALLOC1 (size: 8, align: 4) { + 01 00 00 00 00 00 00 00 │ ........ + } + -+ alloc7 (size: 8, align: 4) { ++ ALLOC0 (size: 8, align: 4) { + 01 00 00 00 00 00 00 00 │ ........ } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-abort.diff index 3d3af62856b..33fe4628d83 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-abort.diff @@ -87,13 +87,13 @@ + _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); -+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc7, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; ++ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(_3, const std::alloc::Global); -+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc10, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); ++ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = A { foo: move _2 }; -+ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc11, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; ++ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; @@ -105,15 +105,15 @@ } + } + -+ alloc11 (size: 16, align: 8) { ++ ALLOC2 (size: 16, align: 8) { + 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ + } + -+ alloc10 (size: 16, align: 8) { ++ ALLOC1 (size: 16, align: 8) { + 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ + } + -+ alloc7 (size: 16, align: 8) { ++ ALLOC0 (size: 16, align: 8) { + 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-unwind.diff index 1933f9bafb3..b2d561911de 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-unwind.diff @@ -87,13 +87,13 @@ + _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); -+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc7, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; ++ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(_3, const std::alloc::Global); -+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc10, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); ++ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = A { foo: move _2 }; -+ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc11, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; ++ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; @@ -109,15 +109,15 @@ } + } + -+ alloc11 (size: 16, align: 8) { ++ ALLOC2 (size: 16, align: 8) { + 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ + } + -+ alloc10 (size: 16, align: 8) { ++ ALLOC1 (size: 16, align: 8) { + 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ + } + -+ alloc7 (size: 16, align: 8) { ++ ALLOC0 (size: 16, align: 8) { + 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff index 7862c23da80..1751b0de2f1 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff @@ -81,11 +81,11 @@ StorageDead(_6); _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc7, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc10, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc11, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; + _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; @@ -97,15 +97,15 @@ } } - alloc11 (size: 8, align: 4) { + ALLOC2 (size: 8, align: 4) { 01 00 00 00 00 00 00 00 │ ........ } - alloc10 (size: 8, align: 4) { + ALLOC1 (size: 8, align: 4) { 01 00 00 00 00 00 00 00 │ ........ } - alloc7 (size: 8, align: 4) { + ALLOC0 (size: 8, align: 4) { 01 00 00 00 00 00 00 00 │ ........ } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff index bd4150ebb45..858a9d33ddf 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff @@ -81,11 +81,11 @@ StorageDead(_6); _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc7, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc10, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc11, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; + _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; @@ -101,15 +101,15 @@ } } - alloc11 (size: 8, align: 4) { + ALLOC2 (size: 8, align: 4) { 01 00 00 00 00 00 00 00 │ ........ } - alloc10 (size: 8, align: 4) { + ALLOC1 (size: 8, align: 4) { 01 00 00 00 00 00 00 00 │ ........ } - alloc7 (size: 8, align: 4) { + ALLOC0 (size: 8, align: 4) { 01 00 00 00 00 00 00 00 │ ........ } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff index 312fc7b7a82..51707042075 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff @@ -81,11 +81,11 @@ StorageDead(_6); _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc7, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc10, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc11, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; + _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; @@ -97,15 +97,15 @@ } } - alloc11 (size: 16, align: 8) { + ALLOC2 (size: 16, align: 8) { 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ } - alloc10 (size: 16, align: 8) { + ALLOC1 (size: 16, align: 8) { 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ } - alloc7 (size: 16, align: 8) { + ALLOC0 (size: 16, align: 8) { 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff index 3227d8b8435..9141a6c67be 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff @@ -81,11 +81,11 @@ StorageDead(_6); _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc7, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc10, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc11, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; + _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; @@ -101,15 +101,15 @@ } } - alloc11 (size: 16, align: 8) { + ALLOC2 (size: 16, align: 8) { 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ } - alloc10 (size: 16, align: 8) { + ALLOC1 (size: 16, align: 8) { 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ } - alloc7 (size: 16, align: 8) { + ALLOC0 (size: 16, align: 8) { 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ } diff --git a/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff index ae8b44c953e..1348b279330 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff +++ b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff @@ -43,7 +43,7 @@ bb0: { StorageLive(_1); StorageLive(_2); - _2 = const {alloc1: &E}; + _2 = const {ALLOC1: &E}; _1 = (*_2); StorageDead(_2); StorageLive(_3); @@ -78,7 +78,7 @@ bb4: { StorageLive(_7); StorageLive(_8); - _8 = const {alloc2: &&E}; + _8 = const {ALLOC2: &&E}; _7 = (*_8); StorageDead(_8); StorageLive(_9); @@ -112,15 +112,15 @@ } } - alloc2 (static: RC, size: 4, align: 4) { - ╾─alloc14─╼ │ ╾──╼ + ALLOC2 (static: RC, size: 4, align: 4) { + ╾ALLOC0╼ │ ╾──╼ } - alloc14 (size: 8, align: 4) { + ALLOC0 (size: 8, align: 4) { 01 00 00 00 04 00 00 00 │ ........ } - alloc1 (static: statics::C, size: 8, align: 4) { + ALLOC1 (static: statics::C, size: 8, align: 4) { 00 00 00 00 00 00 00 00 │ ........ } diff --git a/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff index 63799b3bac3..66929e886d3 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff +++ b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff @@ -43,7 +43,7 @@ bb0: { StorageLive(_1); StorageLive(_2); - _2 = const {alloc1: &E}; + _2 = const {ALLOC1: &E}; _1 = (*_2); StorageDead(_2); StorageLive(_3); @@ -78,7 +78,7 @@ bb4: { StorageLive(_7); StorageLive(_8); - _8 = const {alloc2: &&E}; + _8 = const {ALLOC2: &&E}; _7 = (*_8); StorageDead(_8); StorageLive(_9); @@ -112,15 +112,15 @@ } } - alloc2 (static: RC, size: 8, align: 8) { - ╾───────alloc14───────╼ │ ╾──────╼ + ALLOC2 (static: RC, size: 8, align: 8) { + ╾ALLOC0╼ │ ╾──────╼ } - alloc14 (size: 8, align: 4) { + ALLOC0 (size: 8, align: 4) { 01 00 00 00 04 00 00 00 │ ........ } - alloc1 (static: statics::C, size: 8, align: 4) { + ALLOC1 (static: statics::C, size: 8, align: 4) { 00 00 00 00 00 00 00 00 │ ........ } diff --git a/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.32bit.diff index 2de6ba307d5..e80f31ca934 100644 --- a/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.32bit.diff +++ b/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.32bit.diff @@ -84,7 +84,7 @@ + _10 = const S(13_i32); StorageDead(_11); StorageLive(_16); - _16 = const {alloc1: &&BigStruct}; + _16 = const {ALLOC1: &&BigStruct}; _17 = deref_copy (*_16); StorageLive(_12); _18 = deref_copy (*_16); @@ -119,11 +119,11 @@ } } - alloc1 (static: STAT, size: 4, align: 4) { - ╾─alloc15─╼ │ ╾──╼ + ALLOC1 (static: STAT, size: 4, align: 4) { + ╾ALLOC0╼ │ ╾──╼ } - alloc15 (size: 16, align: 4) { + ALLOC0 (size: 16, align: 4) { 01 00 00 00 00 00 e0 40 0d 00 00 00 05 __ __ __ │ .......@.....░░░ } diff --git a/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.64bit.diff index 71a28f2165b..de9cf197199 100644 --- a/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.64bit.diff +++ b/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.64bit.diff @@ -84,7 +84,7 @@ + _10 = const S(13_i32); StorageDead(_11); StorageLive(_16); - _16 = const {alloc1: &&BigStruct}; + _16 = const {ALLOC1: &&BigStruct}; _17 = deref_copy (*_16); StorageLive(_12); _18 = deref_copy (*_16); @@ -119,11 +119,11 @@ } } - alloc1 (static: STAT, size: 8, align: 8) { - ╾───────alloc15───────╼ │ ╾──────╼ + ALLOC1 (static: STAT, size: 8, align: 8) { + ╾ALLOC0╼ │ ╾──────╼ } - alloc15 (size: 16, align: 4) { + ALLOC0 (size: 16, align: 4) { 01 00 00 00 00 00 e0 40 0d 00 00 00 05 __ __ __ │ .......@.....░░░ } diff --git a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff index d5e58265dcc..142e08f4d6c 100644 --- a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff +++ b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff @@ -4,29 +4,20 @@ fn main() -> () { let mut _0: (); let _1: main::Un; - let mut _2: u32; - let mut _3: u32; scope 1 { debug un => _1; scope 2 { } - scope 3 (inlined std::mem::drop::<u32>) { - debug _x => _3; + scope 4 (inlined std::mem::drop::<u32>) { + debug _x => const 1_u32; } } + scope 3 (inlined val) { + } bb0: { StorageLive(_1); - StorageLive(_2); - _2 = val() -> [return: bb1, unwind unreachable]; - } - - bb1: { - _1 = Un { us: move _2 }; - StorageDead(_2); - StorageLive(_3); - _3 = (_1.0: u32); - StorageDead(_3); + _1 = Un { us: const 1_u32 }; StorageDead(_1); return; } diff --git a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff index 5eaaeba135b..142e08f4d6c 100644 --- a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff +++ b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff @@ -4,29 +4,20 @@ fn main() -> () { let mut _0: (); let _1: main::Un; - let mut _2: u32; - let mut _3: u32; scope 1 { debug un => _1; scope 2 { } - scope 3 (inlined std::mem::drop::<u32>) { - debug _x => _3; + scope 4 (inlined std::mem::drop::<u32>) { + debug _x => const 1_u32; } } + scope 3 (inlined val) { + } bb0: { StorageLive(_1); - StorageLive(_2); - _2 = val() -> [return: bb1, unwind continue]; - } - - bb1: { - _1 = Un { us: move _2 }; - StorageDead(_2); - StorageLive(_3); - _3 = (_1.0: u32); - StorageDead(_3); + _1 = Un { us: const 1_u32 }; StorageDead(_1); return; } diff --git a/tests/mir-opt/enum_opt.cand.EnumSizeOpt.32bit.diff b/tests/mir-opt/enum_opt.cand.EnumSizeOpt.32bit.diff index ec5f5c1f1fc..775a60f1c96 100644 --- a/tests/mir-opt/enum_opt.cand.EnumSizeOpt.32bit.diff +++ b/tests/mir-opt/enum_opt.cand.EnumSizeOpt.32bit.diff @@ -66,7 +66,7 @@ } + } + -+ alloc15 (size: 8, align: 4) { ++ ALLOC0 (size: 8, align: 4) { + 02 00 00 00 05 20 00 00 │ ..... .. } diff --git a/tests/mir-opt/enum_opt.cand.EnumSizeOpt.64bit.diff b/tests/mir-opt/enum_opt.cand.EnumSizeOpt.64bit.diff index 9bf8637ec76..c4b57579943 100644 --- a/tests/mir-opt/enum_opt.cand.EnumSizeOpt.64bit.diff +++ b/tests/mir-opt/enum_opt.cand.EnumSizeOpt.64bit.diff @@ -66,7 +66,7 @@ } + } + -+ alloc15 (size: 16, align: 8) { ++ ALLOC0 (size: 16, align: 8) { + 02 00 00 00 00 00 00 00 05 20 00 00 00 00 00 00 │ ......... ...... } diff --git a/tests/mir-opt/enum_opt.unin.EnumSizeOpt.32bit.diff b/tests/mir-opt/enum_opt.unin.EnumSizeOpt.32bit.diff index 7dc6d21a907..f7d0d1fb56c 100644 --- a/tests/mir-opt/enum_opt.unin.EnumSizeOpt.32bit.diff +++ b/tests/mir-opt/enum_opt.unin.EnumSizeOpt.32bit.diff @@ -66,7 +66,7 @@ } + } + -+ alloc14 (size: 8, align: 4) { ++ ALLOC0 (size: 8, align: 4) { + 05 20 00 00 01 00 00 00 │ . ...... } diff --git a/tests/mir-opt/enum_opt.unin.EnumSizeOpt.64bit.diff b/tests/mir-opt/enum_opt.unin.EnumSizeOpt.64bit.diff index 0b000876a86..15f1bd0df51 100644 --- a/tests/mir-opt/enum_opt.unin.EnumSizeOpt.64bit.diff +++ b/tests/mir-opt/enum_opt.unin.EnumSizeOpt.64bit.diff @@ -66,7 +66,7 @@ } + } + -+ alloc14 (size: 16, align: 8) { ++ ALLOC0 (size: 16, align: 8) { + 05 20 00 00 00 00 00 00 01 00 00 00 00 00 00 00 │ . .............. } diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-abort.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-abort.diff index a538756ba2d..298a6084899 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-abort.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-abort.diff @@ -7,104 +7,104 @@ debug upper => _3; let mut _0: std::result::Result<(), std::fmt::Error>; let _4: bool; - let mut _5: &std::fmt::Formatter<'_>; - let mut _7: std::option::Option<usize>; - let mut _8: &std::fmt::Formatter<'_>; - let mut _9: isize; - let mut _11: &mut std::fmt::Formatter<'_>; - let mut _12: &T; - let mut _13: core::num::flt2dec::Sign; - let mut _14: u32; - let mut _15: u32; - let mut _16: usize; - let mut _17: bool; - let mut _18: &mut std::fmt::Formatter<'_>; - let mut _19: &T; - let mut _20: core::num::flt2dec::Sign; - let mut _21: bool; + let mut _6: std::option::Option<usize>; + let mut _7: isize; + let mut _9: &mut std::fmt::Formatter<'_>; + let mut _10: &T; + let mut _11: core::num::flt2dec::Sign; + let mut _12: u32; + let mut _13: u32; + let mut _14: usize; + let mut _15: bool; + let mut _16: &mut std::fmt::Formatter<'_>; + let mut _17: &T; + let mut _18: core::num::flt2dec::Sign; + let mut _19: bool; scope 1 { debug force_sign => _4; - let _6: core::num::flt2dec::Sign; + let _5: core::num::flt2dec::Sign; scope 2 { - debug sign => _6; + debug sign => _5; scope 3 { - debug precision => _10; - let _10: usize; + debug precision => _8; + let _8: usize; + scope 5 (inlined Formatter::<'_>::precision) { + debug self => _1; + } } } } + scope 4 (inlined Formatter::<'_>::sign_plus) { + debug self => _1; + let mut _20: u32; + let mut _21: u32; + } bb0: { StorageLive(_4); + StorageLive(_20); + StorageLive(_21); + _21 = ((*_1).0: u32); + _20 = BitAnd(move _21, const 1_u32); + StorageDead(_21); + _4 = Ne(move _20, const 0_u32); + StorageDead(_20); StorageLive(_5); - _5 = &(*_1); - _4 = Formatter::<'_>::sign_plus(move _5) -> [return: bb1, unwind unreachable]; + switchInt(_4) -> [0: bb2, otherwise: bb1]; } bb1: { - StorageDead(_5); - StorageLive(_6); - switchInt(_4) -> [0: bb3, otherwise: bb2]; +- _5 = MinusPlus; ++ _5 = const MinusPlus; + goto -> bb3; } bb2: { -- _6 = MinusPlus; -+ _6 = const MinusPlus; - goto -> bb4; +- _5 = Minus; ++ _5 = const Minus; + goto -> bb3; } bb3: { -- _6 = Minus; -+ _6 = const Minus; - goto -> bb4; + StorageLive(_6); + _6 = ((*_1).4: std::option::Option<usize>); + _7 = discriminant(_6); + switchInt(move _7) -> [1: bb4, otherwise: bb6]; } bb4: { - StorageLive(_7); - StorageLive(_8); - _8 = &(*_1); - _7 = Formatter::<'_>::precision(move _8) -> [return: bb5, unwind unreachable]; + _8 = ((_6 as Some).0: usize); + StorageLive(_11); + _11 = _5; + StorageLive(_12); + StorageLive(_13); + _13 = _8 as u32 (IntToInt); + _12 = Add(move _13, const 1_u32); + StorageDead(_13); + _0 = float_to_exponential_common_exact::<T>(_1, _2, move _11, move _12, _3) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_8); - _9 = discriminant(_7); - switchInt(move _9) -> [1: bb6, otherwise: bb8]; + StorageDead(_12); + StorageDead(_11); + goto -> bb8; } bb6: { - _10 = ((_7 as Some).0: usize); - StorageLive(_13); - _13 = _6; - StorageLive(_14); - StorageLive(_15); - _15 = _10 as u32 (IntToInt); - _14 = Add(move _15, const 1_u32); - StorageDead(_15); - _0 = float_to_exponential_common_exact::<T>(_1, _2, move _13, move _14, _3) -> [return: bb7, unwind unreachable]; + StorageLive(_18); + _18 = _5; + _0 = float_to_exponential_common_shortest::<T>(_1, _2, move _18, _3) -> [return: bb7, unwind unreachable]; } bb7: { - StorageDead(_14); - StorageDead(_13); - goto -> bb10; + StorageDead(_18); + goto -> bb8; } bb8: { - StorageLive(_20); - _20 = _6; - _0 = float_to_exponential_common_shortest::<T>(_1, _2, move _20, _3) -> [return: bb9, unwind unreachable]; - } - - bb9: { - StorageDead(_20); - goto -> bb10; - } - - bb10: { - StorageDead(_6); + StorageDead(_5); StorageDead(_4); - StorageDead(_7); + StorageDead(_6); return; } } diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-unwind.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-unwind.diff index 8a3dcfab44b..037f4f7cfac 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-unwind.diff @@ -7,104 +7,104 @@ debug upper => _3; let mut _0: std::result::Result<(), std::fmt::Error>; let _4: bool; - let mut _5: &std::fmt::Formatter<'_>; - let mut _7: std::option::Option<usize>; - let mut _8: &std::fmt::Formatter<'_>; - let mut _9: isize; - let mut _11: &mut std::fmt::Formatter<'_>; - let mut _12: &T; - let mut _13: core::num::flt2dec::Sign; - let mut _14: u32; - let mut _15: u32; - let mut _16: usize; - let mut _17: bool; - let mut _18: &mut std::fmt::Formatter<'_>; - let mut _19: &T; - let mut _20: core::num::flt2dec::Sign; - let mut _21: bool; + let mut _6: std::option::Option<usize>; + let mut _7: isize; + let mut _9: &mut std::fmt::Formatter<'_>; + let mut _10: &T; + let mut _11: core::num::flt2dec::Sign; + let mut _12: u32; + let mut _13: u32; + let mut _14: usize; + let mut _15: bool; + let mut _16: &mut std::fmt::Formatter<'_>; + let mut _17: &T; + let mut _18: core::num::flt2dec::Sign; + let mut _19: bool; scope 1 { debug force_sign => _4; - let _6: core::num::flt2dec::Sign; + let _5: core::num::flt2dec::Sign; scope 2 { - debug sign => _6; + debug sign => _5; scope 3 { - debug precision => _10; - let _10: usize; + debug precision => _8; + let _8: usize; + scope 5 (inlined Formatter::<'_>::precision) { + debug self => _1; + } } } } + scope 4 (inlined Formatter::<'_>::sign_plus) { + debug self => _1; + let mut _20: u32; + let mut _21: u32; + } bb0: { StorageLive(_4); + StorageLive(_20); + StorageLive(_21); + _21 = ((*_1).0: u32); + _20 = BitAnd(move _21, const 1_u32); + StorageDead(_21); + _4 = Ne(move _20, const 0_u32); + StorageDead(_20); StorageLive(_5); - _5 = &(*_1); - _4 = Formatter::<'_>::sign_plus(move _5) -> [return: bb1, unwind continue]; + switchInt(_4) -> [0: bb2, otherwise: bb1]; } bb1: { - StorageDead(_5); - StorageLive(_6); - switchInt(_4) -> [0: bb3, otherwise: bb2]; +- _5 = MinusPlus; ++ _5 = const MinusPlus; + goto -> bb3; } bb2: { -- _6 = MinusPlus; -+ _6 = const MinusPlus; - goto -> bb4; +- _5 = Minus; ++ _5 = const Minus; + goto -> bb3; } bb3: { -- _6 = Minus; -+ _6 = const Minus; - goto -> bb4; + StorageLive(_6); + _6 = ((*_1).4: std::option::Option<usize>); + _7 = discriminant(_6); + switchInt(move _7) -> [1: bb4, otherwise: bb6]; } bb4: { - StorageLive(_7); - StorageLive(_8); - _8 = &(*_1); - _7 = Formatter::<'_>::precision(move _8) -> [return: bb5, unwind continue]; + _8 = ((_6 as Some).0: usize); + StorageLive(_11); + _11 = _5; + StorageLive(_12); + StorageLive(_13); + _13 = _8 as u32 (IntToInt); + _12 = Add(move _13, const 1_u32); + StorageDead(_13); + _0 = float_to_exponential_common_exact::<T>(_1, _2, move _11, move _12, _3) -> [return: bb5, unwind continue]; } bb5: { - StorageDead(_8); - _9 = discriminant(_7); - switchInt(move _9) -> [1: bb6, otherwise: bb8]; + StorageDead(_12); + StorageDead(_11); + goto -> bb8; } bb6: { - _10 = ((_7 as Some).0: usize); - StorageLive(_13); - _13 = _6; - StorageLive(_14); - StorageLive(_15); - _15 = _10 as u32 (IntToInt); - _14 = Add(move _15, const 1_u32); - StorageDead(_15); - _0 = float_to_exponential_common_exact::<T>(_1, _2, move _13, move _14, _3) -> [return: bb7, unwind continue]; + StorageLive(_18); + _18 = _5; + _0 = float_to_exponential_common_shortest::<T>(_1, _2, move _18, _3) -> [return: bb7, unwind continue]; } bb7: { - StorageDead(_14); - StorageDead(_13); - goto -> bb10; + StorageDead(_18); + goto -> bb8; } bb8: { - StorageLive(_20); - _20 = _6; - _0 = float_to_exponential_common_shortest::<T>(_1, _2, move _20, _3) -> [return: bb9, unwind continue]; - } - - bb9: { - StorageDead(_20); - goto -> bb10; - } - - bb10: { - StorageDead(_6); + StorageDead(_5); StorageDead(_4); - StorageDead(_7); + StorageDead(_6); return; } } diff --git a/tests/mir-opt/inline/issue_106141.rs b/tests/mir-opt/inline/issue_106141.rs index eed1d89172c..e442f8a7522 100644 --- a/tests/mir-opt/inline/issue_106141.rs +++ b/tests/mir-opt/inline/issue_106141.rs @@ -3,6 +3,7 @@ pub fn outer() -> usize { inner() } +#[inline(never)] fn index() -> usize { loop {} } diff --git a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff index bee01a5f97b..b9f268df351 100644 --- a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff @@ -8,31 +8,37 @@ let mut _3: &fn() {foo}; let _4: fn() {foo}; let mut _5: (); ++ scope 1 (inlined hide_foo) { ++ } bb0: { StorageLive(_2); StorageLive(_3); StorageLive(_4); - _4 = hide_foo() -> [return: bb1, unwind unreachable]; - } - - bb1: { +- _4 = hide_foo() -> [return: bb1, unwind unreachable]; +- } +- +- bb1: { _3 = &_4; StorageLive(_5); _5 = (); - _2 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind unreachable]; +- _2 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind unreachable]; ++ _2 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb1, unwind unreachable]; } - bb2: { +- bb2: { ++ bb1: { StorageDead(_5); StorageDead(_3); StorageDead(_4); StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb3, unwind unreachable]; +- drop(_1) -> [return: bb3, unwind unreachable]; ++ drop(_1) -> [return: bb2, unwind unreachable]; } - bb3: { +- bb3: { ++ bb2: { return; } } diff --git a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff index 5a946712ea4..8495164df9c 100644 --- a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff @@ -8,39 +8,48 @@ let mut _3: &fn() {foo}; let _4: fn() {foo}; let mut _5: (); ++ scope 1 (inlined hide_foo) { ++ } bb0: { StorageLive(_2); StorageLive(_3); StorageLive(_4); - _4 = hide_foo() -> [return: bb1, unwind: bb4]; - } - - bb1: { +- _4 = hide_foo() -> [return: bb1, unwind: bb4]; +- } +- +- bb1: { _3 = &_4; StorageLive(_5); _5 = (); - _2 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind: bb4]; +- _2 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind: bb4]; ++ _2 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb1, unwind: bb3]; } - bb2: { +- bb2: { ++ bb1: { StorageDead(_5); StorageDead(_3); StorageDead(_4); StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb3, unwind: bb5]; +- drop(_1) -> [return: bb3, unwind: bb5]; ++ drop(_1) -> [return: bb2, unwind: bb4]; } - bb3: { +- bb3: { ++ bb2: { return; } - bb4 (cleanup): { - drop(_1) -> [return: bb5, unwind terminate(cleanup)]; +- bb4 (cleanup): { +- drop(_1) -> [return: bb5, unwind terminate(cleanup)]; ++ bb3 (cleanup): { ++ drop(_1) -> [return: bb4, unwind terminate(cleanup)]; } - bb5 (cleanup): { +- bb5 (cleanup): { ++ bb4 (cleanup): { resume; } } diff --git a/tests/mir-opt/instrument_coverage.bar.InstrumentCoverage.diff b/tests/mir-opt/instrument_coverage.bar.InstrumentCoverage.diff index 28a7ffda371..13ff1e284d9 100644 --- a/tests/mir-opt/instrument_coverage.bar.InstrumentCoverage.diff +++ b/tests/mir-opt/instrument_coverage.bar.InstrumentCoverage.diff @@ -4,8 +4,10 @@ fn bar() -> bool { let mut _0: bool; ++ coverage Counter(0) => /the/src/instrument_coverage.rs:20:1 - 22:2; ++ bb0: { -+ Coverage::Counter(0) for [/the/src/instrument_coverage.rs:20:1 - 22:2]; ++ Coverage::CounterIncrement(0); _0 = const true; return; } diff --git a/tests/mir-opt/instrument_coverage.main.InstrumentCoverage.diff b/tests/mir-opt/instrument_coverage.main.InstrumentCoverage.diff index 9a8caa26307..f5c59c84693 100644 --- a/tests/mir-opt/instrument_coverage.main.InstrumentCoverage.diff +++ b/tests/mir-opt/instrument_coverage.main.InstrumentCoverage.diff @@ -7,13 +7,21 @@ let mut _2: bool; let mut _3: !; ++ coverage ExpressionId(0) => Expression { lhs: Counter(0), op: Add, rhs: Counter(1) }; ++ coverage ExpressionId(1) => Expression { lhs: Expression(0), op: Subtract, rhs: Counter(1) }; ++ coverage Counter(0) => /the/src/instrument_coverage.rs:11:1 - 11:11; ++ coverage Expression(0) => /the/src/instrument_coverage.rs:12:5 - 13:17; ++ coverage Expression(1) => /the/src/instrument_coverage.rs:14:13 - 14:18; ++ coverage Expression(1) => /the/src/instrument_coverage.rs:17:1 - 17:2; ++ coverage Counter(1) => /the/src/instrument_coverage.rs:15:10 - 15:11; ++ bb0: { -+ Coverage::Counter(0) for [/the/src/instrument_coverage.rs:11:1 - 11:11]; ++ Coverage::CounterIncrement(0); goto -> bb1; } bb1: { -+ Coverage::Expression(0) = Counter(0) + Counter(1) for [/the/src/instrument_coverage.rs:12:5 - 13:17]; ++ Coverage::ExpressionUsed(0); falseUnwind -> [real: bb2, unwind: bb6]; } @@ -27,14 +35,14 @@ } bb4: { -+ Coverage::Expression(1) = Expression(0) - Counter(1) for [/the/src/instrument_coverage.rs:14:13 - 14:18, /the/src/instrument_coverage.rs:17:1 - 17:2]; ++ Coverage::ExpressionUsed(1); _0 = const (); StorageDead(_2); return; } bb5: { -+ Coverage::Counter(1) for [/the/src/instrument_coverage.rs:15:10 - 15:11]; ++ Coverage::CounterIncrement(1); _1 = const (); StorageDead(_2); goto -> bb1; diff --git a/tests/mir-opt/issue_99325.main.built.after.32bit.mir b/tests/mir-opt/issue_99325.main.built.after.32bit.mir index 132b713356e..f8ac75513ba 100644 --- a/tests/mir-opt/issue_99325.main.built.after.32bit.mir +++ b/tests/mir-opt/issue_99325.main.built.after.32bit.mir @@ -271,6 +271,6 @@ fn main() -> () { } } -alloc4 (size: 4, align: 1) { +ALLOC0 (size: 4, align: 1) { 41 41 41 41 │ AAAA } diff --git a/tests/mir-opt/issue_99325.main.built.after.64bit.mir b/tests/mir-opt/issue_99325.main.built.after.64bit.mir index 132b713356e..f8ac75513ba 100644 --- a/tests/mir-opt/issue_99325.main.built.after.64bit.mir +++ b/tests/mir-opt/issue_99325.main.built.after.64bit.mir @@ -271,6 +271,6 @@ fn main() -> () { } } -alloc4 (size: 4, align: 1) { +ALLOC0 (size: 4, align: 1) { 41 41 41 41 │ AAAA } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-abort.diff index 681e9666e0f..bddd961c933 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-abort.diff @@ -57,7 +57,7 @@ } + } + -+ alloc5 (size: 8, align: 4) { ++ ALLOC0 (size: 8, align: 4) { + 04 00 00 00 00 __ __ __ │ .....░░░ } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-unwind.diff index db16b8d82d2..297ebd79fad 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-unwind.diff @@ -57,7 +57,7 @@ } + } + -+ alloc5 (size: 8, align: 4) { ++ ALLOC0 (size: 8, align: 4) { + 04 00 00 00 00 __ __ __ │ .....░░░ } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-abort.diff index 681e9666e0f..bddd961c933 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-abort.diff @@ -57,7 +57,7 @@ } + } + -+ alloc5 (size: 8, align: 4) { ++ ALLOC0 (size: 8, align: 4) { + 04 00 00 00 00 __ __ __ │ .....░░░ } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-unwind.diff index db16b8d82d2..297ebd79fad 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-unwind.diff @@ -57,7 +57,7 @@ } + } + -+ alloc5 (size: 8, align: 4) { ++ ALLOC0 (size: 8, align: 4) { + 04 00 00 00 00 __ __ __ │ .....░░░ } diff --git a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir index 1d3317efd41..7af69e08ca1 100644 --- a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir @@ -4,17 +4,14 @@ fn outer(_1: u8) -> u8 { debug v => _1; // in scope 0 at $DIR/spans.rs:9:14: 9:15 let mut _0: u8; // return place in scope 0 at $DIR/spans.rs:9:24: 9:26 let mut _2: &u8; // in scope 0 at $DIR/spans.rs:10:11: 10:13 + scope 1 (inlined inner) { // at $DIR/spans.rs:10:5: 10:14 + debug x => _2; // in scope 1 at $DIR/spans.rs:13:14: 13:15 + } bb0: { StorageLive(_2); // scope 0 at $DIR/spans.rs:10:11: 10:13 _2 = &_1; // scope 0 at $DIR/spans.rs:10:11: 10:13 - _0 = inner(move _2) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/spans.rs:10:5: 10:14 - // mir::ConstOperand - // + span: $DIR/spans.rs:10:5: 10:10 - // + const_: Const { ty: for<'a> fn(&'a u8) -> u8 {inner}, val: Value(inner) } - } - - bb1: { + _0 = _1; // scope 1 at $DIR/spans.rs:14:5: 14:7 StorageDead(_2); // scope 0 at $DIR/spans.rs:10:13: 10:14 return; // scope 0 at $DIR/spans.rs:11:2: 11:2 } diff --git a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir index aba66861f7d..7af69e08ca1 100644 --- a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir @@ -4,17 +4,14 @@ fn outer(_1: u8) -> u8 { debug v => _1; // in scope 0 at $DIR/spans.rs:9:14: 9:15 let mut _0: u8; // return place in scope 0 at $DIR/spans.rs:9:24: 9:26 let mut _2: &u8; // in scope 0 at $DIR/spans.rs:10:11: 10:13 + scope 1 (inlined inner) { // at $DIR/spans.rs:10:5: 10:14 + debug x => _2; // in scope 1 at $DIR/spans.rs:13:14: 13:15 + } bb0: { StorageLive(_2); // scope 0 at $DIR/spans.rs:10:11: 10:13 _2 = &_1; // scope 0 at $DIR/spans.rs:10:11: 10:13 - _0 = inner(move _2) -> [return: bb1, unwind continue]; // scope 0 at $DIR/spans.rs:10:5: 10:14 - // mir::ConstOperand - // + span: $DIR/spans.rs:10:5: 10:10 - // + const_: Const { ty: for<'a> fn(&'a u8) -> u8 {inner}, val: Value(inner) } - } - - bb1: { + _0 = _1; // scope 1 at $DIR/spans.rs:14:5: 14:7 StorageDead(_2); // scope 0 at $DIR/spans.rs:10:13: 10:14 return; // scope 0 at $DIR/spans.rs:11:2: 11:2 } diff --git a/tests/mir-opt/while_storage.while_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/while_storage.while_loop.PreCodegen.after.panic-abort.mir index c04fdeb637d..e6ce33ed682 100644 --- a/tests/mir-opt/while_storage.while_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/while_storage.while_loop.PreCodegen.after.panic-abort.mir @@ -3,44 +3,26 @@ fn while_loop(_1: bool) -> () { debug c => _1; let mut _0: (); - let mut _2: bool; - let mut _3: bool; + scope 1 (inlined get_bool) { + debug c => _1; + } + scope 2 (inlined get_bool) { + debug c => _1; + } bb0: { goto -> bb1; } bb1: { - StorageLive(_2); - _2 = get_bool(_1) -> [return: bb2, unwind unreachable]; + switchInt(_1) -> [0: bb3, otherwise: bb2]; } bb2: { - switchInt(move _2) -> [0: bb7, otherwise: bb3]; + switchInt(_1) -> [0: bb1, otherwise: bb3]; } bb3: { - StorageLive(_3); - _3 = get_bool(_1) -> [return: bb4, unwind unreachable]; - } - - bb4: { - switchInt(move _3) -> [0: bb5, otherwise: bb6]; - } - - bb5: { - StorageDead(_3); - StorageDead(_2); - goto -> bb1; - } - - bb6: { - StorageDead(_3); - goto -> bb7; - } - - bb7: { - StorageDead(_2); return; } } diff --git a/tests/mir-opt/while_storage.while_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/while_storage.while_loop.PreCodegen.after.panic-unwind.mir index 7dc4f7ab1a8..e6ce33ed682 100644 --- a/tests/mir-opt/while_storage.while_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/while_storage.while_loop.PreCodegen.after.panic-unwind.mir @@ -3,44 +3,26 @@ fn while_loop(_1: bool) -> () { debug c => _1; let mut _0: (); - let mut _2: bool; - let mut _3: bool; + scope 1 (inlined get_bool) { + debug c => _1; + } + scope 2 (inlined get_bool) { + debug c => _1; + } bb0: { goto -> bb1; } bb1: { - StorageLive(_2); - _2 = get_bool(_1) -> [return: bb2, unwind continue]; + switchInt(_1) -> [0: bb3, otherwise: bb2]; } bb2: { - switchInt(move _2) -> [0: bb7, otherwise: bb3]; + switchInt(_1) -> [0: bb1, otherwise: bb3]; } bb3: { - StorageLive(_3); - _3 = get_bool(_1) -> [return: bb4, unwind continue]; - } - - bb4: { - switchInt(move _3) -> [0: bb5, otherwise: bb6]; - } - - bb5: { - StorageDead(_3); - StorageDead(_2); - goto -> bb1; - } - - bb6: { - StorageDead(_3); - goto -> bb7; - } - - bb7: { - StorageDead(_2); return; } } diff --git a/tests/pretty/format-args-str-escape.pp b/tests/pretty/format-args-str-escape.pp new file mode 100644 index 00000000000..b84bc2303b7 --- /dev/null +++ b/tests/pretty/format-args-str-escape.pp @@ -0,0 +1,21 @@ +#![feature(prelude_import)] +#![no_std] +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; +// pretty-compare-only +// pretty-mode:expanded +// pp-exact:format-args-str-escape.pp + +fn main() { + { ::std::io::_print(format_args!("\u{1b}[1mHello, world!\u{1b}[0m\n")); }; + { ::std::io::_print(format_args!("\u{1b}[1mHello, world!\u{1b}[0m\n")); }; + { + ::std::io::_print(format_args!("Not an escape sequence: \\u{{1B}}[1mbold\\x1B[0m\n")); + }; + { + ::std::io::_print(format_args!("{0}\n", + "\x1B[1mHello, world!\x1B[0m")); + }; +} diff --git a/tests/pretty/format-args-str-escape.rs b/tests/pretty/format-args-str-escape.rs new file mode 100644 index 00000000000..e596fcfd8bc --- /dev/null +++ b/tests/pretty/format-args-str-escape.rs @@ -0,0 +1,10 @@ +// pretty-compare-only +// pretty-mode:expanded +// pp-exact:format-args-str-escape.pp + +fn main() { + println!("\x1B[1mHello, world!\x1B[0m"); + println!("\u{1B}[1mHello, world!\u{1B}[0m"); + println!("Not an escape sequence: \\u{{1B}}[1mbold\\x1B[0m"); + println!("{}", "\x1B[1mHello, world!\x1B[0m"); +} diff --git a/tests/run-make-fulldeps/issue-19371/foo.rs b/tests/run-make-fulldeps/issue-19371/foo.rs index 1c9d33dcc8e..7ee46e1520a 100644 --- a/tests/run-make-fulldeps/issue-19371/foo.rs +++ b/tests/run-make-fulldeps/issue-19371/foo.rs @@ -57,6 +57,7 @@ fn compile(code: String, output: PathBuf, sysroot: PathBuf) { locale_resources: &[], lint_caps: Default::default(), parse_sess_created: None, + hash_untracked_state: None, register_lints: None, override_queries: None, make_codegen_backend: None, diff --git a/tests/run-make/dump-ice-to-disk/check.sh b/tests/run-make/dump-ice-to-disk/check.sh index ab6f9ab6018..ff6e4be35af 100644 --- a/tests/run-make/dump-ice-to-disk/check.sh +++ b/tests/run-make/dump-ice-to-disk/check.sh @@ -11,6 +11,12 @@ export RUSTC_ICE=$TMPDIR $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-default-set.log 2>&1 default_set=$(cat $TMPDIR/rustc-ice-*.txt | wc -l) content=$(cat $TMPDIR/rustc-ice-*.txt) +# Ensure that the ICE dump path doesn't contain `:` because they cause problems on Windows +windows_safe=$(echo rustc-ice-*.txt | grep ':') +if [ ! -z "$windows_safe" ]; then + exit 1 +fi + rm $TMPDIR/rustc-ice-*.txt RUST_BACKTRACE=short $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-short.log 2>&1 short=$(cat $TMPDIR/rustc-ice-*.txt | wc -l) diff --git a/tests/run-make/emit-stack-sizes/foo.rs b/tests/run-make/emit-stack-sizes/foo.rs index ee51ae32886..fd0b5120578 100644 --- a/tests/run-make/emit-stack-sizes/foo.rs +++ b/tests/run-make/emit-stack-sizes/foo.rs @@ -1,3 +1,4 @@ #![crate_type = "lib"] +#[inline(never)] pub fn foo() {} diff --git a/tests/run-make/intrinsic-unreachable/exit-ret.rs b/tests/run-make/intrinsic-unreachable/exit-ret.rs index e7b9694d9f2..c8ba5b4599f 100644 --- a/tests/run-make/intrinsic-unreachable/exit-ret.rs +++ b/tests/run-make/intrinsic-unreachable/exit-ret.rs @@ -2,6 +2,7 @@ use std::arch::asm; #[deny(unreachable_code)] +#[inline(never)] pub fn exit(n: usize) -> i32 { unsafe { // Pretend this asm is an exit() syscall. diff --git a/tests/run-make/intrinsic-unreachable/exit-unreachable.rs b/tests/run-make/intrinsic-unreachable/exit-unreachable.rs index ec85db733df..75f893eb2df 100644 --- a/tests/run-make/intrinsic-unreachable/exit-unreachable.rs +++ b/tests/run-make/intrinsic-unreachable/exit-unreachable.rs @@ -5,6 +5,7 @@ use std::arch::asm; use std::intrinsics; #[allow(unreachable_code)] +#[inline(never)] pub fn exit(n: usize) -> i32 { unsafe { // Pretend this asm is an exit() syscall. diff --git a/tests/run-make/wasm-override-linker/Makefile b/tests/run-make/wasm-override-linker/Makefile new file mode 100644 index 00000000000..52339f9261c --- /dev/null +++ b/tests/run-make/wasm-override-linker/Makefile @@ -0,0 +1,13 @@ +# needs-matching-clang + +include ../tools.mk + +ifeq ($(TARGET),wasm32-unknown-unknown) +all: + $(RUSTC) foo.rs --crate-type cdylib --target $(TARGET) -C linker=$(CLANG) +else ifeq ($(TARGET),wasm64-unknown-unknown) +all: + $(RUSTC) foo.rs --crate-type cdylib --target $(TARGET) -C linker=$(CLANG) +else +all: +endif diff --git a/tests/run-make/wasm-override-linker/foo.rs b/tests/run-make/wasm-override-linker/foo.rs new file mode 100644 index 00000000000..f4167a4fc4a --- /dev/null +++ b/tests/run-make/wasm-override-linker/foo.rs @@ -0,0 +1,6 @@ +#![crate_type = "cdylib"] + +#[no_mangle] +pub extern "C" fn add(a: i32, b: i32) -> i32 { + a + b +} diff --git a/tests/rustdoc-ui/check-cfg/check-cfg-unstable.rs b/tests/rustdoc-ui/check-cfg/check-cfg-unstable.rs index 5c500ce6ce0..806b6d1253d 100644 --- a/tests/rustdoc-ui/check-cfg/check-cfg-unstable.rs +++ b/tests/rustdoc-ui/check-cfg/check-cfg-unstable.rs @@ -1,2 +1,2 @@ // check-fail -// compile-flags: --check-cfg=names() +// compile-flags: --check-cfg=cfg() diff --git a/tests/rustdoc-ui/check-cfg/check-cfg.rs b/tests/rustdoc-ui/check-cfg/check-cfg.rs index fa8789ad3ed..96fa9e08dde 100644 --- a/tests/rustdoc-ui/check-cfg/check-cfg.rs +++ b/tests/rustdoc-ui/check-cfg/check-cfg.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: --check-cfg=names() -Z unstable-options +// compile-flags: --check-cfg=cfg() -Z unstable-options /// uniz is nor a builtin nor pass as arguments so is unexpected #[cfg(uniz)] diff --git a/tests/rustdoc-ui/check-cfg/check-cfg.stderr b/tests/rustdoc-ui/check-cfg/check-cfg.stderr index 03fb6f96fb5..d010c1f7ec6 100644 --- a/tests/rustdoc-ui/check-cfg/check-cfg.stderr +++ b/tests/rustdoc-ui/check-cfg/check-cfg.stderr @@ -1,4 +1,4 @@ -warning: unexpected `cfg` condition name +warning: unexpected `cfg` condition name: `uniz` --> $DIR/check-cfg.rs:5:7 | LL | #[cfg(uniz)] diff --git a/tests/rustdoc-ui/doctest/check-cfg-test.rs b/tests/rustdoc-ui/doctest/check-cfg-test.rs index 49a801c3fb3..38cd59aa790 100644 --- a/tests/rustdoc-ui/doctest/check-cfg-test.rs +++ b/tests/rustdoc-ui/doctest/check-cfg-test.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: --test --nocapture --check-cfg=values(feature,"test") -Z unstable-options +// compile-flags: --test --nocapture --check-cfg=cfg(feature,values("test")) -Z unstable-options // normalize-stderr-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" diff --git a/tests/rustdoc-ui/doctest/check-cfg-test.stderr b/tests/rustdoc-ui/doctest/check-cfg-test.stderr index f84543c2072..0bfd569e381 100644 --- a/tests/rustdoc-ui/doctest/check-cfg-test.stderr +++ b/tests/rustdoc-ui/doctest/check-cfg-test.stderr @@ -1,4 +1,4 @@ -warning: unexpected `cfg` condition value +warning: unexpected `cfg` condition value: `invalid` --> $DIR/check-cfg-test.rs:9:7 | LL | #[cfg(feature = "invalid")] diff --git a/tests/rustdoc/issue-31808.rs b/tests/rustdoc-ui/ice-assoc-const-for-primitive-31808.rs index e55c5bd4f7c..6e4709403a4 100644 --- a/tests/rustdoc/issue-31808.rs +++ b/tests/rustdoc-ui/ice-assoc-const-for-primitive-31808.rs @@ -1,5 +1,10 @@ +// check-pass + // Test that associated item impls on primitive types don't crash rustdoc +// https://github.com/rust-lang/rust/issues/31808 +#![crate_name="issue_31808"] + pub trait Foo { const BAR: usize; type BAZ; diff --git a/tests/rustdoc-ui/issues/issue-96287.stderr b/tests/rustdoc-ui/issues/issue-96287.stderr index 7722eb96028..c4809a311fc 100644 --- a/tests/rustdoc-ui/issues/issue-96287.stderr +++ b/tests/rustdoc-ui/issues/issue-96287.stderr @@ -2,7 +2,12 @@ error[E0220]: associated type `Assoc` not found for `V` --> $DIR/issue-96287.rs:7:33 | LL | pub type Foo<V> = impl Trait<V::Assoc>; - | ^^^^^ there is a similarly named associated type `Assoc` in the trait `TraitWithAssoc` + | ^^^^^ there is an associated type `Assoc` in the trait `TraitWithAssoc` + | +help: consider restricting type parameter `V` + | +LL | pub type Foo<V: TraitWithAssoc> = impl Trait<V::Assoc>; + | ++++++++++++++++ error: aborting due to previous error diff --git a/tests/rustdoc/async-trait-sig.rs b/tests/rustdoc/async-trait-sig.rs index 2578bc8f7a1..db1848f716d 100644 --- a/tests/rustdoc/async-trait-sig.rs +++ b/tests/rustdoc/async-trait-sig.rs @@ -1,6 +1,5 @@ // edition:2021 -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] pub trait Foo { diff --git a/tests/rustdoc/async-trait.rs b/tests/rustdoc/async-trait.rs index a473e467473..8de95aac22c 100644 --- a/tests/rustdoc/async-trait.rs +++ b/tests/rustdoc/async-trait.rs @@ -1,7 +1,6 @@ // aux-build:async-trait-dep.rs // edition:2021 -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] extern crate async_trait_dep; diff --git a/tests/rustdoc/auxiliary/async-trait-dep.rs b/tests/rustdoc/auxiliary/async-trait-dep.rs index 10a55dd0260..d455ee99e09 100644 --- a/tests/rustdoc/auxiliary/async-trait-dep.rs +++ b/tests/rustdoc/auxiliary/async-trait-dep.rs @@ -1,6 +1,5 @@ // edition:2021 -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] pub trait Meow { diff --git a/tests/rustdoc/issue-29503.rs b/tests/rustdoc/blanket-impl-29503.rs index 01ae4438500..d6a132e1c26 100644 --- a/tests/rustdoc/issue-29503.rs +++ b/tests/rustdoc/blanket-impl-29503.rs @@ -1,3 +1,6 @@ +// https://github.com/rust-lang/rust/issues/29503 +#![crate_name="issue_29503"] + use std::fmt; // @has issue_29503/trait.MyTrait.html diff --git a/tests/rustdoc/const-effect-param.rs b/tests/rustdoc/const-effect-param.rs new file mode 100644 index 00000000000..f50a9b96d81 --- /dev/null +++ b/tests/rustdoc/const-effect-param.rs @@ -0,0 +1,12 @@ +#![crate_name = "foo"] +#![feature(effects, const_trait_impl)] + +#[const_trait] +pub trait Tr { + fn f(); +} + +// @has foo/fn.g.html +// @has - '//pre[@class="rust item-decl"]' 'pub const fn g<T: Tr>()' +/// foo +pub const fn g<T: ~const Tr>() {} diff --git a/tests/rustdoc/const-fn-effects.rs b/tests/rustdoc/const-fn-effects.rs new file mode 100644 index 00000000000..7c19b4b2c0c --- /dev/null +++ b/tests/rustdoc/const-fn-effects.rs @@ -0,0 +1,19 @@ +#![crate_name = "foo"] +#![feature(effects)] + +// @has foo/fn.bar.html +// @has - '//pre[@class="rust item-decl"]' 'pub const fn bar() -> ' +/// foo +pub const fn bar() -> usize { + 2 +} + +// @has foo/struct.Foo.html +// @has - '//*[@class="method"]' 'const fn new()' +pub struct Foo(usize); + +impl Foo { + pub const fn new() -> Foo { + Foo(0) + } +} diff --git a/tests/rustdoc/issue-33302.rs b/tests/rustdoc/const-rendering-macros-33302.rs index a316f3ad99b..0f5cb921411 100644 --- a/tests/rustdoc/issue-33302.rs +++ b/tests/rustdoc/const-rendering-macros-33302.rs @@ -1,3 +1,6 @@ +// https://github.com/rust-lang/rust/issues/33302 +#![crate_name="issue_33302"] + // Ensure constant and array length values are not taken from source // code, which wreaks havoc with macros. diff --git a/tests/rustdoc/issue-32890.rs b/tests/rustdoc/disambiguate-anchors-32890.rs index 970954433ec..d88601d65d3 100644 --- a/tests/rustdoc/issue-32890.rs +++ b/tests/rustdoc/disambiguate-anchors-32890.rs @@ -1,3 +1,6 @@ +// https://github.com/rust-lang/rust/issues/32890 +#![crate_name="issue_32890"] + // @has issue_32890/struct.Foo.html pub struct Foo<T>(T); diff --git a/tests/rustdoc/issue-29449.rs b/tests/rustdoc/disambiguate-anchors-header-29449.rs index 0d829cf6fcf..38a4954fc13 100644 --- a/tests/rustdoc/issue-29449.rs +++ b/tests/rustdoc/disambiguate-anchors-header-29449.rs @@ -1,3 +1,6 @@ +// https://github.com/rust-lang/rust/issues/29449 +#![crate_name="issue_29449"] + // @has issue_29449/struct.Foo.html pub struct Foo; diff --git a/tests/rustdoc/issue-33069.rs b/tests/rustdoc/doc-hidden-trait-implementors-33069.rs index 0213a53cab5..35570668ea1 100644 --- a/tests/rustdoc/issue-33069.rs +++ b/tests/rustdoc/doc-hidden-trait-implementors-33069.rs @@ -1,3 +1,6 @@ +// https://github.com/rust-lang/rust/issues/33069 +#![crate_name="issue_33069"] + pub trait Bar {} #[doc(hidden)] diff --git a/tests/rustdoc/issue-30252.rs b/tests/rustdoc/doctest-cfg-feature-30252.rs index c3777362a66..ceb8076fe35 100644 --- a/tests/rustdoc/issue-30252.rs +++ b/tests/rustdoc/doctest-cfg-feature-30252.rs @@ -1,5 +1,8 @@ // compile-flags:--test --cfg feature="bar" +// https://github.com/rust-lang/rust/issues/30252 +#![crate_name="issue_30252"] + /// ```rust /// assert_eq!(cfg!(feature = "bar"), true); /// ``` diff --git a/tests/rustdoc/issue-32556.rs b/tests/rustdoc/doctest-ignore-32556.rs index e1cf1150997..99da9358bd6 100644 --- a/tests/rustdoc/issue-32556.rs +++ b/tests/rustdoc/doctest-ignore-32556.rs @@ -1,3 +1,6 @@ +// https://github.com/rust-lang/rust/issues/32556 +#![crate_name="issue_32556"] + /// Blah blah blah /// ```ignore (testing rustdoc's handling of ignore) /// bad_assert!(); diff --git a/tests/rustdoc/issue-34025.rs b/tests/rustdoc/hidden-extern-34025.rs index 9b9f21cb316..81ccf2a0e5c 100644 --- a/tests/rustdoc/issue-34025.rs +++ b/tests/rustdoc/hidden-extern-34025.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/34025 #![crate_name = "foo"] // @!has 'foo/sys/index.html' diff --git a/tests/rustdoc/issue-33592.rs b/tests/rustdoc/impl-type-parameter-33592.rs index 7a128f0b897..77f53710e5e 100644 --- a/tests/rustdoc/issue-33592.rs +++ b/tests/rustdoc/impl-type-parameter-33592.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/33592 #![crate_name = "foo"] pub trait Foo<T> {} diff --git a/tests/rustdoc/inline_cross/attributes.rs b/tests/rustdoc/inline_cross/attributes.rs new file mode 100644 index 00000000000..c0b75c48fee --- /dev/null +++ b/tests/rustdoc/inline_cross/attributes.rs @@ -0,0 +1,7 @@ +// aux-crate:attributes=attributes.rs +// edition:2021 +#![crate_name = "user"] + +// @has 'user/struct.NonExhaustive.html' +// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[non_exhaustive]' +pub use attributes::NonExhaustive; diff --git a/tests/rustdoc/inline_cross/auxiliary/async-fn.rs b/tests/rustdoc/inline_cross/auxiliary/async-fn.rs index 767564ed145..564ca7d671e 100644 --- a/tests/rustdoc/inline_cross/auxiliary/async-fn.rs +++ b/tests/rustdoc/inline_cross/auxiliary/async-fn.rs @@ -1,4 +1,3 @@ -#![feature(async_fn_in_trait)] // edition: 2021 pub async fn load() -> i32 { diff --git a/tests/rustdoc/inline_cross/auxiliary/attributes.rs b/tests/rustdoc/inline_cross/auxiliary/attributes.rs new file mode 100644 index 00000000000..c6f155d4ba5 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/attributes.rs @@ -0,0 +1,2 @@ +#[non_exhaustive] +pub struct NonExhaustive; diff --git a/tests/rustdoc/inline_cross/auxiliary/const-fn.rs b/tests/rustdoc/inline_cross/auxiliary/const-fn.rs new file mode 100644 index 00000000000..26332b419b6 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/const-fn.rs @@ -0,0 +1,5 @@ +#![feature(effects)] + +pub const fn load() -> i32 { + 0 +} diff --git a/tests/rustdoc/auxiliary/issue-29584.rs b/tests/rustdoc/inline_cross/auxiliary/issue-29584.rs index a9b8796c0fe..a9b8796c0fe 100644 --- a/tests/rustdoc/auxiliary/issue-29584.rs +++ b/tests/rustdoc/inline_cross/auxiliary/issue-29584.rs diff --git a/tests/rustdoc/inline_cross/auxiliary/repr.rs b/tests/rustdoc/inline_cross/auxiliary/repr.rs index 4a6648a6439..35f08c11b7b 100644 --- a/tests/rustdoc/inline_cross/auxiliary/repr.rs +++ b/tests/rustdoc/inline_cross/auxiliary/repr.rs @@ -10,7 +10,7 @@ pub struct ReprSimd { } #[repr(transparent)] pub struct ReprTransparent { - field: u8, + pub field: u8, } #[repr(isize)] pub enum ReprIsize { @@ -20,3 +20,23 @@ pub enum ReprIsize { pub enum ReprU8 { Bla, } + +#[repr(transparent)] // private +pub struct ReprTransparentPrivField { + field: u32, // non-1-ZST field +} + +#[repr(transparent)] // public +pub struct ReprTransparentPriv1ZstFields { + marker0: Marker, + pub main: u64, // non-1-ZST field + marker1: Marker, +} + +#[repr(transparent)] // private +pub struct ReprTransparentPrivFieldPub1ZstFields { + main: [u16; 0], // non-1-ZST field + pub marker: Marker, +} + +pub struct Marker; // 1-ZST diff --git a/tests/rustdoc/inline_cross/auxiliary/ret-pos-impl-trait-in-trait.rs b/tests/rustdoc/inline_cross/auxiliary/ret-pos-impl-trait-in-trait.rs index c72f011152d..08a3f517671 100644 --- a/tests/rustdoc/inline_cross/auxiliary/ret-pos-impl-trait-in-trait.rs +++ b/tests/rustdoc/inline_cross/auxiliary/ret-pos-impl-trait-in-trait.rs @@ -1,5 +1,3 @@ -#![feature(return_position_impl_trait_in_trait)] - pub trait Trait { fn create() -> impl Iterator<Item = u64> { std::iter::empty() diff --git a/tests/rustdoc/inline_cross/const-fn.rs b/tests/rustdoc/inline_cross/const-fn.rs new file mode 100644 index 00000000000..24934b873c2 --- /dev/null +++ b/tests/rustdoc/inline_cross/const-fn.rs @@ -0,0 +1,10 @@ +// Regression test for issue #116629. +// Check that we render the correct generic params of const fn + +// aux-crate:const_fn=const-fn.rs +// edition: 2021 +#![crate_name = "user"] + +// @has user/fn.load.html +// @has - '//pre[@class="rust item-decl"]' "pub const fn load() -> i32" +pub use const_fn::load; diff --git a/tests/rustdoc/issue-29584.rs b/tests/rustdoc/inline_cross/doc-hidden-extern-trait-impl-29584.rs index 4364a9649b5..b246e94e048 100644 --- a/tests/rustdoc/issue-29584.rs +++ b/tests/rustdoc/inline_cross/doc-hidden-extern-trait-impl-29584.rs @@ -1,6 +1,9 @@ // aux-build:issue-29584.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/29584 +#![crate_name="issue_29584"] + extern crate issue_29584; // @has issue_29584/struct.Foo.html diff --git a/tests/rustdoc/inline_cross/repr.rs b/tests/rustdoc/inline_cross/repr.rs index 9e107cee9e9..2f3d8f00388 100644 --- a/tests/rustdoc/inline_cross/repr.rs +++ b/tests/rustdoc/inline_cross/repr.rs @@ -9,21 +9,32 @@ extern crate repr; // @has 'foo/struct.ReprC.html' // @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(C, align(8))]' -#[doc(inline)] pub use repr::ReprC; // @has 'foo/struct.ReprSimd.html' // @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(simd, packed(2))]' -#[doc(inline)] pub use repr::ReprSimd; // @has 'foo/struct.ReprTransparent.html' // @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' -#[doc(inline)] pub use repr::ReprTransparent; // @has 'foo/enum.ReprIsize.html' // @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(isize)]' -#[doc(inline)] pub use repr::ReprIsize; // @has 'foo/enum.ReprU8.html' // @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(u8)]' -#[doc(inline)] pub use repr::ReprU8; + +// Regression test for <https://github.com/rust-lang/rust/issues/90435>. +// Check that we show `#[repr(transparent)]` iff the non-1-ZST field is public or at least one +// field is public in case all fields are 1-ZST fields. + +// @has 'foo/struct.ReprTransparentPrivField.html' +// @!has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +pub use repr::ReprTransparentPrivField; + +// @has 'foo/struct.ReprTransparentPriv1ZstFields.html' +// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +pub use repr::ReprTransparentPriv1ZstFields; + +// @has 'foo/struct.ReprTransparentPrivFieldPub1ZstFields.html' +// @!has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +pub use repr::ReprTransparentPrivFieldPub1ZstFields; diff --git a/tests/rustdoc/issue-33178.rs b/tests/rustdoc/link-extern-crate-33178.rs index ed643f5ae11..6a63712c4a7 100644 --- a/tests/rustdoc/issue-33178.rs +++ b/tests/rustdoc/link-extern-crate-33178.rs @@ -3,6 +3,9 @@ // build-aux-docs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/33178 +#![crate_name="issue_33178"] + // @has issue_33178/index.html // @has - '//a[@title="mod empty"][@href="../empty/index.html"]' empty pub extern crate empty; diff --git a/tests/rustdoc/issue-30109.rs b/tests/rustdoc/link-extern-crate-item-30109.rs index e9447538ad7..c83234352ad 100644 --- a/tests/rustdoc/issue-30109.rs +++ b/tests/rustdoc/link-extern-crate-item-30109.rs @@ -2,6 +2,9 @@ // aux-build:issue-30109-1.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/30109 +#![crate_name="issue_30109"] + pub mod quux { extern crate issue_30109_1 as bar; use self::bar::Bar; diff --git a/tests/rustdoc/issue-33178-1.rs b/tests/rustdoc/link-extern-crate-title-33178.rs index 4dc425346ab..d2f115a386e 100644 --- a/tests/rustdoc/issue-33178-1.rs +++ b/tests/rustdoc/link-extern-crate-title-33178.rs @@ -2,6 +2,9 @@ // aux-build:variant-struct.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/33178 +#![crate_name="issue_33178_1"] + // @has issue_33178_1/index.html // @!has - //a/@title empty pub extern crate empty; diff --git a/tests/rustdoc/issue-32395.rs b/tests/rustdoc/render-enum-variant-structlike-32395.rs index 5552300f9fe..2200d8ec637 100644 --- a/tests/rustdoc/issue-32395.rs +++ b/tests/rustdoc/render-enum-variant-structlike-32395.rs @@ -2,6 +2,9 @@ // build-aux-docs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/32395 +#![crate_name="issue_32395"] + // @has variant_struct/enum.Foo.html // @!hasraw - 'pub qux' // @!hasraw - 'pub(crate) qux' diff --git a/tests/rustdoc/repr.rs b/tests/rustdoc/repr.rs new file mode 100644 index 00000000000..fbb46e126ba --- /dev/null +++ b/tests/rustdoc/repr.rs @@ -0,0 +1,29 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/90435>. +// Check that we show `#[repr(transparent)]` iff the non-1-ZST field is public or at least one +// field is public in case all fields are 1-ZST fields. + +// @has 'repr/struct.ReprTransparentPrivField.html' +// @!has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +#[repr(transparent)] // private +pub struct ReprTransparentPrivField { + field: u32, // non-1-ZST field +} + +// @has 'repr/struct.ReprTransparentPriv1ZstFields.html' +// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +#[repr(transparent)] // public +pub struct ReprTransparentPriv1ZstFields { + marker0: Marker, + pub main: u64, // non-1-ZST field + marker1: Marker, +} + +// @has 'repr/struct.ReprTransparentPub1ZstField.html' +// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +#[repr(transparent)] // public +pub struct ReprTransparentPub1ZstField { + marker0: Marker, + pub marker1: Marker, +} + +struct Marker; // 1-ZST diff --git a/tests/rustdoc/issue-34274.rs b/tests/rustdoc/src-links-inlined-34274.rs index ce5be84a549..a3c9bf7e45c 100644 --- a/tests/rustdoc/issue-34274.rs +++ b/tests/rustdoc/src-links-inlined-34274.rs @@ -2,6 +2,7 @@ // build-aux-docs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/34274 #![crate_name = "foo"] extern crate issue_34274; diff --git a/tests/rustdoc/issue-32374.rs b/tests/rustdoc/staged-api-deprecated-unstable-32374.rs index 985bf03a121..d282dea907e 100644 --- a/tests/rustdoc/issue-32374.rs +++ b/tests/rustdoc/staged-api-deprecated-unstable-32374.rs @@ -1,6 +1,8 @@ +// https://github.com/rust-lang/rust/issues/32374 #![feature(staged_api)] #![doc(issue_tracker_base_url = "https://issue_url/")] #![unstable(feature = "test", issue = "32374")] +#![crate_name="issue_32374"] // @matches issue_32374/index.html '//*[@class="item-name"]/span[@class="stab deprecated"]' \ // 'Deprecated' diff --git a/tests/rustdoc/issue-31899.rs b/tests/rustdoc/summary-codeblock-31899.rs index 3eee374465d..c1b33058c9e 100644 --- a/tests/rustdoc/issue-31899.rs +++ b/tests/rustdoc/summary-codeblock-31899.rs @@ -1,3 +1,6 @@ +// https://github.com/rust-lang/rust/issues/31899 +#![crate_name="issue_31899"] + // @has issue_31899/index.html // @hasraw - 'Make this line a bit longer.' // @!hasraw - 'rust rust-example-rendered' diff --git a/tests/rustdoc/issue-30366.rs b/tests/rustdoc/summary-reference-link-30366.rs index c6274a058b0..5b9854c5390 100644 --- a/tests/rustdoc/issue-30366.rs +++ b/tests/rustdoc/summary-reference-link-30366.rs @@ -1,5 +1,8 @@ // @has issue_30366/index.html '//a/@href' 'http://www.rust-lang.org/' +// https://github.com/rust-lang/rust/issues/30366 +#![crate_name="issue_30366"] + /// Describe it. [Link somewhere][1]. /// /// [1]: http://www.rust-lang.org/ diff --git a/tests/rustdoc/issue-32077-type-alias-impls.rs b/tests/rustdoc/type-alias-impls-32077.rs index 664b678093e..7bb763f86af 100644 --- a/tests/rustdoc/issue-32077-type-alias-impls.rs +++ b/tests/rustdoc/type-alias-impls-32077.rs @@ -1,5 +1,6 @@ // Regression test for <https://github.com/rust-lang/rust/issues/32077>. +// https://github.com/rust-lang/rust/issues/32077 #![crate_name = "foo"] pub struct GenericStruct<T>(T); diff --git a/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.rs b/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.rs new file mode 100644 index 00000000000..39980ee7c67 --- /dev/null +++ b/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.rs @@ -0,0 +1,13 @@ +// Test the `rustc::span_use_eq_ctxt` internal lint +// compile-flags: -Z unstable-options + +#![feature(rustc_private)] +#![deny(rustc::span_use_eq_ctxt)] +#![crate_type = "lib"] + +extern crate rustc_span; +use rustc_span::Span; + +pub fn f(s: Span, t: Span) -> bool { + s.ctxt() == t.ctxt() //~ ERROR use `.eq_ctxt()` instead of `.ctxt() == .ctxt()` +} diff --git a/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.stderr b/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.stderr new file mode 100644 index 00000000000..b33f6212545 --- /dev/null +++ b/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.stderr @@ -0,0 +1,14 @@ +error: use `.eq_ctxt()` instead of `.ctxt() == .ctxt()` + --> $DIR/span_use_eq_ctxt.rs:12:5 + | +LL | s.ctxt() == t.ctxt() + | ^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/span_use_eq_ctxt.rs:5:9 + | +LL | #![deny(rustc::span_use_eq_ctxt)] + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui-fulldeps/stable-mir/instance.rs b/tests/ui-fulldeps/stable-mir/instance.rs new file mode 100644 index 00000000000..fe06d9b5cc9 --- /dev/null +++ b/tests/ui-fulldeps/stable-mir/instance.rs @@ -0,0 +1,91 @@ +// run-pass +// Test that users are able to use stable mir APIs to retrieve monomorphized instances + +// ignore-stage1 +// ignore-cross-compile +// ignore-remote +// edition: 2021 + +#![feature(rustc_private)] +#![feature(assert_matches)] +#![feature(control_flow_enum)] + +extern crate rustc_middle; +extern crate rustc_smir; +extern crate stable_mir; + +use rustc_middle::ty::TyCtxt; + +use stable_mir::*; +use rustc_smir::rustc_internal; +use std::io::Write; +use std::ops::ControlFlow; + +const CRATE_NAME: &str = "input"; + +/// This function uses the Stable MIR APIs to get information about the test crate. +fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { + let items = stable_mir::all_local_items(); + + // Get all items and split generic vs monomorphic items. + let (generic, mono) : (Vec<_>, Vec<_>) = items.into_iter().partition(|item| { + item.requires_monomorphization() + }); + assert_eq!(mono.len(), 3, "Expected 2 mono functions and one constant"); + assert_eq!(generic.len(), 2, "Expected 2 generic functions"); + + // For all monomorphic items, get the correspondent instances. + let instances = mono.iter().filter_map(|item| { + mir::mono::Instance::try_from(*item).ok() + }).collect::<Vec<mir::mono::Instance>>(); + assert_eq!(instances.len(), mono.len()); + + // For all generic items, try_from should fail. + assert!(generic.iter().all(|item| mir::mono::Instance::try_from(*item).is_err())); + + ControlFlow::Continue(()) +} + + +/// This test will generate and analyze a dummy crate using the stable mir. +/// For that, it will first write the dummy crate into a file. +/// Then it will create a `StableMir` using custom arguments and then +/// it will run the compiler. +fn main() { + let path = "instance_input.rs"; + generate_input(&path).unwrap(); + let args = vec![ + "rustc".to_string(), + "--crate-type=lib".to_string(), + "--crate-name".to_string(), + CRATE_NAME.to_string(), + path.to_string(), + ]; + rustc_internal::StableMir::new(args, test_stable_mir).run().unwrap(); +} + +fn generate_input(path: &str) -> std::io::Result<()> { + let mut file = std::fs::File::create(path)?; + write!( + file, + r#" + pub fn ty_param<T>(t: &T) -> T where T: Clone {{ + t.clone() + }} + + pub fn const_param<const LEN: usize>(a: [bool; LEN]) -> bool {{ + LEN > 0 && a[0] + }} + + pub fn monomorphic() {{ + }} + + pub mod foo {{ + pub fn bar_mono(i: i32) -> i64 {{ + i as i64 + }} + }} + "# + )?; + Ok(()) +} diff --git a/tests/ui/associated-consts/associated-const-ambiguity-report.stderr b/tests/ui/associated-consts/associated-const-ambiguity-report.stderr index 5435f22321c..e39224f2c16 100644 --- a/tests/ui/associated-consts/associated-const-ambiguity-report.stderr +++ b/tests/ui/associated-consts/associated-const-ambiguity-report.stderr @@ -14,14 +14,12 @@ note: candidate #2 is defined in an impl of the trait `Bar` for the type `i32` | LL | const ID: i32 = 3; | ^^^^^^^^^^^^^ -help: disambiguate the associated constant for candidate #1 - | -LL | const X: i32 = <i32 as Foo>::ID; - | ~~~~~~~~~~~~~~ -help: disambiguate the associated constant for candidate #2 +help: use fully-qualified syntax to disambiguate | LL | const X: i32 = <i32 as Bar>::ID; | ~~~~~~~~~~~~~~ +LL | const X: i32 = <i32 as Foo>::ID; + | ~~~~~~~~~~~~~~ error: aborting due to previous error diff --git a/tests/ui/associated-inherent-types/issue-109071.no_gate.stderr b/tests/ui/associated-inherent-types/issue-109071.no_gate.stderr index 6f206f2b89c..866a53f57fc 100644 --- a/tests/ui/associated-inherent-types/issue-109071.no_gate.stderr +++ b/tests/ui/associated-inherent-types/issue-109071.no_gate.stderr @@ -33,7 +33,7 @@ error[E0223]: ambiguous associated type --> $DIR/issue-109071.rs:15:22 | LL | fn T() -> Option<Self::Item> {} - | ^^^^^^^^^^ help: use the fully-qualified path: `<Windows<T> as IntoIterator>::Item` + | ^^^^^^^^^^ help: use fully-qualified syntax: `<Windows<T> as IntoIterator>::Item` error: aborting due to 4 previous errors diff --git a/tests/ui/associated-inherent-types/not-found-self-type-differs-shadowing-trait-item.uncovered.stderr b/tests/ui/associated-inherent-types/not-found-self-type-differs-shadowing-trait-item.uncovered.stderr index 88c72042ce2..9206b4f6db7 100644 --- a/tests/ui/associated-inherent-types/not-found-self-type-differs-shadowing-trait-item.uncovered.stderr +++ b/tests/ui/associated-inherent-types/not-found-self-type-differs-shadowing-trait-item.uncovered.stderr @@ -2,7 +2,7 @@ error[E0223]: ambiguous associated type --> $DIR/not-found-self-type-differs-shadowing-trait-item.rs:28:12 | LL | let _: S::<bool>::Pr = (); - | ^^^^^^^^^^^^^ help: use the fully-qualified path: `<S<bool> as Tr>::Pr` + | ^^^^^^^^^^^^^ help: use fully-qualified syntax: `<S<bool> as Tr>::Pr` error: aborting due to previous error diff --git a/tests/ui/associated-item/ambiguous-associated-type-with-generics.stderr b/tests/ui/associated-item/ambiguous-associated-type-with-generics.stderr index 97088b79fd6..f7a47be8dc3 100644 --- a/tests/ui/associated-item/ambiguous-associated-type-with-generics.stderr +++ b/tests/ui/associated-item/ambiguous-associated-type-with-generics.stderr @@ -2,7 +2,7 @@ error[E0223]: ambiguous associated type --> $DIR/ambiguous-associated-type-with-generics.rs:13:13 | LL | let _x: <dyn Trait<i32>>::Ty; - | ^^^^^^^^^^^^^^^^^^^^ help: use the fully-qualified path: `<dyn Trait<i32> as Assoc>::Ty` + | ^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<dyn Trait<i32> as Assoc>::Ty` error: aborting due to previous error diff --git a/tests/ui/associated-item/associated-item-duplicate-names-3.stderr b/tests/ui/associated-item/associated-item-duplicate-names-3.stderr index d0c17062076..a2346e292ac 100644 --- a/tests/ui/associated-item/associated-item-duplicate-names-3.stderr +++ b/tests/ui/associated-item/associated-item-duplicate-names-3.stderr @@ -13,7 +13,7 @@ error[E0223]: ambiguous associated type --> $DIR/associated-item-duplicate-names-3.rs:18:12 | LL | let x: Baz::Bar = 5; - | ^^^^^^^^ help: use the fully-qualified path: `<Baz as Foo>::Bar` + | ^^^^^^^^ help: use fully-qualified syntax: `<Baz as Foo>::Bar` error: aborting due to 2 previous errors diff --git a/tests/ui/associated-type-bounds/elision.stderr b/tests/ui/associated-type-bounds/elision.stderr index cc10bbcc0b5..a29e32a784f 100644 --- a/tests/ui/associated-type-bounds/elision.stderr +++ b/tests/ui/associated-type-bounds/elision.stderr @@ -17,7 +17,7 @@ LL | fn f(x: &mut dyn Iterator<Item: Iterator<Item = &'_ ()>>) -> Option<&'_ ()> | ----------------------------- -------------- ^^^^^^^^ expected `Option<&()>`, found `Option<impl Iterator<Item = &'_ ()>>` | | | | | expected `Option<&()>` because of return type - | this type parameter + | found this type parameter | = note: expected enum `Option<&()>` found enum `Option<impl Iterator<Item = &'_ ()>>` diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.current.stderr b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.current.stderr index b8be132e6b6..65f7a72fbff 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.current.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.current.stderr @@ -25,7 +25,7 @@ LL | fn bar<T: Trait<method() -> (): Send>>() {} warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/bad-inputs-and-output.rs:5:12 | -LL | #![feature(return_type_notation, async_fn_in_trait)] +LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.next.stderr b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.next.stderr index b8be132e6b6..65f7a72fbff 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.next.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.next.stderr @@ -25,7 +25,7 @@ LL | fn bar<T: Trait<method() -> (): Send>>() {} warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/bad-inputs-and-output.rs:5:12 | -LL | #![feature(return_type_notation, async_fn_in_trait)] +LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs index 58ce41d1a89..4f332fa13d0 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs @@ -1,6 +1,6 @@ // edition: 2021 -#![feature(return_type_notation, async_fn_in_trait)] +#![feature(return_type_notation)] //~^ WARN the feature `return_type_notation` is incomplete trait Trait { diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr index 95ef7d82fca..1714dac12db 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr @@ -25,7 +25,7 @@ LL | fn bar<T: Trait<method() -> (): Send>>() {} warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/bad-inputs-and-output.rs:3:12 | -LL | #![feature(return_type_notation, async_fn_in_trait)] +LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.current_with.stderr b/tests/ui/associated-type-bounds/return-type-notation/basic.current_with.stderr index 98c1a282779..c4dc5d36296 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/basic.current_with.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.current_with.stderr @@ -1,7 +1,7 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/basic.rs:8:12 | -LL | #![feature(return_type_notation, async_fn_in_trait)] +LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.current_without.stderr b/tests/ui/associated-type-bounds/return-type-notation/basic.current_without.stderr index 1066c420c31..6c2645ae5bd 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/basic.current_without.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.current_without.stderr @@ -1,7 +1,7 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/basic.rs:8:12 | -LL | #![feature(return_type_notation, async_fn_in_trait)] +LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.next_with.stderr b/tests/ui/associated-type-bounds/return-type-notation/basic.next_with.stderr index 98c1a282779..c4dc5d36296 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/basic.next_with.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.next_with.stderr @@ -1,7 +1,7 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/basic.rs:8:12 | -LL | #![feature(return_type_notation, async_fn_in_trait)] +LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.next_without.stderr b/tests/ui/associated-type-bounds/return-type-notation/basic.next_without.stderr index 1066c420c31..6c2645ae5bd 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/basic.next_without.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.next_without.stderr @@ -1,7 +1,7 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/basic.rs:8:12 | -LL | #![feature(return_type_notation, async_fn_in_trait)] +LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.rs b/tests/ui/associated-type-bounds/return-type-notation/basic.rs index 3dd9249a791..7f0647534f2 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/basic.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.rs @@ -2,7 +2,7 @@ // edition: 2021 // [with] check-pass -#![feature(return_type_notation, async_fn_in_trait)] +#![feature(return_type_notation)] //~^ WARN the feature `return_type_notation` is incomplete trait Foo { diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.with.stderr b/tests/ui/associated-type-bounds/return-type-notation/basic.with.stderr index 9962f4706b3..9d4bb356caa 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/basic.with.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.with.stderr @@ -1,7 +1,7 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/basic.rs:5:12 | -LL | #![feature(return_type_notation, async_fn_in_trait)] +LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr b/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr index edce1045e24..5b96676d037 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr @@ -1,7 +1,7 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/basic.rs:5:12 | -LL | #![feature(return_type_notation, async_fn_in_trait)] +LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information diff --git a/tests/ui/associated-type-bounds/return-type-notation/equality.current.stderr b/tests/ui/associated-type-bounds/return-type-notation/equality.current.stderr index b631dd0ebb5..d2a445f3387 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/equality.current.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/equality.current.stderr @@ -1,7 +1,7 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/equality.rs:5:12 | -LL | #![feature(return_type_notation, async_fn_in_trait)] +LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information diff --git a/tests/ui/associated-type-bounds/return-type-notation/equality.next.stderr b/tests/ui/associated-type-bounds/return-type-notation/equality.next.stderr index b631dd0ebb5..d2a445f3387 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/equality.next.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/equality.next.stderr @@ -1,7 +1,7 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/equality.rs:5:12 | -LL | #![feature(return_type_notation, async_fn_in_trait)] +LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information diff --git a/tests/ui/associated-type-bounds/return-type-notation/equality.rs b/tests/ui/associated-type-bounds/return-type-notation/equality.rs index 6884305d7b3..d5a29616ac5 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/equality.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/equality.rs @@ -1,6 +1,6 @@ // edition: 2021 -#![feature(return_type_notation, async_fn_in_trait)] +#![feature(return_type_notation)] //~^ WARN the feature `return_type_notation` is incomplete use std::future::Future; diff --git a/tests/ui/associated-type-bounds/return-type-notation/equality.stderr b/tests/ui/associated-type-bounds/return-type-notation/equality.stderr index 490bfdc4c3c..1a2f8471524 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/equality.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/equality.stderr @@ -1,7 +1,7 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/equality.rs:3:12 | -LL | #![feature(return_type_notation, async_fn_in_trait)] +LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information diff --git a/tests/ui/associated-type-bounds/return-type-notation/missing.rs b/tests/ui/associated-type-bounds/return-type-notation/missing.rs index a52562d78f8..0679b96f6c5 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/missing.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/missing.rs @@ -1,6 +1,6 @@ // edition: 2021 -#![feature(return_type_notation, async_fn_in_trait)] +#![feature(return_type_notation)] //~^ WARN the feature `return_type_notation` is incomplete trait Trait { diff --git a/tests/ui/associated-type-bounds/return-type-notation/missing.stderr b/tests/ui/associated-type-bounds/return-type-notation/missing.stderr index 5b1c4cb0b2c..fb6538fa05c 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/missing.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/missing.stderr @@ -1,7 +1,7 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/missing.rs:3:12 | -LL | #![feature(return_type_notation, async_fn_in_trait)] +LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information diff --git a/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.fixed b/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.fixed new file mode 100644 index 00000000000..b9f26a40219 --- /dev/null +++ b/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.fixed @@ -0,0 +1,14 @@ +// run-rustfix +trait O { + type M; +} +trait U<A: O> { + const N: A::M; +} +impl<D> O for D { + type M = u8; +} +impl<C: O<M = u8>> U<C> for u16 { + const N: C::M = 4u8; //~ ERROR mismatched types +} +fn main() {} diff --git a/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.rs b/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.rs new file mode 100644 index 00000000000..abff6af73e2 --- /dev/null +++ b/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.rs @@ -0,0 +1,14 @@ +// run-rustfix +trait O { + type M; +} +trait U<A: O> { + const N: A::M; +} +impl<D> O for D { + type M = u8; +} +impl<C: O> U<C> for u16 { + const N: C::M = 4u8; //~ ERROR mismatched types +} +fn main() {} diff --git a/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.stderr b/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.stderr new file mode 100644 index 00000000000..b104f38ce90 --- /dev/null +++ b/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/suggest-contraining-assoc-type-because-of-assoc-const.rs:12:21 + | +LL | const N: C::M = 4u8; + | ^^^ expected associated type, found `u8` + | + = note: expected associated type `<C as O>::M` + found type `u8` +help: consider constraining the associated type `<C as O>::M` to `u8` + | +LL | impl<C: O<M = u8>> U<C> for u16 { + | ++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/associated-types/associated-type-projection-ambig-between-bound-and-where-clause.stderr b/tests/ui/associated-types/associated-type-projection-ambig-between-bound-and-where-clause.stderr index 236552baf92..df01e1e3768 100644 --- a/tests/ui/associated-types/associated-type-projection-ambig-between-bound-and-where-clause.stderr +++ b/tests/ui/associated-types/associated-type-projection-ambig-between-bound-and-where-clause.stderr @@ -10,11 +10,11 @@ LL | type Color; LL | fn a<C:Vehicle+Box>(_: C::Color) { | ^^^^^^^^ ambiguous associated type `Color` | -help: use fully qualified syntax to disambiguate +help: use fully-qualified syntax to disambiguate | LL | fn a<C:Vehicle+Box>(_: <C as Box>::Color) { | ~~~~~~~~~~~~ -help: use fully qualified syntax to disambiguate +help: use fully-qualified syntax to disambiguate | LL | fn a<C:Vehicle+Box>(_: <C as Vehicle>::Color) { | ~~~~~~~~~~~~~~~~ @@ -31,11 +31,11 @@ LL | type Color; LL | fn b<C>(_: C::Color) where C : Vehicle+Box { | ^^^^^^^^ ambiguous associated type `Color` | -help: use fully qualified syntax to disambiguate +help: use fully-qualified syntax to disambiguate | LL | fn b<C>(_: <C as Box>::Color) where C : Vehicle+Box { | ~~~~~~~~~~~~ -help: use fully qualified syntax to disambiguate +help: use fully-qualified syntax to disambiguate | LL | fn b<C>(_: <C as Vehicle>::Color) where C : Vehicle+Box { | ~~~~~~~~~~~~~~~~ @@ -52,11 +52,11 @@ LL | type Color; LL | fn c<C>(_: C::Color) where C : Vehicle, C : Box { | ^^^^^^^^ ambiguous associated type `Color` | -help: use fully qualified syntax to disambiguate +help: use fully-qualified syntax to disambiguate | LL | fn c<C>(_: <C as Box>::Color) where C : Vehicle, C : Box { | ~~~~~~~~~~~~ -help: use fully qualified syntax to disambiguate +help: use fully-qualified syntax to disambiguate | LL | fn c<C>(_: <C as Vehicle>::Color) where C : Vehicle, C : Box { | ~~~~~~~~~~~~~~~~ @@ -73,11 +73,11 @@ LL | type Color; LL | fn e(&self, _: X::Color) where X : Box; | ^^^^^^^^ ambiguous associated type `Color` | -help: use fully qualified syntax to disambiguate +help: use fully-qualified syntax to disambiguate | LL | fn e(&self, _: <X as Box>::Color) where X : Box; | ~~~~~~~~~~~~ -help: use fully qualified syntax to disambiguate +help: use fully-qualified syntax to disambiguate | LL | fn e(&self, _: <X as Vehicle>::Color) where X : Box; | ~~~~~~~~~~~~~~~~ @@ -94,11 +94,11 @@ LL | type Color; LL | fn f(&self, _: X::Color) where X : Box { } | ^^^^^^^^ ambiguous associated type `Color` | -help: use fully qualified syntax to disambiguate +help: use fully-qualified syntax to disambiguate | LL | fn f(&self, _: <X as Box>::Color) where X : Box { } | ~~~~~~~~~~~~ -help: use fully qualified syntax to disambiguate +help: use fully-qualified syntax to disambiguate | LL | fn f(&self, _: <X as Vehicle>::Color) where X : Box { } | ~~~~~~~~~~~~~~~~ @@ -115,11 +115,11 @@ LL | type Color; LL | fn d(&self, _: X::Color) where X : Box { } | ^^^^^^^^ ambiguous associated type `Color` | -help: use fully qualified syntax to disambiguate +help: use fully-qualified syntax to disambiguate | LL | fn d(&self, _: <X as Box>::Color) where X : Box { } | ~~~~~~~~~~~~ -help: use fully qualified syntax to disambiguate +help: use fully-qualified syntax to disambiguate | LL | fn d(&self, _: <X as Vehicle>::Color) where X : Box { } | ~~~~~~~~~~~~~~~~ diff --git a/tests/ui/associated-types/associated-type-projection-from-multiple-supertraits.stderr b/tests/ui/associated-types/associated-type-projection-from-multiple-supertraits.stderr index e765f932398..4f8954b80bc 100644 --- a/tests/ui/associated-types/associated-type-projection-from-multiple-supertraits.stderr +++ b/tests/ui/associated-types/associated-type-projection-from-multiple-supertraits.stderr @@ -18,11 +18,11 @@ LL | type Color; LL | fn dent<C:BoxCar>(c: C, color: C::Color) { | ^^^^^^^^ ambiguous associated type `Color` | -help: use fully qualified syntax to disambiguate +help: use fully-qualified syntax to disambiguate | LL | fn dent<C:BoxCar>(c: C, color: <C as Vehicle>::Color) { | ~~~~~~~~~~~~~~~~ -help: use fully qualified syntax to disambiguate +help: use fully-qualified syntax to disambiguate | LL | fn dent<C:BoxCar>(c: C, color: <C as Box>::Color) { | ~~~~~~~~~~~~ @@ -71,11 +71,11 @@ LL | type Color; LL | fn paint<C:BoxCar>(c: C, d: C::Color) { | ^^^^^^^^ ambiguous associated type `Color` | -help: use fully qualified syntax to disambiguate +help: use fully-qualified syntax to disambiguate | LL | fn paint<C:BoxCar>(c: C, d: <C as Vehicle>::Color) { | ~~~~~~~~~~~~~~~~ -help: use fully qualified syntax to disambiguate +help: use fully-qualified syntax to disambiguate | LL | fn paint<C:BoxCar>(c: C, d: <C as Box>::Color) { | ~~~~~~~~~~~~ diff --git a/tests/ui/associated-types/associated-types-in-ambiguous-context.stderr b/tests/ui/associated-types/associated-types-in-ambiguous-context.stderr index 1ff6fd4b821..d361643f024 100644 --- a/tests/ui/associated-types/associated-types-in-ambiguous-context.stderr +++ b/tests/ui/associated-types/associated-types-in-ambiguous-context.stderr @@ -13,7 +13,7 @@ error[E0223]: ambiguous associated type --> $DIR/associated-types-in-ambiguous-context.rs:22:17 | LL | trait Foo where Foo::Assoc: Bar { - | ^^^^^^^^^^ help: use the fully-qualified path: `<Self as Foo>::Assoc` + | ^^^^^^^^^^ help: use fully-qualified syntax: `<Self as Foo>::Assoc` error[E0223]: ambiguous associated type --> $DIR/associated-types-in-ambiguous-context.rs:27:10 @@ -21,7 +21,7 @@ error[E0223]: ambiguous associated type LL | type X = std::ops::Deref::Target; | ^^^^^^^^^^^^^^^^^^^^^^^ | -help: use the fully-qualified path +help: use fully-qualified syntax | LL | type X = <CString as Deref>::Target; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -37,7 +37,7 @@ error[E0223]: ambiguous associated type --> $DIR/associated-types-in-ambiguous-context.rs:13:23 | LL | fn grab(&self) -> Grab::Value; - | ^^^^^^^^^^^ help: use the fully-qualified path: `<Self as Grab>::Value` + | ^^^^^^^^^^^ help: use fully-qualified syntax: `<Self as Grab>::Value` error[E0223]: ambiguous associated type --> $DIR/associated-types-in-ambiguous-context.rs:16:22 diff --git a/tests/ui/associated-types/associated-types-issue-20346.stderr b/tests/ui/associated-types/associated-types-issue-20346.stderr index b1708b96e52..f384079862f 100644 --- a/tests/ui/associated-types/associated-types-issue-20346.stderr +++ b/tests/ui/associated-types/associated-types-issue-20346.stderr @@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `<Adapter<I> as Iterator>::Item == Option< --> $DIR/associated-types-issue-20346.rs:34:36 | LL | fn test_adapter<T, I: Iterator<Item=Option<T>>>(it: I) { - | - this type parameter + | - found this type parameter ... LL | is_iterator_of::<Option<T>, _>(&adapter); | ------------------------------ ^^^^^^^^ type mismatch resolving `<Adapter<I> as Iterator>::Item == Option<T>` diff --git a/tests/ui/associated-types/associated-types-path-1.stderr b/tests/ui/associated-types/associated-types-path-1.stderr index a67f77e37c7..cab9dcec0b6 100644 --- a/tests/ui/associated-types/associated-types-path-1.stderr +++ b/tests/ui/associated-types/associated-types-path-1.stderr @@ -16,11 +16,11 @@ LL | type A; LL | pub fn f2<T: Foo + Bar>(a: T, x: T::A) {} | ^^^^ ambiguous associated type `A` | -help: use fully qualified syntax to disambiguate +help: use fully-qualified syntax to disambiguate | LL | pub fn f2<T: Foo + Bar>(a: T, x: <T as Bar>::A) {} | ~~~~~~~~~~~~ -help: use fully qualified syntax to disambiguate +help: use fully-qualified syntax to disambiguate | LL | pub fn f2<T: Foo + Bar>(a: T, x: <T as Foo>::A) {} | ~~~~~~~~~~~~ diff --git a/tests/ui/associated-types/hr-associated-type-projection-1.stderr b/tests/ui/associated-types/hr-associated-type-projection-1.stderr index dd0389c34e6..425cfdca01d 100644 --- a/tests/ui/associated-types/hr-associated-type-projection-1.stderr +++ b/tests/ui/associated-types/hr-associated-type-projection-1.stderr @@ -2,7 +2,9 @@ error[E0271]: type mismatch resolving `<T as Deref>::Target == T` --> $DIR/hr-associated-type-projection-1.rs:13:33 | LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<'_, T> for T { - | - this type parameter ^^^^^^^^^^^^^^^^^ expected type parameter `T`, found associated type + | - ^^^^^^^^^^^^^^^^^ expected type parameter `T`, found associated type + | | + | expected this type parameter | = note: expected type parameter `T` found associated type `<T as Deref>::Target` diff --git a/tests/ui/async-await/async-trait-fn.current.stderr b/tests/ui/async-await/async-trait-fn.current.stderr deleted file mode 100644 index 7ccf2f2301d..00000000000 --- a/tests/ui/async-await/async-trait-fn.current.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/async-trait-fn.rs:6:5 - | -LL | async fn foo() {} - | -----^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/async-trait-fn.rs:7:5 - | -LL | async fn bar(&self) {} - | -----^^^^^^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/async-trait-fn.rs:8:5 - | -LL | async fn baz() { - | -----^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0706`. diff --git a/tests/ui/async-await/async-trait-fn.next.stderr b/tests/ui/async-await/async-trait-fn.next.stderr deleted file mode 100644 index 7ccf2f2301d..00000000000 --- a/tests/ui/async-await/async-trait-fn.next.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/async-trait-fn.rs:6:5 - | -LL | async fn foo() {} - | -----^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/async-trait-fn.rs:7:5 - | -LL | async fn bar(&self) {} - | -----^^^^^^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/async-trait-fn.rs:8:5 - | -LL | async fn baz() { - | -----^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0706`. diff --git a/tests/ui/async-await/async-trait-fn.rs b/tests/ui/async-await/async-trait-fn.rs index 04123badb53..4e5e3ba83e4 100644 --- a/tests/ui/async-await/async-trait-fn.rs +++ b/tests/ui/async-await/async-trait-fn.rs @@ -1,9 +1,10 @@ // edition:2018 +// check-pass trait T { - async fn foo() {} //~ ERROR functions in traits cannot be declared `async` - async fn bar(&self) {} //~ ERROR functions in traits cannot be declared `async` - async fn baz() { //~ ERROR functions in traits cannot be declared `async` + async fn foo() {} + async fn bar(&self) {} + async fn baz() { // Nested item must not ICE. fn a() {} } diff --git a/tests/ui/async-await/async-trait-fn.stderr b/tests/ui/async-await/async-trait-fn.stderr deleted file mode 100644 index 68ebe3507ac..00000000000 --- a/tests/ui/async-await/async-trait-fn.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/async-trait-fn.rs:4:5 - | -LL | async fn foo() {} - | -----^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/async-trait-fn.rs:5:5 - | -LL | async fn bar(&self) {} - | -----^^^^^^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/async-trait-fn.rs:6:5 - | -LL | async fn baz() { - | -----^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0706`. diff --git a/tests/ui/async-await/edition-deny-async-fns-2015.current.stderr b/tests/ui/async-await/edition-deny-async-fns-2015.current.stderr deleted file mode 100644 index c47b99e657e..00000000000 --- a/tests/ui/async-await/edition-deny-async-fns-2015.current.stderr +++ /dev/null @@ -1,98 +0,0 @@ -error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:5:1 - | -LL | async fn foo() {} - | ^^^^^ to use `async fn`, switch to Rust 2018 or later - | - = help: pass `--edition 2021` to `rustc` - = note: for more on editions, read https://doc.rust-lang.org/edition-guide - -error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:7:12 - | -LL | fn baz() { async fn foo() {} } - | ^^^^^ to use `async fn`, switch to Rust 2018 or later - | - = help: pass `--edition 2021` to `rustc` - = note: for more on editions, read https://doc.rust-lang.org/edition-guide - -error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:9:1 - | -LL | async fn async_baz() { - | ^^^^^ to use `async fn`, switch to Rust 2018 or later - | - = help: pass `--edition 2021` to `rustc` - = note: for more on editions, read https://doc.rust-lang.org/edition-guide - -error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:10:5 - | -LL | async fn bar() {} - | ^^^^^ to use `async fn`, switch to Rust 2018 or later - | - = help: pass `--edition 2021` to `rustc` - = note: for more on editions, read https://doc.rust-lang.org/edition-guide - -error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:16:5 - | -LL | async fn foo() {} - | ^^^^^ to use `async fn`, switch to Rust 2018 or later - | - = help: pass `--edition 2021` to `rustc` - = note: for more on editions, read https://doc.rust-lang.org/edition-guide - -error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:20:5 - | -LL | async fn foo() {} - | ^^^^^ to use `async fn`, switch to Rust 2018 or later - | - = help: pass `--edition 2021` to `rustc` - = note: for more on editions, read https://doc.rust-lang.org/edition-guide - -error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:38:9 - | -LL | async fn bar() {} - | ^^^^^ to use `async fn`, switch to Rust 2018 or later - | - = help: pass `--edition 2021` to `rustc` - = note: for more on editions, read https://doc.rust-lang.org/edition-guide - -error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:28:9 - | -LL | async fn foo() {} - | ^^^^^ to use `async fn`, switch to Rust 2018 or later - | - = help: pass `--edition 2021` to `rustc` - = note: for more on editions, read https://doc.rust-lang.org/edition-guide - -error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:33:13 - | -LL | async fn bar() {} - | ^^^^^ to use `async fn`, switch to Rust 2018 or later - | - = help: pass `--edition 2021` to `rustc` - = note: for more on editions, read https://doc.rust-lang.org/edition-guide - -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/edition-deny-async-fns-2015.rs:20:5 - | -LL | async fn foo() {} - | -----^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error: aborting due to 10 previous errors - -Some errors have detailed explanations: E0670, E0706. -For more information about an error, try `rustc --explain E0670`. diff --git a/tests/ui/async-await/edition-deny-async-fns-2015.next.stderr b/tests/ui/async-await/edition-deny-async-fns-2015.next.stderr deleted file mode 100644 index c47b99e657e..00000000000 --- a/tests/ui/async-await/edition-deny-async-fns-2015.next.stderr +++ /dev/null @@ -1,98 +0,0 @@ -error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:5:1 - | -LL | async fn foo() {} - | ^^^^^ to use `async fn`, switch to Rust 2018 or later - | - = help: pass `--edition 2021` to `rustc` - = note: for more on editions, read https://doc.rust-lang.org/edition-guide - -error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:7:12 - | -LL | fn baz() { async fn foo() {} } - | ^^^^^ to use `async fn`, switch to Rust 2018 or later - | - = help: pass `--edition 2021` to `rustc` - = note: for more on editions, read https://doc.rust-lang.org/edition-guide - -error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:9:1 - | -LL | async fn async_baz() { - | ^^^^^ to use `async fn`, switch to Rust 2018 or later - | - = help: pass `--edition 2021` to `rustc` - = note: for more on editions, read https://doc.rust-lang.org/edition-guide - -error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:10:5 - | -LL | async fn bar() {} - | ^^^^^ to use `async fn`, switch to Rust 2018 or later - | - = help: pass `--edition 2021` to `rustc` - = note: for more on editions, read https://doc.rust-lang.org/edition-guide - -error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:16:5 - | -LL | async fn foo() {} - | ^^^^^ to use `async fn`, switch to Rust 2018 or later - | - = help: pass `--edition 2021` to `rustc` - = note: for more on editions, read https://doc.rust-lang.org/edition-guide - -error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:20:5 - | -LL | async fn foo() {} - | ^^^^^ to use `async fn`, switch to Rust 2018 or later - | - = help: pass `--edition 2021` to `rustc` - = note: for more on editions, read https://doc.rust-lang.org/edition-guide - -error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:38:9 - | -LL | async fn bar() {} - | ^^^^^ to use `async fn`, switch to Rust 2018 or later - | - = help: pass `--edition 2021` to `rustc` - = note: for more on editions, read https://doc.rust-lang.org/edition-guide - -error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:28:9 - | -LL | async fn foo() {} - | ^^^^^ to use `async fn`, switch to Rust 2018 or later - | - = help: pass `--edition 2021` to `rustc` - = note: for more on editions, read https://doc.rust-lang.org/edition-guide - -error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:33:13 - | -LL | async fn bar() {} - | ^^^^^ to use `async fn`, switch to Rust 2018 or later - | - = help: pass `--edition 2021` to `rustc` - = note: for more on editions, read https://doc.rust-lang.org/edition-guide - -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/edition-deny-async-fns-2015.rs:20:5 - | -LL | async fn foo() {} - | -----^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error: aborting due to 10 previous errors - -Some errors have detailed explanations: E0670, E0706. -For more information about an error, try `rustc --explain E0670`. diff --git a/tests/ui/async-await/edition-deny-async-fns-2015.rs b/tests/ui/async-await/edition-deny-async-fns-2015.rs index 6bd6d879a4a..9059f99ba66 100644 --- a/tests/ui/async-await/edition-deny-async-fns-2015.rs +++ b/tests/ui/async-await/edition-deny-async-fns-2015.rs @@ -16,7 +16,6 @@ impl Foo { trait Bar { async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015 - //~^ ERROR functions in traits cannot be declared `async` } fn main() { diff --git a/tests/ui/async-await/edition-deny-async-fns-2015.stderr b/tests/ui/async-await/edition-deny-async-fns-2015.stderr index ba918eb28de..c40cdc5acec 100644 --- a/tests/ui/async-await/edition-deny-async-fns-2015.stderr +++ b/tests/ui/async-await/edition-deny-async-fns-2015.stderr @@ -53,7 +53,7 @@ LL | async fn foo() {} = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:36:9 + --> $DIR/edition-deny-async-fns-2015.rs:35:9 | LL | async fn bar() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -62,7 +62,7 @@ LL | async fn bar() {} = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:26:9 + --> $DIR/edition-deny-async-fns-2015.rs:25:9 | LL | async fn foo() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -71,7 +71,7 @@ LL | async fn foo() {} = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:31:13 + --> $DIR/edition-deny-async-fns-2015.rs:30:13 | LL | async fn bar() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -79,20 +79,6 @@ LL | async fn bar() {} = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/edition-deny-async-fns-2015.rs:18:5 - | -LL | async fn foo() {} - | -----^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error: aborting due to 10 previous errors +error: aborting due to 9 previous errors -Some errors have detailed explanations: E0670, E0706. -For more information about an error, try `rustc --explain E0670`. +For more information about this error, try `rustc --explain E0670`. diff --git a/tests/ui/async-await/feature-gate-async_fn_in_trait.rs b/tests/ui/async-await/feature-gate-async_fn_in_trait.rs deleted file mode 100644 index 792f378cb57..00000000000 --- a/tests/ui/async-await/feature-gate-async_fn_in_trait.rs +++ /dev/null @@ -1,25 +0,0 @@ -// edition:2021 - -// RPITIT is not enough to allow use of async functions -#![allow(incomplete_features)] -#![feature(return_position_impl_trait_in_trait)] - -trait T { - async fn foo(); //~ ERROR functions in traits cannot be declared `async` -} - -// Both return_position_impl_trait_in_trait and async_fn_in_trait are required for this (see also -// feature-gate-return_position_impl_trait_in_trait.rs) -trait T2 { - async fn foo() -> impl Sized; //~ ERROR functions in traits cannot be declared `async` -} - -trait T3 { - fn foo() -> impl std::future::Future<Output = ()>; -} - -impl T3 for () { - async fn foo() {} //~ ERROR functions in traits cannot be declared `async` -} - -fn main() {} diff --git a/tests/ui/async-await/feature-gate-async_fn_in_trait.stderr b/tests/ui/async-await/feature-gate-async_fn_in_trait.stderr deleted file mode 100644 index 2a5fbd1ecd0..00000000000 --- a/tests/ui/async-await/feature-gate-async_fn_in_trait.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/feature-gate-async_fn_in_trait.rs:8:5 - | -LL | async fn foo(); - | -----^^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/feature-gate-async_fn_in_trait.rs:14:5 - | -LL | async fn foo() -> impl Sized; - | -----^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/feature-gate-async_fn_in_trait.rs:22:5 - | -LL | async fn foo() {} - | -----^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0706`. diff --git a/tests/ui/async-await/in-trait/async-associated-types.rs b/tests/ui/async-await/in-trait/async-associated-types.rs index 14f18811c1e..8d89500477b 100644 --- a/tests/ui/async-await/in-trait/async-associated-types.rs +++ b/tests/ui/async-await/in-trait/async-associated-types.rs @@ -1,9 +1,6 @@ // check-pass // edition: 2021 -#![feature(async_fn_in_trait)] -#![allow(incomplete_features)] - use std::fmt::Debug; trait MyTrait<'a, 'b, T> where Self: 'a, T: Debug + Sized + 'b { diff --git a/tests/ui/async-await/in-trait/async-default-fn-overridden.rs b/tests/ui/async-await/in-trait/async-default-fn-overridden.rs index 8143f0bca03..c8fd2d8f6c2 100644 --- a/tests/ui/async-await/in-trait/async-default-fn-overridden.rs +++ b/tests/ui/async-await/in-trait/async-default-fn-overridden.rs @@ -1,7 +1,6 @@ // run-pass // edition:2021 -#![feature(async_fn_in_trait)] use std::future::Future; diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs index 38ba297189c..3cc11d241f7 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs @@ -1,7 +1,5 @@ // edition: 2021 -#![feature(async_fn_in_trait)] -#![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] use std::future::Future; diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr index 3f1f1766eb5..e6dd83b6b0a 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr @@ -1,11 +1,11 @@ error[E0053]: method `foo` has an incompatible type for trait - --> $DIR/async-example-desugared-boxed-in-trait.rs:15:5 + --> $DIR/async-example-desugared-boxed-in-trait.rs:13:5 | LL | async fn foo(&self) -> i32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Pin<Box<dyn Future<Output = i32>>>`, found future | note: type in trait - --> $DIR/async-example-desugared-boxed-in-trait.rs:11:22 + --> $DIR/async-example-desugared-boxed-in-trait.rs:9:22 | LL | fn foo(&self) -> Pin<Box<dyn Future<Output = i32> + '_>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed.rs b/tests/ui/async-await/in-trait/async-example-desugared-boxed.rs index 1b1b3cffd58..81d25ce27ae 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed.rs @@ -1,7 +1,5 @@ // edition: 2021 -#![feature(async_fn_in_trait)] -#![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] use std::future::Future; diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr index 60fa534a64f..cd18790fdfb 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr @@ -1,5 +1,5 @@ error: method `foo` should be async because the method from the trait is async - --> $DIR/async-example-desugared-boxed.rs:15:5 + --> $DIR/async-example-desugared-boxed.rs:13:5 | LL | async fn foo(&self) -> i32; | --------------------------- required because the trait method is async diff --git a/tests/ui/async-await/in-trait/async-example-desugared-extra.rs b/tests/ui/async-await/in-trait/async-example-desugared-extra.rs index 5d5aa817b4c..f0c59180fb5 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-extra.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-extra.rs @@ -1,8 +1,7 @@ // check-pass // edition: 2021 -#![feature(async_fn_in_trait)] -#![feature(return_position_impl_trait_in_trait, lint_reasons)] +#![feature(lint_reasons)] #![allow(incomplete_features)] use std::future::Future; diff --git a/tests/ui/async-await/in-trait/async-example-desugared-in-trait.rs b/tests/ui/async-await/in-trait/async-example-desugared-in-trait.rs index feeda719e03..deca28af853 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-in-trait.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-in-trait.rs @@ -1,8 +1,6 @@ // check-pass // edition: 2021 -#![feature(async_fn_in_trait)] -#![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] use std::future::Future; diff --git a/tests/ui/async-await/in-trait/async-example-desugared-manual.rs b/tests/ui/async-await/in-trait/async-example-desugared-manual.rs index 71473e7455f..fdba4d93c77 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-manual.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-manual.rs @@ -1,7 +1,5 @@ // edition: 2021 -#![feature(async_fn_in_trait)] -#![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] use std::future::Future; diff --git a/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr b/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr index 567a36a86d1..463892f21bf 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr +++ b/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr @@ -1,5 +1,5 @@ error: method `foo` should be async because the method from the trait is async - --> $DIR/async-example-desugared-manual.rs:23:5 + --> $DIR/async-example-desugared-manual.rs:21:5 | LL | async fn foo(&self) -> i32; | --------------------------- required because the trait method is async diff --git a/tests/ui/async-await/in-trait/async-example-desugared.rs b/tests/ui/async-await/in-trait/async-example-desugared.rs index 7987645c97b..7fc78f7da6d 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared.rs @@ -1,8 +1,6 @@ // check-pass // edition: 2021 -#![feature(async_fn_in_trait)] -#![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] use std::future::Future; diff --git a/tests/ui/async-await/in-trait/async-example.rs b/tests/ui/async-await/in-trait/async-example.rs index 8c80c21eabe..62ed490bf05 100644 --- a/tests/ui/async-await/in-trait/async-example.rs +++ b/tests/ui/async-await/in-trait/async-example.rs @@ -1,7 +1,6 @@ // check-pass // edition: 2021 -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] trait MyTrait { diff --git a/tests/ui/async-await/in-trait/async-generics-and-bounds.rs b/tests/ui/async-await/in-trait/async-generics-and-bounds.rs index a73d55adfec..4e859fb27a9 100644 --- a/tests/ui/async-await/in-trait/async-generics-and-bounds.rs +++ b/tests/ui/async-await/in-trait/async-generics-and-bounds.rs @@ -2,7 +2,6 @@ // known-bug: #102682 // edition: 2021 -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] use std::fmt::Debug; diff --git a/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr b/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr index 965c385e9bc..d7251a52863 100644 --- a/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr +++ b/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr @@ -1,5 +1,5 @@ error[E0311]: the parameter type `U` may not live long enough - --> $DIR/async-generics-and-bounds.rs:12:5 + --> $DIR/async-generics-and-bounds.rs:11:5 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^^^^^^^^^-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | async fn foo<'a>(&'a self) -> &'a (T, U) where T: Debug + Sized, U: Has | ++++ ++ ++ +++++++ error[E0311]: the parameter type `T` may not live long enough - --> $DIR/async-generics-and-bounds.rs:12:5 + --> $DIR/async-generics-and-bounds.rs:11:5 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^^^^^^^^^-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/in-trait/async-generics.rs b/tests/ui/async-await/in-trait/async-generics.rs index 67000e5770e..2d342592848 100644 --- a/tests/ui/async-await/in-trait/async-generics.rs +++ b/tests/ui/async-await/in-trait/async-generics.rs @@ -2,7 +2,6 @@ // known-bug: #102682 // edition: 2021 -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] trait MyTrait<T, U> { diff --git a/tests/ui/async-await/in-trait/async-generics.stderr b/tests/ui/async-await/in-trait/async-generics.stderr index 20c2491e9d0..aec62d12201 100644 --- a/tests/ui/async-await/in-trait/async-generics.stderr +++ b/tests/ui/async-await/in-trait/async-generics.stderr @@ -1,5 +1,5 @@ error[E0311]: the parameter type `U` may not live long enough - --> $DIR/async-generics.rs:9:5 + --> $DIR/async-generics.rs:8:5 | LL | async fn foo(&self) -> &(T, U); | ^^^^^^^^^^^^^-^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | async fn foo<'a>(&'a self) -> &'a (T, U) where U: 'a; | ++++ ++ ++ +++++++++++ error[E0311]: the parameter type `T` may not live long enough - --> $DIR/async-generics.rs:9:5 + --> $DIR/async-generics.rs:8:5 | LL | async fn foo(&self) -> &(T, U); | ^^^^^^^^^^^^^-^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/in-trait/async-lifetimes-and-bounds.rs b/tests/ui/async-await/in-trait/async-lifetimes-and-bounds.rs index 96cda4e35da..ea8330a4b52 100644 --- a/tests/ui/async-await/in-trait/async-lifetimes-and-bounds.rs +++ b/tests/ui/async-await/in-trait/async-lifetimes-and-bounds.rs @@ -1,7 +1,6 @@ // check-pass // edition: 2021 -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] use std::fmt::Debug; diff --git a/tests/ui/async-await/in-trait/async-lifetimes.rs b/tests/ui/async-await/in-trait/async-lifetimes.rs index 4b0264bc8d0..6e573b9cc8b 100644 --- a/tests/ui/async-await/in-trait/async-lifetimes.rs +++ b/tests/ui/async-await/in-trait/async-lifetimes.rs @@ -1,7 +1,6 @@ // check-pass // edition: 2021 -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] trait MyTrait<'a, 'b, T> { diff --git a/tests/ui/async-await/in-trait/async-recursive-generic.rs b/tests/ui/async-await/in-trait/async-recursive-generic.rs index 6839abd381c..34f1b09756e 100644 --- a/tests/ui/async-await/in-trait/async-recursive-generic.rs +++ b/tests/ui/async-await/in-trait/async-recursive-generic.rs @@ -1,6 +1,5 @@ // edition: 2021 -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] trait MyTrait<T> { diff --git a/tests/ui/async-await/in-trait/async-recursive-generic.stderr b/tests/ui/async-await/in-trait/async-recursive-generic.stderr index 6897bf1c999..7c2df6683f0 100644 --- a/tests/ui/async-await/in-trait/async-recursive-generic.stderr +++ b/tests/ui/async-await/in-trait/async-recursive-generic.stderr @@ -1,5 +1,5 @@ error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/async-recursive-generic.rs:11:5 + --> $DIR/async-recursive-generic.rs:10:5 | LL | async fn foo_recursive(&self, n: usize) -> T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ recursive `async fn` diff --git a/tests/ui/async-await/in-trait/async-recursive.rs b/tests/ui/async-await/in-trait/async-recursive.rs index 61119f8095b..ddf119b252f 100644 --- a/tests/ui/async-await/in-trait/async-recursive.rs +++ b/tests/ui/async-await/in-trait/async-recursive.rs @@ -1,6 +1,5 @@ // edition: 2021 -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] trait MyTrait { diff --git a/tests/ui/async-await/in-trait/async-recursive.stderr b/tests/ui/async-await/in-trait/async-recursive.stderr index c9b4784e3b4..1253252cc40 100644 --- a/tests/ui/async-await/in-trait/async-recursive.stderr +++ b/tests/ui/async-await/in-trait/async-recursive.stderr @@ -1,5 +1,5 @@ error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/async-recursive.rs:11:5 + --> $DIR/async-recursive.rs:10:5 | LL | async fn foo_recursive(&self, n: usize) -> i32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ recursive `async fn` diff --git a/tests/ui/async-await/in-trait/auxiliary/foreign-async-fn.rs b/tests/ui/async-await/in-trait/auxiliary/foreign-async-fn.rs index bba886f175e..57c9b3ae8b3 100644 --- a/tests/ui/async-await/in-trait/auxiliary/foreign-async-fn.rs +++ b/tests/ui/async-await/in-trait/auxiliary/foreign-async-fn.rs @@ -1,7 +1,5 @@ // edition:2021 -#![feature(async_fn_in_trait)] - pub trait Foo { async fn test(); } diff --git a/tests/ui/async-await/in-trait/bad-signatures.rs b/tests/ui/async-await/in-trait/bad-signatures.rs index 98dddc126c5..5adede5b5cf 100644 --- a/tests/ui/async-await/in-trait/bad-signatures.rs +++ b/tests/ui/async-await/in-trait/bad-signatures.rs @@ -1,6 +1,5 @@ // edition:2021 -#![feature(async_fn_in_trait)] trait MyTrait { async fn bar(&abc self); diff --git a/tests/ui/async-await/in-trait/bad-signatures.stderr b/tests/ui/async-await/in-trait/bad-signatures.stderr index 7cbd96e2487..127a343a930 100644 --- a/tests/ui/async-await/in-trait/bad-signatures.stderr +++ b/tests/ui/async-await/in-trait/bad-signatures.stderr @@ -1,11 +1,11 @@ error: expected identifier, found keyword `self` - --> $DIR/bad-signatures.rs:6:23 + --> $DIR/bad-signatures.rs:5:23 | LL | async fn bar(&abc self); | ^^^^ expected identifier, found keyword error: expected one of `:`, `@`, or `|`, found keyword `self` - --> $DIR/bad-signatures.rs:6:23 + --> $DIR/bad-signatures.rs:5:23 | LL | async fn bar(&abc self); | -----^^^^ diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs index afd3db5e052..18b0fa4856d 100644 --- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs @@ -1,7 +1,6 @@ // edition: 2021 // known-bug: #108309 -#![feature(async_fn_in_trait)] #![feature(min_specialization)] struct MyStruct; diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr index 4ba6d4cba0c..5e2be08623b 100644 --- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr @@ -1,11 +1,11 @@ error[E0053]: method `foo` has an incompatible type for trait - --> $DIR/dont-project-to-specializable-projection.rs:14:5 + --> $DIR/dont-project-to-specializable-projection.rs:13:5 | LL | default async fn foo(_: T) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found future | note: type in trait - --> $DIR/dont-project-to-specializable-projection.rs:10:5 + --> $DIR/dont-project-to-specializable-projection.rs:9:5 | LL | async fn foo(_: T) -> &'static str; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,12 +13,12 @@ LL | async fn foo(_: T) -> &'static str; found signature `fn(_) -> impl Future<Output = &'static str>` error: async associated function in trait cannot be specialized - --> $DIR/dont-project-to-specializable-projection.rs:14:5 + --> $DIR/dont-project-to-specializable-projection.rs:13:5 | LL | default async fn foo(_: T) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: specialization behaves in inconsistent and surprising ways with `#![feature(async_fn_in_trait)]`, and for now is disallowed + = note: specialization behaves in inconsistent and surprising ways with async functions in traits, and for now is disallowed error: aborting due to 2 previous errors diff --git a/tests/ui/async-await/in-trait/early-bound-1.rs b/tests/ui/async-await/in-trait/early-bound-1.rs index bc410cc2954..f79d6f23c93 100644 --- a/tests/ui/async-await/in-trait/early-bound-1.rs +++ b/tests/ui/async-await/in-trait/early-bound-1.rs @@ -1,7 +1,6 @@ // check-pass // edition:2021 -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] pub trait Foo { diff --git a/tests/ui/async-await/in-trait/early-bound-2.rs b/tests/ui/async-await/in-trait/early-bound-2.rs index 1974b1d9f7a..3eba5bf757f 100644 --- a/tests/ui/async-await/in-trait/early-bound-2.rs +++ b/tests/ui/async-await/in-trait/early-bound-2.rs @@ -1,7 +1,6 @@ // check-pass // edition:2021 -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] pub trait Foo { diff --git a/tests/ui/async-await/in-trait/fn-not-async-err.rs b/tests/ui/async-await/in-trait/fn-not-async-err.rs index 9598d53bce8..60077a7e00c 100644 --- a/tests/ui/async-await/in-trait/fn-not-async-err.rs +++ b/tests/ui/async-await/in-trait/fn-not-async-err.rs @@ -1,6 +1,5 @@ // edition: 2021 -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] trait MyTrait { diff --git a/tests/ui/async-await/in-trait/fn-not-async-err.stderr b/tests/ui/async-await/in-trait/fn-not-async-err.stderr index 579801d0f39..cd085074ae3 100644 --- a/tests/ui/async-await/in-trait/fn-not-async-err.stderr +++ b/tests/ui/async-await/in-trait/fn-not-async-err.stderr @@ -1,5 +1,5 @@ error: method `foo` should be async because the method from the trait is async - --> $DIR/fn-not-async-err.rs:11:5 + --> $DIR/fn-not-async-err.rs:10:5 | LL | async fn foo(&self) -> i32; | --------------------------- required because the trait method is async diff --git a/tests/ui/async-await/in-trait/fn-not-async-err2.rs b/tests/ui/async-await/in-trait/fn-not-async-err2.rs index e1703415dbd..ed626edc4c4 100644 --- a/tests/ui/async-await/in-trait/fn-not-async-err2.rs +++ b/tests/ui/async-await/in-trait/fn-not-async-err2.rs @@ -1,6 +1,6 @@ // edition: 2021 +// check-pass -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] use std::future::Future; @@ -11,7 +11,6 @@ trait MyTrait { impl MyTrait for i32 { fn foo(&self) -> impl Future<Output = i32> { - //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in `impl` method return types async { *self } } } diff --git a/tests/ui/async-await/in-trait/fn-not-async-err2.stderr b/tests/ui/async-await/in-trait/fn-not-async-err2.stderr deleted file mode 100644 index a7c897f786e..00000000000 --- a/tests/ui/async-await/in-trait/fn-not-async-err2.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `impl` method return types - --> $DIR/fn-not-async-err2.rs:13:22 - | -LL | fn foo(&self) -> impl Future<Output = i32> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0562`. diff --git a/tests/ui/async-await/in-trait/generics-mismatch.rs b/tests/ui/async-await/in-trait/generics-mismatch.rs index fc29783c0e3..51fdc2fe8a8 100644 --- a/tests/ui/async-await/in-trait/generics-mismatch.rs +++ b/tests/ui/async-await/in-trait/generics-mismatch.rs @@ -1,6 +1,5 @@ // edition: 2021 -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] trait Foo { diff --git a/tests/ui/async-await/in-trait/generics-mismatch.stderr b/tests/ui/async-await/in-trait/generics-mismatch.stderr index 3518aa05cec..647cc698f9f 100644 --- a/tests/ui/async-await/in-trait/generics-mismatch.stderr +++ b/tests/ui/async-await/in-trait/generics-mismatch.stderr @@ -1,5 +1,5 @@ error[E0053]: method `foo` has an incompatible generic parameter for trait `Foo` - --> $DIR/generics-mismatch.rs:11:18 + --> $DIR/generics-mismatch.rs:10:18 | LL | trait Foo { | --- diff --git a/tests/ui/async-await/in-trait/implied-bounds.rs b/tests/ui/async-await/in-trait/implied-bounds.rs index 40eebad86c2..0d8177c8e60 100644 --- a/tests/ui/async-await/in-trait/implied-bounds.rs +++ b/tests/ui/async-await/in-trait/implied-bounds.rs @@ -1,7 +1,6 @@ // check-pass // edition: 2021 -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] trait TcpStack { diff --git a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.rs b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.rs index 2fe6b473df6..8443cbcf4ac 100644 --- a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.rs +++ b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.rs @@ -2,8 +2,6 @@ // build-fail //~^^ ERROR cycle detected when computing layout of -#![feature(async_fn_in_trait)] - fn main() { let _ = async { A.first().await.second().await; diff --git a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr index 41e84466a14..ce02c1e9967 100644 --- a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr +++ b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr @@ -1,8 +1,8 @@ -error[E0391]: cycle detected when computing layout of `{async fn body@$DIR/indirect-recursion-issue-112047.rs:35:27: 37:6}` +error[E0391]: cycle detected when computing layout of `{async fn body@$DIR/indirect-recursion-issue-112047.rs:33:27: 35:6}` | = note: ...which requires computing layout of `<<A as First>::Second as Second>::{opaque#0}`... - = note: ...which again requires computing layout of `{async fn body@$DIR/indirect-recursion-issue-112047.rs:35:27: 37:6}`, completing the cycle - = note: cycle used when computing layout of `{async block@$DIR/indirect-recursion-issue-112047.rs:8:13: 10:6}` + = note: ...which again requires computing layout of `{async fn body@$DIR/indirect-recursion-issue-112047.rs:33:27: 35:6}`, completing the cycle + = note: cycle used when computing layout of `{async block@$DIR/indirect-recursion-issue-112047.rs:6:13: 8:6}` = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/async-await/in-trait/issue-102138.rs b/tests/ui/async-await/in-trait/issue-102138.rs index 3d9cef0210f..221b830fc5f 100644 --- a/tests/ui/async-await/in-trait/issue-102138.rs +++ b/tests/ui/async-await/in-trait/issue-102138.rs @@ -1,7 +1,6 @@ // check-pass // edition:2021 -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] use std::future::Future; diff --git a/tests/ui/async-await/in-trait/issue-102219.rs b/tests/ui/async-await/in-trait/issue-102219.rs index 4a23e4be4f7..1f32cf691eb 100644 --- a/tests/ui/async-await/in-trait/issue-102219.rs +++ b/tests/ui/async-await/in-trait/issue-102219.rs @@ -2,7 +2,6 @@ // edition:2021 // check-pass -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] trait T { diff --git a/tests/ui/async-await/in-trait/issue-102310.rs b/tests/ui/async-await/in-trait/issue-102310.rs index 327d432a6a6..c6321dfcbe8 100644 --- a/tests/ui/async-await/in-trait/issue-102310.rs +++ b/tests/ui/async-await/in-trait/issue-102310.rs @@ -1,7 +1,6 @@ // check-pass // edition:2021 -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] pub trait SpiDevice { diff --git a/tests/ui/async-await/in-trait/issue-104678.rs b/tests/ui/async-await/in-trait/issue-104678.rs index 0a334707505..db2fa3026fc 100644 --- a/tests/ui/async-await/in-trait/issue-104678.rs +++ b/tests/ui/async-await/in-trait/issue-104678.rs @@ -1,7 +1,6 @@ // edition:2021 // check-pass -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] use std::future::Future; diff --git a/tests/ui/async-await/in-trait/lifetime-mismatch.rs b/tests/ui/async-await/in-trait/lifetime-mismatch.rs index bb793df5d85..b45d1758da4 100644 --- a/tests/ui/async-await/in-trait/lifetime-mismatch.rs +++ b/tests/ui/async-await/in-trait/lifetime-mismatch.rs @@ -1,6 +1,5 @@ // edition:2021 -#![feature(async_fn_in_trait)] trait MyTrait { async fn foo<'a>(&self); diff --git a/tests/ui/async-await/in-trait/lifetime-mismatch.stderr b/tests/ui/async-await/in-trait/lifetime-mismatch.stderr index 86592269c02..3841ab9345f 100644 --- a/tests/ui/async-await/in-trait/lifetime-mismatch.stderr +++ b/tests/ui/async-await/in-trait/lifetime-mismatch.stderr @@ -1,5 +1,5 @@ error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration - --> $DIR/lifetime-mismatch.rs:11:17 + --> $DIR/lifetime-mismatch.rs:10:17 | LL | async fn foo<'a>(&self); | ---- lifetimes in impl do not match this method in trait diff --git a/tests/ui/async-await/in-trait/missing-feature-flag.rs b/tests/ui/async-await/in-trait/missing-feature-flag.rs index 34dd50a1c30..898299a7d9d 100644 --- a/tests/ui/async-await/in-trait/missing-feature-flag.rs +++ b/tests/ui/async-await/in-trait/missing-feature-flag.rs @@ -1,6 +1,5 @@ // edition:2018 -#![feature(async_fn_in_trait)] #![feature(min_specialization)] struct MyStruct; diff --git a/tests/ui/async-await/in-trait/missing-feature-flag.stderr b/tests/ui/async-await/in-trait/missing-feature-flag.stderr index 87a7e85bfbb..b7a9e98fc49 100644 --- a/tests/ui/async-await/in-trait/missing-feature-flag.stderr +++ b/tests/ui/async-await/in-trait/missing-feature-flag.stderr @@ -1,5 +1,5 @@ error[E0046]: not all trait items implemented, missing: `foo` - --> $DIR/missing-feature-flag.rs:12:1 + --> $DIR/missing-feature-flag.rs:11:1 | LL | async fn foo(_: T) -> &'static str; | ----------------------------------- `foo` from trait @@ -8,13 +8,13 @@ LL | impl<T> MyTrait<T> for MyStruct {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation error[E0308]: mismatched types - --> $DIR/missing-feature-flag.rs:16:42 + --> $DIR/missing-feature-flag.rs:15:42 | LL | async fn foo(_: i32) -> &'static str {} | ^^ expected `&str`, found `()` error[E0520]: `foo` specializes an item from a parent `impl`, but that item is not marked `default` - --> $DIR/missing-feature-flag.rs:16:5 + --> $DIR/missing-feature-flag.rs:15:5 | LL | impl<T> MyTrait<T> for MyStruct {} | ------------------------------- parent `impl` is here diff --git a/tests/ui/async-await/in-trait/missing-send-bound.rs b/tests/ui/async-await/in-trait/missing-send-bound.rs index dbcc6657618..596aece748d 100644 --- a/tests/ui/async-await/in-trait/missing-send-bound.rs +++ b/tests/ui/async-await/in-trait/missing-send-bound.rs @@ -1,6 +1,5 @@ // edition:2021 -#![feature(async_fn_in_trait)] trait Foo { async fn bar(); diff --git a/tests/ui/async-await/in-trait/missing-send-bound.stderr b/tests/ui/async-await/in-trait/missing-send-bound.stderr index 7e59d94d456..139bd06c7df 100644 --- a/tests/ui/async-await/in-trait/missing-send-bound.stderr +++ b/tests/ui/async-await/in-trait/missing-send-bound.stderr @@ -1,17 +1,17 @@ error: future cannot be sent between threads safely - --> $DIR/missing-send-bound.rs:14:20 + --> $DIR/missing-send-bound.rs:13:20 | LL | assert_is_send(test::<T>()); | ^^^^^^^^^^^ future returned by `test` is not `Send` | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `impl Future<Output = ()>` note: future is not `Send` as it awaits another future which is not `Send` - --> $DIR/missing-send-bound.rs:10:5 + --> $DIR/missing-send-bound.rs:9:5 | LL | T::bar().await; | ^^^^^^^^ await occurs here on type `impl Future<Output = ()>`, which is not `Send` note: required by a bound in `assert_is_send` - --> $DIR/missing-send-bound.rs:18:27 + --> $DIR/missing-send-bound.rs:17:27 | LL | fn assert_is_send(_: impl Send) {} | ^^^^ required by this bound in `assert_is_send` diff --git a/tests/ui/async-await/in-trait/nested-rpit.rs b/tests/ui/async-await/in-trait/nested-rpit.rs index 8c43e1b07e2..ccae08accb6 100644 --- a/tests/ui/async-await/in-trait/nested-rpit.rs +++ b/tests/ui/async-await/in-trait/nested-rpit.rs @@ -1,8 +1,6 @@ // edition: 2021 // check-pass -#![feature(async_fn_in_trait)] -#![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] use std::future::Future; diff --git a/tests/ui/async-await/in-trait/normalize-opaque-with-bound-vars.rs b/tests/ui/async-await/in-trait/normalize-opaque-with-bound-vars.rs index f8fe0d1bde8..9eb396f3202 100644 --- a/tests/ui/async-await/in-trait/normalize-opaque-with-bound-vars.rs +++ b/tests/ui/async-await/in-trait/normalize-opaque-with-bound-vars.rs @@ -5,7 +5,6 @@ // We were not normalizing opaques with escaping bound vars during codegen, // leading to later errors during debuginfo computation. -#![feature(async_fn_in_trait)] #[derive(Clone, Copy)] pub struct SharedState {} diff --git a/tests/ui/async-await/in-trait/object-safety.rs b/tests/ui/async-await/in-trait/object-safety.rs index 441539e5dd4..5e5375b082b 100644 --- a/tests/ui/async-await/in-trait/object-safety.rs +++ b/tests/ui/async-await/in-trait/object-safety.rs @@ -1,6 +1,5 @@ // edition:2021 -#![feature(async_fn_in_trait)] trait Foo { async fn foo(&self); diff --git a/tests/ui/async-await/in-trait/object-safety.stderr b/tests/ui/async-await/in-trait/object-safety.stderr index ccdf9d88708..5b9fd98ac60 100644 --- a/tests/ui/async-await/in-trait/object-safety.stderr +++ b/tests/ui/async-await/in-trait/object-safety.stderr @@ -1,11 +1,11 @@ error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:10:12 + --> $DIR/object-safety.rs:9: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:6:14 + --> $DIR/object-safety.rs:5:14 | LL | trait Foo { | --- this trait cannot be made into an object... diff --git a/tests/ui/async-await/in-trait/return-not-existing-pair.rs b/tests/ui/async-await/in-trait/return-not-existing-pair.rs index a14dfceed75..2286316dd88 100644 --- a/tests/ui/async-await/in-trait/return-not-existing-pair.rs +++ b/tests/ui/async-await/in-trait/return-not-existing-pair.rs @@ -1,6 +1,5 @@ // edition:2021 -#![feature(async_fn_in_trait)] trait MyTrait<'a, 'b, T> { async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T); diff --git a/tests/ui/async-await/in-trait/return-not-existing-pair.stderr b/tests/ui/async-await/in-trait/return-not-existing-pair.stderr index e573b851706..4694e608097 100644 --- a/tests/ui/async-await/in-trait/return-not-existing-pair.stderr +++ b/tests/ui/async-await/in-trait/return-not-existing-pair.stderr @@ -1,5 +1,5 @@ error[E0726]: implicit elided lifetime not allowed here - --> $DIR/return-not-existing-pair.rs:10:20 + --> $DIR/return-not-existing-pair.rs:9:20 | LL | impl<'a, 'b, T, U> MyTrait<T> for U { | ^^^^^^^^^^ expected lifetime parameters @@ -10,13 +10,13 @@ LL | impl<'a, 'b, T, U> MyTrait<'_, '_, T> for U { | +++++++ error[E0412]: cannot find type `ConnImpl` in this scope - --> $DIR/return-not-existing-pair.rs:6:48 + --> $DIR/return-not-existing-pair.rs:5:48 | LL | async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T); | ^^^^^^^^ not found in this scope error[E0186]: method `foo` has a `&self` declaration in the trait, but not in the impl - --> $DIR/return-not-existing-pair.rs:12:5 + --> $DIR/return-not-existing-pair.rs:11:5 | LL | async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T); | ------------------------------------------------------------ `&self` used in trait @@ -25,7 +25,7 @@ LL | async fn foo(_: T) -> (&'a U, &'b T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&self` in impl error[E0308]: mismatched types - --> $DIR/return-not-existing-pair.rs:12:42 + --> $DIR/return-not-existing-pair.rs:11:42 | LL | async fn foo(_: T) -> (&'a U, &'b T) {} | ^^ expected `(&U, &T)`, found `()` diff --git a/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.rs b/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.rs index 254b9a7824f..d23ef093be1 100644 --- a/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.rs +++ b/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.rs @@ -1,6 +1,5 @@ // edition:2021 -#![feature(return_position_impl_trait_in_trait)] struct Wrapper<T>(T); diff --git a/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.stderr b/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.stderr index 059934d245c..a66dd13bb7a 100644 --- a/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.stderr +++ b/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.stderr @@ -1,5 +1,5 @@ error[E0412]: cannot find type `Missing` in this scope - --> $DIR/return-not-existing-type-wrapping-rpitit.rs:8:25 + --> $DIR/return-not-existing-type-wrapping-rpitit.rs:7:25 | LL | fn bar() -> Wrapper<Missing<impl Sized>>; | ^^^^^^^ not found in this scope diff --git a/tests/ui/async-await/in-trait/return-type-suggestion.rs b/tests/ui/async-await/in-trait/return-type-suggestion.rs index cdab4ea0f37..2b19b24cf7a 100644 --- a/tests/ui/async-await/in-trait/return-type-suggestion.rs +++ b/tests/ui/async-await/in-trait/return-type-suggestion.rs @@ -1,6 +1,5 @@ // edition: 2021 -#![feature(async_fn_in_trait)] trait A { async fn e() { diff --git a/tests/ui/async-await/in-trait/return-type-suggestion.stderr b/tests/ui/async-await/in-trait/return-type-suggestion.stderr index 179c9ed93db..363870619f0 100644 --- a/tests/ui/async-await/in-trait/return-type-suggestion.stderr +++ b/tests/ui/async-await/in-trait/return-type-suggestion.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/return-type-suggestion.rs:7:9 + --> $DIR/return-type-suggestion.rs:6:9 | LL | Ok(()) | ^^^^^^ expected `()`, found `Result<(), _>` diff --git a/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.fixed b/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.fixed index 33c00587439..affe6cded8f 100644 --- a/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.fixed +++ b/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.fixed @@ -1,7 +1,6 @@ // run-rustfix // edition: 2021 -#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] #![allow(unused)] trait Foo { diff --git a/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.rs b/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.rs index 96b623d6988..02bfee1a25f 100644 --- a/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.rs +++ b/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.rs @@ -1,7 +1,6 @@ // run-rustfix // edition: 2021 -#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] #![allow(unused)] trait Foo { diff --git a/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.stderr b/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.stderr index 4319a14118b..da51f10af94 100644 --- a/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.stderr +++ b/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.stderr @@ -1,5 +1,5 @@ error[E0277]: `impl Future<Output = ()>` cannot be sent between threads safely - --> $DIR/send-on-async-fn-in-trait.rs:14:16 + --> $DIR/send-on-async-fn-in-trait.rs:13:16 | LL | needs_send(T::test()); | ---------- ^^^^^^^^^ `impl Future<Output = ()>` cannot be sent between threads safely @@ -8,7 +8,7 @@ LL | needs_send(T::test()); | = help: the trait `Send` is not implemented for `impl Future<Output = ()>` note: required by a bound in `needs_send` - --> $DIR/send-on-async-fn-in-trait.rs:13:27 + --> $DIR/send-on-async-fn-in-trait.rs:12:27 | LL | fn needs_send(_: impl Send) {} | ^^^^ required by this bound in `needs_send` @@ -19,7 +19,7 @@ LL + fn test() -> impl std::future::Future<Output = ()> + Send { async {} } | error[E0277]: `impl Future<Output = i32>` cannot be sent between threads safely - --> $DIR/send-on-async-fn-in-trait.rs:16:16 + --> $DIR/send-on-async-fn-in-trait.rs:15:16 | LL | needs_send(T::test2()); | ---------- ^^^^^^^^^^ `impl Future<Output = i32>` cannot be sent between threads safely @@ -28,7 +28,7 @@ LL | needs_send(T::test2()); | = help: the trait `Send` is not implemented for `impl Future<Output = i32>` note: required by a bound in `needs_send` - --> $DIR/send-on-async-fn-in-trait.rs:13:27 + --> $DIR/send-on-async-fn-in-trait.rs:12:27 | LL | fn needs_send(_: impl Send) {} | ^^^^ required by this bound in `needs_send` diff --git a/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.rs b/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.rs index 83b69d72a96..f0d750714cd 100644 --- a/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.rs +++ b/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.rs @@ -1,8 +1,6 @@ // aux-build:foreign-async-fn.rs // edition:2021 -#![feature(async_fn_in_trait)] - extern crate foreign_async_fn; use foreign_async_fn::Foo; diff --git a/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.stderr b/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.stderr index f337a04ba19..482707351d7 100644 --- a/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.stderr +++ b/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.stderr @@ -1,5 +1,5 @@ error[E0277]: `impl Future<Output = ()>` cannot be sent between threads safely - --> $DIR/send-on-foreign-async-fn-in-trait.rs:11:16 + --> $DIR/send-on-foreign-async-fn-in-trait.rs:9:16 | LL | needs_send(T::test()); | ---------- ^^^^^^^^^ `impl Future<Output = ()>` cannot be sent between threads safely @@ -8,12 +8,12 @@ LL | needs_send(T::test()); | = help: the trait `Send` is not implemented for `impl Future<Output = ()>` note: `<T as Foo>::test` is an `async fn` in trait, which does not automatically imply that its future is `Send` - --> $DIR/auxiliary/foreign-async-fn.rs:6:5 + --> $DIR/auxiliary/foreign-async-fn.rs:4:5 | LL | async fn test(); | ^^^^^^^^^^^^^^^^ note: required by a bound in `needs_send` - --> $DIR/send-on-foreign-async-fn-in-trait.rs:10:27 + --> $DIR/send-on-foreign-async-fn-in-trait.rs:8:27 | LL | fn needs_send(_: impl Send) {} | ^^^^ required by this bound in `needs_send` diff --git a/tests/ui/async-await/in-trait/unconstrained-impl-region.rs b/tests/ui/async-await/in-trait/unconstrained-impl-region.rs new file mode 100644 index 00000000000..c06f9f005f1 --- /dev/null +++ b/tests/ui/async-await/in-trait/unconstrained-impl-region.rs @@ -0,0 +1,19 @@ +// edition: 2021 + +pub(crate) trait Inbox<M> { + async fn next(self) -> M; +} + +pub(crate) trait Actor: Sized { + type Message; + + async fn on_mount(self, _: impl Inbox<Self::Message>); +} + +impl<'a> Actor for () { +//~^ ERROR the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates + type Message = &'a (); + async fn on_mount(self, _: impl Inbox<&'a ()>) {} +} + +fn main() {} diff --git a/tests/ui/async-await/in-trait/unconstrained-impl-region.stderr b/tests/ui/async-await/in-trait/unconstrained-impl-region.stderr new file mode 100644 index 00000000000..2cb0da2e8bc --- /dev/null +++ b/tests/ui/async-await/in-trait/unconstrained-impl-region.stderr @@ -0,0 +1,9 @@ +error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates + --> $DIR/unconstrained-impl-region.rs:13:6 + | +LL | impl<'a> Actor for () { + | ^^ unconstrained lifetime parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/async-await/in-trait/warn.rs b/tests/ui/async-await/in-trait/warn.rs index 4f981c31f5c..71f3822dfb1 100644 --- a/tests/ui/async-await/in-trait/warn.rs +++ b/tests/ui/async-await/in-trait/warn.rs @@ -1,6 +1,5 @@ // edition: 2021 -#![feature(async_fn_in_trait)] #![deny(async_fn_in_trait)] pub trait Foo { diff --git a/tests/ui/async-await/in-trait/warn.stderr b/tests/ui/async-await/in-trait/warn.stderr index eac41a6e924..d0278628c97 100644 --- a/tests/ui/async-await/in-trait/warn.stderr +++ b/tests/ui/async-await/in-trait/warn.stderr @@ -1,16 +1,16 @@ error: use of `async fn` in public traits is discouraged as auto trait bounds cannot be specified - --> $DIR/warn.rs:7:5 + --> $DIR/warn.rs:6:5 | LL | async fn not_send(); | ^^^^^ | = note: you can suppress this lint if you plan to use the trait only in your own code, or do not care about auto traits like `Send` on the `Future` note: the lint level is defined here - --> $DIR/warn.rs:4:9 + --> $DIR/warn.rs:3:9 | LL | #![deny(async_fn_in_trait)] | ^^^^^^^^^^^^^^^^^ -help: you can alternatively desugar to a normal `fn` that returns `impl Future` and add any desired bounds such as `Send` +help: you can alternatively desugar to a normal `fn` that returns `impl Future` and add any desired bounds such as `Send`, but these cannot be relaxed without a breaking API change | LL - async fn not_send(); LL + fn not_send() -> impl std::future::Future<Output = ()> + Send; diff --git a/tests/ui/async-await/issues/issue-95307.rs b/tests/ui/async-await/issues/issue-95307.rs index f7e48070ccd..35dce2c6217 100644 --- a/tests/ui/async-await/issues/issue-95307.rs +++ b/tests/ui/async-await/issues/issue-95307.rs @@ -5,8 +5,7 @@ pub trait C { async fn new() -> [u8; _]; - //~^ ERROR: functions in traits cannot be declared `async` - //~| ERROR: using `_` for array lengths is unstable + //~^ ERROR: using `_` for array lengths is unstable //~| ERROR: in expressions, `_` can only be used on the left-hand side of an assignment } diff --git a/tests/ui/async-await/issues/issue-95307.stderr b/tests/ui/async-await/issues/issue-95307.stderr index a497cebe3c3..fdc6d5de1a8 100644 --- a/tests/ui/async-await/issues/issue-95307.stderr +++ b/tests/ui/async-await/issues/issue-95307.stderr @@ -1,16 +1,3 @@ -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/issue-95307.rs:7:5 - | -LL | async fn new() -> [u8; _]; - | -----^^^^^^^^^^^^^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - error: in expressions, `_` can only be used on the left-hand side of an assignment --> $DIR/issue-95307.rs:7:28 | @@ -26,7 +13,6 @@ LL | async fn new() -> [u8; _]; = note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information = help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0658, E0706. -For more information about an error, try `rustc --explain E0658`. +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/async-await/return-type-notation/issue-110963-early.rs b/tests/ui/async-await/return-type-notation/issue-110963-early.rs index 0ecbca5c13b..07f2130bab5 100644 --- a/tests/ui/async-await/return-type-notation/issue-110963-early.rs +++ b/tests/ui/async-await/return-type-notation/issue-110963-early.rs @@ -2,7 +2,6 @@ // known-bug: #110963 #![feature(return_type_notation)] -#![feature(async_fn_in_trait)] trait HealthCheck { async fn check<'a: 'a>(&'a mut self) -> bool; diff --git a/tests/ui/async-await/return-type-notation/issue-110963-early.stderr b/tests/ui/async-await/return-type-notation/issue-110963-early.stderr index 98e3cbd0d7f..feae2698e8f 100644 --- a/tests/ui/async-await/return-type-notation/issue-110963-early.stderr +++ b/tests/ui/async-await/return-type-notation/issue-110963-early.stderr @@ -8,7 +8,7 @@ LL | #![feature(return_type_notation)] = note: `#[warn(incomplete_features)]` on by default error[E0308]: mismatched types - --> $DIR/issue-110963-early.rs:15:5 + --> $DIR/issue-110963-early.rs:14:5 | LL | / spawn(async move { LL | | let mut hc = hc; @@ -21,13 +21,13 @@ LL | | }); = note: expected trait `Send` found trait `for<'a> Send` note: the lifetime requirement is introduced here - --> $DIR/issue-110963-early.rs:35:17 + --> $DIR/issue-110963-early.rs:34:17 | LL | F: Future + Send + 'static, | ^^^^ error[E0308]: mismatched types - --> $DIR/issue-110963-early.rs:15:5 + --> $DIR/issue-110963-early.rs:14:5 | LL | / spawn(async move { LL | | let mut hc = hc; @@ -40,7 +40,7 @@ LL | | }); = note: expected trait `Send` found trait `for<'a> Send` note: the lifetime requirement is introduced here - --> $DIR/issue-110963-early.rs:35:17 + --> $DIR/issue-110963-early.rs:34:17 | LL | F: Future + Send + 'static, | ^^^^ diff --git a/tests/ui/async-await/return-type-notation/issue-110963-late.rs b/tests/ui/async-await/return-type-notation/issue-110963-late.rs index 17b5d775d44..7533844fb43 100644 --- a/tests/ui/async-await/return-type-notation/issue-110963-late.rs +++ b/tests/ui/async-await/return-type-notation/issue-110963-late.rs @@ -3,7 +3,6 @@ #![feature(return_type_notation)] //~^ WARN the feature `return_type_notation` is incomplete -#![feature(async_fn_in_trait)] trait HealthCheck { async fn check(&mut self) -> bool; diff --git a/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.current.stderr b/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.current.stderr index 8f45902035e..6a47f1ab983 100644 --- a/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.current.stderr +++ b/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.current.stderr @@ -1,5 +1,5 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/normalizing-self-auto-trait-issue-109924.rs:8:12 + --> $DIR/normalizing-self-auto-trait-issue-109924.rs:7:12 | LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | #![feature(return_type_notation)] = note: `#[warn(incomplete_features)]` on by default error[E0277]: `impl Future<Output = ()> { <_ as Foo>::bar() }` cannot be sent between threads safely - --> $DIR/normalizing-self-auto-trait-issue-109924.rs:23:11 + --> $DIR/normalizing-self-auto-trait-issue-109924.rs:22:11 | LL | build(Bar); | ----- ^^^ `impl Future<Output = ()> { <_ as Foo>::bar() }` cannot be sent between threads safely @@ -17,7 +17,7 @@ LL | build(Bar); | = help: the trait `for<'a> Send` is not implemented for `impl Future<Output = ()> { <_ as Foo>::bar() }` note: this is a known limitation of the trait solver that will be lifted in the future - --> $DIR/normalizing-self-auto-trait-issue-109924.rs:23:11 + --> $DIR/normalizing-self-auto-trait-issue-109924.rs:22:11 | LL | build(Bar); | ------^^^- @@ -25,7 +25,7 @@ LL | build(Bar); | | the trait solver is unable to infer the generic types that should be inferred from this argument | add turbofish arguments to this call to specify the types manually, even if it's redundant note: required by a bound in `build` - --> $DIR/normalizing-self-auto-trait-issue-109924.rs:20:39 + --> $DIR/normalizing-self-auto-trait-issue-109924.rs:19:39 | LL | fn build<T>(_: T) where T: Foo<bar(): Send> {} | ^^^^ required by this bound in `build` diff --git a/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.next.stderr b/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.next.stderr index 6fab7178767..4837815fad4 100644 --- a/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.next.stderr +++ b/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.next.stderr @@ -1,5 +1,5 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/normalizing-self-auto-trait-issue-109924.rs:8:12 + --> $DIR/normalizing-self-auto-trait-issue-109924.rs:7:12 | LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.rs b/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.rs index b2cd9707db9..e581e5ffda7 100644 --- a/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.rs +++ b/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.rs @@ -4,7 +4,6 @@ //[next] compile-flags: -Ztrait-solver=next // edition:2021 -#![feature(async_fn_in_trait)] #![feature(return_type_notation)] //[next]~^ WARN the feature `return_type_notation` is incomplete diff --git a/tests/ui/async-await/return-type-notation/rtn-implied-in-supertrait.rs b/tests/ui/async-await/return-type-notation/rtn-implied-in-supertrait.rs index e55104ee968..0ceb62d449a 100644 --- a/tests/ui/async-await/return-type-notation/rtn-implied-in-supertrait.rs +++ b/tests/ui/async-await/return-type-notation/rtn-implied-in-supertrait.rs @@ -1,7 +1,7 @@ // edition:2021 // check-pass -#![feature(async_fn_in_trait, return_position_impl_trait_in_trait, return_type_notation)] +#![feature(return_type_notation)] //~^ WARN the feature `return_type_notation` is incomplete use std::future::Future; diff --git a/tests/ui/async-await/return-type-notation/rtn-implied-in-supertrait.stderr b/tests/ui/async-await/return-type-notation/rtn-implied-in-supertrait.stderr index 8626648b523..4a52e807bff 100644 --- a/tests/ui/async-await/return-type-notation/rtn-implied-in-supertrait.stderr +++ b/tests/ui/async-await/return-type-notation/rtn-implied-in-supertrait.stderr @@ -1,8 +1,8 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/rtn-implied-in-supertrait.rs:4:68 + --> $DIR/rtn-implied-in-supertrait.rs:4:12 | -LL | #![feature(async_fn_in_trait, return_position_impl_trait_in_trait, return_type_notation)] - | ^^^^^^^^^^^^^^^^^^^^ +LL | #![feature(return_type_notation)] + | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = note: `#[warn(incomplete_features)]` on by default diff --git a/tests/ui/async-await/return-type-notation/super-method-bound-ambig.rs b/tests/ui/async-await/return-type-notation/super-method-bound-ambig.rs index 028e526b5f5..891b30638ee 100644 --- a/tests/ui/async-await/return-type-notation/super-method-bound-ambig.rs +++ b/tests/ui/async-await/return-type-notation/super-method-bound-ambig.rs @@ -1,6 +1,6 @@ // edition:2021 -#![feature(async_fn_in_trait, return_type_notation)] +#![feature(return_type_notation)] //~^ WARN the feature `return_type_notation` is incomplete trait Super1<'a> { diff --git a/tests/ui/async-await/return-type-notation/super-method-bound-ambig.stderr b/tests/ui/async-await/return-type-notation/super-method-bound-ambig.stderr index 5bc8dbde4bc..d9caab5875a 100644 --- a/tests/ui/async-await/return-type-notation/super-method-bound-ambig.stderr +++ b/tests/ui/async-await/return-type-notation/super-method-bound-ambig.stderr @@ -1,8 +1,8 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/super-method-bound-ambig.rs:3:31 + --> $DIR/super-method-bound-ambig.rs:3:12 | -LL | #![feature(async_fn_in_trait, return_type_notation)] - | ^^^^^^^^^^^^^^^^^^^^ +LL | #![feature(return_type_notation)] + | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = note: `#[warn(incomplete_features)]` on by default diff --git a/tests/ui/async-await/return-type-notation/super-method-bound.current.stderr b/tests/ui/async-await/return-type-notation/super-method-bound.current.stderr index 891c802c5f4..5f482b60878 100644 --- a/tests/ui/async-await/return-type-notation/super-method-bound.current.stderr +++ b/tests/ui/async-await/return-type-notation/super-method-bound.current.stderr @@ -1,8 +1,7 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/super-method-bound.rs:6:31 | -LL | #![feature(async_fn_in_trait, return_type_notation)] - | ^^^^^^^^^^^^^^^^^^^^ +LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = note: `#[warn(incomplete_features)]` on by default diff --git a/tests/ui/async-await/return-type-notation/super-method-bound.next.stderr b/tests/ui/async-await/return-type-notation/super-method-bound.next.stderr index 891c802c5f4..5f482b60878 100644 --- a/tests/ui/async-await/return-type-notation/super-method-bound.next.stderr +++ b/tests/ui/async-await/return-type-notation/super-method-bound.next.stderr @@ -1,8 +1,7 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/super-method-bound.rs:6:31 | -LL | #![feature(async_fn_in_trait, return_type_notation)] - | ^^^^^^^^^^^^^^^^^^^^ +LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = note: `#[warn(incomplete_features)]` on by default diff --git a/tests/ui/async-await/return-type-notation/super-method-bound.rs b/tests/ui/async-await/return-type-notation/super-method-bound.rs index 58ea3578db6..6025cda2f5d 100644 --- a/tests/ui/async-await/return-type-notation/super-method-bound.rs +++ b/tests/ui/async-await/return-type-notation/super-method-bound.rs @@ -1,7 +1,7 @@ // edition:2021 // check-pass -#![feature(async_fn_in_trait, return_type_notation)] +#![feature(return_type_notation)] //~^ WARN the feature `return_type_notation` is incomplete trait Super<'a> { diff --git a/tests/ui/async-await/return-type-notation/super-method-bound.stderr b/tests/ui/async-await/return-type-notation/super-method-bound.stderr index ac0668d3c44..64fda71c1a1 100644 --- a/tests/ui/async-await/return-type-notation/super-method-bound.stderr +++ b/tests/ui/async-await/return-type-notation/super-method-bound.stderr @@ -1,8 +1,8 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/super-method-bound.rs:4:31 + --> $DIR/super-method-bound.rs:4:12 | -LL | #![feature(async_fn_in_trait, return_type_notation)] - | ^^^^^^^^^^^^^^^^^^^^ +LL | #![feature(return_type_notation)] + | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = note: `#[warn(incomplete_features)]` on by default diff --git a/tests/ui/async-await/return-type-notation/supertrait-bound.current.stderr b/tests/ui/async-await/return-type-notation/supertrait-bound.current.stderr index 05cb0ca4abd..928b321697c 100644 --- a/tests/ui/async-await/return-type-notation/supertrait-bound.current.stderr +++ b/tests/ui/async-await/return-type-notation/supertrait-bound.current.stderr @@ -1,7 +1,7 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/supertrait-bound.rs:5:49 | -LL | #![feature(return_position_impl_trait_in_trait, return_type_notation)] +LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information diff --git a/tests/ui/async-await/return-type-notation/supertrait-bound.next.stderr b/tests/ui/async-await/return-type-notation/supertrait-bound.next.stderr index 05cb0ca4abd..928b321697c 100644 --- a/tests/ui/async-await/return-type-notation/supertrait-bound.next.stderr +++ b/tests/ui/async-await/return-type-notation/supertrait-bound.next.stderr @@ -1,7 +1,7 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/supertrait-bound.rs:5:49 | -LL | #![feature(return_position_impl_trait_in_trait, return_type_notation)] +LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information diff --git a/tests/ui/async-await/return-type-notation/supertrait-bound.rs b/tests/ui/async-await/return-type-notation/supertrait-bound.rs index 19bcfe3046b..a85596a9fee 100644 --- a/tests/ui/async-await/return-type-notation/supertrait-bound.rs +++ b/tests/ui/async-await/return-type-notation/supertrait-bound.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(return_position_impl_trait_in_trait, return_type_notation)] +#![feature(return_type_notation)] //~^ WARN the feature `return_type_notation` is incomplete and may not be safe to use trait IntFactory { diff --git a/tests/ui/async-await/return-type-notation/supertrait-bound.stderr b/tests/ui/async-await/return-type-notation/supertrait-bound.stderr index c8cec4946b4..eb6917fc7d5 100644 --- a/tests/ui/async-await/return-type-notation/supertrait-bound.stderr +++ b/tests/ui/async-await/return-type-notation/supertrait-bound.stderr @@ -1,8 +1,8 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/supertrait-bound.rs:3:49 + --> $DIR/supertrait-bound.rs:3:12 | -LL | #![feature(return_position_impl_trait_in_trait, return_type_notation)] - | ^^^^^^^^^^^^^^^^^^^^ +LL | #![feature(return_type_notation)] + | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = note: `#[warn(incomplete_features)]` on by default diff --git a/tests/ui/async-await/return-type-notation/ty-or-ct-params.current.stderr b/tests/ui/async-await/return-type-notation/ty-or-ct-params.current.stderr index 1aa008fe469..e2bbb6013fc 100644 --- a/tests/ui/async-await/return-type-notation/ty-or-ct-params.current.stderr +++ b/tests/ui/async-await/return-type-notation/ty-or-ct-params.current.stderr @@ -1,8 +1,7 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/ty-or-ct-params.rs:5:31 | -LL | #![feature(async_fn_in_trait, return_type_notation)] - | ^^^^^^^^^^^^^^^^^^^^ +LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = note: `#[warn(incomplete_features)]` on by default diff --git a/tests/ui/async-await/return-type-notation/ty-or-ct-params.next.stderr b/tests/ui/async-await/return-type-notation/ty-or-ct-params.next.stderr index 1aa008fe469..e2bbb6013fc 100644 --- a/tests/ui/async-await/return-type-notation/ty-or-ct-params.next.stderr +++ b/tests/ui/async-await/return-type-notation/ty-or-ct-params.next.stderr @@ -1,8 +1,7 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/ty-or-ct-params.rs:5:31 | -LL | #![feature(async_fn_in_trait, return_type_notation)] - | ^^^^^^^^^^^^^^^^^^^^ +LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = note: `#[warn(incomplete_features)]` on by default diff --git a/tests/ui/async-await/return-type-notation/ty-or-ct-params.rs b/tests/ui/async-await/return-type-notation/ty-or-ct-params.rs index 7871a2fed03..ac320cfc679 100644 --- a/tests/ui/async-await/return-type-notation/ty-or-ct-params.rs +++ b/tests/ui/async-await/return-type-notation/ty-or-ct-params.rs @@ -1,6 +1,6 @@ // edition: 2021 -#![feature(async_fn_in_trait, return_type_notation)] +#![feature(return_type_notation)] //~^ WARN the feature `return_type_notation` is incomplete trait Foo { diff --git a/tests/ui/async-await/return-type-notation/ty-or-ct-params.stderr b/tests/ui/async-await/return-type-notation/ty-or-ct-params.stderr index 76928c5d7a3..da94d9d1e6d 100644 --- a/tests/ui/async-await/return-type-notation/ty-or-ct-params.stderr +++ b/tests/ui/async-await/return-type-notation/ty-or-ct-params.stderr @@ -1,8 +1,8 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/ty-or-ct-params.rs:3:31 + --> $DIR/ty-or-ct-params.rs:3:12 | -LL | #![feature(async_fn_in_trait, return_type_notation)] - | ^^^^^^^^^^^^^^^^^^^^ +LL | #![feature(return_type_notation)] + | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = note: `#[warn(incomplete_features)]` on by default diff --git a/tests/ui/check-cfg/allow-at-crate-level.rs b/tests/ui/check-cfg/allow-at-crate-level.rs index ce3383a2961..1629d2e0b67 100644 --- a/tests/ui/check-cfg/allow-at-crate-level.rs +++ b/tests/ui/check-cfg/allow-at-crate-level.rs @@ -1,7 +1,7 @@ // This test check that #![allow(unexpected_cfgs)] works with --cfg // // check-pass -// compile-flags: --cfg=unexpected --check-cfg=names() -Z unstable-options +// compile-flags: --cfg=unexpected --check-cfg=cfg() -Z unstable-options #![allow(unexpected_cfgs)] diff --git a/tests/ui/check-cfg/allow-macro-cfg.rs b/tests/ui/check-cfg/allow-macro-cfg.rs index 8016a4d190c..ea26355aca8 100644 --- a/tests/ui/check-cfg/allow-macro-cfg.rs +++ b/tests/ui/check-cfg/allow-macro-cfg.rs @@ -1,7 +1,7 @@ // This test check that local #[allow(unexpected_cfgs)] works // // check-pass -// compile-flags:--check-cfg=names() -Z unstable-options +// compile-flags: --check-cfg=cfg() -Z unstable-options #[allow(unexpected_cfgs)] fn foo() { diff --git a/tests/ui/check-cfg/allow-same-level.rs b/tests/ui/check-cfg/allow-same-level.rs index 6c869dc4202..29491e0b39e 100644 --- a/tests/ui/check-cfg/allow-same-level.rs +++ b/tests/ui/check-cfg/allow-same-level.rs @@ -1,7 +1,7 @@ // This test check that #[allow(unexpected_cfgs)] doesn't work if put on the same level // // check-pass -// compile-flags:--check-cfg=names() -Z unstable-options +// compile-flags: --check-cfg=cfg() -Z unstable-options #[allow(unexpected_cfgs)] #[cfg(FALSE)] diff --git a/tests/ui/check-cfg/allow-same-level.stderr b/tests/ui/check-cfg/allow-same-level.stderr index 7797de584b9..b0c459fabf8 100644 --- a/tests/ui/check-cfg/allow-same-level.stderr +++ b/tests/ui/check-cfg/allow-same-level.stderr @@ -1,9 +1,10 @@ -warning: unexpected `cfg` condition name +warning: unexpected `cfg` condition name: `FALSE` --> $DIR/allow-same-level.rs:7:7 | LL | #[cfg(FALSE)] | ^^^^^ | + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/allow-top-level.rs b/tests/ui/check-cfg/allow-top-level.rs index d14b0eae5cc..df06f655d9a 100644 --- a/tests/ui/check-cfg/allow-top-level.rs +++ b/tests/ui/check-cfg/allow-top-level.rs @@ -1,7 +1,7 @@ // This test check that a top-level #![allow(unexpected_cfgs)] works // // check-pass -// compile-flags:--check-cfg=names() -Z unstable-options +// compile-flags: --check-cfg=cfg() -Z unstable-options #![allow(unexpected_cfgs)] diff --git a/tests/ui/check-cfg/allow-upper-level.rs b/tests/ui/check-cfg/allow-upper-level.rs index 04340694d9c..bd5c97815f2 100644 --- a/tests/ui/check-cfg/allow-upper-level.rs +++ b/tests/ui/check-cfg/allow-upper-level.rs @@ -1,7 +1,7 @@ // This test check that #[allow(unexpected_cfgs)] work if put on an upper level // // check-pass -// compile-flags:--check-cfg=names() -Z unstable-options +// compile-flags: --check-cfg=cfg() -Z unstable-options #[allow(unexpected_cfgs)] mod aa { diff --git a/tests/ui/check-cfg/compact-names.rs b/tests/ui/check-cfg/compact-names.rs index bff80740039..4f7168255cf 100644 --- a/tests/ui/check-cfg/compact-names.rs +++ b/tests/ui/check-cfg/compact-names.rs @@ -1,7 +1,7 @@ // This test check that we correctly emit an warning for compact cfg // // check-pass -// compile-flags:--check-cfg=names() -Z unstable-options +// compile-flags: --check-cfg=cfg() -Z unstable-options #![feature(cfg_target_compact)] diff --git a/tests/ui/check-cfg/compact-names.stderr b/tests/ui/check-cfg/compact-names.stderr index f1fc4285a71..b0228774b75 100644 --- a/tests/ui/check-cfg/compact-names.stderr +++ b/tests/ui/check-cfg/compact-names.stderr @@ -1,9 +1,10 @@ -warning: unexpected `cfg` condition name +warning: unexpected `cfg` condition name: `target_architecture` --> $DIR/compact-names.rs:11:28 | LL | #[cfg(target(os = "linux", architecture = "arm"))] | ^^^^^^^^^^^^^^^^^^^^ | + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/compact-values.rs b/tests/ui/check-cfg/compact-values.rs index 1f17057840c..13c072fe920 100644 --- a/tests/ui/check-cfg/compact-values.rs +++ b/tests/ui/check-cfg/compact-values.rs @@ -1,7 +1,7 @@ // This test check that we correctly emit an warning for compact cfg // // check-pass -// compile-flags:--check-cfg=values() -Z unstable-options +// compile-flags: --check-cfg=cfg() -Z unstable-options #![feature(cfg_target_compact)] diff --git a/tests/ui/check-cfg/compact-values.stderr b/tests/ui/check-cfg/compact-values.stderr index b7269a652ea..bb2f4915b5e 100644 --- a/tests/ui/check-cfg/compact-values.stderr +++ b/tests/ui/check-cfg/compact-values.stderr @@ -1,4 +1,4 @@ -warning: unexpected `cfg` condition value +warning: unexpected `cfg` condition value: `X` --> $DIR/compact-values.rs:11:28 | LL | #[cfg(target(os = "linux", arch = "X"))] diff --git a/tests/ui/check-cfg/concat-values.rs b/tests/ui/check-cfg/concat-values.rs new file mode 100644 index 00000000000..0f9178ce6a5 --- /dev/null +++ b/tests/ui/check-cfg/concat-values.rs @@ -0,0 +1,13 @@ +// check-pass +// compile-flags: -Z unstable-options +// compile-flags: --check-cfg=cfg(my_cfg,values("foo")) --check-cfg=cfg(my_cfg,values("bar")) + +#[cfg(my_cfg)] +//~^ WARNING unexpected `cfg` condition value +fn my_cfg() {} + +#[cfg(my_cfg = "unk")] +//~^ WARNING unexpected `cfg` condition value +fn my_cfg() {} + +fn main() {} diff --git a/tests/ui/check-cfg/concat-values.stderr b/tests/ui/check-cfg/concat-values.stderr new file mode 100644 index 00000000000..da2bd7d6ad9 --- /dev/null +++ b/tests/ui/check-cfg/concat-values.stderr @@ -0,0 +1,19 @@ +warning: unexpected `cfg` condition value: (none) + --> $DIR/concat-values.rs:5:7 + | +LL | #[cfg(my_cfg)] + | ^^^^^^ + | + = note: expected values for `my_cfg` are: `bar`, `foo` + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition value: `unk` + --> $DIR/concat-values.rs:9:7 + | +LL | #[cfg(my_cfg = "unk")] + | ^^^^^^^^^^^^^^ + | + = note: expected values for `my_cfg` are: `bar`, `foo` + +warning: 2 warnings emitted + diff --git a/tests/ui/check-cfg/diagnotics.rs b/tests/ui/check-cfg/diagnotics.rs index 49e127d079a..45875bddc17 100644 --- a/tests/ui/check-cfg/diagnotics.rs +++ b/tests/ui/check-cfg/diagnotics.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: --check-cfg=names() --check-cfg=values(feature,"foo") --check-cfg=values(no_values) -Z unstable-options +// compile-flags: --check-cfg=cfg(feature,values("foo")) --check-cfg=cfg(no_values) -Z unstable-options #[cfg(featur)] //~^ WARNING unexpected `cfg` condition name diff --git a/tests/ui/check-cfg/diagnotics.stderr b/tests/ui/check-cfg/diagnotics.stderr index 8b9fef09d09..31c0db03a7e 100644 --- a/tests/ui/check-cfg/diagnotics.stderr +++ b/tests/ui/check-cfg/diagnotics.stderr @@ -1,4 +1,4 @@ -warning: unexpected `cfg` condition name +warning: unexpected `cfg` condition name: `featur` --> $DIR/diagnotics.rs:4:7 | LL | #[cfg(featur)] @@ -7,19 +7,18 @@ LL | #[cfg(featur)] = help: expected values for `feature` are: `foo` = note: `#[warn(unexpected_cfgs)]` on by default -warning: unexpected `cfg` condition name +warning: unexpected `cfg` condition name: `featur` --> $DIR/diagnotics.rs:8:7 | LL | #[cfg(featur = "foo")] | ^^^^^^^^^^^^^^ | - = help: expected values for `feature` are: `foo` help: there is a config with a similar name and value | LL | #[cfg(feature = "foo")] | ~~~~~~~ -warning: unexpected `cfg` condition name +warning: unexpected `cfg` condition name: `featur` --> $DIR/diagnotics.rs:12:7 | LL | #[cfg(featur = "fo")] @@ -31,13 +30,13 @@ help: there is a config with a similar name and different values LL | #[cfg(feature = "foo")] | ~~~~~~~~~~~~~~~ -warning: unexpected `cfg` condition name +warning: unexpected `cfg` condition name: `no_value` --> $DIR/diagnotics.rs:19:7 | LL | #[cfg(no_value)] | ^^^^^^^^ help: there is a config with a similar name: `no_values` -warning: unexpected `cfg` condition name +warning: unexpected `cfg` condition name: `no_value` --> $DIR/diagnotics.rs:23:7 | LL | #[cfg(no_value = "foo")] @@ -48,7 +47,7 @@ help: there is a config with a similar name and no value LL | #[cfg(no_values)] | ~~~~~~~~~ -warning: unexpected `cfg` condition value +warning: unexpected `cfg` condition value: `bar` --> $DIR/diagnotics.rs:27:7 | LL | #[cfg(no_values = "bar")] diff --git a/tests/ui/check-cfg/empty-names.rs b/tests/ui/check-cfg/empty-names.rs deleted file mode 100644 index 046ff0364e2..00000000000 --- a/tests/ui/check-cfg/empty-names.rs +++ /dev/null @@ -1,10 +0,0 @@ -// Check warning for unexpected cfg -// -// check-pass -// compile-flags: --check-cfg=names() -Z unstable-options - -#[cfg(unknown_key = "value")] -//~^ WARNING unexpected `cfg` condition name -pub fn f() {} - -fn main() {} diff --git a/tests/ui/check-cfg/empty-names.stderr b/tests/ui/check-cfg/empty-names.stderr deleted file mode 100644 index f926d1133cc..00000000000 --- a/tests/ui/check-cfg/empty-names.stderr +++ /dev/null @@ -1,10 +0,0 @@ -warning: unexpected `cfg` condition name - --> $DIR/empty-names.rs:6:7 - | -LL | #[cfg(unknown_key = "value")] - | ^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(unexpected_cfgs)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/check-cfg/empty-values.rs b/tests/ui/check-cfg/empty-values.rs deleted file mode 100644 index 9bda42e5d15..00000000000 --- a/tests/ui/check-cfg/empty-values.rs +++ /dev/null @@ -1,10 +0,0 @@ -// Check warning for unexpected cfg value -// -// check-pass -// compile-flags: --check-cfg=values() -Z unstable-options - -#[cfg(test = "value")] -//~^ WARNING unexpected `cfg` condition value -pub fn f() {} - -fn main() {} diff --git a/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr b/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr new file mode 100644 index 00000000000..53ccc0f4d31 --- /dev/null +++ b/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr @@ -0,0 +1,25 @@ +warning: unexpected `cfg` condition name: `unknown_key` + --> $DIR/exhaustive-names-values.rs:12:7 + | +LL | #[cfg(unknown_key = "value")] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition value: `value` + --> $DIR/exhaustive-names-values.rs:16:7 + | +LL | #[cfg(test = "value")] + | ^^^^---------- + | | + | help: remove the value + | + = note: no expected value for `test` + +warning: unexpected `empty_cfg` as condition name + | + = help: was set with `--cfg` but isn't in the `--check-cfg` expected names + +warning: 3 warnings emitted + diff --git a/tests/ui/check-cfg/exhaustive-names-values.empty_names_values.stderr b/tests/ui/check-cfg/exhaustive-names-values.empty_names_values.stderr new file mode 100644 index 00000000000..5e8b74054ce --- /dev/null +++ b/tests/ui/check-cfg/exhaustive-names-values.empty_names_values.stderr @@ -0,0 +1,25 @@ +warning: unexpected `cfg` condition name: `unknown_key` + --> $DIR/exhaustive-names-values.rs:12:7 + | +LL | #[cfg(unknown_key = "value")] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition value: `value` + --> $DIR/exhaustive-names-values.rs:16:7 + | +LL | #[cfg(test = "value")] + | ^^^^---------- + | | + | help: remove the value + | + = note: no expected value for `test` + +warning: unexpected `empty_names_values` as condition name + | + = help: was set with `--cfg` but isn't in the `--check-cfg` expected names + +warning: 3 warnings emitted + diff --git a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr new file mode 100644 index 00000000000..7705a665eb7 --- /dev/null +++ b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr @@ -0,0 +1,33 @@ +warning: unexpected `cfg` condition name: `unknown_key` + --> $DIR/exhaustive-names-values.rs:12:7 + | +LL | #[cfg(unknown_key = "value")] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition value: `value` + --> $DIR/exhaustive-names-values.rs:16:7 + | +LL | #[cfg(test = "value")] + | ^^^^---------- + | | + | help: remove the value + | + = note: no expected value for `test` + +warning: unexpected `cfg` condition value: `unk` + --> $DIR/exhaustive-names-values.rs:20:7 + | +LL | #[cfg(feature = "unk")] + | ^^^^^^^^^^^^^^^ + | + = note: expected values for `feature` are: `std` + +warning: unexpected condition value `` for condition name `feature` + | + = help: was set with `--cfg` but isn't in the `--check-cfg` expected values + +warning: 4 warnings emitted + diff --git a/tests/ui/check-cfg/exhaustive-names-values.full.stderr b/tests/ui/check-cfg/exhaustive-names-values.full.stderr new file mode 100644 index 00000000000..f0224a2e33c --- /dev/null +++ b/tests/ui/check-cfg/exhaustive-names-values.full.stderr @@ -0,0 +1,33 @@ +warning: unexpected `cfg` condition name: `unknown_key` + --> $DIR/exhaustive-names-values.rs:12:7 + | +LL | #[cfg(unknown_key = "value")] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition value: `value` + --> $DIR/exhaustive-names-values.rs:16:7 + | +LL | #[cfg(test = "value")] + | ^^^^---------- + | | + | help: remove the value + | + = note: no expected value for `test` + +warning: unexpected `cfg` condition value: `unk` + --> $DIR/exhaustive-names-values.rs:20:7 + | +LL | #[cfg(feature = "unk")] + | ^^^^^^^^^^^^^^^ + | + = note: expected values for `feature` are: `std` + +warning: unexpected `full` as condition name + | + = help: was set with `--cfg` but isn't in the `--check-cfg` expected names + +warning: 4 warnings emitted + diff --git a/tests/ui/check-cfg/exhaustive-names-values.rs b/tests/ui/check-cfg/exhaustive-names-values.rs new file mode 100644 index 00000000000..f553d93cae2 --- /dev/null +++ b/tests/ui/check-cfg/exhaustive-names-values.rs @@ -0,0 +1,34 @@ +// Check warning for unexpected cfg in the code and in the CLI +// arguments (here the revision cfg). +// +// check-pass +// revisions: empty_names_values empty_cfg feature full +// compile-flags: -Z unstable-options +// [empty_names_values]compile-flags: --check-cfg=names() --check-cfg=values() +// [empty_cfg]compile-flags: --check-cfg=cfg() +// [feature]compile-flags: --check-cfg=cfg(feature,values("std")) +// [full]compile-flags: --check-cfg=cfg(feature,values("std")) --check-cfg=cfg() + +#[cfg(unknown_key = "value")] +//~^ WARNING unexpected `cfg` condition name +pub fn f() {} + +#[cfg(test = "value")] +//~^ WARNING unexpected `cfg` condition value +pub fn f() {} + +#[cfg(feature = "unk")] +//[feature]~^ WARNING unexpected `cfg` condition value +//[full]~^^ WARNING unexpected `cfg` condition value +pub fn feat() {} + +#[cfg(feature = "std")] +pub fn feat() {} + +#[cfg(windows)] +pub fn win() {} + +#[cfg(unix)] +pub fn unix() {} + +fn main() {} diff --git a/tests/ui/check-cfg/exhaustive-names.empty_names.stderr b/tests/ui/check-cfg/exhaustive-names.empty_names.stderr new file mode 100644 index 00000000000..6190ff71464 --- /dev/null +++ b/tests/ui/check-cfg/exhaustive-names.empty_names.stderr @@ -0,0 +1,15 @@ +warning: unexpected `cfg` condition name: `unknown_key` + --> $DIR/exhaustive-names.rs:8:7 + | +LL | #[cfg(unknown_key = "value")] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `empty_names` as condition name + | + = help: was set with `--cfg` but isn't in the `--check-cfg` expected names + +warning: 2 warnings emitted + diff --git a/tests/ui/check-cfg/exhaustive-names.exhaustive_names.stderr b/tests/ui/check-cfg/exhaustive-names.exhaustive_names.stderr new file mode 100644 index 00000000000..f338434cd29 --- /dev/null +++ b/tests/ui/check-cfg/exhaustive-names.exhaustive_names.stderr @@ -0,0 +1,15 @@ +warning: unexpected `cfg` condition name: `unknown_key` + --> $DIR/exhaustive-names.rs:8:7 + | +LL | #[cfg(unknown_key = "value")] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `exhaustive_names` as condition name + | + = help: was set with `--cfg` but isn't in the `--check-cfg` expected names + +warning: 2 warnings emitted + diff --git a/tests/ui/check-cfg/exhaustive-names.rs b/tests/ui/check-cfg/exhaustive-names.rs new file mode 100644 index 00000000000..b86a7f84eb4 --- /dev/null +++ b/tests/ui/check-cfg/exhaustive-names.rs @@ -0,0 +1,12 @@ +// Check warning for unexpected cfg +// +// check-pass +// revisions: empty_names exhaustive_names +// [empty_names]compile-flags: --check-cfg=names() -Z unstable-options +// [exhaustive_names]compile-flags: --check-cfg=cfg() -Z unstable-options + +#[cfg(unknown_key = "value")] +//~^ WARNING unexpected `cfg` condition name +pub fn f() {} + +fn main() {} diff --git a/tests/ui/check-cfg/exhaustive-values.empty_cfg.stderr b/tests/ui/check-cfg/exhaustive-values.empty_cfg.stderr new file mode 100644 index 00000000000..999b2702849 --- /dev/null +++ b/tests/ui/check-cfg/exhaustive-values.empty_cfg.stderr @@ -0,0 +1,17 @@ +warning: unexpected `cfg` condition value: `value` + --> $DIR/exhaustive-values.rs:9:7 + | +LL | #[cfg(test = "value")] + | ^^^^---------- + | | + | help: remove the value + | + = note: no expected value for `test` + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `empty_cfg` as condition name + | + = help: was set with `--cfg` but isn't in the `--check-cfg` expected names + +warning: 2 warnings emitted + diff --git a/tests/ui/check-cfg/empty-values.stderr b/tests/ui/check-cfg/exhaustive-values.empty_values.stderr index a0168b2caa8..77ddc35100a 100644 --- a/tests/ui/check-cfg/empty-values.stderr +++ b/tests/ui/check-cfg/exhaustive-values.empty_values.stderr @@ -1,5 +1,5 @@ -warning: unexpected `cfg` condition value - --> $DIR/empty-values.rs:6:7 +warning: unexpected `cfg` condition value: `value` + --> $DIR/exhaustive-values.rs:9:7 | LL | #[cfg(test = "value")] | ^^^^---------- diff --git a/tests/ui/check-cfg/exhaustive-values.rs b/tests/ui/check-cfg/exhaustive-values.rs new file mode 100644 index 00000000000..8a1689ba86b --- /dev/null +++ b/tests/ui/check-cfg/exhaustive-values.rs @@ -0,0 +1,13 @@ +// Check warning for unexpected cfg value +// +// check-pass +// revisions: empty_values empty_cfg without_names +// [empty_values]compile-flags: --check-cfg=values() -Z unstable-options +// [empty_cfg]compile-flags: --check-cfg=cfg() -Z unstable-options +// [without_names]compile-flags: --check-cfg=cfg(any()) -Z unstable-options + +#[cfg(test = "value")] +//~^ WARNING unexpected `cfg` condition value +pub fn f() {} + +fn main() {} diff --git a/tests/ui/check-cfg/exhaustive-values.without_names.stderr b/tests/ui/check-cfg/exhaustive-values.without_names.stderr new file mode 100644 index 00000000000..77ddc35100a --- /dev/null +++ b/tests/ui/check-cfg/exhaustive-values.without_names.stderr @@ -0,0 +1,13 @@ +warning: unexpected `cfg` condition value: `value` + --> $DIR/exhaustive-values.rs:9:7 + | +LL | #[cfg(test = "value")] + | ^^^^---------- + | | + | help: remove the value + | + = note: no expected value for `test` + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/check-cfg/invalid-arguments.anything_else.stderr b/tests/ui/check-cfg/invalid-arguments.anything_else.stderr index 850924d993a..925664bb3fc 100644 --- a/tests/ui/check-cfg/invalid-arguments.anything_else.stderr +++ b/tests/ui/check-cfg/invalid-arguments.anything_else.stderr @@ -1,2 +1,2 @@ -error: invalid `--check-cfg` argument: `anything_else(...)` (expected `names(name1, name2, ... nameN)` or `values(name, "value1", "value2", ... "valueN")`) +error: invalid `--check-cfg` argument: `anything_else(...)` (expected `cfg(name, values("value1", "value2", ... "valueN"))`) diff --git a/tests/ui/check-cfg/invalid-arguments.giberich.stderr b/tests/ui/check-cfg/invalid-arguments.giberich.stderr new file mode 100644 index 00000000000..d427033fcc2 --- /dev/null +++ b/tests/ui/check-cfg/invalid-arguments.giberich.stderr @@ -0,0 +1,2 @@ +error: invalid `--check-cfg` argument: `cfg(...)` (expected `cfg(name, values("value1", "value2", ... "valueN"))`) + diff --git a/tests/ui/check-cfg/invalid-arguments.ident_in_values_1.stderr b/tests/ui/check-cfg/invalid-arguments.ident_in_values_1.stderr new file mode 100644 index 00000000000..0dc44d9ac76 --- /dev/null +++ b/tests/ui/check-cfg/invalid-arguments.ident_in_values_1.stderr @@ -0,0 +1,2 @@ +error: invalid `--check-cfg` argument: `cfg(foo,values(bar))` (`values()` arguments must be string literals or `any()`) + diff --git a/tests/ui/check-cfg/invalid-arguments.ident_in_values_2.stderr b/tests/ui/check-cfg/invalid-arguments.ident_in_values_2.stderr new file mode 100644 index 00000000000..d0a1453e3c4 --- /dev/null +++ b/tests/ui/check-cfg/invalid-arguments.ident_in_values_2.stderr @@ -0,0 +1,2 @@ +error: invalid `--check-cfg` argument: `cfg(foo,values("bar",bar,"bar"))` (`values()` arguments must be string literals or `any()`) + diff --git a/tests/ui/check-cfg/invalid-arguments.mixed_any.stderr b/tests/ui/check-cfg/invalid-arguments.mixed_any.stderr new file mode 100644 index 00000000000..9239f8cce94 --- /dev/null +++ b/tests/ui/check-cfg/invalid-arguments.mixed_any.stderr @@ -0,0 +1,2 @@ +error: invalid `--check-cfg` argument: `cfg(any(),values(any()))` (`values()` cannot be specified before the names) + diff --git a/tests/ui/check-cfg/invalid-arguments.mixed_values_any.stderr b/tests/ui/check-cfg/invalid-arguments.mixed_values_any.stderr new file mode 100644 index 00000000000..4c406143d08 --- /dev/null +++ b/tests/ui/check-cfg/invalid-arguments.mixed_values_any.stderr @@ -0,0 +1,2 @@ +error: invalid `--check-cfg` argument: `cfg(foo,values("bar",any()))` (`values()` arguments cannot specify string literals and `any()` at the same time) + diff --git a/tests/ui/check-cfg/invalid-arguments.multiple_any.stderr b/tests/ui/check-cfg/invalid-arguments.multiple_any.stderr new file mode 100644 index 00000000000..6f1db1b13c3 --- /dev/null +++ b/tests/ui/check-cfg/invalid-arguments.multiple_any.stderr @@ -0,0 +1,2 @@ +error: invalid `--check-cfg` argument: `cfg(any(),any())` (`any()` cannot be specified multiple times) + diff --git a/tests/ui/check-cfg/invalid-arguments.multiple_values.stderr b/tests/ui/check-cfg/invalid-arguments.multiple_values.stderr new file mode 100644 index 00000000000..bce305b09c3 --- /dev/null +++ b/tests/ui/check-cfg/invalid-arguments.multiple_values.stderr @@ -0,0 +1,2 @@ +error: invalid `--check-cfg` argument: `cfg(foo,values(),values())` (`values()` cannot be specified multiple times) + diff --git a/tests/ui/check-cfg/invalid-arguments.multiple_values_any.stderr b/tests/ui/check-cfg/invalid-arguments.multiple_values_any.stderr new file mode 100644 index 00000000000..748ce231af7 --- /dev/null +++ b/tests/ui/check-cfg/invalid-arguments.multiple_values_any.stderr @@ -0,0 +1,2 @@ +error: invalid `--check-cfg` argument: `cfg(foo,values(any(),any()))` (`any()` in `values()` cannot be specified multiple times) + diff --git a/tests/ui/check-cfg/invalid-arguments.not_empty_any.stderr b/tests/ui/check-cfg/invalid-arguments.not_empty_any.stderr new file mode 100644 index 00000000000..daf38147fe5 --- /dev/null +++ b/tests/ui/check-cfg/invalid-arguments.not_empty_any.stderr @@ -0,0 +1,2 @@ +error: invalid `--check-cfg` argument: `cfg(any(foo))` (`any()` must be empty) + diff --git a/tests/ui/check-cfg/invalid-arguments.not_empty_values_any.stderr b/tests/ui/check-cfg/invalid-arguments.not_empty_values_any.stderr new file mode 100644 index 00000000000..79f83e802ca --- /dev/null +++ b/tests/ui/check-cfg/invalid-arguments.not_empty_values_any.stderr @@ -0,0 +1,2 @@ +error: invalid `--check-cfg` argument: `cfg(foo,values(any(bar)))` (`any()` must be empty) + diff --git a/tests/ui/check-cfg/invalid-arguments.rs b/tests/ui/check-cfg/invalid-arguments.rs index 5090ce3e845..79bef89c957 100644 --- a/tests/ui/check-cfg/invalid-arguments.rs +++ b/tests/ui/check-cfg/invalid-arguments.rs @@ -2,9 +2,33 @@ // // check-fail // revisions: anything_else names_simple_ident values_simple_ident values_string_literals -// [anything_else]compile-flags: -Z unstable-options --check-cfg=anything_else(...) -// [names_simple_ident]compile-flags: -Z unstable-options --check-cfg=names("NOT_IDENT") -// [values_simple_ident]compile-flags: -Z unstable-options --check-cfg=values("NOT_IDENT") -// [values_string_literals]compile-flags: -Z unstable-options --check-cfg=values(test,12) +// revisions: string_for_name_1 string_for_name_2 multiple_any multiple_values +// revisions: multiple_values_any not_empty_any not_empty_values_any +// revisions: values_any_missing_values values_any_before_ident ident_in_values_1 +// revisions: ident_in_values_2 unknown_meta_item_1 unknown_meta_item_2 unknown_meta_item_3 +// revisions: mixed_values_any mixed_any giberich +// +// compile-flags: -Z unstable-options +// [anything_else]compile-flags: --check-cfg=anything_else(...) +// [names_simple_ident]compile-flags: --check-cfg=names("NOT_IDENT") +// [values_simple_ident]compile-flags: --check-cfg=values("NOT_IDENT") +// [values_string_literals]compile-flags: --check-cfg=values(test,12) +// [string_for_name_1]compile-flags: --check-cfg=cfg("NOT_IDENT") +// [string_for_name_2]compile-flags: --check-cfg=cfg(foo,"NOT_IDENT",bar) +// [multiple_any]compile-flags: --check-cfg=cfg(any(),any()) +// [multiple_values]compile-flags: --check-cfg=cfg(foo,values(),values()) +// [multiple_values_any]compile-flags: --check-cfg=cfg(foo,values(any(),any())) +// [not_empty_any]compile-flags: --check-cfg=cfg(any(foo)) +// [not_empty_values_any]compile-flags: --check-cfg=cfg(foo,values(any(bar))) +// [values_any_missing_values]compile-flags: --check-cfg=cfg(foo,any()) +// [values_any_before_ident]compile-flags: --check-cfg=cfg(values(any()),foo) +// [ident_in_values_1]compile-flags: --check-cfg=cfg(foo,values(bar)) +// [ident_in_values_2]compile-flags: --check-cfg=cfg(foo,values("bar",bar,"bar")) +// [unknown_meta_item_1]compile-flags: --check-cfg=abc() +// [unknown_meta_item_2]compile-flags: --check-cfg=cfg(foo,test()) +// [unknown_meta_item_3]compile-flags: --check-cfg=cfg(foo,values(test())) +// [mixed_values_any]compile-flags: --check-cfg=cfg(foo,values("bar",any())) +// [mixed_any]compile-flags: --check-cfg=cfg(any(),values(any())) +// [giberich]compile-flags: --check-cfg=cfg(...) fn main() {} diff --git a/tests/ui/check-cfg/invalid-arguments.string_for_name_1.stderr b/tests/ui/check-cfg/invalid-arguments.string_for_name_1.stderr new file mode 100644 index 00000000000..c6f6834ffd3 --- /dev/null +++ b/tests/ui/check-cfg/invalid-arguments.string_for_name_1.stderr @@ -0,0 +1,2 @@ +error: invalid `--check-cfg` argument: `cfg("NOT_IDENT")` (`cfg()` arguments must be simple identifiers, `any()` or `values(...)`) + diff --git a/tests/ui/check-cfg/invalid-arguments.string_for_name_2.stderr b/tests/ui/check-cfg/invalid-arguments.string_for_name_2.stderr new file mode 100644 index 00000000000..ab3dc86cd1a --- /dev/null +++ b/tests/ui/check-cfg/invalid-arguments.string_for_name_2.stderr @@ -0,0 +1,2 @@ +error: invalid `--check-cfg` argument: `cfg(foo,"NOT_IDENT",bar)` (`cfg()` arguments must be simple identifiers, `any()` or `values(...)`) + diff --git a/tests/ui/check-cfg/invalid-arguments.unknown_meta_item_1.stderr b/tests/ui/check-cfg/invalid-arguments.unknown_meta_item_1.stderr new file mode 100644 index 00000000000..c04b15ec265 --- /dev/null +++ b/tests/ui/check-cfg/invalid-arguments.unknown_meta_item_1.stderr @@ -0,0 +1,2 @@ +error: invalid `--check-cfg` argument: `abc()` (expected `cfg(name, values("value1", "value2", ... "valueN"))`) + diff --git a/tests/ui/check-cfg/invalid-arguments.unknown_meta_item_2.stderr b/tests/ui/check-cfg/invalid-arguments.unknown_meta_item_2.stderr new file mode 100644 index 00000000000..cee65f9887b --- /dev/null +++ b/tests/ui/check-cfg/invalid-arguments.unknown_meta_item_2.stderr @@ -0,0 +1,2 @@ +error: invalid `--check-cfg` argument: `cfg(foo,test())` (`cfg()` arguments must be simple identifiers, `any()` or `values(...)`) + diff --git a/tests/ui/check-cfg/invalid-arguments.unknown_meta_item_3.stderr b/tests/ui/check-cfg/invalid-arguments.unknown_meta_item_3.stderr new file mode 100644 index 00000000000..2441e2537b7 --- /dev/null +++ b/tests/ui/check-cfg/invalid-arguments.unknown_meta_item_3.stderr @@ -0,0 +1,2 @@ +error: invalid `--check-cfg` argument: `cfg(foo,values(test()))` (`values()` arguments must be string literals or `any()`) + diff --git a/tests/ui/check-cfg/invalid-arguments.values_any_before_ident.stderr b/tests/ui/check-cfg/invalid-arguments.values_any_before_ident.stderr new file mode 100644 index 00000000000..fc93ec8fbdf --- /dev/null +++ b/tests/ui/check-cfg/invalid-arguments.values_any_before_ident.stderr @@ -0,0 +1,2 @@ +error: invalid `--check-cfg` argument: `cfg(values(any()),foo)` (`values()` cannot be specified before the names) + diff --git a/tests/ui/check-cfg/invalid-arguments.values_any_missing_values.stderr b/tests/ui/check-cfg/invalid-arguments.values_any_missing_values.stderr new file mode 100644 index 00000000000..f41672fcbdb --- /dev/null +++ b/tests/ui/check-cfg/invalid-arguments.values_any_missing_values.stderr @@ -0,0 +1,2 @@ +error: invalid `--check-cfg` argument: `cfg(foo,any())` (`cfg(any())` can only be provided in isolation) + diff --git a/tests/ui/check-cfg/invalid-cfg-name.rs b/tests/ui/check-cfg/invalid-cfg-name.rs deleted file mode 100644 index 8499d3d4448..00000000000 --- a/tests/ui/check-cfg/invalid-cfg-name.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Check warning for invalid configuration name -// -// edition:2018 -// check-pass -// compile-flags: --check-cfg=names() -Z unstable-options - -#[cfg(widnows)] -//~^ WARNING unexpected `cfg` condition name -pub fn f() {} - -#[cfg(windows)] -pub fn g() {} - -pub fn main() {} diff --git a/tests/ui/check-cfg/invalid-cfg-value.rs b/tests/ui/check-cfg/invalid-cfg-value.rs deleted file mode 100644 index 9e428d367fd..00000000000 --- a/tests/ui/check-cfg/invalid-cfg-value.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Check warning for invalid configuration value -// -// edition:2018 -// check-pass -// compile-flags: --check-cfg=values(feature,"serde","full") --cfg=feature="rand" -Z unstable-options - -#[cfg(feature = "sedre")] -//~^ WARNING unexpected `cfg` condition value -pub fn f() {} - -#[cfg(feature = "serde")] -pub fn g() {} - -#[cfg(feature = "rand")] -//~^ WARNING unexpected `cfg` condition value -pub fn h() {} - -pub fn main() {} diff --git a/tests/ui/check-cfg/mix.stderr b/tests/ui/check-cfg/mix.cfg.stderr index 07c514aed52..daa200440cc 100644 --- a/tests/ui/check-cfg/mix.stderr +++ b/tests/ui/check-cfg/mix.cfg.stderr @@ -1,40 +1,42 @@ -warning: unexpected `cfg` condition name - --> $DIR/mix.rs:11:7 +warning: unexpected `cfg` condition name: `widnows` + --> $DIR/mix.rs:15:7 | LL | #[cfg(widnows)] | ^^^^^^^ help: there is a config with a similar name: `windows` | = note: `#[warn(unexpected_cfgs)]` on by default -warning: unexpected `cfg` condition value - --> $DIR/mix.rs:15:7 +warning: unexpected `cfg` condition value: (none) + --> $DIR/mix.rs:19:7 | LL | #[cfg(feature)] | ^^^^^^^- help: specify a config value: `= "foo"` | = note: expected values for `feature` are: `foo` -warning: unexpected `cfg` condition value - --> $DIR/mix.rs:22:7 +warning: unexpected `cfg` condition value: `bar` + --> $DIR/mix.rs:26:7 | LL | #[cfg(feature = "bar")] | ^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` -warning: unexpected `cfg` condition value - --> $DIR/mix.rs:26:7 +warning: unexpected `cfg` condition value: `zebra` + --> $DIR/mix.rs:30:7 | LL | #[cfg(feature = "zebra")] | ^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` -warning: unexpected `cfg` condition name - --> $DIR/mix.rs:30:12 +warning: unexpected `cfg` condition name: `uu` + --> $DIR/mix.rs:34:12 | LL | #[cfg_attr(uu, test)] | ^^ + | + = help: expected names are: `cfg`, `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `names_values`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` warning: unexpected condition value `bar` for condition name `feature` | @@ -44,142 +46,142 @@ warning: unexpected `unknown_name` as condition name | = help: was set with `--cfg` but isn't in the `--check-cfg` expected names -warning: unexpected `cfg` condition name - --> $DIR/mix.rs:39:10 +warning: unexpected `cfg` condition name: `widnows` + --> $DIR/mix.rs:43:10 | LL | cfg!(widnows); | ^^^^^^^ help: there is a config with a similar name: `windows` -warning: unexpected `cfg` condition value - --> $DIR/mix.rs:42:10 +warning: unexpected `cfg` condition value: `bar` + --> $DIR/mix.rs:46:10 | LL | cfg!(feature = "bar"); | ^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` -warning: unexpected `cfg` condition value - --> $DIR/mix.rs:44:10 +warning: unexpected `cfg` condition value: `zebra` + --> $DIR/mix.rs:48:10 | LL | cfg!(feature = "zebra"); | ^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` -warning: unexpected `cfg` condition name - --> $DIR/mix.rs:46:10 +warning: unexpected `cfg` condition name: `xxx` + --> $DIR/mix.rs:50:10 | LL | cfg!(xxx = "foo"); | ^^^^^^^^^^^ -warning: unexpected `cfg` condition name - --> $DIR/mix.rs:48:10 +warning: unexpected `cfg` condition name: `xxx` + --> $DIR/mix.rs:52:10 | LL | cfg!(xxx); | ^^^ -warning: unexpected `cfg` condition name - --> $DIR/mix.rs:50:14 +warning: unexpected `cfg` condition name: `xxx` + --> $DIR/mix.rs:54:14 | LL | cfg!(any(xxx, windows)); | ^^^ -warning: unexpected `cfg` condition value - --> $DIR/mix.rs:52:14 +warning: unexpected `cfg` condition value: `bad` + --> $DIR/mix.rs:56:14 | LL | cfg!(any(feature = "bad", windows)); | ^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` -warning: unexpected `cfg` condition name - --> $DIR/mix.rs:54:23 +warning: unexpected `cfg` condition name: `xxx` + --> $DIR/mix.rs:58:23 | LL | cfg!(any(windows, xxx)); | ^^^ -warning: unexpected `cfg` condition name - --> $DIR/mix.rs:56:20 +warning: unexpected `cfg` condition name: `xxx` + --> $DIR/mix.rs:60:20 | LL | cfg!(all(unix, xxx)); | ^^^ -warning: unexpected `cfg` condition name - --> $DIR/mix.rs:58:14 +warning: unexpected `cfg` condition name: `aa` + --> $DIR/mix.rs:62:14 | LL | cfg!(all(aa, bb)); | ^^ -warning: unexpected `cfg` condition name - --> $DIR/mix.rs:58:18 +warning: unexpected `cfg` condition name: `bb` + --> $DIR/mix.rs:62:18 | LL | cfg!(all(aa, bb)); | ^^ -warning: unexpected `cfg` condition name - --> $DIR/mix.rs:61:14 +warning: unexpected `cfg` condition name: `aa` + --> $DIR/mix.rs:65:14 | LL | cfg!(any(aa, bb)); | ^^ -warning: unexpected `cfg` condition name - --> $DIR/mix.rs:61:18 +warning: unexpected `cfg` condition name: `bb` + --> $DIR/mix.rs:65:18 | LL | cfg!(any(aa, bb)); | ^^ -warning: unexpected `cfg` condition value - --> $DIR/mix.rs:64:20 +warning: unexpected `cfg` condition value: `zebra` + --> $DIR/mix.rs:68:20 | LL | cfg!(any(unix, feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` -warning: unexpected `cfg` condition name - --> $DIR/mix.rs:66:14 +warning: unexpected `cfg` condition name: `xxx` + --> $DIR/mix.rs:70:14 | LL | cfg!(any(xxx, feature = "zebra")); | ^^^ -warning: unexpected `cfg` condition value - --> $DIR/mix.rs:66:19 +warning: unexpected `cfg` condition value: `zebra` + --> $DIR/mix.rs:70:19 | LL | cfg!(any(xxx, feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` -warning: unexpected `cfg` condition name - --> $DIR/mix.rs:69:14 +warning: unexpected `cfg` condition name: `xxx` + --> $DIR/mix.rs:73:14 | LL | cfg!(any(xxx, unix, xxx)); | ^^^ -warning: unexpected `cfg` condition name - --> $DIR/mix.rs:69:25 +warning: unexpected `cfg` condition name: `xxx` + --> $DIR/mix.rs:73:25 | LL | cfg!(any(xxx, unix, xxx)); | ^^^ -warning: unexpected `cfg` condition value - --> $DIR/mix.rs:72:14 +warning: unexpected `cfg` condition value: `zebra` + --> $DIR/mix.rs:76:14 | LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` -warning: unexpected `cfg` condition value - --> $DIR/mix.rs:72:33 +warning: unexpected `cfg` condition value: `zebra` + --> $DIR/mix.rs:76:33 | LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` -warning: unexpected `cfg` condition value - --> $DIR/mix.rs:72:52 +warning: unexpected `cfg` condition value: `zebra` + --> $DIR/mix.rs:76:52 | LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/mix.names_values.stderr b/tests/ui/check-cfg/mix.names_values.stderr new file mode 100644 index 00000000000..daa200440cc --- /dev/null +++ b/tests/ui/check-cfg/mix.names_values.stderr @@ -0,0 +1,192 @@ +warning: unexpected `cfg` condition name: `widnows` + --> $DIR/mix.rs:15:7 + | +LL | #[cfg(widnows)] + | ^^^^^^^ help: there is a config with a similar name: `windows` + | + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition value: (none) + --> $DIR/mix.rs:19:7 + | +LL | #[cfg(feature)] + | ^^^^^^^- help: specify a config value: `= "foo"` + | + = note: expected values for `feature` are: `foo` + +warning: unexpected `cfg` condition value: `bar` + --> $DIR/mix.rs:26:7 + | +LL | #[cfg(feature = "bar")] + | ^^^^^^^^^^^^^^^ + | + = note: expected values for `feature` are: `foo` + +warning: unexpected `cfg` condition value: `zebra` + --> $DIR/mix.rs:30:7 + | +LL | #[cfg(feature = "zebra")] + | ^^^^^^^^^^^^^^^^^ + | + = note: expected values for `feature` are: `foo` + +warning: unexpected `cfg` condition name: `uu` + --> $DIR/mix.rs:34:12 + | +LL | #[cfg_attr(uu, test)] + | ^^ + | + = help: expected names are: `cfg`, `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `names_values`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + +warning: unexpected condition value `bar` for condition name `feature` + | + = help: was set with `--cfg` but isn't in the `--check-cfg` expected values + +warning: unexpected `unknown_name` as condition name + | + = help: was set with `--cfg` but isn't in the `--check-cfg` expected names + +warning: unexpected `cfg` condition name: `widnows` + --> $DIR/mix.rs:43:10 + | +LL | cfg!(widnows); + | ^^^^^^^ help: there is a config with a similar name: `windows` + +warning: unexpected `cfg` condition value: `bar` + --> $DIR/mix.rs:46:10 + | +LL | cfg!(feature = "bar"); + | ^^^^^^^^^^^^^^^ + | + = note: expected values for `feature` are: `foo` + +warning: unexpected `cfg` condition value: `zebra` + --> $DIR/mix.rs:48:10 + | +LL | cfg!(feature = "zebra"); + | ^^^^^^^^^^^^^^^^^ + | + = note: expected values for `feature` are: `foo` + +warning: unexpected `cfg` condition name: `xxx` + --> $DIR/mix.rs:50:10 + | +LL | cfg!(xxx = "foo"); + | ^^^^^^^^^^^ + +warning: unexpected `cfg` condition name: `xxx` + --> $DIR/mix.rs:52:10 + | +LL | cfg!(xxx); + | ^^^ + +warning: unexpected `cfg` condition name: `xxx` + --> $DIR/mix.rs:54:14 + | +LL | cfg!(any(xxx, windows)); + | ^^^ + +warning: unexpected `cfg` condition value: `bad` + --> $DIR/mix.rs:56:14 + | +LL | cfg!(any(feature = "bad", windows)); + | ^^^^^^^^^^^^^^^ + | + = note: expected values for `feature` are: `foo` + +warning: unexpected `cfg` condition name: `xxx` + --> $DIR/mix.rs:58:23 + | +LL | cfg!(any(windows, xxx)); + | ^^^ + +warning: unexpected `cfg` condition name: `xxx` + --> $DIR/mix.rs:60:20 + | +LL | cfg!(all(unix, xxx)); + | ^^^ + +warning: unexpected `cfg` condition name: `aa` + --> $DIR/mix.rs:62:14 + | +LL | cfg!(all(aa, bb)); + | ^^ + +warning: unexpected `cfg` condition name: `bb` + --> $DIR/mix.rs:62:18 + | +LL | cfg!(all(aa, bb)); + | ^^ + +warning: unexpected `cfg` condition name: `aa` + --> $DIR/mix.rs:65:14 + | +LL | cfg!(any(aa, bb)); + | ^^ + +warning: unexpected `cfg` condition name: `bb` + --> $DIR/mix.rs:65:18 + | +LL | cfg!(any(aa, bb)); + | ^^ + +warning: unexpected `cfg` condition value: `zebra` + --> $DIR/mix.rs:68:20 + | +LL | cfg!(any(unix, feature = "zebra")); + | ^^^^^^^^^^^^^^^^^ + | + = note: expected values for `feature` are: `foo` + +warning: unexpected `cfg` condition name: `xxx` + --> $DIR/mix.rs:70:14 + | +LL | cfg!(any(xxx, feature = "zebra")); + | ^^^ + +warning: unexpected `cfg` condition value: `zebra` + --> $DIR/mix.rs:70:19 + | +LL | cfg!(any(xxx, feature = "zebra")); + | ^^^^^^^^^^^^^^^^^ + | + = note: expected values for `feature` are: `foo` + +warning: unexpected `cfg` condition name: `xxx` + --> $DIR/mix.rs:73:14 + | +LL | cfg!(any(xxx, unix, xxx)); + | ^^^ + +warning: unexpected `cfg` condition name: `xxx` + --> $DIR/mix.rs:73:25 + | +LL | cfg!(any(xxx, unix, xxx)); + | ^^^ + +warning: unexpected `cfg` condition value: `zebra` + --> $DIR/mix.rs:76:14 + | +LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); + | ^^^^^^^^^^^^^^^^^ + | + = note: expected values for `feature` are: `foo` + +warning: unexpected `cfg` condition value: `zebra` + --> $DIR/mix.rs:76:33 + | +LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); + | ^^^^^^^^^^^^^^^^^ + | + = note: expected values for `feature` are: `foo` + +warning: unexpected `cfg` condition value: `zebra` + --> $DIR/mix.rs:76:52 + | +LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); + | ^^^^^^^^^^^^^^^^^ + | + = note: expected values for `feature` are: `foo` + +warning: 28 warnings emitted + diff --git a/tests/ui/check-cfg/mix.rs b/tests/ui/check-cfg/mix.rs index 9adf5c46e43..d7b3b4953b7 100644 --- a/tests/ui/check-cfg/mix.rs +++ b/tests/ui/check-cfg/mix.rs @@ -3,7 +3,11 @@ // we correctly lint on the `cfg!` macro and `cfg_attr` attribute. // // check-pass -// compile-flags: --check-cfg=names() --check-cfg=values(feature,"foo") --cfg feature="bar" --cfg unknown_name -Z unstable-options +// revisions: names_values cfg +// compile-flags: --cfg feature="bar" --cfg unknown_name -Z unstable-options +// compile-flags: --check-cfg=cfg(names_values,cfg) +// [names_values]compile-flags: --check-cfg=names() --check-cfg=values(feature,"foo") +// [cfg]compile-flags: --check-cfg=cfg(feature,values("foo")) #[cfg(windows)] fn do_windows_stuff() {} diff --git a/tests/ui/check-cfg/no-values.stderr b/tests/ui/check-cfg/no-expected-values.empty.stderr index ffa87dc58f2..5d261b2a5e6 100644 --- a/tests/ui/check-cfg/no-values.stderr +++ b/tests/ui/check-cfg/no-expected-values.empty.stderr @@ -1,5 +1,5 @@ -warning: unexpected `cfg` condition value - --> $DIR/no-values.rs:6:7 +warning: unexpected `cfg` condition value: `foo` + --> $DIR/no-expected-values.rs:12:7 | LL | #[cfg(feature = "foo")] | ^^^^^^^-------- @@ -9,8 +9,8 @@ LL | #[cfg(feature = "foo")] = note: no expected value for `feature` = note: `#[warn(unexpected_cfgs)]` on by default -warning: unexpected `cfg` condition value - --> $DIR/no-values.rs:10:7 +warning: unexpected `cfg` condition value: `foo` + --> $DIR/no-expected-values.rs:16:7 | LL | #[cfg(test = "foo")] | ^^^^-------- diff --git a/tests/ui/check-cfg/no-expected-values.mixed.stderr b/tests/ui/check-cfg/no-expected-values.mixed.stderr new file mode 100644 index 00000000000..5d261b2a5e6 --- /dev/null +++ b/tests/ui/check-cfg/no-expected-values.mixed.stderr @@ -0,0 +1,23 @@ +warning: unexpected `cfg` condition value: `foo` + --> $DIR/no-expected-values.rs:12:7 + | +LL | #[cfg(feature = "foo")] + | ^^^^^^^-------- + | | + | help: remove the value + | + = note: no expected value for `feature` + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition value: `foo` + --> $DIR/no-expected-values.rs:16:7 + | +LL | #[cfg(test = "foo")] + | ^^^^-------- + | | + | help: remove the value + | + = note: no expected value for `test` + +warning: 2 warnings emitted + diff --git a/tests/ui/check-cfg/no-expected-values.rs b/tests/ui/check-cfg/no-expected-values.rs new file mode 100644 index 00000000000..9e2a9f09aed --- /dev/null +++ b/tests/ui/check-cfg/no-expected-values.rs @@ -0,0 +1,20 @@ +// Check that we detect unexpected value when none are allowed +// +// check-pass +// revisions: values simple mixed empty +// compile-flags: -Z unstable-options +// compile-flags: --check-cfg=cfg(values,simple,mixed,empty) +// [values]compile-flags: --check-cfg=values(test) --check-cfg=values(feature) +// [simple]compile-flags: --check-cfg=cfg(test) --check-cfg=cfg(feature) +// [mixed]compile-flags: --check-cfg=cfg(test,feature) +// [empty]compile-flags: --check-cfg=cfg(test,feature,values()) + +#[cfg(feature = "foo")] +//~^ WARNING unexpected `cfg` condition value +fn do_foo() {} + +#[cfg(test = "foo")] +//~^ WARNING unexpected `cfg` condition value +fn do_foo() {} + +fn main() {} diff --git a/tests/ui/check-cfg/no-expected-values.simple.stderr b/tests/ui/check-cfg/no-expected-values.simple.stderr new file mode 100644 index 00000000000..5d261b2a5e6 --- /dev/null +++ b/tests/ui/check-cfg/no-expected-values.simple.stderr @@ -0,0 +1,23 @@ +warning: unexpected `cfg` condition value: `foo` + --> $DIR/no-expected-values.rs:12:7 + | +LL | #[cfg(feature = "foo")] + | ^^^^^^^-------- + | | + | help: remove the value + | + = note: no expected value for `feature` + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition value: `foo` + --> $DIR/no-expected-values.rs:16:7 + | +LL | #[cfg(test = "foo")] + | ^^^^-------- + | | + | help: remove the value + | + = note: no expected value for `test` + +warning: 2 warnings emitted + diff --git a/tests/ui/check-cfg/no-expected-values.values.stderr b/tests/ui/check-cfg/no-expected-values.values.stderr new file mode 100644 index 00000000000..5d261b2a5e6 --- /dev/null +++ b/tests/ui/check-cfg/no-expected-values.values.stderr @@ -0,0 +1,23 @@ +warning: unexpected `cfg` condition value: `foo` + --> $DIR/no-expected-values.rs:12:7 + | +LL | #[cfg(feature = "foo")] + | ^^^^^^^-------- + | | + | help: remove the value + | + = note: no expected value for `feature` + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition value: `foo` + --> $DIR/no-expected-values.rs:16:7 + | +LL | #[cfg(test = "foo")] + | ^^^^-------- + | | + | help: remove the value + | + = note: no expected value for `test` + +warning: 2 warnings emitted + diff --git a/tests/ui/check-cfg/no-values.rs b/tests/ui/check-cfg/no-values.rs deleted file mode 100644 index 8c80f56cb5a..00000000000 --- a/tests/ui/check-cfg/no-values.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Check that we detect unexpected value when none are allowed -// -// check-pass -// compile-flags: --check-cfg=values(test) --check-cfg=values(feature) -Z unstable-options - -#[cfg(feature = "foo")] -//~^ WARNING unexpected `cfg` condition value -fn do_foo() {} - -#[cfg(test = "foo")] -//~^ WARNING unexpected `cfg` condition value -fn do_foo() {} - -fn main() {} diff --git a/tests/ui/check-cfg/order-independant.names_after.stderr b/tests/ui/check-cfg/order-independant.names_after.stderr index 91b81428b38..a308358e485 100644 --- a/tests/ui/check-cfg/order-independant.names_after.stderr +++ b/tests/ui/check-cfg/order-independant.names_after.stderr @@ -1,4 +1,4 @@ -warning: unexpected `cfg` condition value +warning: unexpected `cfg` condition value: (none) --> $DIR/order-independant.rs:8:7 | LL | #[cfg(a)] @@ -7,7 +7,7 @@ LL | #[cfg(a)] = note: expected values for `a` are: `b` = note: `#[warn(unexpected_cfgs)]` on by default -warning: unexpected `cfg` condition value +warning: unexpected `cfg` condition value: `unk` --> $DIR/order-independant.rs:12:7 | LL | #[cfg(a = "unk")] diff --git a/tests/ui/check-cfg/order-independant.names_before.stderr b/tests/ui/check-cfg/order-independant.names_before.stderr index 91b81428b38..a308358e485 100644 --- a/tests/ui/check-cfg/order-independant.names_before.stderr +++ b/tests/ui/check-cfg/order-independant.names_before.stderr @@ -1,4 +1,4 @@ -warning: unexpected `cfg` condition value +warning: unexpected `cfg` condition value: (none) --> $DIR/order-independant.rs:8:7 | LL | #[cfg(a)] @@ -7,7 +7,7 @@ LL | #[cfg(a)] = note: expected values for `a` are: `b` = note: `#[warn(unexpected_cfgs)]` on by default -warning: unexpected `cfg` condition value +warning: unexpected `cfg` condition value: `unk` --> $DIR/order-independant.rs:12:7 | LL | #[cfg(a = "unk")] diff --git a/tests/ui/check-cfg/stmt-no-ice.rs b/tests/ui/check-cfg/stmt-no-ice.rs index cf76487ed46..383e830a1b2 100644 --- a/tests/ui/check-cfg/stmt-no-ice.rs +++ b/tests/ui/check-cfg/stmt-no-ice.rs @@ -1,7 +1,7 @@ // This test checks that there is no ICE with this code // // check-pass -// compile-flags:--check-cfg=names() -Z unstable-options +// compile-flags:--check-cfg=cfg() -Z unstable-options fn main() { #[cfg(crossbeam_loom)] diff --git a/tests/ui/check-cfg/stmt-no-ice.stderr b/tests/ui/check-cfg/stmt-no-ice.stderr index da65b596911..900ea4e4da0 100644 --- a/tests/ui/check-cfg/stmt-no-ice.stderr +++ b/tests/ui/check-cfg/stmt-no-ice.stderr @@ -1,9 +1,10 @@ -warning: unexpected `cfg` condition name +warning: unexpected `cfg` condition name: `crossbeam_loom` --> $DIR/stmt-no-ice.rs:7:11 | LL | #[cfg(crossbeam_loom)] | ^^^^^^^^^^^^^^ | + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/invalid-cfg-name.stderr b/tests/ui/check-cfg/unexpected-cfg-name.exhaustive.stderr index ed09f8cb66d..513f7ac7fd1 100644 --- a/tests/ui/check-cfg/invalid-cfg-name.stderr +++ b/tests/ui/check-cfg/unexpected-cfg-name.exhaustive.stderr @@ -1,5 +1,5 @@ -warning: unexpected `cfg` condition name - --> $DIR/invalid-cfg-name.rs:7:7 +warning: unexpected `cfg` condition name: `widnows` + --> $DIR/unexpected-cfg-name.rs:9:7 | LL | #[cfg(widnows)] | ^^^^^^^ help: there is a config with a similar name: `windows` diff --git a/tests/ui/check-cfg/unexpected-cfg-name.names.stderr b/tests/ui/check-cfg/unexpected-cfg-name.names.stderr new file mode 100644 index 00000000000..513f7ac7fd1 --- /dev/null +++ b/tests/ui/check-cfg/unexpected-cfg-name.names.stderr @@ -0,0 +1,10 @@ +warning: unexpected `cfg` condition name: `widnows` + --> $DIR/unexpected-cfg-name.rs:9:7 + | +LL | #[cfg(widnows)] + | ^^^^^^^ help: there is a config with a similar name: `windows` + | + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/check-cfg/unexpected-cfg-name.rs b/tests/ui/check-cfg/unexpected-cfg-name.rs new file mode 100644 index 00000000000..15c3aa6e081 --- /dev/null +++ b/tests/ui/check-cfg/unexpected-cfg-name.rs @@ -0,0 +1,16 @@ +// Check warning for unexpected configuration name +// +// check-pass +// revisions: names exhaustive +// compile-flags: --check-cfg=cfg(names,exhaustive) +// [names]compile-flags: --check-cfg=names() -Z unstable-options +// [exhaustive]compile-flags: --check-cfg=cfg() -Z unstable-options + +#[cfg(widnows)] +//~^ WARNING unexpected `cfg` condition name +pub fn f() {} + +#[cfg(windows)] +pub fn g() {} + +pub fn main() {} diff --git a/tests/ui/check-cfg/invalid-cfg-value.stderr b/tests/ui/check-cfg/unexpected-cfg-value.cfg.stderr index 776d264a7ad..2ed7f900557 100644 --- a/tests/ui/check-cfg/invalid-cfg-value.stderr +++ b/tests/ui/check-cfg/unexpected-cfg-value.cfg.stderr @@ -1,5 +1,5 @@ -warning: unexpected `cfg` condition value - --> $DIR/invalid-cfg-value.rs:7:7 +warning: unexpected `cfg` condition value: `sedre` + --> $DIR/unexpected-cfg-value.rs:11:7 | LL | #[cfg(feature = "sedre")] | ^^^^^^^^^^------- @@ -9,8 +9,8 @@ LL | #[cfg(feature = "sedre")] = note: expected values for `feature` are: `full`, `serde` = note: `#[warn(unexpected_cfgs)]` on by default -warning: unexpected `cfg` condition value - --> $DIR/invalid-cfg-value.rs:14:7 +warning: unexpected `cfg` condition value: `rand` + --> $DIR/unexpected-cfg-value.rs:18:7 | LL | #[cfg(feature = "rand")] | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/unexpected-cfg-value.rs b/tests/ui/check-cfg/unexpected-cfg-value.rs new file mode 100644 index 00000000000..a84458071de --- /dev/null +++ b/tests/ui/check-cfg/unexpected-cfg-value.rs @@ -0,0 +1,22 @@ +// Check warning for invalid configuration value in the code and +// in the cli +// +// check-pass +// revisions: values cfg +// compile-flags: --cfg=feature="rand" -Z unstable-options +// compile-flags: --check-cfg=cfg(values,cfg) +// [values]compile-flags: --check-cfg=values(feature,"serde","full") +// [cfg]compile-flags: --check-cfg=cfg(feature,values("serde","full")) + +#[cfg(feature = "sedre")] +//~^ WARNING unexpected `cfg` condition value +pub fn f() {} + +#[cfg(feature = "serde")] +pub fn g() {} + +#[cfg(feature = "rand")] +//~^ WARNING unexpected `cfg` condition value +pub fn h() {} + +pub fn main() {} diff --git a/tests/ui/check-cfg/unexpected-cfg-value.values.stderr b/tests/ui/check-cfg/unexpected-cfg-value.values.stderr new file mode 100644 index 00000000000..2ed7f900557 --- /dev/null +++ b/tests/ui/check-cfg/unexpected-cfg-value.values.stderr @@ -0,0 +1,25 @@ +warning: unexpected `cfg` condition value: `sedre` + --> $DIR/unexpected-cfg-value.rs:11:7 + | +LL | #[cfg(feature = "sedre")] + | ^^^^^^^^^^------- + | | + | help: there is a expected value with a similar name: `"serde"` + | + = note: expected values for `feature` are: `full`, `serde` + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition value: `rand` + --> $DIR/unexpected-cfg-value.rs:18:7 + | +LL | #[cfg(feature = "rand")] + | ^^^^^^^^^^^^^^^^ + | + = note: expected values for `feature` are: `full`, `serde` + +warning: unexpected condition value `rand` for condition name `feature` + | + = help: was set with `--cfg` but isn't in the `--check-cfg` expected values + +warning: 3 warnings emitted + diff --git a/tests/ui/check-cfg/unknown-values.rs b/tests/ui/check-cfg/unknown-values.rs new file mode 100644 index 00000000000..c082a2f25ac --- /dev/null +++ b/tests/ui/check-cfg/unknown-values.rs @@ -0,0 +1,17 @@ +// Check that no warning is emitted for unknown cfg value +// +// check-pass +// revisions: simple mixed with_values +// compile-flags: -Z unstable-options +// compile-flags: --check-cfg=cfg(simple,mixed,with_values) +// [simple]compile-flags: --check-cfg=cfg(foo,values(any())) +// [mixed]compile-flags: --check-cfg=cfg(foo) --check-cfg=cfg(foo,values(any())) +// [with_values]compile-flags:--check-cfg=cfg(foo,values(any())) --check-cfg=cfg(foo,values("aa")) + +#[cfg(foo = "value")] +pub fn f() {} + +#[cfg(foo)] +pub fn f() {} + +fn main() {} diff --git a/tests/ui/check-cfg/values-target-json.stderr b/tests/ui/check-cfg/values-target-json.stderr index c705152d9fc..e71149f337f 100644 --- a/tests/ui/check-cfg/values-target-json.stderr +++ b/tests/ui/check-cfg/values-target-json.stderr @@ -1,4 +1,4 @@ -warning: unexpected `cfg` condition value +warning: unexpected `cfg` condition value: `linuz` --> $DIR/values-target-json.rs:13:7 | LL | #[cfg(target_os = "linuz")] diff --git a/tests/ui/check-cfg/well-known-names.rs b/tests/ui/check-cfg/well-known-names.rs index e57fb69a1e0..1dcb419b4a7 100644 --- a/tests/ui/check-cfg/well-known-names.rs +++ b/tests/ui/check-cfg/well-known-names.rs @@ -1,7 +1,7 @@ // This test checks that we lint on non well known names and that we don't lint on well known names // // check-pass -// compile-flags: --check-cfg=names() -Z unstable-options +// compile-flags: --check-cfg=cfg() -Z unstable-options #[cfg(target_oz = "linux")] //~^ WARNING unexpected `cfg` condition name diff --git a/tests/ui/check-cfg/well-known-names.stderr b/tests/ui/check-cfg/well-known-names.stderr index 34c5d6172d9..3001289b7e0 100644 --- a/tests/ui/check-cfg/well-known-names.stderr +++ b/tests/ui/check-cfg/well-known-names.stderr @@ -1,14 +1,16 @@ -warning: unexpected `cfg` condition name +warning: unexpected `cfg` condition name: `target_oz` --> $DIR/well-known-names.rs:6:7 | LL | #[cfg(target_oz = "linux")] - | ---------^^^^^^^^^^ - | | - | help: there is a config with a similar name: `target_os` + | ^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unexpected_cfgs)]` on by default +help: there is a config with a similar name and value + | +LL | #[cfg(target_os = "linux")] + | ~~~~~~~~~ -warning: unexpected `cfg` condition name +warning: unexpected `cfg` condition name: `features` --> $DIR/well-known-names.rs:13:7 | LL | #[cfg(features = "foo")] @@ -16,7 +18,7 @@ LL | #[cfg(features = "foo")] | | | help: there is a config with a similar name: `feature` -warning: unexpected `cfg` condition name +warning: unexpected `cfg` condition name: `uniw` --> $DIR/well-known-names.rs:20:7 | LL | #[cfg(uniw)] diff --git a/tests/ui/check-cfg/well-known-values.rs b/tests/ui/check-cfg/well-known-values.rs index 96375dc8d31..8b56c8729d8 100644 --- a/tests/ui/check-cfg/well-known-values.rs +++ b/tests/ui/check-cfg/well-known-values.rs @@ -2,7 +2,7 @@ // values // // check-pass -// compile-flags: --check-cfg=values() -Z unstable-options +// compile-flags: --check-cfg=cfg() -Z unstable-options #[cfg(target_os = "linuz")] //~^ WARNING unexpected `cfg` condition value diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index b381f5a4a0a..6877d8f5bb7 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -1,4 +1,4 @@ -warning: unexpected `cfg` condition value +warning: unexpected `cfg` condition value: `linuz` --> $DIR/well-known-values.rs:7:7 | LL | #[cfg(target_os = "linuz")] @@ -9,7 +9,7 @@ LL | #[cfg(target_os = "linuz")] = note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous` = note: `#[warn(unexpected_cfgs)]` on by default -warning: unexpected `cfg` condition value +warning: unexpected `cfg` condition value: `0` --> $DIR/well-known-values.rs:14:7 | LL | #[cfg(target_has_atomic = "0")] @@ -19,7 +19,7 @@ LL | #[cfg(target_has_atomic = "0")] | = note: expected values for `target_has_atomic` are: (none), `128`, `16`, `32`, `64`, `8`, `ptr` -warning: unexpected `cfg` condition value +warning: unexpected `cfg` condition value: `aa` --> $DIR/well-known-values.rs:21:7 | LL | #[cfg(unix = "aa")] @@ -29,7 +29,7 @@ LL | #[cfg(unix = "aa")] | = note: no expected value for `unix` -warning: unexpected `cfg` condition value +warning: unexpected `cfg` condition value: `miri` --> $DIR/well-known-values.rs:28:7 | LL | #[cfg(miri = "miri")] @@ -39,7 +39,7 @@ LL | #[cfg(miri = "miri")] | = note: no expected value for `miri` -warning: unexpected `cfg` condition value +warning: unexpected `cfg` condition value: `linux` --> $DIR/well-known-values.rs:35:7 | LL | #[cfg(doc = "linux")] diff --git a/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.stderr b/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.stderr index ecc73d994f9..4f32639a631 100644 --- a/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.stderr +++ b/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.stderr @@ -24,3 +24,28 @@ LL | #![deny(coinductive_overlap_in_coherence)] error: aborting due to previous error +Future incompatibility report: Future breakage diagnostic: +error: implementations of `PartialEq<Interval<_>>` for `Interval<_>` will conflict in the future + --> $DIR/warn-when-cycle-is-error-in-coherence.rs:13:1 + | +LL | #[derive(PartialEq, Default)] + | --------- the second impl is here +... +LL | / impl<T, Q> PartialEq<Q> for Interval<T> +LL | | +LL | | +LL | | where +LL | | T: Borrow<Q>, +LL | | Q: ?Sized + PartialOrd, + | |___________________________^ the first impl is 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 #114040 <https://github.com/rust-lang/rust/issues/114040> + = note: impls that are not considered to overlap may be considered to overlap in the future + = note: `Interval<_>: PartialOrd` may be considered to hold in future releases, causing the impls to overlap +note: the lint level is defined here + --> $DIR/warn-when-cycle-is-error-in-coherence.rs:1:9 + | +LL | #![deny(coinductive_overlap_in_coherence)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/ui/const-generics/generic_const_exprs/issue-80742.rs b/tests/ui/const-generics/generic_const_exprs/issue-80742.rs index 6b2a0153f51..5f612780f39 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-80742.rs +++ b/tests/ui/const-generics/generic_const_exprs/issue-80742.rs @@ -3,6 +3,7 @@ // failure-status: 101 // normalize-stderr-test "note: .*\n\n" -> "" // normalize-stderr-test "thread 'rustc' panicked.*\n" -> "" +// normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " // rustc-env:RUST_BACKTRACE=0 // This test used to cause an ICE in rustc_mir::interpret::step::eval_rvalue_into_place diff --git a/tests/ui/const-generics/generic_const_exprs/issue-80742.stderr b/tests/ui/const-generics/generic_const_exprs/issue-80742.stderr index 25a455d3308..9b66fc502b7 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-80742.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-80742.stderr @@ -1,9 +1,9 @@ -error: internal compiler error: compiler/rustc_const_eval/src/interpret/step.rs:272:21: SizeOf MIR operator called for unsized type dyn Debug +error: internal compiler error: compiler/rustc_const_eval/src/interpret/step.rs:LL:CC: SizeOf MIR operator called for unsized type dyn Debug --> $SRC_DIR/core/src/mem/mod.rs:LL:COL Box<dyn Any> query stack during panic: -#0 [eval_to_allocation_raw] const-evaluating + checking `<impl at $DIR/issue-80742.rs:25:1: 27:32>::{constant#0}` +#0 [eval_to_allocation_raw] const-evaluating + checking `<impl at $DIR/issue-80742.rs:26:1: 28:32>::{constant#0}` #1 [eval_to_valtree] evaluating type-level constant end of query stack error: aborting due to previous error diff --git a/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.stderr b/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.stderr index 69bc174b6be..8cbd1265448 100644 --- a/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.stderr +++ b/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.stderr @@ -7,17 +7,5 @@ LL | WHAT_A_TYPE => 0, = note: the traits must be derived, manual `impl`s are not sufficient = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details -error[E0015]: cannot match on `TypeId` in constant functions - --> $DIR/typeid-equality-by-subtyping.rs:18:9 - | -LL | WHAT_A_TYPE => 0, - | ^^^^^^^^^^^ - | - = note: `TypeId` cannot be compared in compile-time, and therefore cannot be used in `match`es -note: impl defined here, but it is not `const` - --> $SRC_DIR/core/src/any.rs:LL:COL - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/const-generics/issues/issue-100313.stderr b/tests/ui/const-generics/issues/issue-100313.stderr index 796966b22d5..5832dbe1777 100644 --- a/tests/ui/const-generics/issues/issue-100313.stderr +++ b/tests/ui/const-generics/issues/issue-100313.stderr @@ -11,7 +11,7 @@ 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ writing to ALLOC0 which is read-only | note: inside `T::<&true>::set_false` --> $DIR/issue-100313.rs:10:13 diff --git a/tests/ui/const-generics/issues/issue-67945-1.full.stderr b/tests/ui/const-generics/issues/issue-67945-1.full.stderr index 8879aec35e5..ee17ec3c698 100644 --- a/tests/ui/const-generics/issues/issue-67945-1.full.stderr +++ b/tests/ui/const-generics/issues/issue-67945-1.full.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-67945-1.rs:10:20 | LL | struct Bug<S> { - | - this type parameter + | - expected this type parameter ... LL | let x: S = MaybeUninit::uninit(); | - ^^^^^^^^^^^^^^^^^^^^^ expected type parameter `S`, found `MaybeUninit<_>` diff --git a/tests/ui/const-ptr/forbidden_slices.rs b/tests/ui/const-ptr/forbidden_slices.rs index 192b6a46de6..03d6499aefb 100644 --- a/tests/ui/const-ptr/forbidden_slices.rs +++ b/tests/ui/const-ptr/forbidden_slices.rs @@ -1,8 +1,7 @@ // Strip out raw byte dumps to make comparison platform-independent: // normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" -// normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*a(lloc)?[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" -// normalize-stderr-test "alloc\d+" -> "allocN" -// error-pattern: could not evaluate static initializer +// normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" + #![feature( slice_from_ptr_range, const_slice_from_ptr_range, @@ -17,10 +16,13 @@ use std::{ // Null is never valid for reads pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) }; +//~^ ERROR: it is undefined behavior to use this value pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) }; +//~^ ERROR: it is undefined behavior to use this value // Out of bounds pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) }; +//~^ ERROR: it is undefined behavior to use this value // Reading uninitialized data pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; //~ ERROR: it is undefined behavior to use this value @@ -39,6 +41,7 @@ pub static S7: &[u16] = unsafe { // Unaligned read pub static S8: &[u64] = unsafe { + //~^ ERROR: it is undefined behavior to use this value let ptr = (&D4 as *const [u32; 2] as *const u32).byte_add(1).cast::<u64>(); from_raw_parts(ptr, 1) @@ -66,8 +69,9 @@ pub static R6: &[bool] = unsafe { from_ptr_range(ptr..ptr.add(4)) }; pub static R7: &[u16] = unsafe { + //~^ ERROR: it is undefined behavior to use this value let ptr = (&D2 as *const Struct as *const u16).byte_add(1); - from_ptr_range(ptr..ptr.add(4)) //~ inside `R7` + from_ptr_range(ptr..ptr.add(4)) }; pub static R8: &[u64] = unsafe { let ptr = (&D4 as *const [u32; 2] as *const u32).byte_add(1).cast::<u64>(); diff --git a/tests/ui/const-ptr/forbidden_slices.stderr b/tests/ui/const-ptr/forbidden_slices.stderr index 294bc77aa31..00230d59a37 100644 --- a/tests/ui/const-ptr/forbidden_slices.stderr +++ b/tests/ui/const-ptr/forbidden_slices.stderr @@ -1,44 +1,38 @@ -error[E0080]: could not evaluate static initializer - --> $SRC_DIR/core/src/slice/raw.rs:LL:COL - | - = note: 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 -note: inside `S0` - --> $DIR/forbidden_slices.rs:19:34 +error[E0080]: it is undefined behavior to use this value + --> $DIR/forbidden_slices.rs:18:1 | LL | pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0080]: could not evaluate static initializer - --> $SRC_DIR/core/src/slice/raw.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference | - = note: 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 -note: inside `S1` - --> $DIR/forbidden_slices.rs:20:33 - | -LL | pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { + HEX_DUMP + } -error[E0080]: could not evaluate static initializer - --> $SRC_DIR/core/src/slice/raw.rs:LL:COL +error[E0080]: it is undefined behavior to use this value + --> $DIR/forbidden_slices.rs:20:1 | - = note: dereferencing pointer failed: allocN has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds +LL | pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) }; + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference | -note: inside `std::slice::from_raw_parts::<'_, u32>` - --> $SRC_DIR/core/src/slice/raw.rs:LL:COL -note: inside `S2` - --> $DIR/forbidden_slices.rs:23:34 + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { + HEX_DUMP + } + +error[E0080]: it is undefined behavior to use this value + --> $DIR/forbidden_slices.rs:24:1 | LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) }; - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { + HEX_DUMP + } error[E0080]: it is undefined behavior to use this value - --> $DIR/forbidden_slices.rs:26:1 + --> $DIR/forbidden_slices.rs:28:1 | LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer @@ -49,7 +43,7 @@ LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) } } error[E0080]: it is undefined behavior to use this value - --> $DIR/forbidden_slices.rs:28:1 + --> $DIR/forbidden_slices.rs:30:1 | LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size_of::<&u32>()) }; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer @@ -62,7 +56,7 @@ LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/forbidden_slices.rs:30:1 + --> $DIR/forbidden_slices.rs:32:1 | LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean @@ -73,7 +67,7 @@ LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) } error[E0080]: it is undefined behavior to use this value - --> $DIR/forbidden_slices.rs:33:1 + --> $DIR/forbidden_slices.rs:35:1 | LL | pub static S7: &[u16] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[1]: encountered uninitialized memory, but expected an integer @@ -83,18 +77,16 @@ LL | pub static S7: &[u16] = unsafe { HEX_DUMP } -error[E0080]: could not evaluate static initializer - --> $SRC_DIR/core/src/slice/raw.rs:LL:COL - | - = note: dereferencing pointer failed: allocN has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds +error[E0080]: it is undefined behavior to use this value + --> $DIR/forbidden_slices.rs:43:1 | -note: inside `std::slice::from_raw_parts::<'_, u64>` - --> $SRC_DIR/core/src/slice/raw.rs:LL:COL -note: inside `S8` - --> $DIR/forbidden_slices.rs:44:5 +LL | pub static S8: &[u64] = unsafe { + | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) | -LL | from_raw_parts(ptr, 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: $SIZE, align: $ALIGN) { + HEX_DUMP + } error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -106,7 +98,7 @@ note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr` note: inside `from_ptr_range::<'_, u32>` --> $SRC_DIR/core/src/slice/raw.rs:LL:COL note: inside `R0` - --> $DIR/forbidden_slices.rs:47:34 + --> $DIR/forbidden_slices.rs:50:34 | LL | pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -121,7 +113,7 @@ note: inside `ptr::const_ptr::<impl *const ()>::sub_ptr` note: inside `from_ptr_range::<'_, ()>` --> $SRC_DIR/core/src/slice/raw.rs:LL:COL note: inside `R1` - --> $DIR/forbidden_slices.rs:48:33 + --> $DIR/forbidden_slices.rs:51:33 | LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -130,18 +122,18 @@ LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: out-of-bounds pointer arithmetic: allocN has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds + = note: out-of-bounds pointer arithmetic: ALLOC10 has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds | note: inside `ptr::const_ptr::<impl *const u32>::add` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL note: inside `R2` - --> $DIR/forbidden_slices.rs:51:25 + --> $DIR/forbidden_slices.rs:54:25 | LL | from_ptr_range(ptr..ptr.add(2)) | ^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/forbidden_slices.rs:53:1 + --> $DIR/forbidden_slices.rs:56:1 | LL | pub static R4: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer @@ -152,7 +144,7 @@ LL | pub static R4: &[u8] = unsafe { } error[E0080]: it is undefined behavior to use this value - --> $DIR/forbidden_slices.rs:58:1 + --> $DIR/forbidden_slices.rs:61:1 | LL | pub static R5: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer @@ -165,7 +157,7 @@ LL | pub static R5: &[u8] = unsafe { = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/forbidden_slices.rs:63:1 + --> $DIR/forbidden_slices.rs:66:1 | LL | pub static R6: &[bool] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean @@ -175,30 +167,26 @@ LL | pub static R6: &[bool] = unsafe { HEX_DUMP } -error[E0080]: could not evaluate static initializer - --> $SRC_DIR/core/src/slice/raw.rs:LL:COL - | - = note: accessing memory with alignment 1, but alignment 2 is required +error[E0080]: it is undefined behavior to use this value + --> $DIR/forbidden_slices.rs:71:1 | -note: inside `std::slice::from_raw_parts::<'_, u16>` - --> $SRC_DIR/core/src/slice/raw.rs:LL:COL -note: inside `from_ptr_range::<'_, u16>` - --> $SRC_DIR/core/src/slice/raw.rs:LL:COL -note: inside `R7` - --> $DIR/forbidden_slices.rs:70:5 +LL | pub static R7: &[u16] = unsafe { + | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) | -LL | from_ptr_range(ptr..ptr.add(4)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { + HEX_DUMP + } error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: out-of-bounds pointer arithmetic: allocN has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds + = note: out-of-bounds pointer arithmetic: ALLOC11 has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds | note: inside `ptr::const_ptr::<impl *const u64>::add` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL note: inside `R8` - --> $DIR/forbidden_slices.rs:74:25 + --> $DIR/forbidden_slices.rs:78:25 | LL | from_ptr_range(ptr..ptr.add(1)) | ^^^^^^^^^^ @@ -213,7 +201,7 @@ note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr` note: inside `from_ptr_range::<'_, u32>` --> $SRC_DIR/core/src/slice/raw.rs:LL:COL note: inside `R9` - --> $DIR/forbidden_slices.rs:79:34 + --> $DIR/forbidden_slices.rs:83:34 | LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -228,7 +216,7 @@ note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr` note: inside `from_ptr_range::<'_, u32>` --> $SRC_DIR/core/src/slice/raw.rs:LL:COL note: inside `R10` - --> $DIR/forbidden_slices.rs:80:35 + --> $DIR/forbidden_slices.rs:84:35 | LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/const-ptr/out_of_bounds_read.stderr b/tests/ui/const-ptr/out_of_bounds_read.stderr index c5c0a1cdefc..be75f76b26f 100644 --- a/tests/ui/const-ptr/out_of_bounds_read.stderr +++ b/tests/ui/const-ptr/out_of_bounds_read.stderr @@ -1,7 +1,7 @@ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | - = note: dereferencing pointer failed: alloc5 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds + = note: memory access failed: ALLOC0 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 @@ -14,7 +14,7 @@ LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | - = note: dereferencing pointer failed: alloc5 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds + = note: memory access failed: ALLOC0 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 @@ -29,7 +29,7 @@ LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | - = note: dereferencing pointer failed: alloc5 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds + = note: memory access failed: ALLOC0 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 diff --git a/tests/ui/consts/const-compare-bytes-ub.stderr b/tests/ui/consts/const-compare-bytes-ub.stderr index 54fafded07b..d8971eb9969 100644 --- a/tests/ui/consts/const-compare-bytes-ub.stderr +++ b/tests/ui/consts/const-compare-bytes-ub.stderr @@ -20,25 +20,25 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-compare-bytes-ub.rs:22:9 | LL | compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: alloc6 has size 3, so pointer to 4 bytes starting at offset 0 is out-of-bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC0 has size 3, so pointer to 4 bytes starting at offset 0 is out-of-bounds error[E0080]: evaluation of constant value failed --> $DIR/const-compare-bytes-ub.rs:26:9 | LL | compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: alloc13 has size 3, so pointer to 4 bytes starting at offset 0 is out-of-bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC1 has size 3, so pointer to 4 bytes starting at offset 0 is out-of-bounds error[E0080]: evaluation of constant value failed --> $DIR/const-compare-bytes-ub.rs:30:9 | LL | compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at alloc17[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at ALLOC2[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory error[E0080]: evaluation of constant value failed --> $DIR/const-compare-bytes-ub.rs:34:9 | LL | compare_bytes([1].as_ptr(), MaybeUninit::uninit().as_ptr(), 1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at alloc25[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at ALLOC3[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory error[E0080]: evaluation of constant value failed --> $DIR/const-compare-bytes-ub.rs:38:9 diff --git a/tests/ui/consts/const-deref-ptr.rs b/tests/ui/consts/const-deref-ptr.rs index 4aca75e3a17..2607d4de229 100644 --- a/tests/ui/consts/const-deref-ptr.rs +++ b/tests/ui/consts/const-deref-ptr.rs @@ -3,5 +3,6 @@ fn main() { static C: u64 = unsafe {*(0xdeadbeef as *const u64)}; //~^ ERROR could not evaluate static initializer + //~| dangling pointer println!("{}", C); } diff --git a/tests/ui/consts/const-deref-ptr.stderr b/tests/ui/consts/const-deref-ptr.stderr index 22cb6451e87..16eb6b0162d 100644 --- a/tests/ui/consts/const-deref-ptr.stderr +++ b/tests/ui/consts/const-deref-ptr.stderr @@ -2,7 +2,7 @@ error[E0080]: could not evaluate static initializer --> $DIR/const-deref-ptr.rs:4:29 | LL | static C: u64 = unsafe {*(0xdeadbeef as *const u64)}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: 0xdeadbeef[noalloc] is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: 0xdeadbeef[noalloc] is a dangling pointer (it has no provenance) error: aborting due to previous error diff --git a/tests/ui/consts/const-eval/const_fn_target_feature_wasm.rs b/tests/ui/consts/const-eval/const_fn_target_feature_wasm.rs new file mode 100644 index 00000000000..c1460fdd9ec --- /dev/null +++ b/tests/ui/consts/const-eval/const_fn_target_feature_wasm.rs @@ -0,0 +1,14 @@ +// only-wasm32 +// compile-flags:-C target-feature=-simd128 +// build-pass + +#![crate_type = "lib"] + +#[cfg(target_feature = "simd128")] +compile_error!("simd128 target feature should be disabled"); + +// Calling functions with `#[target_feature]` is not unsound on WASM, see #84988 +const A: () = simd128_fn(); + +#[target_feature(enable = "simd128")] +const fn simd128_fn() {} diff --git a/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr b/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr index e41dea873ac..e6cd25e42ff 100644 --- a/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr +++ b/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr @@ -2,13 +2,13 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_raw_ptr_ops2.rs:7:26 | LL | const Z2: i32 = unsafe { *(42 as *const i32) }; - | ^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: 0x2a[noalloc] is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^ memory access failed: 0x2a[noalloc] is a dangling pointer (it has no provenance) error[E0080]: evaluation of constant value failed --> $DIR/const_raw_ptr_ops2.rs:9:26 | LL | const Z3: i32 = unsafe { *(44 as *const i32) }; - | ^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: 0x2c[noalloc] is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^ memory access failed: 0x2c[noalloc] is a dangling pointer (it has no provenance) error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/dangling.rs b/tests/ui/consts/const-eval/dangling.rs deleted file mode 100644 index 4fcf879218b..00000000000 --- a/tests/ui/consts/const-eval/dangling.rs +++ /dev/null @@ -1,10 +0,0 @@ -use std::mem; - -// Make sure we error with the right kind of error on a too large slice. -const TEST: () = { unsafe { - let slice: *const [u8] = mem::transmute((1usize, usize::MAX)); - let _val = &*slice; //~ ERROR: evaluation of constant value failed - //~| slice is bigger than largest supported object -} }; - -fn main() {} diff --git a/tests/ui/consts/const-eval/dangling.stderr b/tests/ui/consts/const-eval/dangling.stderr deleted file mode 100644 index 92d70573d98..00000000000 --- a/tests/ui/consts/const-eval/dangling.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/dangling.rs:6:16 - | -LL | let _val = &*slice; - | ^^^^^^^ invalid metadata in wide pointer: slice is bigger than largest supported object - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr index a0f4519eaad..82de91effe7 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr @@ -6,7 +6,7 @@ LL | const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { - ╾─alloc2──╼ │ ╾──╼ + ╾ALLOC0╼ │ ╾──╼ } error: aborting due to previous error diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr index d2bffa42561..de23aafe05c 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr @@ -6,7 +6,7 @@ LL | const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { - ╾───────alloc2────────╼ │ ╾──────╼ + ╾ALLOC0╼ │ ╾──────╼ } error: aborting due to previous error diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs index b6d89a58dce..a717a5f8292 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs @@ -5,10 +5,10 @@ use std::intrinsics; const _X: &'static u8 = unsafe { + //~^ error: dangling pointer in final constant let ptr = intrinsics::const_allocate(4, 4); intrinsics::const_deallocate(ptr, 4, 4); &*ptr - //~^ error: evaluation of constant value failed }; const _Y: u8 = unsafe { diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr index b50ef0c68a1..5f4630f6f4b 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/dealloc_intrinsic_dangling.rs:10:5 +error: encountered dangling pointer in final constant + --> $DIR/dealloc_intrinsic_dangling.rs:7:1 | -LL | &*ptr - | ^^^^^ dereferencing pointer failed: alloc2 has been freed, so this pointer is dangling +LL | const _X: &'static u8 = unsafe { + | ^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $DIR/dealloc_intrinsic_dangling.rs:18:5 | LL | *reference - | ^^^^^^^^^^ dereferencing pointer failed: alloc4 has been freed, so this pointer is dangling + | ^^^^^^^^^^ memory access failed: ALLOC0 has been freed, so this pointer is dangling error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr index 0884ade45a7..916344a7b81 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/dealloc_intrinsic_duplicate.rs:9:5 | LL | intrinsics::const_deallocate(ptr, 4, 4); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: alloc2 has been freed, so this pointer is dangling + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC0 has been freed, so this pointer is dangling error: aborting due to previous error diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr index 4c23957a1f8..4b1f0f686ca 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr @@ -2,19 +2,19 @@ error[E0080]: evaluation of constant value failed --> $DIR/dealloc_intrinsic_incorrect_layout.rs:8:5 | LL | intrinsics::const_deallocate(ptr, 4, 2); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: alloc2 has size 4 and alignment 4, but gave size 4 and alignment 2 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC0 has size 4 and alignment 4, but gave size 4 and alignment 2 error[E0080]: evaluation of constant value failed --> $DIR/dealloc_intrinsic_incorrect_layout.rs:13:5 | LL | intrinsics::const_deallocate(ptr, 2, 4); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: alloc4 has size 4 and alignment 4, but gave size 2 and alignment 4 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC1 has size 4 and alignment 4, but gave size 2 and alignment 4 error[E0080]: evaluation of constant value failed --> $DIR/dealloc_intrinsic_incorrect_layout.rs:19:5 | LL | intrinsics::const_deallocate(ptr, 3, 4); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: alloc6 has size 4 and alignment 4, but gave size 3 and alignment 4 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC2 has size 4 and alignment 4, but gave size 3 and alignment 4 error[E0080]: evaluation of constant value failed --> $DIR/dealloc_intrinsic_incorrect_layout.rs:25:5 diff --git a/tests/ui/consts/const-eval/issue-114994-fail.rs b/tests/ui/consts/const-eval/issue-114994-fail.rs new file mode 100644 index 00000000000..72350464091 --- /dev/null +++ b/tests/ui/consts/const-eval/issue-114994-fail.rs @@ -0,0 +1,14 @@ +// This checks that function pointer signatures that are referenced mutably +// but contain a &mut T parameter still fail in a constant context: see issue #114994. +// +// check-fail + +const fn use_mut_const_fn(_f: &mut fn(&mut String)) { //~ ERROR mutable references are not allowed in constant functions + () +} + +const fn use_mut_const_tuple_fn(_f: (fn(), &mut u32)) { //~ ERROR mutable references are not allowed in constant functions + +} + +fn main() {} diff --git a/tests/ui/consts/const-eval/issue-114994-fail.stderr b/tests/ui/consts/const-eval/issue-114994-fail.stderr new file mode 100644 index 00000000000..4dae8ea9bca --- /dev/null +++ b/tests/ui/consts/const-eval/issue-114994-fail.stderr @@ -0,0 +1,21 @@ +error[E0658]: mutable references are not allowed in constant functions + --> $DIR/issue-114994-fail.rs:6:27 + | +LL | const fn use_mut_const_fn(_f: &mut fn(&mut String)) { + | ^^ + | + = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable + +error[E0658]: mutable references are not allowed in constant functions + --> $DIR/issue-114994-fail.rs:10:33 + | +LL | const fn use_mut_const_tuple_fn(_f: (fn(), &mut u32)) { + | ^^ + | + = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/consts/const-eval/issue-114994.rs b/tests/ui/consts/const-eval/issue-114994.rs new file mode 100644 index 00000000000..a4cb2e61e5f --- /dev/null +++ b/tests/ui/consts/const-eval/issue-114994.rs @@ -0,0 +1,18 @@ +// This checks that function pointer signatures containing &mut T types +// work in a constant context: see issue #114994. +// +// check-pass + +const fn use_const_fn(_f: fn(&mut String)) { + () +} + +const fn get_some_fn() -> fn(&mut String) { + String::clear +} + +const fn some_const_fn() { + let _f: fn(&mut String) = String::clear; +} + +fn main() {} diff --git a/tests/ui/consts/const-eval/issue-49296.stderr b/tests/ui/consts/const-eval/issue-49296.stderr index 45ba0ea183e..2022a16e789 100644 --- a/tests/ui/consts/const-eval/issue-49296.stderr +++ b/tests/ui/consts/const-eval/issue-49296.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/issue-49296.rs:9:16 | LL | const X: u64 = *wat(42); - | ^^^^^^^^ dereferencing pointer failed: alloc3 has been freed, so this pointer is dangling + | ^^^^^^^^ memory access failed: ALLOC0 has been freed, so this pointer is dangling error: aborting due to previous error diff --git a/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs b/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs index 3b48e972923..19ab5239986 100644 --- a/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs +++ b/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs @@ -1,6 +1,6 @@ use std::ptr::NonNull; const NON_NULL: NonNull<u8> = unsafe { NonNull::dangling() }; -const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() }); +const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() }); //~ERROR: evaluation of constant value failed fn main() {} diff --git a/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr b/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr index de93cb0c3ca..e34f3f43c64 100644 --- a/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr +++ b/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr @@ -1,15 +1,8 @@ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/non_null.rs:LL:COL - | - = note: dereferencing pointer failed: 0x1[noalloc] is a dangling pointer (it has no provenance) - | -note: inside `NonNull::<u8>::as_ref::<'_>` - --> $SRC_DIR/core/src/ptr/non_null.rs:LL:COL -note: inside `_` - --> $DIR/nonnull_as_ref_ub.rs:4:39 + --> $DIR/nonnull_as_ref_ub.rs:4:29 | LL | const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() }); - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: 0x1[noalloc] is a dangling pointer (it has no provenance) error: aborting due to previous error diff --git a/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr b/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr index 13ca4379b7b..b948e07b92d 100644 --- a/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr +++ b/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/partial_ptr_overwrite.rs:8:9 | LL | *(ptr as *mut u8) = 123; - | ^^^^^^^^^^^^^^^^^^^^^^^ unable to overwrite parts of a pointer in memory at alloc4 + | ^^^^^^^^^^^^^^^^^^^^^^^ unable to overwrite parts of a pointer in memory at ALLOC0 | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr index 042e7eeb31e..689ebf75223 100644 --- a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr @@ -211,7 +211,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:106:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered allocN, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3, but expected a function pointer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { @@ -385,7 +385,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:175:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC17, but expected a vtable pointer | = 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) { @@ -396,7 +396,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:179:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC19, but expected a vtable pointer | = 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) { @@ -418,7 +418,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:186:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC22, but expected a vtable pointer | = 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) { @@ -451,7 +451,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:196:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered allocN, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC27, but expected a vtable pointer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { diff --git a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr index 8426a95055c..3447a8ab432 100644 --- a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr @@ -211,7 +211,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:106:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered allocN, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3, but expected a function pointer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { @@ -385,7 +385,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:175:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC17, but expected a vtable pointer | = 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) { @@ -396,7 +396,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:179:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC19, but expected a vtable pointer | = 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) { @@ -418,7 +418,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:186:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC22, but expected a vtable pointer | = 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) { @@ -451,7 +451,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:196:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered allocN, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC27, but expected a vtable pointer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { diff --git a/tests/ui/consts/const-eval/raw-bytes.rs b/tests/ui/consts/const-eval/raw-bytes.rs index 6c1238c0a06..e005922223a 100644 --- a/tests/ui/consts/const-eval/raw-bytes.rs +++ b/tests/ui/consts/const-eval/raw-bytes.rs @@ -1,8 +1,8 @@ // stderr-per-bitwidth // ignore-endian-big // ignore-tidy-linelength -// normalize-stderr-test "╾─*a(lloc)?[0-9]+(\+[a-z0-9]+)?─*╼" -> "╾ALLOC_ID$2╼" -// normalize-stderr-test "alloc\d+" -> "allocN" +// normalize-stderr-test "╾─*ALLOC[0-9]+(\+[a-z0-9]+)?─*╼" -> "╾ALLOC_ID$1╼" + #![feature(never_type, rustc_attrs, ptr_metadata, slice_from_ptr_range, const_slice_from_ptr_range)] #![allow(invalid_value)] diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.rs b/tests/ui/consts/const-eval/raw-pointer-ub.rs new file mode 100644 index 00000000000..9b79a0a7d34 --- /dev/null +++ b/tests/ui/consts/const-eval/raw-pointer-ub.rs @@ -0,0 +1,47 @@ +#![feature(const_pointer_byte_offsets)] +#![feature(pointer_byte_offsets)] +#![feature(const_mut_refs)] + + +const MISALIGNED_LOAD: () = unsafe { + let mem = [0u32; 8]; + let ptr = mem.as_ptr().byte_add(1); + let _val = *ptr; //~ERROR: evaluation of constant value failed + //~^NOTE: based on pointer with alignment 1, but alignment 4 is required +}; + +const MISALIGNED_STORE: () = unsafe { + let mut mem = [0u32; 8]; + let ptr = mem.as_mut_ptr().byte_add(1); + *ptr = 0; //~ERROR: evaluation of constant value failed + //~^NOTE: based on pointer with alignment 1, but alignment 4 is required +}; + +const MISALIGNED_COPY: () = unsafe { + let x = &[0_u8; 4]; + let y = x.as_ptr().cast::<u32>(); + let mut z = 123; + y.copy_to_nonoverlapping(&mut z, 1); + //~^NOTE + // The actual error points into the implementation of `copy_to_nonoverlapping`. +}; + +const MISALIGNED_FIELD: () = unsafe { + #[repr(align(16))] + struct Aligned(f32); + + let mem = [0f32; 8]; + let ptr = mem.as_ptr().cast::<Aligned>(); + // Accessing an f32 field but we still require the alignment of the pointer type. + let _val = (*ptr).0; //~ERROR: evaluation of constant value failed + //~^NOTE: based on pointer with alignment 4, but alignment 16 is required +}; + +const OOB: () = unsafe { + let mem = [0u32; 1]; + let ptr = mem.as_ptr().cast::<u64>(); + let _val = *ptr; //~ERROR: evaluation of constant value failed + //~^NOTE: size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds +}; + +fn main() {} diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.stderr b/tests/ui/consts/const-eval/raw-pointer-ub.stderr new file mode 100644 index 00000000000..f644e5f8748 --- /dev/null +++ b/tests/ui/consts/const-eval/raw-pointer-ub.stderr @@ -0,0 +1,42 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/raw-pointer-ub.rs:9:16 + | +LL | let _val = *ptr; + | ^^^^ accessing memory based on pointer with alignment 1, but alignment 4 is required + +error[E0080]: evaluation of constant value failed + --> $DIR/raw-pointer-ub.rs:16:5 + | +LL | *ptr = 0; + | ^^^^^^^^ accessing memory based on pointer with alignment 1, but alignment 4 is required + +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/intrinsics.rs:LL:COL + | + = note: accessing memory with alignment 1, but alignment 4 is required + | +note: inside `copy_nonoverlapping::<u32>` + --> $SRC_DIR/core/src/intrinsics.rs:LL:COL +note: inside `ptr::const_ptr::<impl *const u32>::copy_to_nonoverlapping` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL +note: inside `MISALIGNED_COPY` + --> $DIR/raw-pointer-ub.rs:24:5 + | +LL | y.copy_to_nonoverlapping(&mut z, 1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0080]: evaluation of constant value failed + --> $DIR/raw-pointer-ub.rs:36:16 + | +LL | let _val = (*ptr).0; + | ^^^^^^^^ accessing memory based on pointer with alignment 4, but alignment 16 is required + +error[E0080]: evaluation of constant value failed + --> $DIR/raw-pointer-ub.rs:43:16 + | +LL | let _val = *ptr; + | ^^^^ memory access failed: ALLOC0 has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr b/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr index 965256de21a..7b30233c025 100644 --- a/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr +++ b/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr @@ -1,46 +1,56 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/ub-incorrect-vtable.rs:19:14 +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-incorrect-vtable.rs:18:1 + | +LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait = + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC1, but expected a vtable pointer | -LL | unsafe { std::mem::transmute((&92u8, &[0usize, 1usize, 1000usize])) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 8, align: 4) { + ╾ALLOC0╼ ╾ALLOC1╼ │ ╾──╼╾──╼ + } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-incorrect-vtable.rs:24:14 +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-incorrect-vtable.rs:23:1 + | +LL | const INVALID_VTABLE_SIZE: &dyn Trait = + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3, but expected a vtable pointer | -LL | unsafe { std::mem::transmute((&92u8, &[1usize, usize::MAX, 1usize])) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 8, align: 4) { + ╾ALLOC2╼ ╾ALLOC3╼ │ ╾──╼╾──╼ + } error[E0080]: it is undefined behavior to use this value --> $DIR/ub-incorrect-vtable.rs:33:1 | LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC5, but expected a vtable pointer | = 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) { - ╾─allocN─╼ ╾─allocN─╼ │ ╾──╼╾──╼ + ╾ALLOC4╼ ╾ALLOC5╼ │ ╾──╼╾──╼ } error[E0080]: it is undefined behavior to use this value --> $DIR/ub-incorrect-vtable.rs:38:1 | LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC7, but expected a vtable pointer | = 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) { - ╾─allocN─╼ ╾─allocN─╼ │ ╾──╼╾──╼ + ╾ALLOC6╼ ╾ALLOC7╼ │ ╾──╼╾──╼ } error[E0080]: it is undefined behavior to use this value --> $DIR/ub-incorrect-vtable.rs:44:1 | LL | const INVALID_VTABLE_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC9, but expected a vtable pointer | = 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) { - ╾─allocN─╼ ╾─allocN─╼ │ ╾──╼╾──╼ + ╾ALLOC8╼ ╾ALLOC9╼ │ ╾──╼╾──╼ } error[E0080]: it is undefined behavior to use this value @@ -51,7 +61,7 @@ LL | const G: Wide = unsafe { Transmute { t: FOO }.u }; | = 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) { - ╾─allocN─╼ ╾─allocN─╼ │ ╾──╼╾──╼ + ╾ALLOC10╼ ╾ALLOC11╼ │ ╾──╼╾──╼ } error: aborting due to 6 previous errors diff --git a/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr b/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr index bd542a7a5f2..9330ae3c9a6 100644 --- a/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr +++ b/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr @@ -1,46 +1,56 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/ub-incorrect-vtable.rs:19:14 +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-incorrect-vtable.rs:18:1 + | +LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait = + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC1, but expected a vtable pointer | -LL | unsafe { std::mem::transmute((&92u8, &[0usize, 1usize, 1000usize])) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 16, align: 8) { + ╾ALLOC0╼ ╾ALLOC1╼ │ ╾──────╼╾──────╼ + } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-incorrect-vtable.rs:24:14 +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-incorrect-vtable.rs:23:1 + | +LL | const INVALID_VTABLE_SIZE: &dyn Trait = + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3, but expected a vtable pointer | -LL | unsafe { std::mem::transmute((&92u8, &[1usize, usize::MAX, 1usize])) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 16, align: 8) { + ╾ALLOC2╼ ╾ALLOC3╼ │ ╾──────╼╾──────╼ + } error[E0080]: it is undefined behavior to use this value --> $DIR/ub-incorrect-vtable.rs:33:1 | LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC5, but expected a vtable pointer | = 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) { - ╾───────allocN───────╼ ╾───────allocN───────╼ │ ╾──────╼╾──────╼ + ╾ALLOC4╼ ╾ALLOC5╼ │ ╾──────╼╾──────╼ } error[E0080]: it is undefined behavior to use this value --> $DIR/ub-incorrect-vtable.rs:38:1 | LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC7, but expected a vtable pointer | = 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) { - ╾───────allocN───────╼ ╾───────allocN───────╼ │ ╾──────╼╾──────╼ + ╾ALLOC6╼ ╾ALLOC7╼ │ ╾──────╼╾──────╼ } error[E0080]: it is undefined behavior to use this value --> $DIR/ub-incorrect-vtable.rs:44:1 | LL | const INVALID_VTABLE_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC9, but expected a vtable pointer | = 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) { - ╾───────allocN───────╼ ╾───────allocN───────╼ │ ╾──────╼╾──────╼ + ╾ALLOC8╼ ╾ALLOC9╼ │ ╾──────╼╾──────╼ } error[E0080]: it is undefined behavior to use this value @@ -51,7 +61,7 @@ LL | const G: Wide = unsafe { Transmute { t: FOO }.u }; | = 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) { - ╾───────allocN───────╼ ╾───────allocN───────╼ │ ╾──────╼╾──────╼ + ╾ALLOC10╼ ╾ALLOC11╼ │ ╾──────╼╾──────╼ } error: aborting due to 6 previous errors diff --git a/tests/ui/consts/const-eval/ub-incorrect-vtable.rs b/tests/ui/consts/const-eval/ub-incorrect-vtable.rs index 4bb30b75bc8..7d1927253f2 100644 --- a/tests/ui/consts/const-eval/ub-incorrect-vtable.rs +++ b/tests/ui/consts/const-eval/ub-incorrect-vtable.rs @@ -11,19 +11,19 @@ // errors are emitted instead of ICEs. // stderr-per-bitwidth -// normalize-stderr-test "alloc\d+" -> "allocN" + trait Trait {} const INVALID_VTABLE_ALIGNMENT: &dyn Trait = unsafe { std::mem::transmute((&92u8, &[0usize, 1usize, 1000usize])) }; -//~^ ERROR evaluation of constant value failed -//~| does not point to a vtable +//~^^ ERROR it is undefined behavior to use this value +//~| expected a vtable pointer const INVALID_VTABLE_SIZE: &dyn Trait = unsafe { std::mem::transmute((&92u8, &[1usize, usize::MAX, 1usize])) }; -//~^ ERROR evaluation of constant value failed -//~| does not point to a vtable +//~^^ ERROR it is undefined behavior to use this value +//~| expected a vtable pointer #[repr(transparent)] struct W<T>(T); diff --git a/tests/ui/consts/const-eval/ub-nonnull.rs b/tests/ui/consts/const-eval/ub-nonnull.rs index a64b3a74cf6..fe4ec4d23d0 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.rs +++ b/tests/ui/consts/const-eval/ub-nonnull.rs @@ -1,6 +1,6 @@ // Strip out raw byte dumps to make comparison platform-independent: // normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" -// normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*a(lloc)?[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" +// normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" #![feature(rustc_attrs, ptr_metadata)] #![allow(invalid_value)] // make sure we cannot allow away the errors tested here diff --git a/tests/ui/consts/const-eval/ub-nonnull.stderr b/tests/ui/consts/const-eval/ub-nonnull.stderr index 96164870804..7822306b654 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.stderr +++ b/tests/ui/consts/const-eval/ub-nonnull.stderr @@ -10,10 +10,10 @@ LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-nonnull.rs:20:30 + --> $DIR/ub-nonnull.rs:20:29 | LL | let out_of_bounds_ptr = &ptr[255]; - | ^^^^^^^^ dereferencing pointer failed: alloc11 has size 1, so pointer to 256 bytes starting at offset 0 is out-of-bounds + | ^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC1 has size 1, so pointer to 255 bytes starting at offset 0 is out-of-bounds error[E0080]: it is undefined behavior to use this value --> $DIR/ub-nonnull.rs:24:1 diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.rs b/tests/ui/consts/const-eval/ub-ref-ptr.rs index a5d2ea01486..08d4dce4d17 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.rs +++ b/tests/ui/consts/const-eval/ub-ref-ptr.rs @@ -1,7 +1,7 @@ // ignore-tidy-linelength // Strip out raw byte dumps to make comparison platform-independent: // normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" -// normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*a(lloc)?[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" +// normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" #![allow(invalid_value)] use std::mem; diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.stderr b/tests/ui/consts/const-eval/ub-ref-ptr.stderr index 6d5c36cea7d..c608bad2a47 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-ref-ptr.stderr @@ -141,7 +141,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-ref-ptr.rs:59:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered alloc39, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC2, but expected a function pointer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -151,7 +151,7 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | - = note: accessing memory with alignment 1, but alignment 4 is required + = note: accessing memory based on pointer with alignment 1, but alignment 4 is required | note: inside `std::ptr::read::<u32>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL diff --git a/tests/ui/consts/const-eval/ub-upvars.32bit.stderr b/tests/ui/consts/const-eval/ub-upvars.32bit.stderr index f7898e55ee2..353a9b78224 100644 --- a/tests/ui/consts/const-eval/ub-upvars.32bit.stderr +++ b/tests/ui/consts/const-eval/ub-upvars.32bit.stderr @@ -6,7 +6,7 @@ LL | const BAD_UPVAR: &dyn FnOnce() = &{ | = 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) { - ╾─alloc3──╼ ╾─alloc4──╼ │ ╾──╼╾──╼ + ╾ALLOC0╼ ╾ALLOC1╼ │ ╾──╼╾──╼ } error: aborting due to previous error diff --git a/tests/ui/consts/const-eval/ub-upvars.64bit.stderr b/tests/ui/consts/const-eval/ub-upvars.64bit.stderr index 60432380e13..097f6b049dc 100644 --- a/tests/ui/consts/const-eval/ub-upvars.64bit.stderr +++ b/tests/ui/consts/const-eval/ub-upvars.64bit.stderr @@ -6,7 +6,7 @@ LL | const BAD_UPVAR: &dyn FnOnce() = &{ | = 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) { - ╾───────alloc3────────╼ ╾───────alloc4────────╼ │ ╾──────╼╾──────╼ + ╾ALLOC0╼ ╾ALLOC1╼ │ ╾──────╼╾──────╼ } error: aborting due to previous error diff --git a/tests/ui/consts/const-eval/ub-wide-ptr.rs b/tests/ui/consts/const-eval/ub-wide-ptr.rs index a765dc71273..dc8d4c640c2 100644 --- a/tests/ui/consts/const-eval/ub-wide-ptr.rs +++ b/tests/ui/consts/const-eval/ub-wide-ptr.rs @@ -5,11 +5,11 @@ use std::mem; // Strip out raw byte dumps to make comparison platform-independent: // normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" -// normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*a(lloc)?[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" +// normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" // normalize-stderr-test "offset \d+" -> "offset N" -// normalize-stderr-test "alloc\d+" -> "allocN" // normalize-stderr-test "size \d+" -> "size N" + /// A newtype wrapper to prevent MIR generation from inserting reborrows that would affect the error /// message. #[repr(transparent)] @@ -122,14 +122,14 @@ const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4u //~^ ERROR it is undefined behavior to use this value //~| expected a vtable const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) }; -//~^ ERROR evaluation of constant value failed -//~| does not point to a vtable +//~^ ERROR it is undefined behavior to use this value +//~| expected a vtable const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) }; -//~^ ERROR evaluation of constant value failed -//~| does not point to a vtable +//~^ ERROR it is undefined behavior to use this value +//~| expected a vtable const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) }; -//~^ ERROR evaluation of constant value failed -//~| does not point to a vtable +//~^ ERROR it is undefined behavior to use this value +//~| expected a vtable const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; //~^ ERROR it is undefined behavior to use this value //~| expected a vtable @@ -148,12 +148,12 @@ const RAW_TRAIT_OBJ_CONTENT_INVALID: *const dyn Trait = unsafe { mem::transmute: // Const eval fails for these, so they need to be statics to error. static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe { +//~^ ERROR it is undefined behavior to use this value mem::transmute::<_, &dyn Trait>((&92u8, 0usize)) - //~^ ERROR could not evaluate static initializer }; static mut RAW_TRAIT_OBJ_VTABLE_INVALID_THROUGH_REF: *const dyn Trait = unsafe { +//~^ ERROR it is undefined behavior to use this value mem::transmute::<_, &dyn Trait>((&92u8, &3u64)) - //~^ ERROR could not evaluate static initializer }; fn main() {} diff --git a/tests/ui/consts/const-eval/ub-wide-ptr.stderr b/tests/ui/consts/const-eval/ub-wide-ptr.stderr index d8add67fac1..b203794858a 100644 --- a/tests/ui/consts/const-eval/ub-wide-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-wide-ptr.stderr @@ -189,7 +189,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-wide-ptr.rs:113:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC12, but expected a vtable pointer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -200,7 +200,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-wide-ptr.rs:117:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC14, but expected a vtable pointer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -218,29 +218,44 @@ LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:124:57 +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-wide-ptr.rs:124:1 | LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC17, but expected a vtable pointer + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { + HEX_DUMP + } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:127:57 +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-wide-ptr.rs:127:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC19, but expected a vtable pointer + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { + HEX_DUMP + } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:130:56 +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-wide-ptr.rs:130:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC21, but expected a vtable pointer + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { + HEX_DUMP + } error[E0080]: it is undefined behavior to use this value --> $DIR/ub-wide-ptr.rs:133:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC23, but expected a vtable pointer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -273,24 +288,34 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-wide-ptr.rs:145:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered allocN, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC28, but expected a vtable pointer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: could not evaluate static initializer - --> $DIR/ub-wide-ptr.rs:151:5 +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-wide-ptr.rs:150:1 + | +LL | static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer | -LL | mem::transmute::<_, &dyn Trait>((&92u8, 0usize)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { + HEX_DUMP + } -error[E0080]: could not evaluate static initializer - --> $DIR/ub-wide-ptr.rs:155:5 +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-wide-ptr.rs:154:1 + | +LL | static mut RAW_TRAIT_OBJ_VTABLE_INVALID_THROUGH_REF: *const dyn Trait = unsafe { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC31, but expected a vtable pointer | -LL | mem::transmute::<_, &dyn Trait>((&92u8, &3u64)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { + HEX_DUMP + } error: aborting due to 29 previous errors diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.32bit.stderr b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.32bit.stderr new file mode 100644 index 00000000000..33d4fec7016 --- /dev/null +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.32bit.stderr @@ -0,0 +1,20 @@ +error[E0080]: it is undefined behavior to use this value + --> $DIR/mut_ref_in_final_dynamic_check.rs:17:1 + | +LL | const A: Option<&mut i32> = helper(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0: encountered mutable reference in a `const` + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 4, align: 4) { + 2a 00 00 00 │ *... + } + +error: encountered dangling pointer in final constant + --> $DIR/mut_ref_in_final_dynamic_check.rs:24:1 + | +LL | const B: Option<&mut i32> = helper2(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.64bit.stderr b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.64bit.stderr new file mode 100644 index 00000000000..9eb2675856f --- /dev/null +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.64bit.stderr @@ -0,0 +1,20 @@ +error[E0080]: it is undefined behavior to use this value + --> $DIR/mut_ref_in_final_dynamic_check.rs:17:1 + | +LL | const A: Option<&mut i32> = helper(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0: encountered mutable reference in a `const` + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 8, align: 8) { + 2a 00 00 00 00 00 00 00 │ *....... + } + +error: encountered dangling pointer in final constant + --> $DIR/mut_ref_in_final_dynamic_check.rs:24:1 + | +LL | const B: Option<&mut i32> = helper2(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs index 074beaab2c4..22e7a74e5fb 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs @@ -1,3 +1,4 @@ +// stderr-per-bitwidth #![feature(const_mut_refs)] #![feature(raw_ref_op)] @@ -9,17 +10,15 @@ const fn helper() -> Option<&'static mut i32> { unsafe { // Undefined behaviour (integer as pointer), who doesn't love tests like this. - // This code never gets executed, because the static checks fail before that. - Some(&mut *(42 as *mut i32)) //~ ERROR evaluation of constant value failed - //~| 0x2a[noalloc] is a dangling pointer + Some(&mut *(42 as *mut i32)) } } // The error is an evaluation error and not a validation error, so the error is reported // directly at the site where it occurs. -const A: Option<&mut i32> = helper(); +const A: Option<&mut i32> = helper(); //~ ERROR it is undefined behavior to use this value +//~^ encountered mutable reference in a `const` const fn helper2() -> Option<&'static mut i32> { unsafe { // Undefined behaviour (dangling pointer), who doesn't love tests like this. - // This code never gets executed, because the static checks fail before that. Some(&mut *(&mut 42 as *mut i32)) } } const B: Option<&mut i32> = helper2(); //~ ERROR encountered dangling pointer in final constant diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr deleted file mode 100644 index 6e110dbdd64..00000000000 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr +++ /dev/null @@ -1,26 +0,0 @@ -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)) - | ^^^^^^^^^^^^^^^^^^^^^^ -note: inside `A` - --> $DIR/mut_ref_in_final_dynamic_check.rs:18:29 - | -LL | const A: Option<&mut i32> = helper(); - | ^^^^^^^^ - -error: encountered dangling pointer in final constant - --> $DIR/mut_ref_in_final_dynamic_check.rs:25:1 - | -LL | const B: Option<&mut i32> = helper2(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-points-to-static.32bit.stderr b/tests/ui/consts/const-points-to-static.32bit.stderr index c7a435a1ee3..12cc7fbb1fc 100644 --- a/tests/ui/consts/const-points-to-static.32bit.stderr +++ b/tests/ui/consts/const-points-to-static.32bit.stderr @@ -6,7 +6,7 @@ LL | const TEST: &u8 = &MY_STATIC; | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { - ╾─alloc1──╼ │ ╾──╼ + ╾ALLOC0╼ │ ╾──╼ } warning: skipping const checks diff --git a/tests/ui/consts/const-points-to-static.64bit.stderr b/tests/ui/consts/const-points-to-static.64bit.stderr index 4d5b8eac541..86506e6ca01 100644 --- a/tests/ui/consts/const-points-to-static.64bit.stderr +++ b/tests/ui/consts/const-points-to-static.64bit.stderr @@ -6,7 +6,7 @@ LL | const TEST: &u8 = &MY_STATIC; | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { - ╾───────alloc1────────╼ │ ╾──────╼ + ╾ALLOC0╼ │ ╾──────╼ } warning: skipping const checks diff --git a/tests/ui/consts/copy-intrinsic.stderr b/tests/ui/consts/copy-intrinsic.stderr index be41c2db398..0e4e6a6ad6c 100644 --- a/tests/ui/consts/copy-intrinsic.stderr +++ b/tests/ui/consts/copy-intrinsic.stderr @@ -2,13 +2,13 @@ error[E0080]: evaluation of constant value failed --> $DIR/copy-intrinsic.rs:27:5 | LL | copy_nonoverlapping(0x100 as *const i32, dangle, 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: alloc5 has size 4, so pointer at offset 40 is out-of-bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC0 has size 4, so pointer at offset 40 is out-of-bounds error[E0080]: evaluation of constant value failed --> $DIR/copy-intrinsic.rs:34:5 | LL | copy_nonoverlapping(dangle, 0x100 as *mut i32, 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: alloc7 has size 4, so pointer at offset 40 is out-of-bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC1 has size 4, so pointer at offset 40 is out-of-bounds error[E0080]: evaluation of constant value failed --> $DIR/copy-intrinsic.rs:41:5 diff --git a/tests/ui/consts/effect_param.rs b/tests/ui/consts/effect_param.rs new file mode 100644 index 00000000000..f11ec739fce --- /dev/null +++ b/tests/ui/consts/effect_param.rs @@ -0,0 +1,11 @@ +//! Ensure we don't allow accessing const effect parameters from stable Rust. + +fn main() { + i8::checked_sub::<true>(42, 43); + //~^ ERROR: method takes 0 generic arguments but 1 generic argument was supplied +} + +const FOO: () = { + i8::checked_sub::<false>(42, 43); + //~^ ERROR: method takes 0 generic arguments but 1 generic argument was supplied +}; diff --git a/tests/ui/consts/effect_param.stderr b/tests/ui/consts/effect_param.stderr new file mode 100644 index 00000000000..f8c4bfc02e5 --- /dev/null +++ b/tests/ui/consts/effect_param.stderr @@ -0,0 +1,19 @@ +error[E0107]: method takes 0 generic arguments but 1 generic argument was supplied + --> $DIR/effect_param.rs:9:9 + | +LL | i8::checked_sub::<false>(42, 43); + | ^^^^^^^^^^^--------- help: remove these generics + | | + | expected 0 generic arguments + +error[E0107]: method takes 0 generic arguments but 1 generic argument was supplied + --> $DIR/effect_param.rs:4:9 + | +LL | i8::checked_sub::<true>(42, 43); + | ^^^^^^^^^^^-------- help: remove these generics + | | + | expected 0 generic arguments + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/consts/extra-const-ub/detect-extra-ub.rs b/tests/ui/consts/extra-const-ub/detect-extra-ub.rs index 37b37e9659e..15c06908447 100644 --- a/tests/ui/consts/extra-const-ub/detect-extra-ub.rs +++ b/tests/ui/consts/extra-const-ub/detect-extra-ub.rs @@ -88,4 +88,15 @@ const PARTIAL_POINTER: () = unsafe { const VALID_ENUM1: E = { let e = E::A; e }; const VALID_ENUM2: Result<&'static [u8], ()> = { let e = Err(()); e }; +// Htting the (non-integer) array code in validation with an immediate local. +const VALID_ARRAY: [Option<i32>; 0] = { let e = [None; 0]; e }; + +// Detecting oversized references. +const OVERSIZED_REF: () = { unsafe { + let slice: *const [u8] = transmute((1usize, usize::MAX)); + let _val = &*slice; + //[with_flag]~^ ERROR: evaluation of constant value failed + //[with_flag]~| slice is bigger than largest supported object +} }; + fn main() {} diff --git a/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr b/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr index 4ee12d501e8..0100aafb6b7 100644 --- a/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr +++ b/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr @@ -52,6 +52,12 @@ LL | let _val = *(&mem as *const Align as *const [*const u8; 2]); = 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 7 previous errors +error[E0080]: evaluation of constant value failed + --> $DIR/detect-extra-ub.rs:97:16 + | +LL | let _val = &*slice; + | ^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + +error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/invalid-union.32bit.stderr b/tests/ui/consts/invalid-union.32bit.stderr index 0c57751cbfa..32b67a13061 100644 --- a/tests/ui/consts/invalid-union.32bit.stderr +++ b/tests/ui/consts/invalid-union.32bit.stderr @@ -6,7 +6,7 @@ LL | fn main() { | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { - ╾─alloc7──╼ │ ╾──╼ + ╾ALLOC0╼ │ ╾──╼ } note: erroneous constant encountered diff --git a/tests/ui/consts/invalid-union.64bit.stderr b/tests/ui/consts/invalid-union.64bit.stderr index 6c4d5882158..45f999eb23c 100644 --- a/tests/ui/consts/invalid-union.64bit.stderr +++ b/tests/ui/consts/invalid-union.64bit.stderr @@ -6,7 +6,7 @@ LL | fn main() { | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { - ╾───────alloc7────────╼ │ ╾──────╼ + ╾ALLOC0╼ │ ╾──────╼ } note: erroneous constant encountered diff --git a/tests/ui/consts/issue-63952.32bit.stderr b/tests/ui/consts/issue-63952.32bit.stderr index 755c7fb7d4d..5375ec1188a 100644 --- a/tests/ui/consts/issue-63952.32bit.stderr +++ b/tests/ui/consts/issue-63952.32bit.stderr @@ -6,7 +6,7 @@ LL | const SLICE_WAY_TOO_LONG: &[u8] = unsafe { | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { - ╾─alloc4──╼ ff ff ff ff │ ╾──╼.... + ╾ALLOC0╼ ff ff ff ff │ ╾──╼.... } error: aborting due to previous error diff --git a/tests/ui/consts/issue-63952.64bit.stderr b/tests/ui/consts/issue-63952.64bit.stderr index abdb9a4f792..a6edbf9321b 100644 --- a/tests/ui/consts/issue-63952.64bit.stderr +++ b/tests/ui/consts/issue-63952.64bit.stderr @@ -6,7 +6,7 @@ LL | const SLICE_WAY_TOO_LONG: &[u8] = unsafe { | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { - ╾───────alloc4────────╼ ff ff ff ff ff ff ff ff │ ╾──────╼........ + ╾ALLOC0╼ ff ff ff ff ff ff ff ff │ ╾──────╼........ } error: aborting due to previous error diff --git a/tests/ui/consts/issue-79690.64bit.stderr b/tests/ui/consts/issue-79690.64bit.stderr index b8798a9755f..af59729d438 100644 --- a/tests/ui/consts/issue-79690.64bit.stderr +++ b/tests/ui/consts/issue-79690.64bit.stderr @@ -6,7 +6,7 @@ LL | const G: Fat = unsafe { Transmute { t: FOO }.u }; | = 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) { - ╾───────alloc3────────╼ ╾───────alloc4────────╼ │ ╾──────╼╾──────╼ + ╾ALLOC0╼ ╾ALLOC1╼ │ ╾──────╼╾──────╼ } error: aborting due to previous error diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static.32bit.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static.32bit.stderr index a6f467b9ef4..4a3344a5b04 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static.32bit.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.32bit.stderr @@ -24,7 +24,7 @@ LL | const REF_INTERIOR_MUT: &usize = { | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { - ╾─alloc4──╼ │ ╾──╼ + ╾ALLOC0╼ │ ╾──╼ } error[E0080]: it is undefined behavior to use this value @@ -35,7 +35,7 @@ LL | const READ_IMMUT: &usize = { | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { - ╾─alloc5──╼ │ ╾──╼ + ╾ALLOC1╼ │ ╾──╼ } warning: skipping const checks diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static.64bit.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static.64bit.stderr index cfaf31a6e0c..7573bfa39ec 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static.64bit.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.64bit.stderr @@ -24,7 +24,7 @@ LL | const REF_INTERIOR_MUT: &usize = { | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { - ╾───────alloc4────────╼ │ ╾──────╼ + ╾ALLOC0╼ │ ╾──────╼ } error[E0080]: it is undefined behavior to use this value @@ -35,7 +35,7 @@ LL | const READ_IMMUT: &usize = { | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { - ╾───────alloc5────────╼ │ ╾──────╼ + ╾ALLOC1╼ │ ╾──────╼ } warning: skipping const checks diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr index e3a0d93f09b..de59d743b17 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr @@ -6,7 +6,7 @@ LL | const SLICE_MUT: &[u8; 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: 4, align: 4) { - ╾─alloc1──╼ │ ╾──╼ + ╾ALLOC0╼ │ ╾──╼ } error: could not evaluate constant pattern @@ -23,7 +23,7 @@ LL | const U8_MUT: &u8 = { | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { - ╾─alloc1──╼ │ ╾──╼ + ╾ALLOC0╼ │ ╾──╼ } error: could not evaluate constant pattern diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr index a323e9a05f0..e62520ef6ad 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr @@ -6,7 +6,7 @@ LL | const SLICE_MUT: &[u8; 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: 8) { - ╾───────alloc1────────╼ │ ╾──────╼ + ╾ALLOC0╼ │ ╾──────╼ } error: could not evaluate constant pattern @@ -23,7 +23,7 @@ LL | const U8_MUT: &u8 = { | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { - ╾───────alloc1────────╼ │ ╾──────╼ + ╾ALLOC0╼ │ ╾──────╼ } error: could not evaluate constant pattern diff --git a/tests/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr b/tests/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr index 0ea1792409b..c9da91a9597 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr +++ b/tests/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr @@ -6,7 +6,7 @@ LL | const MUH: Meh = Meh { | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { - ╾─alloc3──╼ │ ╾──╼ + ╾ALLOC0╼ │ ╾──╼ } error[E0080]: it is undefined behavior to use this value @@ -17,7 +17,7 @@ LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; | = 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) { - ╾─alloc7──╼ ╾─alloc8──╼ │ ╾──╼╾──╼ + ╾ALLOC1╼ ╾ALLOC2╼ │ ╾──╼╾──╼ } error[E0080]: it is undefined behavior to use this value @@ -28,7 +28,7 @@ LL | const BLUNT: &mut i32 = &mut 42; | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { - ╾─alloc10─╼ │ ╾──╼ + ╾ALLOC3╼ │ ╾──╼ } warning: skipping const checks diff --git a/tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr b/tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr index 67959d25634..71be616b7ed 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr +++ b/tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr @@ -6,7 +6,7 @@ LL | const MUH: Meh = Meh { | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { - ╾───────alloc3────────╼ │ ╾──────╼ + ╾ALLOC0╼ │ ╾──────╼ } error[E0080]: it is undefined behavior to use this value @@ -17,7 +17,7 @@ LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; | = 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) { - ╾───────alloc7────────╼ ╾───────alloc8────────╼ │ ╾──────╼╾──────╼ + ╾ALLOC1╼ ╾ALLOC2╼ │ ╾──────╼╾──────╼ } error[E0080]: it is undefined behavior to use this value @@ -28,7 +28,7 @@ LL | const BLUNT: &mut i32 = &mut 42; | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { - ╾───────alloc10───────╼ │ ╾──────╼ + ╾ALLOC3╼ │ ╾──────╼ } warning: skipping const checks diff --git a/tests/ui/consts/missing_span_in_backtrace.rs b/tests/ui/consts/missing_span_in_backtrace.rs index dd2b81c5af2..1ac3777f5fe 100644 --- a/tests/ui/consts/missing_span_in_backtrace.rs +++ b/tests/ui/consts/missing_span_in_backtrace.rs @@ -1,5 +1,5 @@ // compile-flags: -Z ui-testing=no -// normalize-stderr-test "alloc[0-9]+" -> "ALLOC_ID" + #![feature(const_swap)] #![feature(const_mut_refs)] diff --git a/tests/ui/consts/missing_span_in_backtrace.stderr b/tests/ui/consts/missing_span_in_backtrace.stderr index fcfb9fbb3f8..6860cee4184 100644 --- a/tests/ui/consts/missing_span_in_backtrace.stderr +++ b/tests/ui/consts/missing_span_in_backtrace.stderr @@ -1,7 +1,7 @@ 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 + = note: unable to copy parts of a pointer from memory at ALLOC0 | note: inside `std::ptr::read::<MaybeUninit<MaybeUninit<u8>>>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL diff --git a/tests/ui/consts/offset_from_ub.stderr b/tests/ui/consts/offset_from_ub.stderr index 97ff6efdd79..1ef727e5b0f 100644 --- a/tests/ui/consts/offset_from_ub.stderr +++ b/tests/ui/consts/offset_from_ub.stderr @@ -39,19 +39,19 @@ error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:53:14 | LL | unsafe { ptr_offset_from(end_ptr, start_ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: alloc17 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: ALLOC0 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:62:14 | LL | unsafe { ptr_offset_from(start_ptr, end_ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: alloc20 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: ALLOC1 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:70:14 | LL | unsafe { ptr_offset_from(end_ptr, end_ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: alloc23 has size 4, so pointer at offset 10 is out-of-bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: ALLOC2 has size 4, so pointer at offset 10 is out-of-bounds error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:79:14 diff --git a/tests/ui/consts/offset_ub.rs b/tests/ui/consts/offset_ub.rs index 1b01e4fd147..db28a6c6a2b 100644 --- a/tests/ui/consts/offset_ub.rs +++ b/tests/ui/consts/offset_ub.rs @@ -1,6 +1,6 @@ use std::ptr; -// normalize-stderr-test "alloc\d+" -> "allocN" + // normalize-stderr-test "0x7f+" -> "0x7f..f" diff --git a/tests/ui/consts/offset_ub.stderr b/tests/ui/consts/offset_ub.stderr index c0c851df507..8bc59d50ee4 100644 --- a/tests/ui/consts/offset_ub.stderr +++ b/tests/ui/consts/offset_ub.stderr @@ -14,7 +14,7 @@ LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: out-of-bounds pointer arithmetic: allocN has size 1, so pointer to 2 bytes starting at offset 0 is out-of-bounds + = note: out-of-bounds pointer arithmetic: ALLOC0 has size 1, so pointer to 2 bytes starting at offset 0 is out-of-bounds | note: inside `ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -27,7 +27,7 @@ LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) }; error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: out-of-bounds pointer arithmetic: allocN has size 100, so pointer to 101 bytes starting at offset 0 is out-of-bounds + = note: out-of-bounds pointer arithmetic: ALLOC1 has size 100, so pointer to 101 bytes starting at offset 0 is out-of-bounds | note: inside `ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -92,7 +92,7 @@ LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).of error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: out-of-bounds pointer arithmetic: allocN has size 1, so pointer to 2 bytes starting at offset -4 is out-of-bounds + = note: out-of-bounds pointer arithmetic: ALLOC2 has size 1, so pointer to 2 bytes starting at offset -4 is out-of-bounds | note: inside `ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -105,7 +105,7 @@ LL | pub const NEGATIVE_OFFSET: *const u8 = unsafe { [0u8; 1].as_ptr().wrapping_ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: out-of-bounds pointer arithmetic: allocN has size 0, so pointer to 1 byte starting at offset 0 is out-of-bounds + = note: out-of-bounds pointer arithmetic: ALLOC3 has size 0, so pointer to 1 byte starting at offset 0 is out-of-bounds | note: inside `ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL diff --git a/tests/ui/did_you_mean/bad-assoc-ty.stderr b/tests/ui/did_you_mean/bad-assoc-ty.stderr index efa6bb66824..5c0c7a0b94f 100644 --- a/tests/ui/did_you_mean/bad-assoc-ty.stderr +++ b/tests/ui/did_you_mean/bad-assoc-ty.stderr @@ -191,7 +191,7 @@ error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:33:10 | LL | type H = Fn(u8) -> (u8)::Output; - | ^^^^^^^^^^^^^^^^^^^^^^ help: use the fully-qualified path: `<(dyn Fn(u8) -> u8 + 'static) as IntoFuture>::Output` + | ^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn Fn(u8) -> u8 + 'static) as IntoFuture>::Output` error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:39:19 diff --git a/tests/ui/error-codes/E0034.stderr b/tests/ui/error-codes/E0034.stderr index e2962170265..da6f221881c 100644 --- a/tests/ui/error-codes/E0034.stderr +++ b/tests/ui/error-codes/E0034.stderr @@ -14,12 +14,10 @@ note: candidate #2 is defined in an impl of the trait `Trait2` for the type `Tes | LL | fn foo() {} | ^^^^^^^^ -help: disambiguate the associated function for candidate #1 +help: use fully-qualified syntax to disambiguate | LL | <Test as Trait1>::foo() | ~~~~~~~~~~~~~~~~~~ -help: disambiguate the associated function for candidate #2 - | LL | <Test as Trait2>::foo() | ~~~~~~~~~~~~~~~~~~ diff --git a/tests/ui/error-codes/E0221.stderr b/tests/ui/error-codes/E0221.stderr index 5414d77ad7c..e600acf7834 100644 --- a/tests/ui/error-codes/E0221.stderr +++ b/tests/ui/error-codes/E0221.stderr @@ -10,11 +10,11 @@ LL | fn do_something() { LL | let _: Self::A; | ^^^^^^^ ambiguous associated type `A` | -help: use fully qualified syntax to disambiguate +help: use fully-qualified syntax to disambiguate | LL | let _: <Self as Foo>::A; | ~~~~~~~~~~~~~~~ -help: use fully qualified syntax to disambiguate +help: use fully-qualified syntax to disambiguate | LL | let _: <Self as Bar>::A; | ~~~~~~~~~~~~~~~ @@ -29,7 +29,7 @@ LL | let _: Self::Err; | ^^^^^^^^^ ambiguous associated type `Err` | = note: associated type `Self` could derive from `FromStr` -help: use fully qualified syntax to disambiguate +help: use fully-qualified syntax to disambiguate | LL | let _: <Self as My>::Err; | ~~~~~~~~~~~~~~ diff --git a/tests/ui/error-codes/E0223.stderr b/tests/ui/error-codes/E0223.stderr index 42945e42f6e..1299ba5f50c 100644 --- a/tests/ui/error-codes/E0223.stderr +++ b/tests/ui/error-codes/E0223.stderr @@ -2,7 +2,7 @@ error[E0223]: ambiguous associated type --> $DIR/E0223.rs:8:14 | LL | let foo: MyTrait::X; - | ^^^^^^^^^^ help: use the fully-qualified path: `<MyStruct as MyTrait>::X` + | ^^^^^^^^^^ help: use fully-qualified syntax: `<MyStruct as MyTrait>::X` error: aborting due to previous error diff --git a/tests/ui/error-codes/E0396-fixed.stderr b/tests/ui/error-codes/E0396-fixed.stderr index 2efbd6989ad..e77b2ce9a22 100644 --- a/tests/ui/error-codes/E0396-fixed.stderr +++ b/tests/ui/error-codes/E0396-fixed.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/E0396-fixed.rs:5:28 | LL | const VALUE: u8 = unsafe { *REG_ADDR }; - | ^^^^^^^^^ dereferencing pointer failed: 0x5f3759df[noalloc] is a dangling pointer (it has no provenance) + | ^^^^^^^^^ memory access failed: 0x5f3759df[noalloc] is a dangling pointer (it has no provenance) error: aborting due to previous error diff --git a/tests/ui/expr/malformed_closure/missing_block_in_fn_call.fixed b/tests/ui/expr/malformed_closure/missing_block_in_fn_call.fixed new file mode 100644 index 00000000000..b81515cda9a --- /dev/null +++ b/tests/ui/expr/malformed_closure/missing_block_in_fn_call.fixed @@ -0,0 +1,10 @@ +// run-rustfix +fn main() { + let _ = vec![1, 2, 3].into_iter().map(|x| { + let y = x; //~ ERROR expected expression, found `let` statement + y + }); + let _: () = foo(); //~ ERROR mismatched types +} + +fn foo() {} diff --git a/tests/ui/expr/malformed_closure/missing_block_in_fn_call.rs b/tests/ui/expr/malformed_closure/missing_block_in_fn_call.rs new file mode 100644 index 00000000000..e47ad562fb0 --- /dev/null +++ b/tests/ui/expr/malformed_closure/missing_block_in_fn_call.rs @@ -0,0 +1,10 @@ +// run-rustfix +fn main() { + let _ = vec![1, 2, 3].into_iter().map(|x| + let y = x; //~ ERROR expected expression, found `let` statement + y + ); + let _: () = foo; //~ ERROR mismatched types +} + +fn foo() {} diff --git a/tests/ui/expr/malformed_closure/missing_block_in_fn_call.stderr b/tests/ui/expr/malformed_closure/missing_block_in_fn_call.stderr new file mode 100644 index 00000000000..fbb7e0e4df5 --- /dev/null +++ b/tests/ui/expr/malformed_closure/missing_block_in_fn_call.stderr @@ -0,0 +1,38 @@ +error: expected expression, found `let` statement + --> $DIR/missing_block_in_fn_call.rs:4:9 + | +LL | let _ = vec![1, 2, 3].into_iter().map(|x| + | --- while parsing the body of this closure +LL | let y = x; + | ^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +help: you might have meant to open the body of the closure + | +LL ~ let _ = vec![1, 2, 3].into_iter().map(|x| { +LL | let y = x; +LL | y +LL ~ }); + | + +error[E0308]: mismatched types + --> $DIR/missing_block_in_fn_call.rs:7:17 + | +LL | let _: () = foo; + | -- ^^^ expected `()`, found fn item + | | + | expected due to this +... +LL | fn foo() {} + | -------- function `foo` defined here + | + = note: expected unit type `()` + found fn item `fn() {foo}` +help: use parentheses to call this function + | +LL | let _: () = foo(); + | ++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/expr/malformed_closure/missing_block_in_let_binding.rs b/tests/ui/expr/malformed_closure/missing_block_in_let_binding.rs new file mode 100644 index 00000000000..1ee215d150d --- /dev/null +++ b/tests/ui/expr/malformed_closure/missing_block_in_let_binding.rs @@ -0,0 +1,6 @@ +fn main() { + let x = |x| + let y = x; //~ ERROR expected expression, found `let` statement + let _ = () + (); + y +} diff --git a/tests/ui/expr/malformed_closure/missing_block_in_let_binding.stderr b/tests/ui/expr/malformed_closure/missing_block_in_let_binding.stderr new file mode 100644 index 00000000000..d4640fba96c --- /dev/null +++ b/tests/ui/expr/malformed_closure/missing_block_in_let_binding.stderr @@ -0,0 +1,16 @@ +error: expected expression, found `let` statement + --> $DIR/missing_block_in_let_binding.rs:3:9 + | +LL | let x = |x| + | --- while parsing the body of this closure +LL | let y = x; + | ^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +help: you might have meant to open the body of the closure + | +LL | let x = |x| { + | + + +error: aborting due to previous error + diff --git a/tests/ui/expr/malformed_closure/ruby_style_closure_parse_error.fixed b/tests/ui/expr/malformed_closure/ruby_style_closure_parse_error.fixed new file mode 100644 index 00000000000..8014dc87c08 --- /dev/null +++ b/tests/ui/expr/malformed_closure/ruby_style_closure_parse_error.fixed @@ -0,0 +1,9 @@ +// run-rustfix +fn main() { + let _ = vec![1, 2, 3].into_iter().map(|x| { + let y = x; //~ ERROR expected expression, found `let` statement + y + }); + let _: () = foo(); //~ ERROR mismatched types +} +fn foo() {} diff --git a/tests/ui/expr/malformed_closure/ruby_style_closure_parse_error.rs b/tests/ui/expr/malformed_closure/ruby_style_closure_parse_error.rs new file mode 100644 index 00000000000..9e4aca888ad --- /dev/null +++ b/tests/ui/expr/malformed_closure/ruby_style_closure_parse_error.rs @@ -0,0 +1,9 @@ +// run-rustfix +fn main() { + let _ = vec![1, 2, 3].into_iter().map({|x| + let y = x; //~ ERROR expected expression, found `let` statement + y + }); + let _: () = foo; //~ ERROR mismatched types +} +fn foo() {} diff --git a/tests/ui/expr/malformed_closure/ruby_style_closure_parse_error.stderr b/tests/ui/expr/malformed_closure/ruby_style_closure_parse_error.stderr new file mode 100644 index 00000000000..5fc48d73b14 --- /dev/null +++ b/tests/ui/expr/malformed_closure/ruby_style_closure_parse_error.stderr @@ -0,0 +1,36 @@ +error: expected expression, found `let` statement + --> $DIR/ruby_style_closure_parse_error.rs:4:9 + | +LL | let _ = vec![1, 2, 3].into_iter().map({|x| + | --- while parsing the body of this closure +LL | let y = x; + | ^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +help: you might have meant to open the body of the closure, instead of enclosing the closure in a block + | +LL - let _ = vec![1, 2, 3].into_iter().map({|x| +LL + let _ = vec![1, 2, 3].into_iter().map(|x| { + | + +error[E0308]: mismatched types + --> $DIR/ruby_style_closure_parse_error.rs:7:17 + | +LL | let _: () = foo; + | -- ^^^ expected `()`, found fn item + | | + | expected due to this +LL | } +LL | fn foo() {} + | -------- function `foo` defined here + | + = note: expected unit type `()` + found fn item `fn() {foo}` +help: use parentheses to call this function + | +LL | let _: () = foo(); + | ++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs b/tests/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs deleted file mode 100644 index a8d6365ca79..00000000000 --- a/tests/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs +++ /dev/null @@ -1,18 +0,0 @@ -// edition:2021 - -// async_fn_in_trait is not enough to allow use of RPITIT -#![allow(incomplete_features)] -#![feature(async_fn_in_trait)] - -trait Foo { - fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return - fn baz() -> Box<impl std::fmt::Display>; //~ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return -} - -// Both return_position_impl_trait_in_trait and async_fn_in_trait are required for this (see also -// feature-gate-async_fn_in_trait.rs) -trait AsyncFoo { - async fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return -} - -fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr b/tests/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr deleted file mode 100644 index 86f138fabdb..00000000000 --- a/tests/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return types - --> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:8:17 - | -LL | fn bar() -> impl Sized; - | ^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = 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 argument and return types, not in trait method return types - --> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:9:21 - | -LL | fn baz() -> Box<impl std::fmt::Display>; - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = 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 argument and return types, not in trait method return types - --> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:15:23 - | -LL | async fn bar() -> impl Sized; - | ^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0562`. diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr b/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr index f6230b76463..1bdb2574ead 100644 --- a/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr +++ b/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr @@ -1,5 +1,5 @@ error[E0658]: return type notation is experimental - --> $DIR/feature-gate-return_type_notation.rs:15:17 + --> $DIR/feature-gate-return_type_notation.rs:14:17 | LL | fn foo<T: Trait<m(): Send>>() {} | ^^^^^^^^^ @@ -8,7 +8,7 @@ LL | fn foo<T: Trait<m(): Send>>() {} = help: add `#![feature(return_type_notation)]` to the crate attributes to enable error: parenthesized generic arguments cannot be used in associated type constraints - --> $DIR/feature-gate-return_type_notation.rs:15:17 + --> $DIR/feature-gate-return_type_notation.rs:14:17 | LL | fn foo<T: Trait<m(): Send>>() {} | ^-- @@ -16,7 +16,7 @@ LL | fn foo<T: Trait<m(): Send>>() {} | help: remove these parentheses error[E0220]: associated type `m` not found for `Trait` - --> $DIR/feature-gate-return_type_notation.rs:15:17 + --> $DIR/feature-gate-return_type_notation.rs:14:17 | LL | fn foo<T: Trait<m(): Send>>() {} | ^ associated type `m` not found diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr b/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr index c7f52d7cddc..dd6ebb61038 100644 --- a/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr +++ b/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr @@ -1,5 +1,5 @@ warning: return type notation is experimental - --> $DIR/feature-gate-return_type_notation.rs:15:17 + --> $DIR/feature-gate-return_type_notation.rs:14:17 | LL | fn foo<T: Trait<m(): Send>>() {} | ^^^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.rs b/tests/ui/feature-gates/feature-gate-return_type_notation.rs index c0c285cef3c..86e2c48e188 100644 --- a/tests/ui/feature-gates/feature-gate-return_type_notation.rs +++ b/tests/ui/feature-gates/feature-gate-return_type_notation.rs @@ -4,7 +4,6 @@ // [no] check-pass // Since we're not adding new syntax, `cfg`'d out RTN must pass. -#![feature(async_fn_in_trait)] trait Trait { #[allow(async_fn_in_trait)] diff --git a/tests/ui/generic-associated-types/issue-68648-2.stderr b/tests/ui/generic-associated-types/issue-68648-2.stderr index b2bef19eb5e..0514e7bd6f6 100644 --- a/tests/ui/generic-associated-types/issue-68648-2.stderr +++ b/tests/ui/generic-associated-types/issue-68648-2.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-68648-2.rs:12:17 | LL | fn bug<'a, T: Fun<F<'a> = T>>(t: T) -> T::F<'a> { - | - this type parameter + | - expected this type parameter LL | T::identity(()) | ----------- ^^ expected type parameter `T`, found `()` | | diff --git a/tests/ui/generic-associated-types/issue-68656-unsized-values.stderr b/tests/ui/generic-associated-types/issue-68656-unsized-values.stderr index f0212e985a9..20c07db4c04 100644 --- a/tests/ui/generic-associated-types/issue-68656-unsized-values.stderr +++ b/tests/ui/generic-associated-types/issue-68656-unsized-values.stderr @@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `<T as Deref>::Target == T` --> $DIR/issue-68656-unsized-values.rs:13:21 | LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<T> for T { - | - this type parameter + | - expected this type parameter LL | type Item<'a> = T; | ^ expected type parameter `T`, found associated type | diff --git a/tests/ui/generic-associated-types/issue-88360.stderr b/tests/ui/generic-associated-types/issue-88360.stderr index 520aeff1894..ad40ee18001 100644 --- a/tests/ui/generic-associated-types/issue-88360.stderr +++ b/tests/ui/generic-associated-types/issue-88360.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-88360.rs:15:9 | LL | trait SuperTrait<T> - | - this type parameter + | - found this type parameter ... LL | fn copy(&self) -> Self::Gat<'_> where T: Copy { | ------------- expected `&T` because of return type diff --git a/tests/ui/generic-associated-types/missing-bounds.stderr b/tests/ui/generic-associated-types/missing-bounds.stderr index 535edec575a..1d7d80d1b07 100644 --- a/tests/ui/generic-associated-types/missing-bounds.stderr +++ b/tests/ui/generic-associated-types/missing-bounds.stderr @@ -14,7 +14,7 @@ error[E0308]: mismatched types --> $DIR/missing-bounds.rs:11:11 | LL | impl<B> Add for A<B> where B: Add { - | - this type parameter + | - expected this type parameter ... LL | A(self.0 + rhs.0) | - ^^^^^^^^^^^^^^ expected type parameter `B`, found associated type @@ -44,7 +44,7 @@ error[E0308]: mismatched types --> $DIR/missing-bounds.rs:21:14 | LL | impl<B: Add> Add for C<B> { - | - this type parameter + | - expected this type parameter ... LL | Self(self.0 + rhs.0) | ---- ^^^^^^^^^^^^^^ expected type parameter `B`, found associated type @@ -80,7 +80,7 @@ error[E0308]: mismatched types --> $DIR/missing-bounds.rs:42:14 | LL | impl<B: Add> Add for E<B> where <B as Add>::Output = B { - | - this type parameter + | - expected this type parameter ... LL | Self(self.0 + rhs.0) | ---- ^^^^^^^^^^^^^^ expected type parameter `B`, found associated type diff --git a/tests/ui/hygiene/panic-location.run.stderr b/tests/ui/hygiene/panic-location.run.stderr index 5ed0d9fcf1e..1fd61084130 100644 --- a/tests/ui/hygiene/panic-location.run.stderr +++ b/tests/ui/hygiene/panic-location.run.stderr @@ -1,3 +1,3 @@ -thread 'main' panicked at library/alloc/src/raw_vec.rs:534:5: +thread 'main' panicked at library/alloc/src/raw_vec.rs:535:5: capacity overflow note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.rs b/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.rs new file mode 100644 index 00000000000..6863a3c73ba --- /dev/null +++ b/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.rs @@ -0,0 +1,25 @@ +// This test should never pass! + +#![feature(type_alias_impl_trait)] + +trait Captures<'a> {} +impl<T> Captures<'_> for T {} + +struct MyTy<'a, 'b>(Option<*mut &'a &'b ()>); +unsafe impl Send for MyTy<'_, 'static> {} + +fn step1<'a, 'b: 'a>() -> impl Sized + Captures<'b> + 'a { + MyTy::<'a, 'b>(None) +} + +fn step2<'a, 'b: 'a>() -> impl Sized + 'a { + step1::<'a, 'b>() + //~^ ERROR hidden type for `impl Sized + 'a` captures lifetime that does not appear in bounds +} + +fn step3<'a, 'b: 'a>() -> impl Send + 'a { + step2::<'a, 'b>() + // This should not be Send unless `'b: 'static` +} + +fn main() {} diff --git a/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.stderr b/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.stderr new file mode 100644 index 00000000000..168a5aa18ec --- /dev/null +++ b/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.stderr @@ -0,0 +1,18 @@ +error[E0700]: hidden type for `impl Sized + 'a` captures lifetime that does not appear in bounds + --> $DIR/rpit-hidden-erased-unsoundness.rs:16:5 + | +LL | fn step2<'a, 'b: 'a>() -> impl Sized + 'a { + | -- --------------- opaque type defined here + | | + | hidden type `impl Captures<'b> + 'a` captures the lifetime `'b` as defined here +LL | step1::<'a, 'b>() + | ^^^^^^^^^^^^^^^^^ + | +help: to declare that `impl Sized + 'a` captures `'b`, you can add an explicit `'b` lifetime bound + | +LL | fn step2<'a, 'b: 'a>() -> impl Sized + 'a + 'b { + | ++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0700`. diff --git a/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.rs b/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.rs new file mode 100644 index 00000000000..4de2ffbb808 --- /dev/null +++ b/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.rs @@ -0,0 +1,32 @@ +// This test should never pass! + +use std::cell::RefCell; +use std::rc::Rc; + +trait Swap: Sized { + fn swap(self, other: Self); +} + +impl<T> Swap for Rc<RefCell<T>> { + fn swap(self, other: Self) { + <RefCell<T>>::swap(&self, &other); + } +} + +fn hide<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a { + x + //~^ ERROR hidden type for `impl Swap + 'a` captures lifetime that does not appear in bounds +} + +fn dangle() -> &'static [i32; 3] { + let long = Rc::new(RefCell::new(&[4, 5, 6])); + let x = [1, 2, 3]; + let short = Rc::new(RefCell::new(&x)); + hide(long.clone()).swap(hide(short)); + let res: &'static [i32; 3] = *long.borrow(); + res +} + +fn main() { + println!("{:?}", dangle()); +} diff --git a/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.stderr b/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.stderr new file mode 100644 index 00000000000..cabba4bafaf --- /dev/null +++ b/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.stderr @@ -0,0 +1,18 @@ +error[E0700]: hidden type for `impl Swap + 'a` captures lifetime that does not appear in bounds + --> $DIR/rpit-hide-lifetime-for-swap.rs:17:5 + | +LL | fn hide<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a { + | -- -------------- opaque type defined here + | | + | hidden type `Rc<RefCell<&'b T>>` captures the lifetime `'b` as defined here +LL | x + | ^ + | +help: to declare that `impl Swap + 'a` captures `'b`, you can add an explicit `'b` lifetime bound + | +LL | fn hide<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a + 'b { + | ++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0700`. diff --git a/tests/ui/impl-trait/alias-liveness/tait-hidden-erased-unsoundness.rs b/tests/ui/impl-trait/alias-liveness/tait-hidden-erased-unsoundness.rs new file mode 100644 index 00000000000..40efd941e33 --- /dev/null +++ b/tests/ui/impl-trait/alias-liveness/tait-hidden-erased-unsoundness.rs @@ -0,0 +1,28 @@ +// This test should never pass! + +#![feature(type_alias_impl_trait)] + +trait Captures<'a> {} +impl<T> Captures<'_> for T {} + +struct MyTy<'a, 'b>(Option<*mut &'a &'b ()>); +unsafe impl Send for MyTy<'_, 'static> {} + +fn step1<'a, 'b: 'a>() -> impl Sized + Captures<'b> + 'a { + MyTy::<'a, 'b>(None) +} + +mod tait { + type Tait<'a> = impl Sized + 'a; + pub(super) fn step2<'a, 'b: 'a>() -> Tait<'a> { + super::step1::<'a, 'b>() + //~^ ERROR hidden type for `Tait<'a>` captures lifetime that does not appear in bounds + } +} + +fn step3<'a, 'b: 'a>() -> impl Send + 'a { + tait::step2::<'a, 'b>() + // This should not be Send unless `'b: 'static` +} + +fn main() {} diff --git a/tests/ui/impl-trait/alias-liveness/tait-hidden-erased-unsoundness.stderr b/tests/ui/impl-trait/alias-liveness/tait-hidden-erased-unsoundness.stderr new file mode 100644 index 00000000000..baeec6d5892 --- /dev/null +++ b/tests/ui/impl-trait/alias-liveness/tait-hidden-erased-unsoundness.stderr @@ -0,0 +1,13 @@ +error[E0700]: hidden type for `Tait<'a>` captures lifetime that does not appear in bounds + --> $DIR/tait-hidden-erased-unsoundness.rs:18:9 + | +LL | type Tait<'a> = impl Sized + 'a; + | --------------- opaque type defined here +LL | pub(super) fn step2<'a, 'b: 'a>() -> Tait<'a> { + | -- hidden type `impl Captures<'b> + 'a` captures the lifetime `'b` as defined here +LL | super::step1::<'a, 'b>() + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0700`. diff --git a/tests/ui/impl-trait/arg-position-impl-trait-too-long.stderr b/tests/ui/impl-trait/arg-position-impl-trait-too-long.stderr index 40446a3d339..d5086c7bc51 100644 --- a/tests/ui/impl-trait/arg-position-impl-trait-too-long.stderr +++ b/tests/ui/impl-trait/arg-position-impl-trait-too-long.stderr @@ -7,7 +7,7 @@ LL | | &mut Header, LL | | &mut [EntryMetadata], LL | | &mut [Entry<C::EncodedKey, C::EncodedValue>] LL | | ) -> R, - | |__________- this type parameter + | |__________- expected this type parameter LL | ) { LL | let () = y; | ^^ - this expression has type `impl FnOnce(&mut Header, &mut [EntryMetadata], &mut [Entry<C::EncodedKey, C::EncodedValue>]) -> R` diff --git a/tests/ui/impl-trait/async_scope_creep.rs b/tests/ui/impl-trait/async_scope_creep.rs index 9a8831a299e..60975439a33 100644 --- a/tests/ui/impl-trait/async_scope_creep.rs +++ b/tests/ui/impl-trait/async_scope_creep.rs @@ -1,6 +1,6 @@ #![feature(type_alias_impl_trait)] // edition:2021 -//[rpit] check-pass +// check-pass // revisions: tait rpit struct Pending {} @@ -23,7 +23,7 @@ impl Pending { #[cfg(tait)] fn read_fut(&mut self) -> OpeningReadFuture<'_> { - self.read() //[tait]~ ERROR: cannot satisfy `impl AsyncRead + 'a == PendingReader<'a>` + self.read() } #[cfg(rpit)] diff --git a/tests/ui/impl-trait/async_scope_creep.tait.stderr b/tests/ui/impl-trait/async_scope_creep.tait.stderr deleted file mode 100644 index 165096a0574..00000000000 --- a/tests/ui/impl-trait/async_scope_creep.tait.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0284]: type annotations needed: cannot satisfy `impl AsyncRead + 'a == PendingReader<'a>` - --> $DIR/async_scope_creep.rs:26:9 - | -LL | self.read() - | ^^^^^^^^^^^ cannot satisfy `impl AsyncRead + 'a == PendingReader<'a>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/impl-trait/auto-trait.stderr b/tests/ui/impl-trait/auto-trait-coherence.next.stderr index 81009413c9a..7833ac688ba 100644 --- a/tests/ui/impl-trait/auto-trait.stderr +++ b/tests/ui/impl-trait/auto-trait-coherence.next.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>` - --> $DIR/auto-trait.rs:21:1 + --> $DIR/auto-trait-coherence.rs:24:1 | LL | impl<T: Send> AnotherTrait for T {} | -------------------------------- first implementation here diff --git a/tests/ui/impl-trait/auto-trait-coherence.old.stderr b/tests/ui/impl-trait/auto-trait-coherence.old.stderr new file mode 100644 index 00000000000..7833ac688ba --- /dev/null +++ b/tests/ui/impl-trait/auto-trait-coherence.old.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>` + --> $DIR/auto-trait-coherence.rs:24:1 + | +LL | impl<T: Send> AnotherTrait for T {} + | -------------------------------- first implementation here +... +LL | impl AnotherTrait for D<OpaqueType> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<OpaqueType>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/impl-trait/auto-trait.rs b/tests/ui/impl-trait/auto-trait-coherence.rs index 35994e4a5ba..a5cd01a87ff 100644 --- a/tests/ui/impl-trait/auto-trait.rs +++ b/tests/ui/impl-trait/auto-trait-coherence.rs @@ -1,3 +1,6 @@ +// revisions: old next +//[next] compile-flags: -Ztrait-solver=next + // Tests that type alias impls traits do not leak auto-traits for // the purposes of coherence checking #![feature(type_alias_impl_trait)] diff --git a/tests/ui/impl-trait/equality-in-canonical-query.clone.stderr b/tests/ui/impl-trait/equality-in-canonical-query.clone.stderr new file mode 100644 index 00000000000..83791f0d3af --- /dev/null +++ b/tests/ui/impl-trait/equality-in-canonical-query.clone.stderr @@ -0,0 +1,29 @@ +error: internal compiler error: no errors encountered even though `delay_span_bug` issued + +error: internal compiler error: {OpaqueTypeKey { def_id: DefId(rpit::{opaque#0}), args: [] }: OpaqueTypeDecl { hidden_type: OpaqueHiddenType { span: no-location (#0), ty: Alias(Opaque, AliasTy { args: [], def_id: DefId(foo::{opaque#0}) }) } }} + | + = + + +error: internal compiler error: error performing ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: ProvePredicate { predicate: Binder { value: ProjectionPredicate(AliasTy { args: [FnDef(DefId(rpit), []), ()], def_id: DefId(ops::function::FnOnce::Output) }, Term::Ty(Alias(Opaque, AliasTy { args: [], def_id: DefId(foo::{opaque#0}) }))), bound_vars: [] } } } + --> $DIR/equality-in-canonical-query.rs:19:5 + | +LL | same_output(foo, rpit); + | ^^^^^^^^^^^^^^^^^^^^^^ + | + + --> $DIR/equality-in-canonical-query.rs:19:5 + | +LL | same_output(foo, rpit); + | ^^^^^^^^^^^^^^^^^^^^^^ + + + + + + + +query stack during panic: +end of query stack +error: aborting due to 3 previous errors + diff --git a/tests/ui/impl-trait/equality-in-canonical-query.rs b/tests/ui/impl-trait/equality-in-canonical-query.rs new file mode 100644 index 00000000000..672b1eeeab6 --- /dev/null +++ b/tests/ui/impl-trait/equality-in-canonical-query.rs @@ -0,0 +1,23 @@ +// issue: #116877 +// revisions: sized clone +//[sized] check-pass + +//[clone] known-bug: #108498 +//[clone] failure-status: 101 +//[clone] normalize-stderr-test: "DefId\(.*?\]::" -> "DefId(" +//[clone] normalize-stderr-test: "(?m)note: .*$" -> "" +//[clone] normalize-stderr-test: "(?m)^ *\d+: .*\n" -> "" +//[clone] normalize-stderr-test: "(?m)^ *at .*\n" -> "" + +#[cfg(sized)] fn rpit() -> impl Sized {} +#[cfg(clone)] fn rpit() -> impl Clone {} + +fn same_output<Out>(_: impl Fn() -> Out, _: impl Fn() -> Out) {} + +pub fn foo() -> impl Sized { + same_output(rpit, foo); + same_output(foo, rpit); + rpit() +} + +fn main () {} diff --git a/tests/ui/impl-trait/in-trait/anonymize-binders-for-refine.rs b/tests/ui/impl-trait/in-trait/anonymize-binders-for-refine.rs index e62662f2f07..09fbef2ec07 100644 --- a/tests/ui/impl-trait/in-trait/anonymize-binders-for-refine.rs +++ b/tests/ui/impl-trait/in-trait/anonymize-binders-for-refine.rs @@ -1,7 +1,6 @@ // compile-flags: --crate-type=lib // check-pass -#![feature(return_position_impl_trait_in_trait)] #![deny(refining_impl_trait)] pub trait Tr<T> { diff --git a/tests/ui/impl-trait/in-trait/assumed-wf-bounds-in-impl.rs b/tests/ui/impl-trait/in-trait/assumed-wf-bounds-in-impl.rs index 5de9c01e3e0..afb9992de49 100644 --- a/tests/ui/impl-trait/in-trait/assumed-wf-bounds-in-impl.rs +++ b/tests/ui/impl-trait/in-trait/assumed-wf-bounds-in-impl.rs @@ -2,7 +2,6 @@ // edition: 2021 // issue: 113796 -#![feature(async_fn_in_trait)] trait AsyncLendingIterator { type Item<'a> diff --git a/tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs b/tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs index 6e99402113a..a213994ff86 100644 --- a/tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs +++ b/tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs @@ -1,4 +1,4 @@ -#![feature(return_position_impl_trait_in_trait, lint_reasons)] +#![feature(lint_reasons)] use std::ops::Deref; diff --git a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.rs b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.rs index 3a93dfee57f..41d5f0f6449 100644 --- a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.rs +++ b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.rs @@ -1,6 +1,5 @@ // issue: 114146 -#![feature(return_position_impl_trait_in_trait)] trait Foo { fn bar<'other: 'a>() -> impl Sized + 'a {} diff --git a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.stderr b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.stderr index 3a1f8f90837..b0832eb33ca 100644 --- a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.stderr +++ b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.stderr @@ -1,5 +1,5 @@ error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/bad-item-bound-within-rpitit-2.rs:6:20 + --> $DIR/bad-item-bound-within-rpitit-2.rs:5:20 | LL | fn bar<'other: 'a>() -> impl Sized + 'a {} | ^^ undeclared lifetime @@ -14,7 +14,7 @@ LL | trait Foo<'a> { | ++++ error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/bad-item-bound-within-rpitit-2.rs:6:42 + --> $DIR/bad-item-bound-within-rpitit-2.rs:5:42 | LL | fn bar<'other: 'a>() -> impl Sized + 'a {} | ^^ undeclared lifetime diff --git a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.rs b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.rs index fbbbb8585d1..5ddc97f1adc 100644 --- a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.rs +++ b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.rs @@ -1,6 +1,5 @@ // issue: 114145 -#![feature(return_position_impl_trait_in_trait)] pub trait Iterable { type Item<'a> diff --git a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr index a5fb338ea4e..324eaa37a3d 100644 --- a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr +++ b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr @@ -1,5 +1,5 @@ error[E0276]: impl has stricter requirements than trait - --> $DIR/bad-item-bound-within-rpitit.rs:16:13 + --> $DIR/bad-item-bound-within-rpitit.rs:15:13 | LL | type Item<'a> | ------------- definition of `Item` from trait @@ -13,7 +13,7 @@ LL | where Self: 'b; | ~~~~~~~~~~~~~~ warning: impl trait in impl method signature does not match trait method signature - --> $DIR/bad-item-bound-within-rpitit.rs:19:28 + --> $DIR/bad-item-bound-within-rpitit.rs:18:28 | LL | fn iter(&self) -> impl '_ + Iterator<Item = Self::Item<'_>>; | ----------------------------------------- return type from trait method defined here diff --git a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs index f5ee4690fa9..87eb7beb1ee 100644 --- a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs +++ b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs @@ -1,6 +1,5 @@ // check-pass -#![feature(return_position_impl_trait_in_trait)] struct TestA {} struct TestB {} diff --git a/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.rs b/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.rs index 742537ffcc4..2845b401bd5 100644 --- a/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.rs +++ b/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.rs @@ -1,5 +1,3 @@ -#![feature(return_position_impl_trait_in_trait)] - struct Wrapper<G: Send>(G); trait Foo { diff --git a/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.stderr b/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.stderr index dee87d08238..1570b2ecd53 100644 --- a/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.stderr +++ b/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.stderr @@ -1,12 +1,12 @@ error[E0277]: `impl Sized` cannot be sent between threads safely - --> $DIR/check-wf-on-non-defaulted-rpitit.rs:6:17 + --> $DIR/check-wf-on-non-defaulted-rpitit.rs:4:17 | LL | fn bar() -> Wrapper<impl Sized>; | ^^^^^^^^^^^^^^^^^^^ `impl Sized` cannot be sent between threads safely | = help: the trait `Send` is not implemented for `impl Sized` note: required by a bound in `Wrapper` - --> $DIR/check-wf-on-non-defaulted-rpitit.rs:3:19 + --> $DIR/check-wf-on-non-defaulted-rpitit.rs:1:19 | LL | struct Wrapper<G: Send>(G); | ^^^^ required by this bound in `Wrapper` diff --git a/tests/ui/impl-trait/in-trait/deep-match-works.rs b/tests/ui/impl-trait/in-trait/deep-match-works.rs index fc290f11f9d..8c992743862 100644 --- a/tests/ui/impl-trait/in-trait/deep-match-works.rs +++ b/tests/ui/impl-trait/in-trait/deep-match-works.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(return_position_impl_trait_in_trait, lint_reasons)] +#![feature(lint_reasons)] #![allow(incomplete_features)] pub struct Wrapper<T>(T); diff --git a/tests/ui/impl-trait/in-trait/deep-match.rs b/tests/ui/impl-trait/in-trait/deep-match.rs index 0cae88f349f..02889347ba4 100644 --- a/tests/ui/impl-trait/in-trait/deep-match.rs +++ b/tests/ui/impl-trait/in-trait/deep-match.rs @@ -1,4 +1,3 @@ -#![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] struct Wrapper<T>(T); diff --git a/tests/ui/impl-trait/in-trait/deep-match.stderr b/tests/ui/impl-trait/in-trait/deep-match.stderr index f0ad3c16e9c..9cfc54f5094 100644 --- a/tests/ui/impl-trait/in-trait/deep-match.stderr +++ b/tests/ui/impl-trait/in-trait/deep-match.stderr @@ -1,5 +1,5 @@ error[E0053]: method `bar` has an incompatible return type for trait - --> $DIR/deep-match.rs:11:17 + --> $DIR/deep-match.rs:10:17 | LL | fn bar() -> i32 { | ^^^ diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs b/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs index 45ae2b8ad3a..29bcbe16d83 100644 --- a/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs +++ b/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs @@ -1,7 +1,6 @@ // edition:2021 #![allow(incomplete_features)] -#![feature(async_fn_in_trait)] pub trait Foo { async fn woopsie_async(&self) -> String { diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr index cc3bdf0e571..fcace10cd01 100644 --- a/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr +++ b/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/default-body-type-err-2.rs:8:9 + --> $DIR/default-body-type-err-2.rs:7:9 | LL | 42 | ^^- help: try using a conversion method: `.to_string()` diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err.rs b/tests/ui/impl-trait/in-trait/default-body-type-err.rs index ac9baf91cae..977ff8111dd 100644 --- a/tests/ui/impl-trait/in-trait/default-body-type-err.rs +++ b/tests/ui/impl-trait/in-trait/default-body-type-err.rs @@ -1,5 +1,4 @@ #![allow(incomplete_features)] -#![feature(return_position_impl_trait_in_trait)] use std::ops::Deref; diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err.stderr index 4742eb37d3e..3d9ca62b0db 100644 --- a/tests/ui/impl-trait/in-trait/default-body-type-err.stderr +++ b/tests/ui/impl-trait/in-trait/default-body-type-err.stderr @@ -1,5 +1,5 @@ error[E0271]: type mismatch resolving `<&i32 as Deref>::Target == String` - --> $DIR/default-body-type-err.rs:7:22 + --> $DIR/default-body-type-err.rs:6:22 | LL | fn lol(&self) -> impl Deref<Target = String> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `String` diff --git a/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs b/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs index 9c60cf4e72a..1d1f555080c 100644 --- a/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs +++ b/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs @@ -1,7 +1,6 @@ // edition:2021 // check-pass -#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] #![allow(incomplete_features)] use std::fmt::Debug; diff --git a/tests/ui/impl-trait/in-trait/default-body.rs b/tests/ui/impl-trait/in-trait/default-body.rs index d3ea9fbeabc..ff70f1e232d 100644 --- a/tests/ui/impl-trait/in-trait/default-body.rs +++ b/tests/ui/impl-trait/in-trait/default-body.rs @@ -1,7 +1,6 @@ // check-pass // edition:2021 -#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] #![allow(incomplete_features)] use std::fmt::Debug; diff --git a/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs b/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs index 817a4d7dbbe..ca41eb8bc71 100644 --- a/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs +++ b/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs @@ -1,6 +1,5 @@ // check-pass -#![feature(return_position_impl_trait_in_trait)] trait Trait { type Type; diff --git a/tests/ui/impl-trait/in-trait/default-method-constraint.rs b/tests/ui/impl-trait/in-trait/default-method-constraint.rs index 28d76241f27..8ab2e2797f1 100644 --- a/tests/ui/impl-trait/in-trait/default-method-constraint.rs +++ b/tests/ui/impl-trait/in-trait/default-method-constraint.rs @@ -2,7 +2,6 @@ // This didn't work in the previous default RPITIT method hack attempt -#![feature(return_position_impl_trait_in_trait)] trait Foo { fn bar(x: bool) -> impl Sized { diff --git a/tests/ui/impl-trait/in-trait/doesnt-satisfy.rs b/tests/ui/impl-trait/in-trait/doesnt-satisfy.rs index bb4e0d44f3e..5a53c9a19b5 100644 --- a/tests/ui/impl-trait/in-trait/doesnt-satisfy.rs +++ b/tests/ui/impl-trait/in-trait/doesnt-satisfy.rs @@ -1,4 +1,3 @@ -#![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] trait Foo { diff --git a/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr b/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr index 7c56ffa10e1..cb9ecc7fa48 100644 --- a/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr +++ b/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr @@ -1,5 +1,5 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` - --> $DIR/doesnt-satisfy.rs:9:17 + --> $DIR/doesnt-satisfy.rs:8:17 | LL | fn bar() -> () {} | ^^ `()` cannot be formatted with the default formatter @@ -7,7 +7,7 @@ LL | fn bar() -> () {} = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `Foo::{opaque#0}` - --> $DIR/doesnt-satisfy.rs:5:22 + --> $DIR/doesnt-satisfy.rs:4:22 | LL | fn bar() -> impl std::fmt::Display; | ^^^^^^^^^^^^^^^^^ required by this bound in `Foo::{opaque#0}` diff --git a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs index 4719d5d3c67..fe0f011b6b0 100644 --- a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs +++ b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs @@ -1,5 +1,3 @@ -#![feature(return_position_impl_trait_in_trait)] - trait MyTrait { fn foo(&self) -> impl Sized; fn bar(&self) -> impl Sized; diff --git a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.stderr b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.stderr index 66ee142ccc4..830e663da37 100644 --- a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.stderr +++ b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.stderr @@ -1,5 +1,5 @@ error[E0046]: not all trait items implemented, missing: `foo` - --> $DIR/dont-project-to-rpitit-with-no-value.rs:8:1 + --> $DIR/dont-project-to-rpitit-with-no-value.rs:6:1 | LL | fn foo(&self) -> impl Sized; | ---------------------------- `foo` from trait diff --git a/tests/ui/impl-trait/in-trait/early.rs b/tests/ui/impl-trait/in-trait/early.rs index bb5718b4934..c4996674dd1 100644 --- a/tests/ui/impl-trait/in-trait/early.rs +++ b/tests/ui/impl-trait/in-trait/early.rs @@ -1,7 +1,6 @@ // check-pass // edition:2021 -#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] #![allow(incomplete_features)] pub trait Foo { diff --git a/tests/ui/impl-trait/in-trait/encode.rs b/tests/ui/impl-trait/in-trait/encode.rs index efb9f6498ba..4df26b0f297 100644 --- a/tests/ui/impl-trait/in-trait/encode.rs +++ b/tests/ui/impl-trait/in-trait/encode.rs @@ -1,7 +1,6 @@ // build-pass // compile-flags: --crate-type=lib -#![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] trait Foo { diff --git a/tests/ui/impl-trait/in-trait/gat-outlives.rs b/tests/ui/impl-trait/in-trait/gat-outlives.rs new file mode 100644 index 00000000000..83dd6cfce53 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/gat-outlives.rs @@ -0,0 +1,17 @@ +// edition: 2021 + +use std::future::Future; + +trait Trait { + type Gat<'a>; + //~^ ERROR missing required bound on `Gat` + async fn foo(&self) -> Self::Gat<'_>; +} + +trait Trait2 { + type Gat<'a>; + //~^ ERROR missing required bound on `Gat` + async fn foo(&self) -> impl Future<Output = Self::Gat<'_>>; +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/gat-outlives.stderr b/tests/ui/impl-trait/in-trait/gat-outlives.stderr new file mode 100644 index 00000000000..8ec4b0ab2ee --- /dev/null +++ b/tests/ui/impl-trait/in-trait/gat-outlives.stderr @@ -0,0 +1,24 @@ +error: missing required bound on `Gat` + --> $DIR/gat-outlives.rs:6:5 + | +LL | type Gat<'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 `Gat` + --> $DIR/gat-outlives.rs:12:5 + | +LL | type Gat<'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: aborting due to 2 previous errors + diff --git a/tests/ui/impl-trait/in-trait/generics-mismatch.rs b/tests/ui/impl-trait/in-trait/generics-mismatch.rs index cc0fc720ebb..2e5373dbd5d 100644 --- a/tests/ui/impl-trait/in-trait/generics-mismatch.rs +++ b/tests/ui/impl-trait/in-trait/generics-mismatch.rs @@ -1,4 +1,3 @@ -#![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] struct U; diff --git a/tests/ui/impl-trait/in-trait/generics-mismatch.stderr b/tests/ui/impl-trait/in-trait/generics-mismatch.stderr index cd42683e022..3dbf2235c5e 100644 --- a/tests/ui/impl-trait/in-trait/generics-mismatch.stderr +++ b/tests/ui/impl-trait/in-trait/generics-mismatch.stderr @@ -1,5 +1,5 @@ error[E0049]: method `bar` has 1 type parameter but its trait declaration has 0 type parameters - --> $DIR/generics-mismatch.rs:11:12 + --> $DIR/generics-mismatch.rs:10:12 | LL | fn bar(&self) -> impl Sized; | - expected 0 type parameters diff --git a/tests/ui/impl-trait/in-trait/issue-102140.rs b/tests/ui/impl-trait/in-trait/issue-102140.rs index be1e012acb1..1132bd25f81 100644 --- a/tests/ui/impl-trait/in-trait/issue-102140.rs +++ b/tests/ui/impl-trait/in-trait/issue-102140.rs @@ -1,4 +1,3 @@ -#![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] trait Marker {} diff --git a/tests/ui/impl-trait/in-trait/issue-102140.stderr b/tests/ui/impl-trait/in-trait/issue-102140.stderr index 18bb63745d7..6d50d2f3a24 100644 --- a/tests/ui/impl-trait/in-trait/issue-102140.stderr +++ b/tests/ui/impl-trait/in-trait/issue-102140.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied - --> $DIR/issue-102140.rs:23:22 + --> $DIR/issue-102140.rs:22:22 | LL | MyTrait::foo(&self) | ------------ ^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` @@ -13,7 +13,7 @@ LL + MyTrait::foo(self) | error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied - --> $DIR/issue-102140.rs:23:9 + --> $DIR/issue-102140.rs:22:9 | LL | MyTrait::foo(&self) | ^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` @@ -21,7 +21,7 @@ LL | MyTrait::foo(&self) = help: the trait `MyTrait` is implemented for `Outer` error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied - --> $DIR/issue-102140.rs:23:9 + --> $DIR/issue-102140.rs:22:9 | LL | MyTrait::foo(&self) | ^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` diff --git a/tests/ui/impl-trait/in-trait/issue-102301.rs b/tests/ui/impl-trait/in-trait/issue-102301.rs index a93714a658e..600a21b07be 100644 --- a/tests/ui/impl-trait/in-trait/issue-102301.rs +++ b/tests/ui/impl-trait/in-trait/issue-102301.rs @@ -1,6 +1,5 @@ // check-pass -#![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] trait Foo<T> { diff --git a/tests/ui/impl-trait/in-trait/issue-102571.rs b/tests/ui/impl-trait/in-trait/issue-102571.rs index ccb53031c44..4534753f0d2 100644 --- a/tests/ui/impl-trait/in-trait/issue-102571.rs +++ b/tests/ui/impl-trait/in-trait/issue-102571.rs @@ -1,4 +1,3 @@ -#![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] use std::fmt::Display; diff --git a/tests/ui/impl-trait/in-trait/issue-102571.stderr b/tests/ui/impl-trait/in-trait/issue-102571.stderr index 594b9ae9cd6..4d1a0feb22b 100644 --- a/tests/ui/impl-trait/in-trait/issue-102571.stderr +++ b/tests/ui/impl-trait/in-trait/issue-102571.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-102571.rs:12:9 + --> $DIR/issue-102571.rs:11:9 | LL | let () = t.bar(); | ^^ ------- this expression has type `impl Deref<Target = impl std::fmt::Display + ?Sized>` diff --git a/tests/ui/impl-trait/in-trait/lifetime-in-associated-trait-bound.rs b/tests/ui/impl-trait/in-trait/lifetime-in-associated-trait-bound.rs index 49d36d6c99c..4073ef8ac19 100644 --- a/tests/ui/impl-trait/in-trait/lifetime-in-associated-trait-bound.rs +++ b/tests/ui/impl-trait/in-trait/lifetime-in-associated-trait-bound.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(associated_type_bounds, return_position_impl_trait_in_trait)] +#![feature(associated_type_bounds)] trait Trait { type Type; diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr index 239c4b35c72..874a1b95a43 100644 --- a/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr +++ b/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr @@ -1,15 +1,15 @@ error[E0053]: method `early` has an incompatible type for trait - --> $DIR/method-signature-matches.rs:58:27 + --> $DIR/method-signature-matches.rs:57:27 | LL | fn early<'late, T>(_: &'late ()) {} | - ^^^^^^^^^ | | | | | expected type parameter `T`, found `()` | | help: change the parameter type to match the trait: `&T` - | this type parameter + | expected this type parameter | note: type in trait - --> $DIR/method-signature-matches.rs:53:28 + --> $DIR/method-signature-matches.rs:52:28 | LL | fn early<'early, T>(x: &'early T) -> impl Sized; | ^^^^^^^^^ diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch.stderr index d3183b92e84..e0bd1cc4f19 100644 --- a/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch.stderr +++ b/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch.stderr @@ -1,5 +1,5 @@ error[E0053]: method `owo` has an incompatible type for trait - --> $DIR/method-signature-matches.rs:14:15 + --> $DIR/method-signature-matches.rs:13:15 | LL | fn owo(_: u8) {} | ^^ @@ -8,7 +8,7 @@ LL | fn owo(_: u8) {} | help: change the parameter type to match the trait: `()` | note: type in trait - --> $DIR/method-signature-matches.rs:9:15 + --> $DIR/method-signature-matches.rs:8:15 | LL | fn owo(x: ()) -> impl Sized; | ^^ diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch_async.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch_async.stderr index 80fda1c9fe1..096e96c85c4 100644 --- a/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch_async.stderr +++ b/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch_async.stderr @@ -1,5 +1,5 @@ error[E0053]: method `owo` has an incompatible type for trait - --> $DIR/method-signature-matches.rs:25:21 + --> $DIR/method-signature-matches.rs:24:21 | LL | async fn owo(_: u8) {} | ^^ @@ -8,7 +8,7 @@ LL | async fn owo(_: u8) {} | help: change the parameter type to match the trait: `()` | note: type in trait - --> $DIR/method-signature-matches.rs:20:21 + --> $DIR/method-signature-matches.rs:19:21 | LL | async fn owo(x: ()) {} | ^^ diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.rs b/tests/ui/impl-trait/in-trait/method-signature-matches.rs index 294f93b30d0..99ace66facb 100644 --- a/tests/ui/impl-trait/in-trait/method-signature-matches.rs +++ b/tests/ui/impl-trait/in-trait/method-signature-matches.rs @@ -1,7 +1,6 @@ // edition: 2021 // revisions: mismatch mismatch_async too_many too_few lt -#![feature(return_position_impl_trait_in_trait, async_fn_in_trait)] #![allow(incomplete_features)] #[cfg(mismatch)] diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.too_few.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.too_few.stderr index 24bcfeb748f..96eff1a5815 100644 --- a/tests/ui/impl-trait/in-trait/method-signature-matches.too_few.stderr +++ b/tests/ui/impl-trait/in-trait/method-signature-matches.too_few.stderr @@ -1,5 +1,5 @@ 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:47:5 + --> $DIR/method-signature-matches.rs:46:5 | LL | fn come_on_a_little_more_effort(_: (), _: (), _: ()) -> impl Sized; | ---------------- trait requires 3 parameters diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.too_many.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.too_many.stderr index 616cbd2905c..0fc847051c9 100644 --- a/tests/ui/impl-trait/in-trait/method-signature-matches.too_many.stderr +++ b/tests/ui/impl-trait/in-trait/method-signature-matches.too_many.stderr @@ -1,5 +1,5 @@ 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:36:28 + --> $DIR/method-signature-matches.rs:35:28 | LL | fn calm_down_please() -> impl Sized; | ------------------------------------ trait requires 0 parameters diff --git a/tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.rs b/tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.rs index abc845d3afa..6088dcc61d6 100644 --- a/tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.rs +++ b/tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.rs @@ -1,5 +1,3 @@ -#![feature(return_position_impl_trait_in_trait)] - trait Iterable { type Item<'a> where diff --git a/tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.stderr b/tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.stderr index 0d74c0b69ce..1fd678a1f3a 100644 --- a/tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.stderr +++ b/tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.stderr @@ -1,5 +1,5 @@ error[E0261]: use of undeclared lifetime name `'missing` - --> $DIR/missing-lt-outlives-in-rpitit-114274.rs:8:55 + --> $DIR/missing-lt-outlives-in-rpitit-114274.rs:6:55 | LL | fn iter(&self) -> impl Iterator<Item = Self::Item<'missing>>; | ^^^^^^^^ undeclared lifetime diff --git a/tests/ui/impl-trait/in-trait/nested-rpitit.rs b/tests/ui/impl-trait/in-trait/nested-rpitit.rs index 58ba1acaf14..58b79c99155 100644 --- a/tests/ui/impl-trait/in-trait/nested-rpitit.rs +++ b/tests/ui/impl-trait/in-trait/nested-rpitit.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(return_position_impl_trait_in_trait, lint_reasons)] +#![feature(lint_reasons)] #![allow(incomplete_features)] use std::fmt::Display; diff --git a/tests/ui/impl-trait/in-trait/object-safety-sized.rs b/tests/ui/impl-trait/in-trait/object-safety-sized.rs index f221cfbb176..35afe80c97f 100644 --- a/tests/ui/impl-trait/in-trait/object-safety-sized.rs +++ b/tests/ui/impl-trait/in-trait/object-safety-sized.rs @@ -2,7 +2,6 @@ // revisions: current next //[next] compile-flags: -Ztrait-solver=next -#![feature(return_position_impl_trait_in_trait)] fn main() { let vec: Vec<Box<dyn Trait>> = Vec::new(); diff --git a/tests/ui/impl-trait/in-trait/object-safety.rs b/tests/ui/impl-trait/in-trait/object-safety.rs index d1c9fba4e99..15634537dae 100644 --- a/tests/ui/impl-trait/in-trait/object-safety.rs +++ b/tests/ui/impl-trait/in-trait/object-safety.rs @@ -1,4 +1,3 @@ -#![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] use std::fmt::Debug; diff --git a/tests/ui/impl-trait/in-trait/object-safety.stderr b/tests/ui/impl-trait/in-trait/object-safety.stderr index 0170dc5d0fc..8d882391251 100644 --- a/tests/ui/impl-trait/in-trait/object-safety.stderr +++ b/tests/ui/impl-trait/in-trait/object-safety.stderr @@ -1,11 +1,11 @@ error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:17:33 + --> $DIR/object-safety.rs:16:33 | 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:22 + --> $DIR/object-safety.rs:6:22 | LL | trait Foo { | --- this trait cannot be made into an object... @@ -14,13 +14,13 @@ LL | fn baz(&self) -> impl Debug; = help: consider moving `baz` to another trait error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:20:15 + --> $DIR/object-safety.rs:19:15 | 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:22 + --> $DIR/object-safety.rs:6:22 | LL | trait Foo { | --- this trait cannot be made into an object... @@ -29,13 +29,13 @@ LL | fn baz(&self) -> impl Debug; = help: consider moving `baz` to another trait error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:20:13 + --> $DIR/object-safety.rs:19:13 | 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:22 + --> $DIR/object-safety.rs:6:22 | LL | trait Foo { | --- this trait cannot be made into an object... @@ -44,13 +44,13 @@ LL | fn baz(&self) -> impl Debug; = help: consider moving `baz` to another trait error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:17:13 + --> $DIR/object-safety.rs:16:13 | 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:22 + --> $DIR/object-safety.rs:6:22 | LL | trait Foo { | --- this trait cannot be made into an object... diff --git a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs index 3ac264e8eba..fc708536b0f 100644 --- a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs +++ b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs @@ -1,4 +1,3 @@ -#![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] use std::fmt::Display; diff --git a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr index 15edda48340..99b62e80acd 100644 --- a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr +++ b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/opaque-in-impl-is-opaque.rs:17:19 + --> $DIR/opaque-in-impl-is-opaque.rs:16:19 | LL | fn bar(&self) -> impl Display { | ------------ the found opaque type diff --git a/tests/ui/impl-trait/in-trait/opaque-in-impl.rs b/tests/ui/impl-trait/in-trait/opaque-in-impl.rs index 2e06629699a..3edd588a1b3 100644 --- a/tests/ui/impl-trait/in-trait/opaque-in-impl.rs +++ b/tests/ui/impl-trait/in-trait/opaque-in-impl.rs @@ -1,6 +1,5 @@ // check-pass -#![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] use std::fmt::Debug; diff --git a/tests/ui/impl-trait/in-trait/outlives-in-nested-rpit.rs b/tests/ui/impl-trait/in-trait/outlives-in-nested-rpit.rs index 6330242ceeb..317ff7fe853 100644 --- a/tests/ui/impl-trait/in-trait/outlives-in-nested-rpit.rs +++ b/tests/ui/impl-trait/in-trait/outlives-in-nested-rpit.rs @@ -1,6 +1,5 @@ // check-pass -#![feature(return_position_impl_trait_in_trait)] trait Foo { fn early<'a, T: 'a>(x: &'a T) -> impl Iterator<Item = impl Into<&'a T>>; diff --git a/tests/ui/impl-trait/in-trait/refine.rs b/tests/ui/impl-trait/in-trait/refine.rs index f00478b0bb9..100e6da06a8 100644 --- a/tests/ui/impl-trait/in-trait/refine.rs +++ b/tests/ui/impl-trait/in-trait/refine.rs @@ -1,4 +1,3 @@ -#![feature(return_position_impl_trait_in_trait, async_fn_in_trait)] #![deny(refining_impl_trait)] pub trait Foo { diff --git a/tests/ui/impl-trait/in-trait/refine.stderr b/tests/ui/impl-trait/in-trait/refine.stderr index 1d9852c682c..96a9bc059c8 100644 --- a/tests/ui/impl-trait/in-trait/refine.stderr +++ b/tests/ui/impl-trait/in-trait/refine.stderr @@ -1,5 +1,5 @@ error: impl trait in impl method signature does not match trait method signature - --> $DIR/refine.rs:10:22 + --> $DIR/refine.rs:9:22 | LL | fn bar() -> impl Sized; | ---------- return type from trait method defined here @@ -9,7 +9,7 @@ LL | fn bar() -> impl Copy {} | = note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate note: the lint level is defined here - --> $DIR/refine.rs:2:9 + --> $DIR/refine.rs:1:9 | LL | #![deny(refining_impl_trait)] | ^^^^^^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | fn bar() -> impl Sized {} | ~~~~~~~~~~ error: impl trait in impl method signature does not match trait method signature - --> $DIR/refine.rs:16:5 + --> $DIR/refine.rs:15:5 | LL | fn bar() -> impl Sized; | ---------- return type from trait method defined here @@ -34,7 +34,7 @@ LL | fn bar()-> impl Sized {} | +++++++++++++ error: impl trait in impl method signature does not match trait method signature - --> $DIR/refine.rs:22:17 + --> $DIR/refine.rs:21:17 | LL | fn bar() -> impl Sized; | ---------- return type from trait method defined here @@ -49,7 +49,7 @@ LL | fn bar() -> impl Sized {} | ~~~~~~~~~~ error: impl trait in impl method signature does not match trait method signature - --> $DIR/refine.rs:44:27 + --> $DIR/refine.rs:43:27 | LL | fn bar<'a>(&'a self) -> impl Sized + 'a; | --------------- return type from trait method defined here diff --git a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs index 5d9a224ccd6..ad73b12feb5 100644 --- a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs +++ b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs @@ -1,5 +1,3 @@ -#![feature(return_position_impl_trait_in_trait)] - trait Foo<T> { fn foo<F2>(self) -> impl Foo<T>; } diff --git a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr index 668fc6cbe7f..181d6a284da 100644 --- a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr +++ b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr @@ -1,12 +1,12 @@ error[E0277]: the trait bound `impl Foo<u8>: Foo<char>` is not satisfied - --> $DIR/return-dont-satisfy-bounds.rs:10:34 + --> $DIR/return-dont-satisfy-bounds.rs:8:34 | LL | fn foo<F2: Foo<u8>>(self) -> impl Foo<u8> { | ^^^^^^^^^^^^ the trait `Foo<char>` is not implemented for `impl Foo<u8>` | = help: the trait `Foo<char>` is implemented for `Bar` note: required by a bound in `Foo::{opaque#0}` - --> $DIR/return-dont-satisfy-bounds.rs:4:30 + --> $DIR/return-dont-satisfy-bounds.rs:2:30 | LL | fn foo<F2>(self) -> impl Foo<T>; | ^^^^^^ required by this bound in `Foo::{opaque#0}` diff --git a/tests/ui/impl-trait/in-trait/reveal.rs b/tests/ui/impl-trait/in-trait/reveal.rs index b1b46d75b8f..cc78ce8fea2 100644 --- a/tests/ui/impl-trait/in-trait/reveal.rs +++ b/tests/ui/impl-trait/in-trait/reveal.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(return_position_impl_trait_in_trait, lint_reasons)] +#![feature(lint_reasons)] #![allow(incomplete_features)] pub trait Foo { diff --git a/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.rs b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.rs index 5e14a7f8e72..37b0b229776 100644 --- a/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.rs +++ b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.rs @@ -1,5 +1,3 @@ -#![feature(return_position_impl_trait_in_trait)] - trait Extend { fn extend<'a: 'a>(_: &'a str) -> (impl Sized + 'a, &'static str); } diff --git a/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.stderr b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.stderr index 1d947310e12..afc59cc5b58 100644 --- a/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.stderr +++ b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.stderr @@ -1,12 +1,12 @@ error[E0491]: in type `&'static &'a ()`, reference has a longer lifetime than the data it references - --> $DIR/rpitit-hidden-types-self-implied-wf-via-param.rs:8:38 + --> $DIR/rpitit-hidden-types-self-implied-wf-via-param.rs:6:38 | LL | fn extend<'a: 'a>(s: &'a str) -> (Option<&'static &'a ()>, &'static str) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the pointer is valid for the static lifetime note: but the referenced data is only valid for the lifetime `'a` as defined here - --> $DIR/rpitit-hidden-types-self-implied-wf-via-param.rs:8:15 + --> $DIR/rpitit-hidden-types-self-implied-wf-via-param.rs:6:15 | LL | fn extend<'a: 'a>(s: &'a str) -> (Option<&'static &'a ()>, &'static str) | ^^ diff --git a/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.rs b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.rs index c1885af4e5e..bacd5007768 100644 --- a/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.rs +++ b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.rs @@ -1,5 +1,3 @@ -#![feature(return_position_impl_trait_in_trait)] - trait Extend { fn extend(_: &str) -> (impl Sized + '_, &'static str); } diff --git a/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.stderr b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.stderr index 7b63e72acbf..7e1a8f083ac 100644 --- a/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.stderr +++ b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.stderr @@ -1,12 +1,12 @@ error[E0491]: in type `&'static &()`, reference has a longer lifetime than the data it references - --> $DIR/rpitit-hidden-types-self-implied-wf.rs:8:27 + --> $DIR/rpitit-hidden-types-self-implied-wf.rs:6:27 | LL | fn extend(s: &str) -> (Option<&'static &'_ ()>, &'static str) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the pointer is valid for the static lifetime note: but the referenced data is only valid for the anonymous lifetime defined here - --> $DIR/rpitit-hidden-types-self-implied-wf.rs:8:18 + --> $DIR/rpitit-hidden-types-self-implied-wf.rs:6:18 | LL | fn extend(s: &str) -> (Option<&'static &'_ ()>, &'static str) { | ^^^^ diff --git a/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.rs b/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.rs index 44a2b430344..b9fe8d8bfc5 100644 --- a/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.rs +++ b/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.rs @@ -1,6 +1,6 @@ // issue: 113903 -#![feature(return_position_impl_trait_in_trait, lint_reasons)] +#![feature(lint_reasons)] use std::ops::Deref; diff --git a/tests/ui/impl-trait/in-trait/sibling-function-constraint.rs b/tests/ui/impl-trait/in-trait/sibling-function-constraint.rs new file mode 100644 index 00000000000..fe162e6cf80 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/sibling-function-constraint.rs @@ -0,0 +1,21 @@ +// Checks that a sibling function (i.e. `foo`) cannot constrain +// an RPITIT from another function (`bar`). + +trait Trait { + fn foo(); + + fn bar() -> impl Sized; +} + +impl Trait for () { + fn foo() { + let _: String = Self::bar(); + //~^ ERROR mismatched types + } + + fn bar() -> impl Sized { + loop {} + } +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/sibling-function-constraint.stderr b/tests/ui/impl-trait/in-trait/sibling-function-constraint.stderr new file mode 100644 index 00000000000..729963a8141 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/sibling-function-constraint.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/sibling-function-constraint.rs:12:25 + | +LL | let _: String = Self::bar(); + | ------ ^^^^^^^^^^^ expected `String`, found opaque type + | | + | expected due to this +... +LL | fn bar() -> impl Sized { + | ---------- the found opaque type + | + = note: expected struct `String` + found opaque type `impl Sized` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/in-trait/signature-mismatch.rs b/tests/ui/impl-trait/in-trait/signature-mismatch.rs index 685c0f06e88..d85ee5fc704 100644 --- a/tests/ui/impl-trait/in-trait/signature-mismatch.rs +++ b/tests/ui/impl-trait/in-trait/signature-mismatch.rs @@ -2,7 +2,7 @@ // revisions: success failure //[success] check-pass -#![feature(return_position_impl_trait_in_trait, lint_reasons)] +#![feature(lint_reasons)] use std::future::Future; diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.rs b/tests/ui/impl-trait/in-trait/specialization-broken.rs index 2fcffdf3f9a..a06cd814f7c 100644 --- a/tests/ui/impl-trait/in-trait/specialization-broken.rs +++ b/tests/ui/impl-trait/in-trait/specialization-broken.rs @@ -2,7 +2,6 @@ // But we fixed an ICE anyways. #![feature(specialization)] -#![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] trait Foo { diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.stderr b/tests/ui/impl-trait/in-trait/specialization-broken.stderr index dc621d6b8a8..25c0adeddbd 100644 --- a/tests/ui/impl-trait/in-trait/specialization-broken.stderr +++ b/tests/ui/impl-trait/in-trait/specialization-broken.stderr @@ -1,8 +1,8 @@ error[E0053]: method `bar` has an incompatible type for trait - --> $DIR/specialization-broken.rs:16:22 + --> $DIR/specialization-broken.rs:15:22 | LL | default impl<U> Foo for U - | - this type parameter + | - found this type parameter ... LL | fn bar(&self) -> U { | ^ @@ -11,7 +11,7 @@ LL | fn bar(&self) -> U { | help: change the output type to match the trait: `impl Sized` | note: type in trait - --> $DIR/specialization-broken.rs:9:22 + --> $DIR/specialization-broken.rs:8:22 | LL | fn bar(&self) -> impl Sized; | ^^^^^^^^^^ @@ -19,12 +19,12 @@ LL | fn bar(&self) -> impl Sized; found signature `fn(&U) -> U` error: method with return-position `impl Trait` in trait cannot be specialized - --> $DIR/specialization-broken.rs:16:5 + --> $DIR/specialization-broken.rs:15:5 | LL | fn bar(&self) -> U { | ^^^^^^^^^^^^^^^^^^ | - = note: specialization behaves in inconsistent and surprising ways with `#![feature(return_position_impl_trait_in_trait)]`, and for now is disallowed + = note: specialization behaves in inconsistent and surprising ways with return position `impl Trait` in traits, and for now is disallowed error: aborting due to 2 previous errors diff --git a/tests/ui/impl-trait/in-trait/specialization-substs-remap.rs b/tests/ui/impl-trait/in-trait/specialization-substs-remap.rs index 41fc285883a..05386632758 100644 --- a/tests/ui/impl-trait/in-trait/specialization-substs-remap.rs +++ b/tests/ui/impl-trait/in-trait/specialization-substs-remap.rs @@ -1,7 +1,7 @@ // check-pass #![feature(specialization)] -#![feature(return_position_impl_trait_in_trait, lint_reasons)] +#![feature(lint_reasons)] #![allow(incomplete_features)] pub trait Foo { diff --git a/tests/ui/impl-trait/in-trait/success.rs b/tests/ui/impl-trait/in-trait/success.rs index 7d415ea17a4..eb2349feb29 100644 --- a/tests/ui/impl-trait/in-trait/success.rs +++ b/tests/ui/impl-trait/in-trait/success.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(return_position_impl_trait_in_trait, lint_reasons)] +#![feature(lint_reasons)] #![allow(incomplete_features)] use std::fmt::Display; diff --git a/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed b/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed index 58d83384a23..8dc8e045d47 100644 --- a/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed +++ b/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed @@ -1,8 +1,6 @@ // edition:2021 // run-rustfix -#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] - trait Trait { #[allow(async_fn_in_trait)] async fn foo(); diff --git a/tests/ui/impl-trait/in-trait/suggest-missing-item.rs b/tests/ui/impl-trait/in-trait/suggest-missing-item.rs index c27229806e1..30b04d87b9a 100644 --- a/tests/ui/impl-trait/in-trait/suggest-missing-item.rs +++ b/tests/ui/impl-trait/in-trait/suggest-missing-item.rs @@ -1,8 +1,6 @@ // edition:2021 // run-rustfix -#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] - trait Trait { #[allow(async_fn_in_trait)] async fn foo(); diff --git a/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr b/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr index 29f6bad86dc..cec94e39a35 100644 --- a/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr +++ b/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr @@ -1,5 +1,5 @@ error[E0046]: not all trait items implemented, missing: `foo`, `bar`, `test`, `baz` - --> $DIR/suggest-missing-item.rs:21:1 + --> $DIR/suggest-missing-item.rs:19:1 | LL | async fn foo(); | --------------- `foo` from trait diff --git a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs index 0bbe50ea6fd..c905bfce852 100644 --- a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs +++ b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs @@ -1,4 +1,3 @@ -#![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] struct S; diff --git a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.stderr b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.stderr index 8ff54cad951..e904548742d 100644 --- a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.stderr +++ b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.stderr @@ -1,5 +1,5 @@ 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 + --> $DIR/trait-more-generics-than-impl.rs:10:11 | LL | fn bar<T>() -> impl Sized; | - expected 1 type parameter diff --git a/tests/ui/impl-trait/in-trait/unconstrained-lt.rs b/tests/ui/impl-trait/in-trait/unconstrained-lt.rs index 07c8606f9fe..ff3753de5a2 100644 --- a/tests/ui/impl-trait/in-trait/unconstrained-lt.rs +++ b/tests/ui/impl-trait/in-trait/unconstrained-lt.rs @@ -1,5 +1,3 @@ -#![feature(return_position_impl_trait_in_trait)] - trait Foo { fn test() -> impl Sized; } diff --git a/tests/ui/impl-trait/in-trait/unconstrained-lt.stderr b/tests/ui/impl-trait/in-trait/unconstrained-lt.stderr index cfce3556720..61a0f8454d1 100644 --- a/tests/ui/impl-trait/in-trait/unconstrained-lt.stderr +++ b/tests/ui/impl-trait/in-trait/unconstrained-lt.stderr @@ -1,5 +1,5 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates - --> $DIR/unconstrained-lt.rs:7:6 + --> $DIR/unconstrained-lt.rs:5:6 | LL | impl<'a, T> Foo for T { | ^^ unconstrained lifetime parameter diff --git a/tests/ui/impl-trait/in-trait/variance.rs b/tests/ui/impl-trait/in-trait/variance.rs index f8e4ab88c19..65565dcc2a6 100644 --- a/tests/ui/impl-trait/in-trait/variance.rs +++ b/tests/ui/impl-trait/in-trait/variance.rs @@ -1,4 +1,4 @@ -#![feature(rustc_attrs, return_position_impl_trait_in_trait)] +#![feature(rustc_attrs)] #![allow(internal_features)] #![rustc_variance_of_opaques] diff --git a/tests/ui/impl-trait/in-trait/variances-of-gat.rs b/tests/ui/impl-trait/in-trait/variances-of-gat.rs index 0d19e1ff416..aabb6f830ed 100644 --- a/tests/ui/impl-trait/in-trait/variances-of-gat.rs +++ b/tests/ui/impl-trait/in-trait/variances-of-gat.rs @@ -1,6 +1,5 @@ // check-pass -#![feature(return_position_impl_trait_in_trait)] trait Foo {} diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.rs b/tests/ui/impl-trait/in-trait/wf-bounds.rs index ee873f94b26..f1e372b196a 100644 --- a/tests/ui/impl-trait/in-trait/wf-bounds.rs +++ b/tests/ui/impl-trait/in-trait/wf-bounds.rs @@ -1,6 +1,5 @@ // issue #101663 -#![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] use std::fmt::Display; diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.stderr b/tests/ui/impl-trait/in-trait/wf-bounds.stderr index 4d60b133048..c20df9b40ed 100644 --- a/tests/ui/impl-trait/in-trait/wf-bounds.stderr +++ b/tests/ui/impl-trait/in-trait/wf-bounds.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/wf-bounds.rs:15:22 + --> $DIR/wf-bounds.rs:14:22 | LL | fn nya() -> impl Wf<Vec<[u8]>>; | ^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -9,14 +9,14 @@ note: required by a bound in `Vec` --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/wf-bounds.rs:18:23 + --> $DIR/wf-bounds.rs:17:23 | LL | fn nya2() -> impl Wf<[u8]>; | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` note: required by a bound in `Wf` - --> $DIR/wf-bounds.rs:8:10 + --> $DIR/wf-bounds.rs:7:10 | LL | trait Wf<T> { | ^ required by this bound in `Wf` @@ -26,7 +26,7 @@ LL | trait Wf<T: ?Sized> { | ++++++++ error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/wf-bounds.rs:21:44 + --> $DIR/wf-bounds.rs:20:44 | LL | fn nya3() -> impl Wf<(), Output = impl Wf<Vec<[u8]>>>; | ^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -36,14 +36,14 @@ note: required by a bound in `Vec` --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL error[E0277]: `T` doesn't implement `std::fmt::Display` - --> $DIR/wf-bounds.rs:24:26 + --> $DIR/wf-bounds.rs:23:26 | LL | fn nya4<T>() -> impl Wf<NeedsDisplay<T>>; | ^^^^^^^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter | = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `NeedsDisplay` - --> $DIR/wf-bounds.rs:12:24 + --> $DIR/wf-bounds.rs:11:24 | LL | struct NeedsDisplay<T: Display>(T); | ^^^^^^^ required by this bound in `NeedsDisplay` diff --git a/tests/ui/impl-trait/in-trait/where-clause.rs b/tests/ui/impl-trait/in-trait/where-clause.rs index 87bac519cf3..f7f4980b730 100644 --- a/tests/ui/impl-trait/in-trait/where-clause.rs +++ b/tests/ui/impl-trait/in-trait/where-clause.rs @@ -1,7 +1,6 @@ // check-pass // edition: 2021 -#![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] use std::fmt::Debug; diff --git a/tests/ui/impl-trait/nested-return-type2-tait2.rs b/tests/ui/impl-trait/nested-return-type2-tait2.rs index af8e0663054..b7fee1d91d1 100644 --- a/tests/ui/impl-trait/nested-return-type2-tait2.rs +++ b/tests/ui/impl-trait/nested-return-type2-tait2.rs @@ -1,3 +1,5 @@ +// check-pass + #![feature(type_alias_impl_trait)] trait Duh {} @@ -17,6 +19,7 @@ impl<R: Duh, F: FnMut() -> R> Trait for F { type Sendable = impl Send; type Traitable = impl Trait<Assoc = Sendable>; +//~^ WARN opaque type `Traitable` does not satisfy its associated type bounds // The `impl Send` here is then later compared against the inference var // created, causing the inference var to be set to `impl Send` instead of @@ -25,7 +28,6 @@ type Traitable = impl Trait<Assoc = Sendable>; // type does not implement `Duh`, even if its hidden type does. So we error out. fn foo() -> Traitable { || 42 - //~^ ERROR `Sendable: Duh` is not satisfied } fn main() { diff --git a/tests/ui/impl-trait/nested-return-type2-tait2.stderr b/tests/ui/impl-trait/nested-return-type2-tait2.stderr index 125262b96e8..790e339c8b1 100644 --- a/tests/ui/impl-trait/nested-return-type2-tait2.stderr +++ b/tests/ui/impl-trait/nested-return-type2-tait2.stderr @@ -1,18 +1,13 @@ -error[E0277]: the trait bound `Sendable: Duh` is not satisfied - --> $DIR/nested-return-type2-tait2.rs:27:5 +warning: opaque type `Traitable` does not satisfy its associated type bounds + --> $DIR/nested-return-type2-tait2.rs:21:29 | -LL | || 42 - | ^^^^^ the trait `Duh` is not implemented for `Sendable` +LL | type Assoc: Duh; + | --- this associated type bound is unsatisfied for `Sendable` +... +LL | type Traitable = impl Trait<Assoc = Sendable>; + | ^^^^^^^^^^^^^^^^ | - = help: the trait `Duh` is implemented for `i32` -note: required for `{closure@$DIR/nested-return-type2-tait2.rs:27:5: 27:7}` to implement `Trait` - --> $DIR/nested-return-type2-tait2.rs:14:31 - | -LL | impl<R: Duh, F: FnMut() -> R> Trait for F { - | --- ^^^^^ ^ - | | - | unsatisfied trait bound introduced here + = note: `#[warn(opaque_hidden_inferred_bound)]` on by default -error: aborting due to previous error +warning: 1 warning emitted -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/nested-return-type2-tait3.rs b/tests/ui/impl-trait/nested-return-type2-tait3.rs index 74fd8a9dda0..eed5c271f88 100644 --- a/tests/ui/impl-trait/nested-return-type2-tait3.rs +++ b/tests/ui/impl-trait/nested-return-type2-tait3.rs @@ -1,3 +1,5 @@ +// check-pass + #![feature(type_alias_impl_trait)] trait Duh {} @@ -16,6 +18,7 @@ impl<R: Duh, F: FnMut() -> R> Trait for F { } type Traitable = impl Trait<Assoc = impl Send>; +//~^ WARN opaque type `Traitable` does not satisfy its associated type bounds // The `impl Send` here is then later compared against the inference var // created, causing the inference var to be set to `impl Send` instead of @@ -24,7 +27,6 @@ type Traitable = impl Trait<Assoc = impl Send>; // type does not implement `Duh`, even if its hidden type does. So we error out. fn foo() -> Traitable { || 42 - //~^ ERROR `impl Send: Duh` is not satisfied } fn main() { diff --git a/tests/ui/impl-trait/nested-return-type2-tait3.stderr b/tests/ui/impl-trait/nested-return-type2-tait3.stderr index c2332b6e4bd..72aa51a23f4 100644 --- a/tests/ui/impl-trait/nested-return-type2-tait3.stderr +++ b/tests/ui/impl-trait/nested-return-type2-tait3.stderr @@ -1,18 +1,17 @@ -error[E0277]: the trait bound `impl Send: Duh` is not satisfied - --> $DIR/nested-return-type2-tait3.rs:26:5 +warning: opaque type `Traitable` does not satisfy its associated type bounds + --> $DIR/nested-return-type2-tait3.rs:20:29 | -LL | || 42 - | ^^^^^ the trait `Duh` is not implemented for `impl Send` +LL | type Assoc: Duh; + | --- this associated type bound is unsatisfied for `impl Send` +... +LL | type Traitable = impl Trait<Assoc = impl Send>; + | ^^^^^^^^^^^^^^^^^ | - = help: the trait `Duh` is implemented for `i32` -note: required for `{closure@$DIR/nested-return-type2-tait3.rs:26:5: 26:7}` to implement `Trait` - --> $DIR/nested-return-type2-tait3.rs:14:31 + = note: `#[warn(opaque_hidden_inferred_bound)]` on by default +help: add this bound | -LL | impl<R: Duh, F: FnMut() -> R> Trait for F { - | --- ^^^^^ ^ - | | - | unsatisfied trait bound introduced here +LL | type Traitable = impl Trait<Assoc = impl Send + Duh>; + | +++++ -error: aborting due to previous error +warning: 1 warning emitted -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/static-lifetime-return-position-impl-trait.rs b/tests/ui/impl-trait/static-lifetime-return-position-impl-trait.rs index 98dbaf036be..91a0e0d4829 100644 --- a/tests/ui/impl-trait/static-lifetime-return-position-impl-trait.rs +++ b/tests/ui/impl-trait/static-lifetime-return-position-impl-trait.rs @@ -1,7 +1,7 @@ // check-pass #![allow(incomplete_features)] -#![feature(adt_const_params, return_position_impl_trait_in_trait)] +#![feature(adt_const_params)] pub struct Element; diff --git a/tests/ui/impl-trait/universal-mismatched-type.stderr b/tests/ui/impl-trait/universal-mismatched-type.stderr index a56e542d834..82e0f23964f 100644 --- a/tests/ui/impl-trait/universal-mismatched-type.stderr +++ b/tests/ui/impl-trait/universal-mismatched-type.stderr @@ -4,7 +4,7 @@ error[E0308]: mismatched types LL | fn foo(x: impl Debug) -> String { | ---------- ------ expected `String` because of return type | | - | this type parameter + | found this type parameter LL | x | ^ expected `String`, found type parameter `impl Debug` | diff --git a/tests/ui/impl-trait/where-allowed.rs b/tests/ui/impl-trait/where-allowed.rs index d3fab326e74..158dc5ab974 100644 --- a/tests/ui/impl-trait/where-allowed.rs +++ b/tests/ui/impl-trait/where-allowed.rs @@ -104,10 +104,9 @@ trait InTraitDefnParameters { fn in_parameters(_: impl Debug); } -// Disallowed +// Allowed trait InTraitDefnReturn { fn in_return() -> impl Debug; - //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types } // Allowed and disallowed in trait impls @@ -124,7 +123,7 @@ impl DummyTrait for () { // Allowed fn in_trait_impl_return() -> impl Debug { () } - //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types + // Allowed } // Allowed diff --git a/tests/ui/impl-trait/where-allowed.stderr b/tests/ui/impl-trait/where-allowed.stderr index bd7c9a94793..2d8895030f2 100644 --- a/tests/ui/impl-trait/where-allowed.stderr +++ b/tests/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 associated types is unstable - --> $DIR/where-allowed.rs:120:16 + --> $DIR/where-allowed.rs:119:16 | LL | type Out = impl Debug; | ^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | type Out = impl Debug; = help: add `#![feature(impl_trait_in_assoc_type)]` to the crate attributes to enable error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:155:23 + --> $DIR/where-allowed.rs:154: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:158:39 + --> $DIR/where-allowed.rs:157:39 | LL | type InReturnInTypeAlias<R> = fn() -> impl Debug; | ^^^^^^^^^^ @@ -145,146 +145,128 @@ error[E0562]: `impl Trait` only allowed in function and inherent method argument LL | InTupleVariant(impl Debug), | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return types - --> $DIR/where-allowed.rs:109:23 - | -LL | fn in_return() -> impl Debug; - | ^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = 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 argument and return types, not in `impl` method return types - --> $DIR/where-allowed.rs:126:34 - | -LL | fn in_trait_impl_return() -> impl Debug { () } - | ^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = 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 argument and return types, not in `extern fn` params - --> $DIR/where-allowed.rs:139:33 + --> $DIR/where-allowed.rs:138:33 | LL | fn in_foreign_parameters(_: impl Debug); | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `extern fn` return types - --> $DIR/where-allowed.rs:142:31 + --> $DIR/where-allowed.rs:141:31 | LL | fn in_foreign_return() -> impl Debug; | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `fn` pointer return types - --> $DIR/where-allowed.rs:158:39 + --> $DIR/where-allowed.rs:157:39 | LL | type InReturnInTypeAlias<R> = fn() -> impl Debug; | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in traits - --> $DIR/where-allowed.rs:163:16 + --> $DIR/where-allowed.rs:162:16 | LL | impl PartialEq<impl Debug> for () { | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in impl headers - --> $DIR/where-allowed.rs:168:24 + --> $DIR/where-allowed.rs:167:24 | LL | impl PartialEq<()> for impl Debug { | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in impl headers - --> $DIR/where-allowed.rs:173:6 + --> $DIR/where-allowed.rs:172:6 | LL | impl impl Debug { | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in impl headers - --> $DIR/where-allowed.rs:179:24 + --> $DIR/where-allowed.rs:178:24 | LL | impl InInherentImplAdt<impl Debug> { | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in bounds - --> $DIR/where-allowed.rs:185:11 + --> $DIR/where-allowed.rs:184:11 | LL | where impl Debug: Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in bounds - --> $DIR/where-allowed.rs:192:15 + --> $DIR/where-allowed.rs:191:15 | LL | where Vec<impl Debug>: Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in bounds - --> $DIR/where-allowed.rs:199:24 + --> $DIR/where-allowed.rs:198:24 | LL | where T: PartialEq<impl Debug> | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait params - --> $DIR/where-allowed.rs:206:17 + --> $DIR/where-allowed.rs:205:17 | LL | where T: Fn(impl Debug) | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return types - --> $DIR/where-allowed.rs:213:22 + --> $DIR/where-allowed.rs:212:22 | LL | where T: Fn() -> impl Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults - --> $DIR/where-allowed.rs:219:40 + --> $DIR/where-allowed.rs:218:40 | LL | struct InStructGenericParamDefault<T = impl Debug>(T); | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults - --> $DIR/where-allowed.rs:223:36 + --> $DIR/where-allowed.rs:222:36 | LL | enum InEnumGenericParamDefault<T = impl Debug> { Variant(T) } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults - --> $DIR/where-allowed.rs:227:38 + --> $DIR/where-allowed.rs:226:38 | LL | trait InTraitGenericParamDefault<T = impl Debug> {} | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults - --> $DIR/where-allowed.rs:231:41 + --> $DIR/where-allowed.rs:230:41 | LL | type InTypeAliasGenericParamDefault<T = impl Debug> = T; | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults - --> $DIR/where-allowed.rs:235:11 + --> $DIR/where-allowed.rs:234:11 | LL | impl <T = impl Debug> T {} | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults - --> $DIR/where-allowed.rs:242:40 + --> $DIR/where-allowed.rs:241:40 | LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {} | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings - --> $DIR/where-allowed.rs:248:29 + --> $DIR/where-allowed.rs:247:29 | LL | let _in_local_variable: impl Fn() = || {}; | ^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in closure return types - --> $DIR/where-allowed.rs:250:46 + --> $DIR/where-allowed.rs:249: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:235:7 + --> $DIR/where-allowed.rs:234:7 | LL | impl <T = impl Debug> T {} | ^^^^^^^^^^^^^^ @@ -294,7 +276,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:242:36 + --> $DIR/where-allowed.rs:241:36 | LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {} | ^^^^^^^^^^^^^^ @@ -303,14 +285,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:235:1 + --> $DIR/where-allowed.rs:234:1 | 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 47 previous errors +error: aborting due to 45 previous errors Some errors have detailed explanations: E0118, E0562, E0658, E0666. For more information about an error, try `rustc --explain E0118`. diff --git a/tests/ui/inference/issue-107090.stderr b/tests/ui/inference/issue-107090.stderr index 6233b629ad6..55825f7765b 100644 --- a/tests/ui/inference/issue-107090.stderr +++ b/tests/ui/inference/issue-107090.stderr @@ -70,7 +70,7 @@ error[E0308]: mismatched types --> $DIR/issue-107090.rs:22:5 | LL | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short, 'out, T>) -> &'out T { - | - this type parameter ------- expected `&'out T` because of return type + | - expected this type parameter ------- expected `&'out T` because of return type LL | LL | sadness.cast() | ^^^^^^^^^^^^^^ expected `&T`, found `&Foo<'_, '_, T>` diff --git a/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.rs b/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.rs new file mode 100644 index 00000000000..4544c898ab8 --- /dev/null +++ b/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.rs @@ -0,0 +1,61 @@ +struct MyError; + +fn foo(x: bool) -> Result<(), MyError> { + if x { + Err(MyError); + //~^ ERROR type annotations needed + } + + Ok(()) +} + +fn bar(x: bool) -> Result<(), MyError> { + if x { + Ok(()); + //~^ ERROR type annotations needed + } + + Ok(()) +} + +fn baz(x: bool) -> Result<(), MyError> { + //~^ ERROR mismatched types + if x { + 1; + } + + Err(MyError); +} + +fn error() -> Result<(), MyError> { + Err(MyError) +} + +fn bak(x: bool) -> Result<(), MyError> { + if x { + //~^ ERROR mismatched types + error(); + } else { + //~^ ERROR mismatched types + error(); + } +} + +fn bad(x: bool) -> Result<(), MyError> { + Err(MyError); //~ ERROR type annotations needed + Ok(()) +} + +fn with_closure<F, A, B>(_: F) -> i32 +where + F: FnOnce(A, B), +{ + 0 +} + +fn a() -> i32 { + with_closure(|x: u32, y| {}); //~ ERROR type annotations needed + 0 +} + +fn main() {} diff --git a/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.stderr b/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.stderr new file mode 100644 index 00000000000..1fea73529a8 --- /dev/null +++ b/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.stderr @@ -0,0 +1,98 @@ +error[E0282]: type annotations needed + --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:5:9 + | +LL | Err(MyError); + | ^^^ cannot infer type of the type parameter `T` declared on the enum `Result` + | +help: consider specifying the generic arguments + | +LL | Err::<T, MyError>(MyError); + | ++++++++++++++ +help: you might have meant to return this to infer its type parameters + | +LL | return Err(MyError); + | ++++++ + +error[E0282]: type annotations needed + --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:14:9 + | +LL | Ok(()); + | ^^ cannot infer type of the type parameter `E` declared on the enum `Result` + | +help: consider specifying the generic arguments + | +LL | Ok::<(), E>(()); + | +++++++++ +help: you might have meant to return this to infer its type parameters + | +LL | return Ok(()); + | ++++++ + +error[E0308]: mismatched types + --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:21:20 + | +LL | fn baz(x: bool) -> Result<(), MyError> { + | --- ^^^^^^^^^^^^^^^^^^^ expected `Result<(), MyError>`, found `()` + | | + | implicitly returns `()` as its body has no tail or `return` expression +... +LL | Err(MyError); + | - help: remove this semicolon to return this value + | + = note: expected enum `Result<(), MyError>` + found unit type `()` + +error[E0308]: mismatched types + --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:35:10 + | +LL | if x { + | __________^ +LL | | +LL | | error(); + | | - help: remove this semicolon to return this value +LL | | } else { + | |_____^ expected `Result<(), MyError>`, found `()` + | + = note: expected enum `Result<(), MyError>` + found unit type `()` + +error[E0308]: mismatched types + --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:38:12 + | +LL | } else { + | ____________^ +LL | | +LL | | error(); + | | - help: remove this semicolon to return this value +LL | | } + | |_____^ expected `Result<(), MyError>`, found `()` + | + = note: expected enum `Result<(), MyError>` + found unit type `()` + +error[E0282]: type annotations needed + --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:45:5 + | +LL | Err(MyError); + | ^^^ cannot infer type of the type parameter `T` declared on the enum `Result` + | +help: consider specifying the generic arguments + | +LL | Err::<T, MyError>(MyError); + | ++++++++++++++ + +error[E0282]: type annotations needed + --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:57:27 + | +LL | with_closure(|x: u32, y| {}); + | ^ + | +help: consider giving this closure parameter an explicit type + | +LL | with_closure(|x: u32, y: /* Type */| {}); + | ++++++++++++ + +error: aborting due to 7 previous errors + +Some errors have detailed explanations: E0282, E0308. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr index 4fc304cda60..317466eb322 100644 --- a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr +++ b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/intrinsic-raw_eq-const-bad.rs:5:5 | LL | std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at alloc3[0x0..0x4], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory error[E0080]: evaluation of constant value failed --> $DIR/intrinsic-raw_eq-const-bad.rs:11:5 diff --git a/tests/ui/issues/issue-20225.stderr b/tests/ui/issues/issue-20225.stderr index b1c15672051..b34aa8e1ff5 100644 --- a/tests/ui/issues/issue-20225.stderr +++ b/tests/ui/issues/issue-20225.stderr @@ -2,7 +2,7 @@ error[E0053]: method `call` has an incompatible type for trait --> $DIR/issue-20225.rs:6:43 | LL | impl<'a, T> Fn<(&'a T,)> for Foo { - | - this type parameter + | - found this type parameter LL | extern "rust-call" fn call(&self, (_,): (T,)) {} | ^^^^ | | @@ -16,7 +16,7 @@ error[E0053]: method `call_mut` has an incompatible type for trait --> $DIR/issue-20225.rs:11:51 | LL | impl<'a, T> FnMut<(&'a T,)> for Foo { - | - this type parameter + | - found this type parameter LL | extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {} | ^^^^ | | @@ -30,7 +30,7 @@ error[E0053]: method `call_once` has an incompatible type for trait --> $DIR/issue-20225.rs:18:47 | LL | impl<'a, T> FnOnce<(&'a T,)> for Foo { - | - this type parameter + | - found this type parameter ... LL | extern "rust-call" fn call_once(self, (_,): (T,)) {} | ^^^^ diff --git a/tests/ui/issues/issue-51154.stderr b/tests/ui/issues/issue-51154.stderr index 002d5ccdc67..5ae8e067807 100644 --- a/tests/ui/issues/issue-51154.stderr +++ b/tests/ui/issues/issue-51154.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-51154.rs:2:30 | LL | fn foo<F: FnMut()>() { - | - this type parameter + | - expected this type parameter LL | let _: Box<F> = Box::new(|| ()); | -------- ^^^^^ expected type parameter `F`, found closure | | diff --git a/tests/ui/issues/issue-69306.stderr b/tests/ui/issues/issue-69306.stderr index 570677298ff..6fc5c33af6a 100644 --- a/tests/ui/issues/issue-69306.stderr +++ b/tests/ui/issues/issue-69306.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-69306.rs:5:28 | LL | impl<T> S0<T> { - | - this type parameter + | - expected this type parameter LL | const C: S0<u8> = Self(0); | ---- ^ expected type parameter `T`, found integer | | @@ -20,7 +20,7 @@ error[E0308]: mismatched types --> $DIR/issue-69306.rs:5:23 | LL | impl<T> S0<T> { - | - this type parameter + | - found this type parameter LL | const C: S0<u8> = Self(0); | ^^^^^^^ expected `S0<u8>`, found `S0<T>` | @@ -31,7 +31,7 @@ error[E0308]: mismatched types --> $DIR/issue-69306.rs:10:14 | LL | impl<T> S0<T> { - | - this type parameter + | - expected this type parameter ... LL | Self(0); | ---- ^ expected type parameter `T`, found integer @@ -50,7 +50,7 @@ error[E0308]: mismatched types --> $DIR/issue-69306.rs:27:14 | LL | impl<T> Foo<T> for <S0<T> as Fun>::Out { - | - this type parameter + | - expected this type parameter LL | fn foo() { LL | Self(0); | ---- ^ expected type parameter `T`, found integer @@ -69,7 +69,7 @@ error[E0308]: mismatched types --> $DIR/issue-69306.rs:33:32 | LL | impl<T> S1<T, u8> { - | - this type parameter + | - expected this type parameter LL | const C: S1<u8, u8> = Self(0, 1); | ---- ^ expected type parameter `T`, found integer | | @@ -87,7 +87,7 @@ error[E0308]: mismatched types --> $DIR/issue-69306.rs:33:27 | LL | impl<T> S1<T, u8> { - | - this type parameter + | - found this type parameter LL | const C: S1<u8, u8> = Self(0, 1); | ^^^^^^^^^^ expected `S1<u8, u8>`, found `S1<T, u8>` | diff --git a/tests/ui/iterators/invalid-iterator-chain-fixable.fixed b/tests/ui/iterators/invalid-iterator-chain-fixable.fixed new file mode 100644 index 00000000000..513b5bd13d8 --- /dev/null +++ b/tests/ui/iterators/invalid-iterator-chain-fixable.fixed @@ -0,0 +1,42 @@ +// run-rustfix +use std::collections::hash_set::Iter; +use std::collections::HashSet; + +fn iter_to_vec<'b, X>(i: Iter<'b, X>) -> Vec<X> where X: Clone { + let i = i.map(|x| x.clone()); + i.collect() //~ ERROR E0277 +} + +fn main() { + let v = vec![(0, 0)]; + let scores = v + .iter() + .map(|(a, b)| { + a + b + }); + println!("{}", scores.sum::<i32>()); //~ ERROR E0277 + println!( + "{}", + vec![0, 1] + .iter() + .map(|x| x * 2) + .map(|x| { x }) + .map(|x| { x }) + .sum::<i32>(), //~ ERROR E0277 + ); + println!("{}", vec![0, 1].iter().map(|x| { x }).sum::<i32>()); //~ ERROR E0277 + let a = vec![0]; + let b = a.into_iter(); + let c = b.map(|x| x + 1); + let d = c.filter(|x| *x > 10 ); + let e = d.map(|x| { + x + 1 + }); + let f = e.filter(|_| false); + let g: Vec<i32> = f.collect(); //~ ERROR E0277 + println!("{g:?}"); + + let mut s = HashSet::new(); + s.insert(1u8); + println!("{:?}", iter_to_vec(s.iter())); +} diff --git a/tests/ui/iterators/invalid-iterator-chain-fixable.rs b/tests/ui/iterators/invalid-iterator-chain-fixable.rs new file mode 100644 index 00000000000..79b861702c7 --- /dev/null +++ b/tests/ui/iterators/invalid-iterator-chain-fixable.rs @@ -0,0 +1,42 @@ +// run-rustfix +use std::collections::hash_set::Iter; +use std::collections::HashSet; + +fn iter_to_vec<'b, X>(i: Iter<'b, X>) -> Vec<X> { + let i = i.map(|x| x.clone()); + i.collect() //~ ERROR E0277 +} + +fn main() { + let v = vec![(0, 0)]; + let scores = v + .iter() + .map(|(a, b)| { + a + b; + }); + println!("{}", scores.sum::<i32>()); //~ ERROR E0277 + println!( + "{}", + vec![0, 1] + .iter() + .map(|x| x * 2) + .map(|x| { x; }) + .map(|x| { x }) + .sum::<i32>(), //~ ERROR E0277 + ); + println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>()); //~ ERROR E0277 + let a = vec![0]; + let b = a.into_iter(); + let c = b.map(|x| x + 1); + let d = c.filter(|x| *x > 10 ); + let e = d.map(|x| { + x + 1; + }); + let f = e.filter(|_| false); + let g: Vec<i32> = f.collect(); //~ ERROR E0277 + println!("{g:?}"); + + let mut s = HashSet::new(); + s.insert(1u8); + println!("{:?}", iter_to_vec(s.iter())); +} diff --git a/tests/ui/iterators/invalid-iterator-chain-fixable.stderr b/tests/ui/iterators/invalid-iterator-chain-fixable.stderr new file mode 100644 index 00000000000..1bfe765e78a --- /dev/null +++ b/tests/ui/iterators/invalid-iterator-chain-fixable.stderr @@ -0,0 +1,157 @@ +error[E0277]: a value of type `Vec<X>` cannot be built from an iterator over elements of type `&X` + --> $DIR/invalid-iterator-chain-fixable.rs:7:7 + | +LL | let i = i.map(|x| x.clone()); + | ------- this method call is cloning the reference `&X`, not `X` which doesn't implement `Clone` +LL | i.collect() + | ^^^^^^^ value of type `Vec<X>` cannot be built from `std::iter::Iterator<Item=&X>` + | + = help: the trait `FromIterator<&X>` is not implemented for `Vec<X>` + = help: the trait `FromIterator<X>` is implemented for `Vec<X>` + = help: for that trait implementation, expected `X`, found `&X` +note: the method call chain might not have had the expected associated types + --> $DIR/invalid-iterator-chain-fixable.rs:5:26 + | +LL | fn iter_to_vec<'b, X>(i: Iter<'b, X>) -> Vec<X> { + | ^^^^^^^^^^^ `Iterator::Item` is `&X` here +LL | let i = i.map(|x| x.clone()); + | ------------------ `Iterator::Item` remains `&X` here +note: required by a bound in `collect` + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL +help: consider further restricting type parameter `X` + | +LL | fn iter_to_vec<'b, X>(i: Iter<'b, X>) -> Vec<X> where X: Clone { + | ++++++++++++++ + +error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()` + --> $DIR/invalid-iterator-chain-fixable.rs:17:33 + | +LL | println!("{}", scores.sum::<i32>()); + | --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>` + | | + | required by a bound introduced by this call + | + = help: the trait `Sum<()>` is not implemented for `i32` + = help: the following other types implement trait `Sum<A>`: + <i32 as Sum> + <i32 as Sum<&'a i32>> +note: the method call chain might not have had the expected associated types + --> $DIR/invalid-iterator-chain-fixable.rs:14:10 + | +LL | let v = vec![(0, 0)]; + | ------------ this expression has type `Vec<({integer}, {integer})>` +LL | let scores = v +LL | .iter() + | ------ `Iterator::Item` is `&({integer}, {integer})` here +LL | .map(|(a, b)| { + | __________^ +LL | | a + b; +LL | | }); + | |__________^ `Iterator::Item` changed to `()` here +note: required by a bound in `std::iter::Iterator::sum` + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL +help: consider removing this semicolon + | +LL - a + b; +LL + a + b + | + +error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()` + --> $DIR/invalid-iterator-chain-fixable.rs:25:20 + | +LL | .sum::<i32>(), + | --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>` + | | + | required by a bound introduced by this call + | + = help: the trait `Sum<()>` is not implemented for `i32` + = help: the following other types implement trait `Sum<A>`: + <i32 as Sum> + <i32 as Sum<&'a i32>> +note: the method call chain might not have had the expected associated types + --> $DIR/invalid-iterator-chain-fixable.rs:23:14 + | +LL | vec![0, 1] + | ---------- this expression has type `Vec<{integer}>` +LL | .iter() + | ------ `Iterator::Item` is `&{integer}` here +LL | .map(|x| x * 2) + | -------------- `Iterator::Item` changed to `{integer}` here +LL | .map(|x| { x; }) + | ^^^^^^^^^^^^^^^ `Iterator::Item` changed to `()` here +LL | .map(|x| { x }) + | -------------- `Iterator::Item` remains `()` here +note: required by a bound in `std::iter::Iterator::sum` + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL +help: consider removing this semicolon + | +LL - .map(|x| { x; }) +LL + .map(|x| { x }) + | + +error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()` + --> $DIR/invalid-iterator-chain-fixable.rs:27:60 + | +LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>()); + | --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>` + | | + | required by a bound introduced by this call + | + = help: the trait `Sum<()>` is not implemented for `i32` + = help: the following other types implement trait `Sum<A>`: + <i32 as Sum> + <i32 as Sum<&'a i32>> +note: the method call chain might not have had the expected associated types + --> $DIR/invalid-iterator-chain-fixable.rs:27:38 + | +LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>()); + | ---------- ------ ^^^^^^^^^^^^^^^ `Iterator::Item` changed to `()` here + | | | + | | `Iterator::Item` is `&{integer}` here + | this expression has type `Vec<{integer}>` +note: required by a bound in `std::iter::Iterator::sum` + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL +help: consider removing this semicolon + | +LL - println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>()); +LL + println!("{}", vec![0, 1].iter().map(|x| { x }).sum::<i32>()); + | + +error[E0277]: a value of type `Vec<i32>` cannot be built from an iterator over elements of type `()` + --> $DIR/invalid-iterator-chain-fixable.rs:36:25 + | +LL | let g: Vec<i32> = f.collect(); + | ^^^^^^^ value of type `Vec<i32>` cannot be built from `std::iter::Iterator<Item=()>` + | + = help: the trait `FromIterator<()>` is not implemented for `Vec<i32>` + = help: the trait `FromIterator<i32>` is implemented for `Vec<i32>` + = help: for that trait implementation, expected `i32`, found `()` +note: the method call chain might not have had the expected associated types + --> $DIR/invalid-iterator-chain-fixable.rs:32:15 + | +LL | let a = vec![0]; + | ------- this expression has type `Vec<{integer}>` +LL | let b = a.into_iter(); + | ----------- `Iterator::Item` is `{integer}` here +LL | let c = b.map(|x| x + 1); + | -------------- `Iterator::Item` remains `{integer}` here +LL | let d = c.filter(|x| *x > 10 ); + | -------------------- `Iterator::Item` remains `{integer}` here +LL | let e = d.map(|x| { + | _______________^ +LL | | x + 1; +LL | | }); + | |______^ `Iterator::Item` changed to `()` here +LL | let f = e.filter(|_| false); + | ----------------- `Iterator::Item` remains `()` here +note: required by a bound in `collect` + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL +help: consider removing this semicolon + | +LL - x + 1; +LL + x + 1 + | + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/iterators/invalid-iterator-chain.stderr b/tests/ui/iterators/invalid-iterator-chain.stderr index 2601c9c0d69..4dc13086912 100644 --- a/tests/ui/iterators/invalid-iterator-chain.stderr +++ b/tests/ui/iterators/invalid-iterator-chain.stderr @@ -1,6 +1,8 @@ error[E0277]: a value of type `Vec<X>` cannot be built from an iterator over elements of type `&X` --> $DIR/invalid-iterator-chain.rs:6:7 | +LL | let i = i.map(|x| x.clone()); + | ------- this method call is cloning the reference `&X`, not `X` which doesn't implement `Clone` LL | i.collect() | ^^^^^^^ value of type `Vec<X>` cannot be built from `std::iter::Iterator<Item=&X>` | @@ -16,6 +18,10 @@ LL | let i = i.map(|x| x.clone()); | ------------------ `Iterator::Item` remains `&X` here note: required by a bound in `collect` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL +help: consider further restricting type parameter `X` + | +LL | fn iter_to_vec<'b, X>(i: Iter<'b, X>) -> Vec<X> where X: Clone { + | ++++++++++++++ error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()` --> $DIR/invalid-iterator-chain.rs:15:33 @@ -43,6 +49,11 @@ LL | | }); | |__________^ `Iterator::Item` changed to `()` here note: required by a bound in `std::iter::Iterator::sum` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL +help: consider removing this semicolon + | +LL - a + b; +LL + a + b + | error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()` --> $DIR/invalid-iterator-chain.rs:26:20 @@ -77,6 +88,11 @@ LL | .map(|x| { x; }) | ^^^^^^^^^^^^^^^ `Iterator::Item` changed to `()` here note: required by a bound in `std::iter::Iterator::sum` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL +help: consider removing this semicolon + | +LL - .map(|x| { x; }) +LL + .map(|x| { x }) + | error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `f64` --> $DIR/invalid-iterator-chain.rs:36:20 @@ -130,6 +146,11 @@ LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>()); | this expression has type `Vec<{integer}>` note: required by a bound in `std::iter::Iterator::sum` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL +help: consider removing this semicolon + | +LL - println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>()); +LL + println!("{}", vec![0, 1].iter().map(|x| { x }).sum::<i32>()); + | error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `&()` --> $DIR/invalid-iterator-chain.rs:39:46 @@ -182,6 +203,11 @@ LL | let f = e.filter(|_| false); | ----------------- `Iterator::Item` remains `()` here note: required by a bound in `collect` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL +help: consider removing this semicolon + | +LL - x + 1; +LL + x + 1 + | error: aborting due to 7 previous errors diff --git a/tests/ui/lang-items/start_lang_item_args.main_ret.stderr b/tests/ui/lang-items/start_lang_item_args.main_ret.stderr index 4582b69850c..25570f96053 100644 --- a/tests/ui/lang-items/start_lang_item_args.main_ret.stderr +++ b/tests/ui/lang-items/start_lang_item_args.main_ret.stderr @@ -4,7 +4,7 @@ error[E0308]: lang item `start` function has wrong type LL | fn start<T>(_main: fn() -> u16, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize { | - ^^^^^^^^^^^ expected type parameter `T`, found `u16` | | - | this type parameter + | expected this type parameter | = note: expected signature `fn(fn() -> T, _, _, _) -> _` found signature `fn(fn() -> u16, _, _, _) -> _` diff --git a/tests/ui/lint/bare-trait-objects-path.stderr b/tests/ui/lint/bare-trait-objects-path.stderr index a19f4963c23..01ca08a6f19 100644 --- a/tests/ui/lint/bare-trait-objects-path.stderr +++ b/tests/ui/lint/bare-trait-objects-path.stderr @@ -16,7 +16,7 @@ error[E0223]: ambiguous associated type --> $DIR/bare-trait-objects-path.rs:23:12 | LL | let _: Dyn::Ty; - | ^^^^^^^ help: use the fully-qualified path: `<dyn Dyn as Assoc>::Ty` + | ^^^^^^^ help: use fully-qualified syntax: `<dyn Dyn as Assoc>::Ty` warning: trait objects without an explicit `dyn` are deprecated --> $DIR/bare-trait-objects-path.rs:14:5 diff --git a/tests/ui/lint/missing-copy-implementations-non-exhaustive.rs b/tests/ui/lint/missing-copy-implementations-non-exhaustive.rs new file mode 100644 index 00000000000..2d5e90720ef --- /dev/null +++ b/tests/ui/lint/missing-copy-implementations-non-exhaustive.rs @@ -0,0 +1,25 @@ +// Test for issue #116766. +// Ensure that we don't suggest impl'ing `Copy` for a type if it or at least one +// of it's variants are marked as `non_exhaustive`. + +// check-pass + +#![deny(missing_copy_implementations)] + +#[non_exhaustive] +pub enum MyEnum { + A, +} + +#[non_exhaustive] +pub struct MyStruct { + foo: usize, +} + +pub enum MyEnum2 { + #[non_exhaustive] + A, + B, +} + +fn main() {} diff --git a/tests/ui/methods/disambiguate-multiple-blanket-impl.rs b/tests/ui/methods/disambiguate-multiple-blanket-impl.rs new file mode 100644 index 00000000000..6a17f6a2172 --- /dev/null +++ b/tests/ui/methods/disambiguate-multiple-blanket-impl.rs @@ -0,0 +1,38 @@ +trait A { + type Type; + const CONST: usize; + fn foo(&self); +} + +trait B { + type Type; + const CONST: usize; + fn foo(&self); +} + +#[derive(Debug)] +struct S; + +impl<T: std::fmt::Debug> A for T { + type Type = (); + const CONST: usize = 1; //~ NOTE candidate #1 + fn foo(&self) {} //~ NOTE candidate #1 +} + +impl<T: std::fmt::Debug> B for T { + type Type = (); + const CONST: usize = 2; //~ NOTE candidate #2 + fn foo(&self) {} //~ NOTE candidate #2 +} + +fn main() { + let s = S; + S::foo(&s); //~ ERROR multiple applicable items in scope + //~^ NOTE multiple `foo` found + //~| HELP use fully-qualified syntax to disambiguate + S::CONST; //~ ERROR multiple applicable items in scope + //~^ NOTE multiple `CONST` found + //~| HELP use fully-qualified syntax to disambiguate + let _: S::Type; //~ ERROR ambiguous associated type + //~^ HELP use fully-qualified syntax +} diff --git a/tests/ui/methods/disambiguate-multiple-blanket-impl.stderr b/tests/ui/methods/disambiguate-multiple-blanket-impl.stderr new file mode 100644 index 00000000000..a9e9c679fdb --- /dev/null +++ b/tests/ui/methods/disambiguate-multiple-blanket-impl.stderr @@ -0,0 +1,63 @@ +error[E0223]: ambiguous associated type + --> $DIR/disambiguate-multiple-blanket-impl.rs:36:12 + | +LL | let _: S::Type; + | ^^^^^^^ + | +help: use fully-qualified syntax + | +LL | let _: <S as A>::Type; + | ~~~~~~~~~~~~~~ +LL | let _: <S as B>::Type; + | ~~~~~~~~~~~~~~ + +error[E0034]: multiple applicable items in scope + --> $DIR/disambiguate-multiple-blanket-impl.rs:30:8 + | +LL | S::foo(&s); + | ^^^ multiple `foo` found + | +note: candidate #1 is defined in an impl of the trait `A` for the type `T` + --> $DIR/disambiguate-multiple-blanket-impl.rs:19:5 + | +LL | fn foo(&self) {} + | ^^^^^^^^^^^^^ +note: candidate #2 is defined in an impl of the trait `B` for the type `T` + --> $DIR/disambiguate-multiple-blanket-impl.rs:25:5 + | +LL | fn foo(&self) {} + | ^^^^^^^^^^^^^ +help: use fully-qualified syntax to disambiguate + | +LL | <T as A>::foo(&s); + | ~~~~~~~~~~ +LL | <T as B>::foo(&s); + | ~~~~~~~~~~ + +error[E0034]: multiple applicable items in scope + --> $DIR/disambiguate-multiple-blanket-impl.rs:33:8 + | +LL | S::CONST; + | ^^^^^ multiple `CONST` found + | +note: candidate #1 is defined in an impl of the trait `A` for the type `T` + --> $DIR/disambiguate-multiple-blanket-impl.rs:18:5 + | +LL | const CONST: usize = 1; + | ^^^^^^^^^^^^^^^^^^ +note: candidate #2 is defined in an impl of the trait `B` for the type `T` + --> $DIR/disambiguate-multiple-blanket-impl.rs:24:5 + | +LL | const CONST: usize = 2; + | ^^^^^^^^^^^^^^^^^^ +help: use fully-qualified syntax to disambiguate + | +LL | <T as A>::CONST; + | ~~~~~~~~~~ +LL | <T as B>::CONST; + | ~~~~~~~~~~ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0034, E0223. +For more information about an error, try `rustc --explain E0034`. diff --git a/tests/ui/methods/disambiguate-multiple-impl.rs b/tests/ui/methods/disambiguate-multiple-impl.rs new file mode 100644 index 00000000000..9a82ff01574 --- /dev/null +++ b/tests/ui/methods/disambiguate-multiple-impl.rs @@ -0,0 +1,37 @@ +trait A { + type Type; + const CONST: usize; + fn foo(&self); +} + +trait B { + type Type; + const CONST: usize; + fn foo(&self); +} + +struct S; + +impl A for S { + type Type = (); + const CONST: usize = 1; //~ NOTE candidate #1 + fn foo(&self) {} //~ NOTE candidate #1 +} + +impl B for S { + type Type = (); + const CONST: usize = 2; //~ NOTE candidate #2 + fn foo(&self) {} //~ NOTE candidate #2 +} + +fn main() { + let s = S; + S::foo(&s); //~ ERROR multiple applicable items in scope + //~^ NOTE multiple `foo` found + //~| HELP use fully-qualified syntax + let _: S::Type = (); //~ ERROR ambiguous associated type + //~| HELP use fully-qualified syntax + let _ = S::CONST; //~ ERROR multiple applicable items in scope + //~^ NOTE multiple `CONST` found + //~| HELP use fully-qualified syntax +} diff --git a/tests/ui/methods/disambiguate-multiple-impl.stderr b/tests/ui/methods/disambiguate-multiple-impl.stderr new file mode 100644 index 00000000000..901bfc30a3f --- /dev/null +++ b/tests/ui/methods/disambiguate-multiple-impl.stderr @@ -0,0 +1,63 @@ +error[E0223]: ambiguous associated type + --> $DIR/disambiguate-multiple-impl.rs:32:12 + | +LL | let _: S::Type = (); + | ^^^^^^^ + | +help: use fully-qualified syntax + | +LL | let _: <S as A>::Type = (); + | ~~~~~~~~~~~~~~ +LL | let _: <S as B>::Type = (); + | ~~~~~~~~~~~~~~ + +error[E0034]: multiple applicable items in scope + --> $DIR/disambiguate-multiple-impl.rs:29:8 + | +LL | S::foo(&s); + | ^^^ multiple `foo` found + | +note: candidate #1 is defined in an impl of the trait `A` for the type `S` + --> $DIR/disambiguate-multiple-impl.rs:18:5 + | +LL | fn foo(&self) {} + | ^^^^^^^^^^^^^ +note: candidate #2 is defined in an impl of the trait `B` for the type `S` + --> $DIR/disambiguate-multiple-impl.rs:24:5 + | +LL | fn foo(&self) {} + | ^^^^^^^^^^^^^ +help: use fully-qualified syntax to disambiguate + | +LL | <S as A>::foo(&s); + | ~~~~~~~~~~ +LL | <S as B>::foo(&s); + | ~~~~~~~~~~ + +error[E0034]: multiple applicable items in scope + --> $DIR/disambiguate-multiple-impl.rs:34:16 + | +LL | let _ = S::CONST; + | ^^^^^ multiple `CONST` found + | +note: candidate #1 is defined in an impl of the trait `A` for the type `S` + --> $DIR/disambiguate-multiple-impl.rs:17:5 + | +LL | const CONST: usize = 1; + | ^^^^^^^^^^^^^^^^^^ +note: candidate #2 is defined in an impl of the trait `B` for the type `S` + --> $DIR/disambiguate-multiple-impl.rs:23:5 + | +LL | const CONST: usize = 2; + | ^^^^^^^^^^^^^^^^^^ +help: use fully-qualified syntax to disambiguate + | +LL | let _ = <S as A>::CONST; + | ~~~~~~~~~~ +LL | let _ = <S as B>::CONST; + | ~~~~~~~~~~ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0034, E0223. +For more information about an error, try `rustc --explain E0034`. diff --git a/tests/ui/methods/disambiguate-multiple-trait-2.rs b/tests/ui/methods/disambiguate-multiple-trait-2.rs new file mode 100644 index 00000000000..829491d824d --- /dev/null +++ b/tests/ui/methods/disambiguate-multiple-trait-2.rs @@ -0,0 +1,54 @@ +trait A { + type Type; //~ NOTE ambiguous `Type` from `A` + const CONST: usize = 1; //~ NOTE candidate #1 + fn foo(&self); //~ NOTE candidate #1 +} + +trait B { + type Type; //~ NOTE ambiguous `Type` from `B` + const CONST: usize; //~ NOTE candidate #2 + fn foo(&self); //~ NOTE candidate #2 +} + +trait C: A + B {} + +fn a<T: C>(t: T) { + t.foo(); //~ ERROR multiple applicable items in scope + //~^ NOTE multiple `foo` found + //~| HELP disambiguate the method + //~| HELP disambiguate the method + let _ = T::CONST; //~ ERROR multiple applicable items in scope + //~^ NOTE multiple `CONST` found + //~| HELP use fully-qualified syntax + let _: T::Type; //~ ERROR ambiguous associated type + //~^ NOTE ambiguous associated type `Type` + //~| HELP use fully-qualified syntax + //~| HELP use fully-qualified syntax +} + +#[derive(Debug)] +struct S; + +impl<T: std::fmt::Debug> A for T { + type Type = (); + const CONST: usize = 1; //~ NOTE candidate #1 + fn foo(&self) {} //~ NOTE candidate #1 +} + +impl<T: std::fmt::Debug> B for T { + type Type = (); + const CONST: usize = 1; //~ NOTE candidate #2 + fn foo(&self) {} //~ NOTE candidate #2 +} + +fn main() { + let s = S; + S::foo(&s); //~ ERROR multiple applicable items in scope + //~^ NOTE multiple `foo` found + //~| HELP use fully-qualified syntax + let _ = S::CONST; //~ ERROR multiple applicable items in scope + //~^ NOTE multiple `CONST` found + //~| HELP use fully-qualified syntax + let _: S::Type; //~ ERROR ambiguous associated type + //~^ HELP use fully-qualified syntax +} diff --git a/tests/ui/methods/disambiguate-multiple-trait-2.stderr b/tests/ui/methods/disambiguate-multiple-trait-2.stderr new file mode 100644 index 00000000000..0f9c60ce243 --- /dev/null +++ b/tests/ui/methods/disambiguate-multiple-trait-2.stderr @@ -0,0 +1,132 @@ +error[E0221]: ambiguous associated type `Type` in bounds of `T` + --> $DIR/disambiguate-multiple-trait-2.rs:23:12 + | +LL | type Type; + | --------- ambiguous `Type` from `A` +... +LL | type Type; + | --------- ambiguous `Type` from `B` +... +LL | let _: T::Type; + | ^^^^^^^ ambiguous associated type `Type` + | +help: use fully-qualified syntax to disambiguate + | +LL | let _: <T as A>::Type; + | ~~~~~~~~~~ +help: use fully-qualified syntax to disambiguate + | +LL | let _: <T as B>::Type; + | ~~~~~~~~~~ + +error[E0034]: multiple applicable items in scope + --> $DIR/disambiguate-multiple-trait-2.rs:16:7 + | +LL | t.foo(); + | ^^^ multiple `foo` found + | +note: candidate #1 is defined in the trait `A` + --> $DIR/disambiguate-multiple-trait-2.rs:4:5 + | +LL | fn foo(&self); + | ^^^^^^^^^^^^^^ +note: candidate #2 is defined in the trait `B` + --> $DIR/disambiguate-multiple-trait-2.rs:10:5 + | +LL | fn foo(&self); + | ^^^^^^^^^^^^^^ +help: disambiguate the method for candidate #1 + | +LL | A::foo(t); + | ~~~~~~~~~ +help: disambiguate the method for candidate #2 + | +LL | B::foo(t); + | ~~~~~~~~~ + +error[E0034]: multiple applicable items in scope + --> $DIR/disambiguate-multiple-trait-2.rs:20:16 + | +LL | let _ = T::CONST; + | ^^^^^ multiple `CONST` found + | +note: candidate #1 is defined in the trait `A` + --> $DIR/disambiguate-multiple-trait-2.rs:3:5 + | +LL | const CONST: usize = 1; + | ^^^^^^^^^^^^^^^^^^ +note: candidate #2 is defined in the trait `B` + --> $DIR/disambiguate-multiple-trait-2.rs:9:5 + | +LL | const CONST: usize; + | ^^^^^^^^^^^^^^^^^^ +help: use fully-qualified syntax to disambiguate + | +LL | let _ = A::CONST; + | ~~~ +LL | let _ = B::CONST; + | ~~~ + +error[E0223]: ambiguous associated type + --> $DIR/disambiguate-multiple-trait-2.rs:52:12 + | +LL | let _: S::Type; + | ^^^^^^^ + | +help: use fully-qualified syntax + | +LL | let _: <S as A>::Type; + | ~~~~~~~~~~~~~~ +LL | let _: <S as B>::Type; + | ~~~~~~~~~~~~~~ + +error[E0034]: multiple applicable items in scope + --> $DIR/disambiguate-multiple-trait-2.rs:46:8 + | +LL | S::foo(&s); + | ^^^ multiple `foo` found + | +note: candidate #1 is defined in an impl of the trait `A` for the type `T` + --> $DIR/disambiguate-multiple-trait-2.rs:35:5 + | +LL | fn foo(&self) {} + | ^^^^^^^^^^^^^ +note: candidate #2 is defined in an impl of the trait `B` for the type `T` + --> $DIR/disambiguate-multiple-trait-2.rs:41:5 + | +LL | fn foo(&self) {} + | ^^^^^^^^^^^^^ +help: use fully-qualified syntax to disambiguate + | +LL | <T as A>::foo(&s); + | ~~~~~~~~~~ +LL | <T as B>::foo(&s); + | ~~~~~~~~~~ + +error[E0034]: multiple applicable items in scope + --> $DIR/disambiguate-multiple-trait-2.rs:49:16 + | +LL | let _ = S::CONST; + | ^^^^^ multiple `CONST` found + | +note: candidate #1 is defined in an impl of the trait `A` for the type `T` + --> $DIR/disambiguate-multiple-trait-2.rs:34:5 + | +LL | const CONST: usize = 1; + | ^^^^^^^^^^^^^^^^^^ +note: candidate #2 is defined in an impl of the trait `B` for the type `T` + --> $DIR/disambiguate-multiple-trait-2.rs:40:5 + | +LL | const CONST: usize = 1; + | ^^^^^^^^^^^^^^^^^^ +help: use fully-qualified syntax to disambiguate + | +LL | let _ = <T as A>::CONST; + | ~~~~~~~~~~ +LL | let _ = <T as B>::CONST; + | ~~~~~~~~~~ + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0034, E0221, E0223. +For more information about an error, try `rustc --explain E0034`. diff --git a/tests/ui/methods/disambiguate-multiple-trait.rs b/tests/ui/methods/disambiguate-multiple-trait.rs new file mode 100644 index 00000000000..c990d047576 --- /dev/null +++ b/tests/ui/methods/disambiguate-multiple-trait.rs @@ -0,0 +1,32 @@ +#![feature(associated_type_defaults)] + +trait A { + type Type = (); + const CONST: usize = 1; //~ NOTE candidate #1 + fn foo(&self) {} //~ NOTE candidate #1 +} + +trait B { + type Type = (); + const CONST: usize = 2; //~ NOTE candidate #2 + fn foo(&self) {} //~ NOTE candidate #2 +} + +#[derive(Debug)] +struct S; + +impl<T: std::fmt::Debug> A for T {} + +impl<T: std::fmt::Debug> B for T {} + +fn main() { + let s = S; + S::foo(&s); //~ ERROR multiple applicable items in scope + //~^ NOTE multiple `foo` found + //~| HELP use fully-qualified syntax + let _ = S::CONST; //~ ERROR multiple applicable items in scope + //~^ NOTE multiple `CONST` found + //~| HELP use fully-qualified syntax + let _: S::Type; //~ ERROR ambiguous associated type + //~^ HELP use fully-qualified syntax +} diff --git a/tests/ui/methods/disambiguate-multiple-trait.stderr b/tests/ui/methods/disambiguate-multiple-trait.stderr new file mode 100644 index 00000000000..9a50d51245b --- /dev/null +++ b/tests/ui/methods/disambiguate-multiple-trait.stderr @@ -0,0 +1,63 @@ +error[E0223]: ambiguous associated type + --> $DIR/disambiguate-multiple-trait.rs:30:12 + | +LL | let _: S::Type; + | ^^^^^^^ + | +help: use fully-qualified syntax + | +LL | let _: <S as A>::Type; + | ~~~~~~~~~~~~~~ +LL | let _: <S as B>::Type; + | ~~~~~~~~~~~~~~ + +error[E0034]: multiple applicable items in scope + --> $DIR/disambiguate-multiple-trait.rs:24:8 + | +LL | S::foo(&s); + | ^^^ multiple `foo` found + | +note: candidate #1 is defined in an impl of the trait `A` for the type `T` + --> $DIR/disambiguate-multiple-trait.rs:6:5 + | +LL | fn foo(&self) {} + | ^^^^^^^^^^^^^ +note: candidate #2 is defined in an impl of the trait `B` for the type `T` + --> $DIR/disambiguate-multiple-trait.rs:12:5 + | +LL | fn foo(&self) {} + | ^^^^^^^^^^^^^ +help: use fully-qualified syntax to disambiguate + | +LL | <T as A>::foo(&s); + | ~~~~~~~~~~ +LL | <T as B>::foo(&s); + | ~~~~~~~~~~ + +error[E0034]: multiple applicable items in scope + --> $DIR/disambiguate-multiple-trait.rs:27:16 + | +LL | let _ = S::CONST; + | ^^^^^ multiple `CONST` found + | +note: candidate #1 is defined in an impl of the trait `A` for the type `T` + --> $DIR/disambiguate-multiple-trait.rs:5:5 + | +LL | const CONST: usize = 1; + | ^^^^^^^^^^^^^^^^^^ +note: candidate #2 is defined in an impl of the trait `B` for the type `T` + --> $DIR/disambiguate-multiple-trait.rs:11:5 + | +LL | const CONST: usize = 2; + | ^^^^^^^^^^^^^^^^^^ +help: use fully-qualified syntax to disambiguate + | +LL | let _ = <T as A>::CONST; + | ~~~~~~~~~~ +LL | let _ = <T as B>::CONST; + | ~~~~~~~~~~ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0034, E0223. +For more information about an error, try `rustc --explain E0034`. diff --git a/tests/ui/methods/method-ambig-two-traits-from-impls2.stderr b/tests/ui/methods/method-ambig-two-traits-from-impls2.stderr index 4ba778e0ef7..5bb887b4503 100644 --- a/tests/ui/methods/method-ambig-two-traits-from-impls2.stderr +++ b/tests/ui/methods/method-ambig-two-traits-from-impls2.stderr @@ -14,12 +14,10 @@ note: candidate #2 is defined in an impl of the trait `B` for the type `AB` | LL | fn foo() {} | ^^^^^^^^ -help: disambiguate the associated function for candidate #1 +help: use fully-qualified syntax to disambiguate | LL | <AB as A>::foo(); | ~~~~~~~~~~~ -help: disambiguate the associated function for candidate #2 - | LL | <AB as B>::foo(); | ~~~~~~~~~~~ diff --git a/tests/ui/mismatched_types/issue-35030.stderr b/tests/ui/mismatched_types/issue-35030.stderr index de4e067fead..881ff909722 100644 --- a/tests/ui/mismatched_types/issue-35030.stderr +++ b/tests/ui/mismatched_types/issue-35030.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-35030.rs:9:14 | LL | impl<bool> Parser<bool> for bool { - | ---- this type parameter + | ---- expected this type parameter LL | fn parse(text: &str) -> Option<bool> { LL | Some(true) | ---- ^^^^ expected type parameter `bool`, found `bool` diff --git a/tests/ui/or-patterns/or-patterns-syntactic-fail.stderr b/tests/ui/or-patterns/or-patterns-syntactic-fail.stderr index c16a90368e1..e09194d5d39 100644 --- a/tests/ui/or-patterns/or-patterns-syntactic-fail.stderr +++ b/tests/ui/or-patterns/or-patterns-syntactic-fail.stderr @@ -2,9 +2,15 @@ error: expected identifier, found `:` --> $DIR/or-patterns-syntactic-fail.rs:11:19 | LL | let _ = |A | B: E| (); - | ^ expected identifier + | ---- ^ expected identifier + | | + | while parsing the body of this closure | = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> +help: you might have meant to open the body of the closure + | +LL | let _ = |A | { B: E| (); + | + error: top-level or-patterns are not allowed in function parameters --> $DIR/or-patterns-syntactic-fail.rs:18:13 diff --git a/tests/ui/parser/fn-header-semantic-fail.rs b/tests/ui/parser/fn-header-semantic-fail.rs index 71f18a27e7c..f8b58cad7c1 100644 --- a/tests/ui/parser/fn-header-semantic-fail.rs +++ b/tests/ui/parser/fn-header-semantic-fail.rs @@ -13,25 +13,23 @@ fn main() { //~^ ERROR functions cannot be both `const` and `async` trait X { - async fn ft1(); //~ ERROR functions in traits cannot be declared `async` + async fn ft1(); // OK. unsafe fn ft2(); // OK. const fn ft3(); //~ ERROR functions in traits cannot be declared const extern "C" fn ft4(); // OK. const async unsafe extern "C" fn ft5(); - //~^ ERROR functions in traits cannot be declared `async` - //~| ERROR functions in traits cannot be declared const + //~^ ERROR functions in traits cannot be declared const //~| ERROR functions cannot be both `const` and `async` } struct Y; impl X for Y { - async fn ft1() {} //~ ERROR functions in traits cannot be declared `async` + async fn ft1() {} // OK. unsafe fn ft2() {} // OK. const fn ft3() {} //~ ERROR functions in traits cannot be declared const extern "C" fn ft4() {} const async unsafe extern "C" fn ft5() {} - //~^ ERROR functions in traits cannot be declared `async` - //~| ERROR functions in traits cannot be declared const + //~^ ERROR functions in traits cannot be declared const //~| ERROR functions cannot be both `const` and `async` } diff --git a/tests/ui/parser/fn-header-semantic-fail.stderr b/tests/ui/parser/fn-header-semantic-fail.stderr index 7f7b7e835f8..cdf01e0c5df 100644 --- a/tests/ui/parser/fn-header-semantic-fail.stderr +++ b/tests/ui/parser/fn-header-semantic-fail.stderr @@ -29,19 +29,19 @@ LL | const async unsafe extern "C" fn ft5(); | `const` because of this error[E0379]: functions in traits cannot be declared const - --> $DIR/fn-header-semantic-fail.rs:30:9 + --> $DIR/fn-header-semantic-fail.rs:29:9 | LL | const fn ft3() {} | ^^^^^ functions in traits cannot be const error[E0379]: functions in traits cannot be declared const - --> $DIR/fn-header-semantic-fail.rs:32:9 + --> $DIR/fn-header-semantic-fail.rs:31:9 | LL | const async unsafe extern "C" fn ft5() {} | ^^^^^ functions in traits cannot be const error: functions cannot be both `const` and `async` - --> $DIR/fn-header-semantic-fail.rs:32:9 + --> $DIR/fn-header-semantic-fail.rs:31:9 | LL | const async unsafe extern "C" fn ft5() {} | ^^^^^-^^^^^------------------------------ @@ -50,7 +50,7 @@ LL | const async unsafe extern "C" fn ft5() {} | `const` because of this error: functions cannot be both `const` and `async` - --> $DIR/fn-header-semantic-fail.rs:43:9 + --> $DIR/fn-header-semantic-fail.rs:41:9 | LL | const async unsafe extern "C" fn fi5() {} | ^^^^^-^^^^^------------------------------ @@ -59,7 +59,7 @@ LL | const async unsafe extern "C" fn fi5() {} | `const` because of this error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:48:18 + --> $DIR/fn-header-semantic-fail.rs:46:18 | LL | extern "C" { | ---------- in this `extern` block @@ -72,7 +72,7 @@ LL | fn fe1(); | ~~ error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:49:19 + --> $DIR/fn-header-semantic-fail.rs:47:19 | LL | extern "C" { | ---------- in this `extern` block @@ -86,7 +86,7 @@ LL | fn fe2(); | ~~ error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:50:18 + --> $DIR/fn-header-semantic-fail.rs:48:18 | LL | extern "C" { | ---------- in this `extern` block @@ -100,7 +100,7 @@ LL | fn fe3(); | ~~ error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:51:23 + --> $DIR/fn-header-semantic-fail.rs:49:23 | LL | extern "C" { | ---------- in this `extern` block @@ -114,7 +114,7 @@ LL | fn fe4(); | ~~ error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:52:42 + --> $DIR/fn-header-semantic-fail.rs:50:42 | LL | extern "C" { | ---------- in this `extern` block @@ -128,7 +128,7 @@ LL | fn fe5(); | ~~ error: functions cannot be both `const` and `async` - --> $DIR/fn-header-semantic-fail.rs:52:9 + --> $DIR/fn-header-semantic-fail.rs:50:9 | LL | const async unsafe extern "C" fn fe5(); | ^^^^^-^^^^^---------------------------- @@ -136,59 +136,6 @@ LL | const async unsafe extern "C" fn fe5(); | | `async` because of this | `const` because of this -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/fn-header-semantic-fail.rs:16:9 - | -LL | async fn ft1(); - | -----^^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/fn-header-semantic-fail.rs:20:9 - | -LL | const async unsafe extern "C" fn ft5(); - | ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/fn-header-semantic-fail.rs:28:9 - | -LL | async fn ft1() {} - | -----^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/fn-header-semantic-fail.rs:32:9 - | -LL | const async unsafe extern "C" fn ft5() {} - | ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error: aborting due to 18 previous errors +error: aborting due to 14 previous errors -Some errors have detailed explanations: E0379, E0706. -For more information about an error, try `rustc --explain E0379`. +For more information about this error, try `rustc --explain E0379`. diff --git a/tests/ui/parser/issues/issue-32505.rs b/tests/ui/parser/issues/issue-32505.rs index f31c00e5cc3..d95e7dc7d9e 100644 --- a/tests/ui/parser/issues/issue-32505.rs +++ b/tests/ui/parser/issues/issue-32505.rs @@ -1,5 +1,6 @@ pub fn test() { foo(|_|) //~ ERROR expected expression, found `)` + //~^ ERROR cannot find function `foo` in this scope } fn main() { } diff --git a/tests/ui/parser/issues/issue-32505.stderr b/tests/ui/parser/issues/issue-32505.stderr index cdd779a93ef..27ad2c3e5be 100644 --- a/tests/ui/parser/issues/issue-32505.stderr +++ b/tests/ui/parser/issues/issue-32505.stderr @@ -2,7 +2,21 @@ error: expected expression, found `)` --> $DIR/issue-32505.rs:2:12 | LL | foo(|_|) - | ^ expected expression + | ---^ expected expression + | | + | while parsing the body of this closure + | +help: you might have meant to open the body of the closure + | +LL | foo(|_| {}) + | ++ + +error[E0425]: cannot find function `foo` in this scope + --> $DIR/issue-32505.rs:2:5 + | +LL | foo(|_|) + | ^^^ not found in this scope -error: aborting due to previous error +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/pattern/issue-115599.rs b/tests/ui/pattern/issue-115599.rs new file mode 100644 index 00000000000..7a222b90aec --- /dev/null +++ b/tests/ui/pattern/issue-115599.rs @@ -0,0 +1,7 @@ +const CONST_STRING: String = String::new(); + +fn main() { + let empty_str = String::from(""); + if let CONST_STRING = empty_str {} + //~^ ERROR to use a constant of type `Vec<u8>` in a pattern, `Vec<u8>` must be annotated with `#[derive(PartialEq, Eq)]` +} diff --git a/tests/ui/pattern/issue-115599.stderr b/tests/ui/pattern/issue-115599.stderr new file mode 100644 index 00000000000..e6cb6c1ddac --- /dev/null +++ b/tests/ui/pattern/issue-115599.stderr @@ -0,0 +1,11 @@ +error: to use a constant of type `Vec<u8>` in a pattern, `Vec<u8>` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/issue-115599.rs:5:12 + | +LL | if let CONST_STRING = empty_str {} + | ^^^^^^^^^^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details + +error: aborting due to previous error + diff --git a/tests/ui/pattern/usefulness/consts-opaque.rs b/tests/ui/pattern/usefulness/consts-opaque.rs index 2032cf13bc2..6dc1425cf03 100644 --- a/tests/ui/pattern/usefulness/consts-opaque.rs +++ b/tests/ui/pattern/usefulness/consts-opaque.rs @@ -52,7 +52,6 @@ fn main() { BAR => {} //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` _ => {} - //~^ ERROR unreachable pattern } match BAR { @@ -60,7 +59,6 @@ fn main() { //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` Bar => {} _ => {} - //~^ ERROR unreachable pattern } match BAR { diff --git a/tests/ui/pattern/usefulness/consts-opaque.stderr b/tests/ui/pattern/usefulness/consts-opaque.stderr index cd88e6a22e4..51f2f276bbe 100644 --- a/tests/ui/pattern/usefulness/consts-opaque.stderr +++ b/tests/ui/pattern/usefulness/consts-opaque.stderr @@ -38,7 +38,7 @@ LL | BAR => {} = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:59:9 + --> $DIR/consts-opaque.rs:58:9 | LL | BAR => {} | ^^^ @@ -47,7 +47,7 @@ LL | BAR => {} = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:67:9 + --> $DIR/consts-opaque.rs:65:9 | LL | BAR => {} | ^^^ @@ -56,7 +56,7 @@ LL | BAR => {} = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:69:9 + --> $DIR/consts-opaque.rs:67:9 | LL | BAR => {} | ^^^ @@ -65,7 +65,7 @@ LL | BAR => {} = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:75:9 + --> $DIR/consts-opaque.rs:73:9 | LL | BAZ => {} | ^^^ @@ -74,7 +74,7 @@ LL | BAZ => {} = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:83:9 + --> $DIR/consts-opaque.rs:81:9 | LL | BAZ => {} | ^^^ @@ -83,7 +83,7 @@ LL | BAZ => {} = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:89:9 + --> $DIR/consts-opaque.rs:87:9 | LL | BAZ => {} | ^^^ @@ -91,37 +91,14 @@ LL | BAZ => {} = note: the traits must be derived, manual `impl`s are not sufficient = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details -error: unreachable pattern - --> $DIR/consts-opaque.rs:54:9 - | -LL | Bar => {} - | --- matches any value -... -LL | _ => {} - | ^ unreachable pattern - | -note: the lint level is defined here - --> $DIR/consts-opaque.rs:6:9 - | -LL | #![deny(unreachable_patterns)] - | ^^^^^^^^^^^^^^^^^^^^ - -error: unreachable pattern - --> $DIR/consts-opaque.rs:62:9 - | -LL | Bar => {} - | --- matches any value -LL | _ => {} - | ^ unreachable pattern - error[E0004]: non-exhaustive patterns: `Wrap(_)` not covered - --> $DIR/consts-opaque.rs:124:11 + --> $DIR/consts-opaque.rs:122:11 | LL | match WRAPQUUX { | ^^^^^^^^ pattern `Wrap(_)` not covered | note: `Wrap<fn(usize, usize) -> usize>` defined here - --> $DIR/consts-opaque.rs:106:12 + --> $DIR/consts-opaque.rs:104:12 | LL | struct Wrap<T>(T); | ^^^^ @@ -132,6 +109,6 @@ LL ~ WRAPQUUX => {}, LL + Wrap(_) => todo!() | -error: aborting due to 12 previous errors; 1 warning emitted +error: aborting due to 10 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/repr/explicit-rust-repr-conflicts.rs b/tests/ui/repr/explicit-rust-repr-conflicts.rs new file mode 100644 index 00000000000..22dd12d316a --- /dev/null +++ b/tests/ui/repr/explicit-rust-repr-conflicts.rs @@ -0,0 +1,23 @@ +#[repr(C, Rust)] //~ ERROR conflicting representation hints +struct S { + a: i32, +} + + +#[repr(Rust)] //~ ERROR conflicting representation hints +#[repr(C)] +struct T { + a: i32, +} + +#[repr(Rust, u64)] //~ ERROR conflicting representation hints +enum U { + V, +} + +#[repr(Rust, simd)] +//~^ ERROR conflicting representation hints +//~| ERROR SIMD types are experimental and possibly buggy +struct F32x4(f32, f32, f32, f32); + +fn main() {} diff --git a/tests/ui/repr/explicit-rust-repr-conflicts.stderr b/tests/ui/repr/explicit-rust-repr-conflicts.stderr new file mode 100644 index 00000000000..7126da574b6 --- /dev/null +++ b/tests/ui/repr/explicit-rust-repr-conflicts.stderr @@ -0,0 +1,39 @@ +error[E0658]: SIMD types are experimental and possibly buggy + --> $DIR/explicit-rust-repr-conflicts.rs:18:1 + | +LL | #[repr(Rust, simd)] + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #27731 <https://github.com/rust-lang/rust/issues/27731> for more information + = help: add `#![feature(repr_simd)]` to the crate attributes to enable + +error[E0566]: conflicting representation hints + --> $DIR/explicit-rust-repr-conflicts.rs:1:8 + | +LL | #[repr(C, Rust)] + | ^ ^^^^ + +error[E0566]: conflicting representation hints + --> $DIR/explicit-rust-repr-conflicts.rs:7:8 + | +LL | #[repr(Rust)] + | ^^^^ +LL | #[repr(C)] + | ^ + +error[E0566]: conflicting representation hints + --> $DIR/explicit-rust-repr-conflicts.rs:13:8 + | +LL | #[repr(Rust, u64)] + | ^^^^ ^^^ + +error[E0566]: conflicting representation hints + --> $DIR/explicit-rust-repr-conflicts.rs:18:8 + | +LL | #[repr(Rust, simd)] + | ^^^^ ^^^^ + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0566, E0658. +For more information about an error, try `rustc --explain E0566`. diff --git a/tests/ui/resolve/issue-55673.fixed b/tests/ui/resolve/issue-55673.fixed new file mode 100644 index 00000000000..261742a26cb --- /dev/null +++ b/tests/ui/resolve/issue-55673.fixed @@ -0,0 +1,21 @@ +// run-rustfix +#![allow(dead_code)] +trait Foo { + type Bar; +} + +fn foo<T: Foo>() +where + T::Bar: std::fmt::Debug, + //~^ ERROR associated type `Baa` not found for `T` +{ +} + +fn bar<T>() +where + T::Bar: std::fmt::Debug, T: Foo + //~^ ERROR associated type `Baa` not found for `T` +{ +} + +fn main() {} diff --git a/tests/ui/resolve/issue-55673.rs b/tests/ui/resolve/issue-55673.rs index 0436bd39742..6ac49be141c 100644 --- a/tests/ui/resolve/issue-55673.rs +++ b/tests/ui/resolve/issue-55673.rs @@ -1,3 +1,5 @@ +// run-rustfix +#![allow(dead_code)] trait Foo { type Bar; } @@ -9,4 +11,11 @@ where { } +fn bar<T>() +where + T::Baa: std::fmt::Debug, + //~^ ERROR associated type `Baa` not found for `T` +{ +} + fn main() {} diff --git a/tests/ui/resolve/issue-55673.stderr b/tests/ui/resolve/issue-55673.stderr index 39318f95905..ffc3252230a 100644 --- a/tests/ui/resolve/issue-55673.stderr +++ b/tests/ui/resolve/issue-55673.stderr @@ -1,9 +1,29 @@ error[E0220]: associated type `Baa` not found for `T` - --> $DIR/issue-55673.rs:7:8 + --> $DIR/issue-55673.rs:9:8 | LL | T::Baa: std::fmt::Debug, | ^^^ there is a similarly named associated type `Bar` in the trait `Foo` + | +help: change the associated type name to use `Bar` from `Foo` + | +LL | T::Bar: std::fmt::Debug, + | ~~~ + +error[E0220]: associated type `Baa` not found for `T` + --> $DIR/issue-55673.rs:16:8 + | +LL | T::Baa: std::fmt::Debug, + | ^^^ there is a similarly named associated type `Bar` in the trait `Foo` + | +help: consider further restricting type parameter `T` + | +LL | T::Baa: std::fmt::Debug, T: Foo + | ~~~~~~~~ +help: and also change the associated type name + | +LL | T::Bar: std::fmt::Debug, + | ~~~ -error: aborting due to previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0220`. diff --git a/tests/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs b/tests/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs index 49462f52fb4..927ecd9aee0 100644 --- a/tests/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs +++ b/tests/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs @@ -9,11 +9,9 @@ impl A { trait B { async fn associated(); - //~^ ERROR cannot be declared `async` } impl B for A { async fn associated(); //~ ERROR without body - //~^ ERROR cannot be declared `async` } fn main() {} diff --git a/tests/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr b/tests/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr index 1354abb4f14..da9eeea954a 100644 --- a/tests/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr +++ b/tests/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr @@ -15,39 +15,12 @@ LL | async fn inherent(); | help: provide a definition for the function: `{ <body> }` error: associated function in `impl` without body - --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:15:5 + --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:14:5 | LL | async fn associated(); | ^^^^^^^^^^^^^^^^^^^^^- | | | help: provide a definition for the function: `{ <body> }` -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:11:5 - | -LL | async fn associated(); - | -----^^^^^^^^^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error[E0706]: functions in traits cannot be declared `async` - --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:15:5 - | -LL | async fn associated(); - | -----^^^^^^^^^^^^^^^^^ - | | - | `async` because of this - | - = note: `async` trait functions are not currently supported - = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable - -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0706`. diff --git a/tests/ui/return/return-impl-trait-bad.stderr b/tests/ui/return/return-impl-trait-bad.stderr index 237b85ee66a..a015b9f53af 100644 --- a/tests/ui/return/return-impl-trait-bad.stderr +++ b/tests/ui/return/return-impl-trait-bad.stderr @@ -4,7 +4,7 @@ error[E0308]: mismatched types LL | fn bad_echo<T>(_t: T) -> T { | - - expected `T` because of return type | | - | this type parameter + | expected this type parameter LL | "this should not suggest impl Trait" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found `&str` | @@ -17,7 +17,7 @@ error[E0308]: mismatched types LL | fn bad_echo_2<T: Trait>(_t: T) -> T { | - - expected `T` because of return type | | - | this type parameter + | expected this type parameter LL | "this will not suggest it, because that would probably be wrong" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found `&str` | @@ -30,7 +30,7 @@ error[E0308]: mismatched types LL | fn other_bounds_bad<T>() -> T | - - expected `T` because of return type | | - | this type parameter + | expected this type parameter ... LL | "don't suggest this, because Option<T> places additional constraints" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found `&str` @@ -46,7 +46,7 @@ LL | fn used_in_trait<T>() -> T | | | | | expected `T` because of return type | | help: consider using an impl return type: `impl Send` - | this type parameter + | expected this type parameter ... LL | "don't suggest this, because the generic param is used in the bound." | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found `&str` diff --git a/tests/ui/return/return-impl-trait.stderr b/tests/ui/return/return-impl-trait.stderr index 43d40972fca..707f014a16f 100644 --- a/tests/ui/return/return-impl-trait.stderr +++ b/tests/ui/return/return-impl-trait.stderr @@ -5,7 +5,7 @@ LL | fn bar<T: Trait + std::marker::Sync>() -> T | - - | | | | | expected `T` because of return type - | this type parameter help: consider using an impl return type: `impl Trait + std::marker::Sync + Send` + | expected this type parameter help: consider using an impl return type: `impl Trait + std::marker::Sync + Send` ... LL | () | ^^ expected type parameter `T`, found `()` @@ -21,7 +21,7 @@ LL | fn other_bounds<T>() -> T | | | | | expected `T` because of return type | | help: consider using an impl return type: `impl Trait` - | this type parameter + | expected this type parameter ... LL | () | ^^ expected type parameter `T`, found `()` diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.rs b/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.rs index 77227ebd834..1933a68c221 100644 --- a/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.rs +++ b/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.rs @@ -1,4 +1,3 @@ -#![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] mod child { diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.stderr b/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.stderr index c4371a0024c..40f736c215d 100644 --- a/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.stderr +++ b/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `Something: Termination` is not satisfied - --> $DIR/issue-103052-2.rs:12:22 + --> $DIR/issue-103052-2.rs:11:22 | LL | fn main() -> Something { | ^^^^^^^^^ the trait `Termination` is not implemented for `Something` | note: required by a bound in `Main::{opaque#0}` - --> $DIR/issue-103052-2.rs:6:27 + --> $DIR/issue-103052-2.rs:5:27 | LL | fn main() -> impl std::process::Termination; | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Main::{opaque#0}` diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.stderr index ad11c090f12..6d436018bf4 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.stderr @@ -1,14 +1,12 @@ -error[E0277]: the trait bound `T: Foo` is not satisfied - --> $DIR/assoc-type-const-bound-usage.rs:12:6 +error[E0308]: mismatched types + --> $DIR/assoc-type-const-bound-usage.rs:12:5 | LL | <T as Foo>::Assoc::foo(); - | ^ the trait `Foo` is not implemented for `T` + | ^^^^^^^^^^^^^^^^^^^^^^^^ expected `host`, found `true` | -help: consider further restricting this bound - | -LL | const fn foo<T: ~const Foo + Foo>() { - | +++++ + = note: expected constant `host` + found constant `true` error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.rs index f396deff4fe..8e4de57b019 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.rs @@ -4,7 +4,6 @@ associated_type_bounds, const_trait_impl, const_cmp, - return_position_impl_trait_in_trait, )] use std::marker::Destruct; diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.stderr index f9078e22791..4a9090d0b53 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.stderr @@ -5,31 +5,31 @@ LL | const_cmp, | ^^^^^^^^^ error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:12:30 + --> $DIR/const-impl-trait.rs:11:30 | LL | const fn cmp(a: &impl ~const PartialEq) -> bool { | ^^^^^^^^^ error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:16:30 + --> $DIR/const-impl-trait.rs:15:30 | LL | const fn wrap(x: impl ~const PartialEq + ~const Destruct) | ^^^^^^^^^ error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:17:20 + --> $DIR/const-impl-trait.rs:16:20 | LL | -> impl ~const PartialEq + ~const Destruct | ^^^^^^^^^ error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:24:29 + --> $DIR/const-impl-trait.rs:23:29 | LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; | ^^^^^^^^^ error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:28:29 + --> $DIR/const-impl-trait.rs:27:29 | LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { | ^^^^^^^^^ diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.rs new file mode 100644 index 00000000000..c38b4b3f1a2 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.rs @@ -0,0 +1,504 @@ +#![crate_type = "lib"] +#![feature(no_core, lang_items, unboxed_closures, auto_traits, intrinsics, rustc_attrs)] +#![feature(fundamental)] +#![feature(const_trait_impl, effects, const_mut_refs)] +#![allow(internal_features)] +#![no_std] +#![no_core] + +// known-bug: #110395 + +#[lang = "sized"] +trait Sized {} +#[lang = "copy"] +trait Copy {} + +#[lang = "add"] +#[const_trait] +trait Add<Rhs = Self> { + type Output; + + fn add(self, rhs: Rhs) -> Self::Output; +} + +// FIXME we shouldn't need to have to specify `Rhs`. +impl const Add<i32> for i32 { + type Output = i32; + fn add(self, rhs: i32) -> i32 { + loop {} + } +} + +fn foo() { + let x = 42_i32 + 43_i32; +} + +const fn bar() { + let x = 42_i32 + 43_i32; +} + + +#[lang = "Try"] +#[const_trait] +trait Try: FromResidual { + type Output; + type Residual; + + #[lang = "from_output"] + fn from_output(output: Self::Output) -> Self; + + #[lang = "branch"] + fn branch(self) -> ControlFlow<Self::Residual, Self::Output>; +} + +// FIXME +// #[const_trait] +trait FromResidual<R = <Self as Try>::Residual> { + #[lang = "from_residual"] + fn from_residual(residual: R) -> Self; +} + +enum ControlFlow<B, C = ()> { + #[lang = "Continue"] + Continue(C), + #[lang = "Break"] + Break(B), +} + +#[const_trait] +#[lang = "fn"] +#[rustc_paren_sugar] +trait Fn<Args: Tuple>: ~const FnMut<Args> { + extern "rust-call" fn call(&self, args: Args) -> Self::Output; +} + +#[const_trait] +#[lang = "fn_mut"] +#[rustc_paren_sugar] +trait FnMut<Args: Tuple>: ~const FnOnce<Args> { + extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output; +} + +#[const_trait] +#[lang = "fn_once"] +#[rustc_paren_sugar] +trait FnOnce<Args: Tuple> { + type Output; + + extern "rust-call" fn call_once(self, args: Args) -> Self::Output; +} + +struct ConstFnMutClosure<CapturedData, Function> { + data: CapturedData, + func: Function, +} + +#[lang = "tuple_trait"] +pub trait Tuple {} + +macro_rules! impl_fn_mut_tuple { + ($($var:ident)*) => { + impl<'a, $($var,)* ClosureArguments: Tuple, Function, ClosureReturnValue> const + FnOnce<ClosureArguments> for ConstFnMutClosure<($(&'a mut $var),*), Function> + where + Function: ~const Fn(($(&mut $var),*), ClosureArguments) -> ClosureReturnValue, + Function: ~const Destruct, + { + type Output = ClosureReturnValue; + + extern "rust-call" fn call_once(mut self, args: ClosureArguments) -> Self::Output { + self.call_mut(args) + } + } + impl<'a, $($var,)* ClosureArguments: Tuple, Function, ClosureReturnValue> const + FnMut<ClosureArguments> for ConstFnMutClosure<($(&'a mut $var),*), Function> + where + Function: ~const Fn(($(&mut $var),*), ClosureArguments)-> ClosureReturnValue, + Function: ~const Destruct, + { + extern "rust-call" fn call_mut(&mut self, args: ClosureArguments) -> Self::Output { + #[allow(non_snake_case)] + let ($($var),*) = &mut self.data; + (self.func)(($($var),*), args) + } + } + }; +} +//impl_fn_mut_tuple!(A); +//impl_fn_mut_tuple!(A B); +//impl_fn_mut_tuple!(A B C); +//impl_fn_mut_tuple!(A B C D); +//impl_fn_mut_tuple!(A B C D E); + +#[lang = "receiver"] +trait Receiver {} + +impl<T: ?Sized> Receiver for &T {} + +impl<T: ?Sized> Receiver for &mut T {} + +#[lang = "destruct"] +#[const_trait] +trait Destruct {} + +#[lang = "freeze"] +unsafe auto trait Freeze {} + +#[lang = "drop"] +#[const_trait] +trait Drop { + fn drop(&mut self); +} + +/* +#[const_trait] +trait Residual<O> { + type TryType: ~const Try<Output = O, Residual = Self> + Try<Output = O, Residual = Self>; +} +*/ + +const fn size_of<T>() -> usize { + 42 +} + +impl Copy for u8 {} + +impl usize { + #[rustc_allow_incoherent_impl] + const fn repeat_u8(x: u8) -> usize { + usize::from_ne_bytes([x; size_of::<usize>()]) + } + #[rustc_allow_incoherent_impl] + const fn from_ne_bytes(bytes: [u8; size_of::<Self>()]) -> Self { + loop {} + } +} + +#[rustc_do_not_const_check] // hooked by const-eval +const fn panic_display() { + panic_fmt(); +} + +fn panic_fmt() {} + +#[lang = "index"] +#[const_trait] +trait Index<Idx: ?Sized> { + type Output: ?Sized; + + fn index(&self, index: Idx) -> &Self::Output; +} + + +#[const_trait] +unsafe trait SliceIndex<T: ?Sized> { + type Output: ?Sized; + fn index(self, slice: &T) -> &Self::Output; +} + +impl<T, I> const Index<I> for [T] +where + I: ~const SliceIndex<[T]>, +{ + type Output = I::Output; + + #[inline] + fn index(&self, index: I) -> &I::Output { + index.index(self) + } +} +/* FIXME +impl<T, I, const N: usize> const Index<I> for [T; N] +where + [T]: ~const Index<I>, +{ + type Output = <[T] as Index<I>>::Output; + + #[inline] + // FIXME: make `Self::Output` act like `<Self as ~const Index<I>>::Output` + fn index(&self, index: I) -> &<[T] as Index<I>>::Output { + Index::index(self as &[T], index) + } +} +*/ + +#[lang = "unsize"] +trait Unsize<T: ?Sized> { +} + +#[lang = "coerce_unsized"] +trait CoerceUnsized<T: ?Sized> { +} + +impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {} + + +#[lang = "deref"] +// #[const_trait] FIXME +trait Deref { + #[lang = "deref_target"] + type Target: ?Sized; + + fn deref(&self) -> &Self::Target; +} + + +impl<T: ?Sized> /* const */ Deref for &T { + type Target = T; + + fn deref(&self) -> &T { + *self + } +} + +impl<T: ?Sized> /* const */ Deref for &mut T { + type Target = T; + + fn deref(&self) -> &T { + *self + } +} + +enum Option<T> { + #[lang = "None"] + None, + #[lang = "Some"] + Some(T), +} + +impl<T> Option<T> { + const fn as_ref(&self) -> Option<&T> { + match *self { + Some(ref x) => Some(x), + None => None, + } + } + + const fn as_mut(&mut self) -> Option<&mut T> { + match *self { + Some(ref mut x) => Some(x), + None => None, + } + } +} + +use Option::*; + +/* +const fn as_deref<T>(opt: &Option<T>) -> Option<&T::Target> +where + T: ~const Deref, +{ + match opt { + Option::Some(t) => Option::Some(t.deref()), + Option::None => Option::None, + } +} +*/ + +#[const_trait] +trait Into<T>: Sized { + fn into(self) -> T; +} + +#[const_trait] +trait From<T>: Sized { + fn from(value: T) -> Self; +} + +impl<T, U> const Into<U> for T +where + U: ~const From<T>, +{ + fn into(self) -> U { + U::from(self) + } +} + +impl<T> const From<T> for T { + fn from(t: T) -> T { + t + } +} + +enum Result<T, E> { + Ok(T), + Err(E), +} +use Result::*; + +fn from_str(s: &str) -> Result<bool, ()> { + match s { + "true" => Ok(true), + "false" => Ok(false), + _ => Err(()), + } +} + +#[lang = "eq"] +#[const_trait] +trait PartialEq<Rhs: ?Sized = Self> { + fn eq(&self, other: &Rhs) -> bool; + fn ne(&self, other: &Rhs) -> bool { + !self.eq(other) + } +} + +// FIXME(effects): again, this should not error without Rhs specified +impl PartialEq<str> for str { + fn eq(&self, other: &str) -> bool { + loop {} + } +} + + +#[lang = "not"] +#[const_trait] +trait Not { + type Output; + fn not(self) -> Self::Output; +} + +impl const Not for bool { + type Output = bool; + fn not(self) -> bool { + !self + } +} + +impl Copy for bool {} +impl<'a> Copy for &'a str {} + +#[lang = "pin"] +#[fundamental] +#[repr(transparent)] +struct Pin<P> { + pointer: P, +} + +impl<P> Pin<P> { + #[lang = "new_unchecked"] + const unsafe fn new_unchecked(pointer: P) -> Pin<P> { + Pin { pointer } + } +} + +impl<'a, T: ?Sized> Pin<&'a T> { + const fn get_ref(self) -> &'a T { + self.pointer + } +} + + +impl<P: Deref> Pin<P> { + /* const */ fn as_ref(&self) -> Pin<&P::Target> + where + P: /* ~const */ Deref, + { + unsafe { Pin::new_unchecked(&*self.pointer) } + } +} + + +impl<'a, T: ?Sized> Pin<&'a mut T> { + const unsafe fn get_unchecked_mut(self) -> &'a mut T { + self.pointer + } +} +/* FIXME lol +impl<T> Option<T> { + const fn as_pin_ref(self: Pin<&Self>) -> Option<Pin<&T>> { + match Pin::get_ref(self).as_ref() { + Some(x) => unsafe { Some(Pin::new_unchecked(x)) }, + None => None, + } + } + + const fn as_pin_mut(self: Pin<&mut Self>) -> Option<Pin<&mut T>> { + unsafe { + match Pin::get_unchecked_mut(self).as_mut() { + Some(x) => Some(Pin::new_unchecked(x)), + None => None, + } + } + } +} +*/ + +impl<P: /* ~const */ Deref> /* const */ Deref for Pin<P> { + type Target = P::Target; + fn deref(&self) -> &P::Target { + Pin::get_ref(Pin::as_ref(self)) + } +} + +impl<T> /* const */ Deref for Option<T> { + type Target = T; + fn deref(&self) -> &T { + loop {} + } +} + +impl<P: Receiver> Receiver for Pin<P> {} + +impl<T: Clone> Clone for RefCell<T> { + fn clone(&self) -> RefCell<T> { + RefCell::new(self.borrow().clone()) + } +} + +struct RefCell<T: ?Sized> { + borrow: UnsafeCell<()>, + value: UnsafeCell<T>, +} +impl<T> RefCell<T> { + const fn new(value: T) -> RefCell<T> { + loop {} + } +} +impl<T: ?Sized> RefCell<T> { + fn borrow(&self) -> Ref<'_, T> { + loop {} + } +} + +#[lang = "unsafe_cell"] +#[repr(transparent)] +struct UnsafeCell<T: ?Sized> { + value: T, +} + +struct Ref<'b, T: ?Sized + 'b> { + value: *const T, + borrow: &'b UnsafeCell<()>, +} + +impl<T: ?Sized> Deref for Ref<'_, T> { + type Target = T; + + #[inline] + fn deref(&self) -> &T { + loop {} + } +} + +#[lang = "clone"] +#[rustc_trivial_field_reads] +#[const_trait] +trait Clone: Sized { + fn clone(&self) -> Self; + fn clone_from(&mut self, source: &Self) + where + Self: ~const Destruct, + { + *self = source.clone() + } +} + +#[lang = "structural_peq"] +trait StructuralPartialEq {} + +#[lang = "structural_teq"] +trait StructuralEq {} + +const fn drop<T: ~const Destruct>(_: T) {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.stderr new file mode 100644 index 00000000000..02429374218 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.stderr @@ -0,0 +1,32 @@ +error[E0369]: cannot add `i32` to `i32` + --> $DIR/minicore.rs:33:20 + | +LL | let x = 42_i32 + 43_i32; + | ------ ^ ------ i32 + | | + | i32 + +error[E0369]: cannot add `i32` to `i32` + --> $DIR/minicore.rs:37:20 + | +LL | let x = 42_i32 + 43_i32; + | ------ ^ ------ i32 + | | + | i32 + +error[E0600]: cannot apply unary operator `!` to type `bool` + --> $DIR/minicore.rs:343:9 + | +LL | !self.eq(other) + | ^^^^^^^^^^^^^^^ cannot apply unary operator `!` + +error[E0600]: cannot apply unary operator `!` to type `bool` + --> $DIR/minicore.rs:365:9 + | +LL | !self + | ^^^^^ cannot apply unary operator `!` + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0369, E0600. +For more information about an error, try `rustc --explain E0369`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/project.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/project.rs new file mode 100644 index 00000000000..b30d7743edf --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/project.rs @@ -0,0 +1,11 @@ +// check-pass +#![feature(const_trait_impl, effects)] + +pub trait Owo<X = <Self as Uwu>::T> {} + +#[const_trait] +pub trait Uwu: Owo { + type T; +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.stderr index c94563d3591..2a9647da782 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.stderr @@ -1,35 +1,21 @@ -error[E0277]: the trait bound `T: ~const Bar` is not satisfied +error[E0308]: mismatched types --> $DIR/trait-where-clause-const.rs:21:5 | LL | T::b(); - | ^ the trait `Bar` is not implemented for `T` + | ^^^^^^ expected `host`, found `true` | -note: required by a bound in `Foo::b` - --> $DIR/trait-where-clause-const.rs:15:24 - | -LL | fn b() where Self: ~const Bar; - | ^^^^^^^^^^ required by this bound in `Foo::b` -help: consider further restricting this bound - | -LL | const fn test1<T: ~const Foo + Bar + Bar>() { - | +++++ + = note: expected constant `host` + found constant `true` -error[E0277]: the trait bound `T: ~const Bar` is not satisfied - --> $DIR/trait-where-clause-const.rs:23:12 +error[E0308]: mismatched types + --> $DIR/trait-where-clause-const.rs:23:5 | LL | T::c::<T>(); - | ^ the trait `Bar` is not implemented for `T` - | -note: required by a bound in `Foo::c` - --> $DIR/trait-where-clause-const.rs:16:13 - | -LL | fn c<T: ~const Bar>(); - | ^^^^^^^^^^ required by this bound in `Foo::c` -help: consider further restricting this bound + | ^^^^^^^^^^^ expected `host`, found `true` | -LL | const fn test1<T: ~const Foo + Bar + Bar>() { - | +++++ + = note: expected constant `host` + found constant `true` error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/self/self-impl.stderr b/tests/ui/self/self-impl.stderr index 36372b644d6..18ffd15427f 100644 --- a/tests/ui/self/self-impl.stderr +++ b/tests/ui/self/self-impl.stderr @@ -2,13 +2,13 @@ error[E0223]: ambiguous associated type --> $DIR/self-impl.rs:23:16 | LL | let _: <Self>::Baz = true; - | ^^^^^^^^^^^ help: use the fully-qualified path: `<Bar as Foo>::Baz` + | ^^^^^^^^^^^ help: use fully-qualified syntax: `<Bar as Foo>::Baz` error[E0223]: ambiguous associated type --> $DIR/self-impl.rs:25:16 | LL | let _: Self::Baz = true; - | ^^^^^^^^^ help: use the fully-qualified path: `<Bar as Foo>::Baz` + | ^^^^^^^^^ help: use fully-qualified syntax: `<Bar as Foo>::Baz` error: aborting due to 2 previous errors diff --git a/tests/ui/structs/struct-path-associated-type.stderr b/tests/ui/structs/struct-path-associated-type.stderr index acfddaf3760..0c9d2aad5d8 100644 --- a/tests/ui/structs/struct-path-associated-type.stderr +++ b/tests/ui/structs/struct-path-associated-type.stderr @@ -48,19 +48,19 @@ error[E0223]: ambiguous associated type --> $DIR/struct-path-associated-type.rs:32:13 | LL | let s = S::A {}; - | ^^^^ help: use the fully-qualified path: `<S as Tr>::A` + | ^^^^ help: use fully-qualified syntax: `<S as Tr>::A` error[E0223]: ambiguous associated type --> $DIR/struct-path-associated-type.rs:33:13 | LL | let z = S::A::<u8> {}; - | ^^^^ help: use the fully-qualified path: `<S as Tr>::A` + | ^^^^ help: use fully-qualified syntax: `<S as Tr>::A` error[E0223]: ambiguous associated type --> $DIR/struct-path-associated-type.rs:35:9 | LL | S::A {} => {} - | ^^^^ help: use the fully-qualified path: `<S as Tr>::A` + | ^^^^ help: use fully-qualified syntax: `<S as Tr>::A` error: aborting due to 8 previous errors diff --git a/tests/ui/suggestions/clone-on-unconstrained-borrowed-type-param.stderr b/tests/ui/suggestions/clone-on-unconstrained-borrowed-type-param.stderr index 0716005c679..8c973995c34 100644 --- a/tests/ui/suggestions/clone-on-unconstrained-borrowed-type-param.stderr +++ b/tests/ui/suggestions/clone-on-unconstrained-borrowed-type-param.stderr @@ -4,7 +4,7 @@ error[E0308]: mismatched types LL | fn wat<T>(t: &T) -> T { | - - expected `T` because of return type | | - | this type parameter + | expected this type parameter LL | t.clone() | ^^^^^^^^^ expected type parameter `T`, found `&T` | diff --git a/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr b/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr index 5093448d2ca..7c81825e576 100644 --- a/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr +++ b/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/expected-boxed-future-isnt-pinned.rs:11:5 | LL | fn foo<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> { - | - this type parameter ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type + | - found this type parameter ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type LL | // We could instead use an `async` block, but this way we have no std spans. LL | x | ^ expected `Pin<Box<...>>`, found type parameter `F` @@ -30,7 +30,7 @@ error[E0308]: mismatched types --> $DIR/expected-boxed-future-isnt-pinned.rs:19:14 | LL | fn baz<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> { - | - this type parameter + | - found this type parameter LL | Pin::new(x) | -------- ^ expected `Box<dyn Future<Output = ...> + Send>`, found type parameter `F` | | diff --git a/tests/ui/suggestions/restrict-existing-type-bounds.stderr b/tests/ui/suggestions/restrict-existing-type-bounds.stderr index 14a244b790a..fe8338c18c2 100644 --- a/tests/ui/suggestions/restrict-existing-type-bounds.stderr +++ b/tests/ui/suggestions/restrict-existing-type-bounds.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/restrict-existing-type-bounds.rs:13:12 | LL | impl<T: TryAdd> TryAdd for Option<T> { - | - this type parameter + | - found this type parameter ... LL | Ok(self) | -- ^^^^ expected `Option<<T as TryAdd>::Output>`, found `Option<T>` @@ -29,7 +29,7 @@ error[E0308]: mismatched types --> $DIR/restrict-existing-type-bounds.rs:26:12 | LL | impl<T: TryAdd<Error = X>> TryAdd for Other<T> { - | - this type parameter + | - found this type parameter ... LL | Ok(self) | -- ^^^^ expected `Other<<T as TryAdd>::Output>`, found `Other<T>` diff --git a/tests/ui/suggestions/suggest-trait-in-ufcs-in-hrtb.stderr b/tests/ui/suggestions/suggest-trait-in-ufcs-in-hrtb.stderr index 0ca5b9b9207..0d1eed67c55 100644 --- a/tests/ui/suggestions/suggest-trait-in-ufcs-in-hrtb.stderr +++ b/tests/ui/suggestions/suggest-trait-in-ufcs-in-hrtb.stderr @@ -2,7 +2,7 @@ error[E0223]: ambiguous associated type --> $DIR/suggest-trait-in-ufcs-in-hrtb.rs:5:38 | LL | impl<S> Foo for Bar<S> where for<'a> <&'a S>::Item: Foo {} - | ^^^^^^^^^^^^^ help: use the fully-qualified path: `<&'a S as IntoIterator>::Item` + | ^^^^^^^^^^^^^ help: use fully-qualified syntax: `<&'a S as IntoIterator>::Item` error: aborting due to previous error diff --git a/tests/ui/suggestions/trait-with-missing-associated-type-restriction.stderr b/tests/ui/suggestions/trait-with-missing-associated-type-restriction.stderr index 7deb9a4342d..980c2455c8e 100644 --- a/tests/ui/suggestions/trait-with-missing-associated-type-restriction.stderr +++ b/tests/ui/suggestions/trait-with-missing-associated-type-restriction.stderr @@ -124,7 +124,7 @@ error[E0308]: mismatched types --> $DIR/trait-with-missing-associated-type-restriction.rs:31:9 | LL | fn baz<D: std::fmt::Debug, T: Trait<A = D>>(x: T) { - | - this type parameter + | - found this type parameter LL | qux(x.func()) | --- ^^^^^^^^ expected `usize`, found type parameter `D` | | diff --git a/tests/ui/traits/issue-52893.stderr b/tests/ui/traits/issue-52893.stderr index db807a38830..c57921a08aa 100644 --- a/tests/ui/traits/issue-52893.stderr +++ b/tests/ui/traits/issue-52893.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-52893.rs:53:22 | LL | impl<F, Name, P> AddClass<Name, F> for Class<P> - | - this type parameter + | - expected this type parameter ... LL | builder.push(output); | ---- ^^^^^^ expected type parameter `F`, found `Class<P>` diff --git a/tests/ui/traits/issue-59029-1.stderr b/tests/ui/traits/issue-59029-1.stderr index 51354bcc545..5c47eefcd6c 100644 --- a/tests/ui/traits/issue-59029-1.stderr +++ b/tests/ui/traits/issue-59029-1.stderr @@ -2,13 +2,13 @@ error[E0220]: associated type `Res` not found for `Self` --> $DIR/issue-59029-1.rs:5:52 | LL | trait MkSvc<Target, Req> = Svc<Target> where Self::Res: Svc<Req>; - | ^^^ there is a similarly named associated type `Res` in the trait `Svc` + | ^^^ there is an associated type `Res` in the trait `Svc` error[E0220]: associated type `Res` not found for `Self` --> $DIR/issue-59029-1.rs:5:52 | LL | trait MkSvc<Target, Req> = Svc<Target> where Self::Res: Svc<Req>; - | ^^^ there is a similarly named associated type `Res` in the trait `Svc` + | ^^^ there is an associated type `Res` in the trait `Svc` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/traits/item-privacy.stderr b/tests/ui/traits/item-privacy.stderr index f5381318925..af2e0763212 100644 --- a/tests/ui/traits/item-privacy.stderr +++ b/tests/ui/traits/item-privacy.stderr @@ -159,13 +159,13 @@ error[E0223]: ambiguous associated type --> $DIR/item-privacy.rs:116:12 | LL | let _: S::B; - | ^^^^ help: use the fully-qualified path: `<S as assoc_ty::B>::B` + | ^^^^ help: use fully-qualified syntax: `<S as assoc_ty::B>::B` error[E0223]: ambiguous associated type --> $DIR/item-privacy.rs:117:12 | LL | let _: S::C; - | ^^^^ help: use the fully-qualified path: `<S as assoc_ty::C>::C` + | ^^^^ help: use fully-qualified syntax: `<S as assoc_ty::C>::C` error[E0624]: associated type `A` is private --> $DIR/item-privacy.rs:119:12 diff --git a/tests/ui/traits/new-solver/deduce-closure-signature-after-normalization.rs b/tests/ui/traits/new-solver/deduce-closure-signature-after-normalization.rs index d67fc65032c..51f62bc2312 100644 --- a/tests/ui/traits/new-solver/deduce-closure-signature-after-normalization.rs +++ b/tests/ui/traits/new-solver/deduce-closure-signature-after-normalization.rs @@ -1,8 +1,6 @@ // compile-flags: -Ztrait-solver=next // check-pass -#![feature(return_position_impl_trait_in_trait)] - trait Foo { fn test() -> impl Fn(u32) -> u32 { |x| x.count_ones() diff --git a/tests/ui/traits/new-solver/normalize-async-closure-in-trait.rs b/tests/ui/traits/new-solver/normalize-async-closure-in-trait.rs index b6200096a89..cc16cc87169 100644 --- a/tests/ui/traits/new-solver/normalize-async-closure-in-trait.rs +++ b/tests/ui/traits/new-solver/normalize-async-closure-in-trait.rs @@ -2,8 +2,6 @@ // check-pass // edition:2021 -#![feature(async_fn_in_trait)] - trait Foo { async fn bar() {} } diff --git a/tests/ui/traits/new-solver/object-unsafety.stderr b/tests/ui/traits/new-solver/object-unsafety.stderr index bb7c68b8941..914a8f9d4c5 100644 --- a/tests/ui/traits/new-solver/object-unsafety.stderr +++ b/tests/ui/traits/new-solver/object-unsafety.stderr @@ -42,7 +42,7 @@ error[E0308]: mismatched types LL | pub fn copy_any<T>(t: &T) -> T { | - - expected `T` because of return type | | - | this type parameter + | expected this type parameter LL | copy::<dyn Setup<From=T>>(t) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ | diff --git a/tests/ui/traits/new-solver/specialization-unconstrained.stderr b/tests/ui/traits/new-solver/specialization-unconstrained.stderr index 9915da1a27a..ed4dafa1484 100644 --- a/tests/ui/traits/new-solver/specialization-unconstrained.stderr +++ b/tests/ui/traits/new-solver/specialization-unconstrained.stderr @@ -8,12 +8,6 @@ LL | #![feature(specialization)] = help: consider using `min_specialization` instead, which is more stable and complete = note: `#[warn(incomplete_features)]` on by default -error[E0282]: type annotations needed - --> $DIR/specialization-unconstrained.rs:14:22 - | -LL | default type Id = T; - | ^ cannot infer type for associated type `<T as Default>::Id` - error[E0284]: type annotations needed: cannot satisfy `<u32 as Default>::Id == ()` --> $DIR/specialization-unconstrained.rs:20:5 | @@ -26,6 +20,12 @@ note: required by a bound in `test` LL | fn test<T: Default<Id = U>, U>() {} | ^^^^^^ required by this bound in `test` +error[E0282]: type annotations needed + --> $DIR/specialization-unconstrained.rs:14:22 + | +LL | default type Id = T; + | ^ cannot infer type for associated type `<T as Default>::Id` + error: aborting due to 2 previous errors; 1 warning emitted Some errors have detailed explanations: E0282, E0284. diff --git a/tests/ui/type-alias-enum-variants/enum-variant-generic-args.stderr b/tests/ui/type-alias-enum-variants/enum-variant-generic-args.stderr index e24cb11288e..96a5c132763 100644 --- a/tests/ui/type-alias-enum-variants/enum-variant-generic-args.stderr +++ b/tests/ui/type-alias-enum-variants/enum-variant-generic-args.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/enum-variant-generic-args.rs:13:25 | LL | impl<T> Enum<T> { - | - this type parameter + | - expected this type parameter LL | fn ts_variant() { LL | Self::TSVariant(()); | --------------- ^^ expected type parameter `T`, found `()` @@ -50,7 +50,7 @@ error[E0308]: mismatched types --> $DIR/enum-variant-generic-args.rs:17:31 | LL | impl<T> Enum<T> { - | - this type parameter + | - expected this type parameter ... LL | Self::<()>::TSVariant(()); | --------------------- ^^ expected type parameter `T`, found `()` @@ -98,7 +98,7 @@ error[E0308]: mismatched types --> $DIR/enum-variant-generic-args.rs:26:29 | LL | impl<T> Enum<T> { - | - this type parameter + | - expected this type parameter ... LL | Self::SVariant { v: () }; | ^^ expected type parameter `T`, found `()` @@ -125,7 +125,7 @@ error[E0308]: mismatched types --> $DIR/enum-variant-generic-args.rs:28:35 | LL | impl<T> Enum<T> { - | - this type parameter + | - expected this type parameter ... LL | Self::SVariant::<()> { v: () }; | ^^ expected type parameter `T`, found `()` @@ -158,7 +158,7 @@ error[E0308]: mismatched types --> $DIR/enum-variant-generic-args.rs:31:35 | LL | impl<T> Enum<T> { - | - this type parameter + | - expected this type parameter ... LL | Self::<()>::SVariant { v: () }; | ^^ expected type parameter `T`, found `()` @@ -206,7 +206,7 @@ error[E0308]: mismatched types --> $DIR/enum-variant-generic-args.rs:34:41 | LL | impl<T> Enum<T> { - | - this type parameter + | - expected this type parameter ... LL | Self::<()>::SVariant::<()> { v: () }; | ^^ expected type parameter `T`, found `()` diff --git a/tests/ui/type-alias-impl-trait/not_well_formed.fixed b/tests/ui/type-alias-impl-trait/not_well_formed.fixed new file mode 100644 index 00000000000..d98e83ff6dd --- /dev/null +++ b/tests/ui/type-alias-impl-trait/not_well_formed.fixed @@ -0,0 +1,19 @@ +// run-rustfix +#![feature(type_alias_impl_trait)] +#![allow(dead_code)] + +fn main() {} + +trait TraitWithAssoc { + type Assoc; +} + +type Foo<V: TraitWithAssoc> = impl Trait<V::Assoc>; //~ associated type `Assoc` not found for `V` + +trait Trait<U> {} + +impl<W> Trait<W> for () {} + +fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T> { + () +} diff --git a/tests/ui/type-alias-impl-trait/not_well_formed.rs b/tests/ui/type-alias-impl-trait/not_well_formed.rs index fbb7a4d58e4..18f173a693d 100644 --- a/tests/ui/type-alias-impl-trait/not_well_formed.rs +++ b/tests/ui/type-alias-impl-trait/not_well_formed.rs @@ -1,4 +1,6 @@ +// run-rustfix #![feature(type_alias_impl_trait)] +#![allow(dead_code)] fn main() {} diff --git a/tests/ui/type-alias-impl-trait/not_well_formed.stderr b/tests/ui/type-alias-impl-trait/not_well_formed.stderr index c36b95f47e8..b267e6a7544 100644 --- a/tests/ui/type-alias-impl-trait/not_well_formed.stderr +++ b/tests/ui/type-alias-impl-trait/not_well_formed.stderr @@ -1,8 +1,13 @@ error[E0220]: associated type `Assoc` not found for `V` - --> $DIR/not_well_formed.rs:9:29 + --> $DIR/not_well_formed.rs:11:29 | LL | type Foo<V> = impl Trait<V::Assoc>; - | ^^^^^ there is a similarly named associated type `Assoc` in the trait `TraitWithAssoc` + | ^^^^^ there is an associated type `Assoc` in the trait `TraitWithAssoc` + | +help: consider restricting type parameter `V` + | +LL | type Foo<V: TraitWithAssoc> = impl Trait<V::Assoc>; + | ++++++++++++++++ error: aborting due to previous error diff --git a/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.current.stderr b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.current.stderr index 4b09a9e743b..844103d77a8 100644 --- a/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.current.stderr +++ b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.current.stderr @@ -1,11 +1,17 @@ error: internal compiler error: no errors encountered even though `delay_span_bug` issued -error: internal compiler error: ambiguity performing ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: ProvePredicate { predicate: Binder { value: ProjectionPredicate(AliasTy { args: [FnDef(DefId(get_rpit), []), ()], def_id: DefId(ops::function::FnOnce::Output) }, Term::Ty(Alias(Opaque, AliasTy { args: [], def_id: DefId(Opaque::{opaque#0}) }))), bound_vars: [] } } } +error: internal compiler error: {OpaqueTypeKey { def_id: DefId(get_rpit::{opaque#0}), args: [] }: OpaqueTypeDecl { hidden_type: OpaqueHiddenType { span: no-location (#0), ty: Alias(Opaque, AliasTy { args: [], def_id: DefId(Opaque::{opaque#0}) }) } }} + | + = + + +error: internal compiler error: error performing ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: ProvePredicate { predicate: Binder { value: ProjectionPredicate(AliasTy { args: [FnDef(DefId(get_rpit), []), ()], def_id: DefId(ops::function::FnOnce::Output) }, Term::Ty(Alias(Opaque, AliasTy { args: [], def_id: DefId(Opaque::{opaque#0}) }))), bound_vars: [] } } } --> $DIR/rpit_tait_equality_in_canonical_query.rs:28:5 | LL | query(get_rpit); | ^^^^^^^^^^^^^^^ | + --> $DIR/rpit_tait_equality_in_canonical_query.rs:28:5 | LL | query(get_rpit); @@ -14,7 +20,10 @@ LL | query(get_rpit); + + + query stack during panic: end of query stack -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs index 8dccd2ed46f..0f0002f7797 100644 --- a/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs +++ b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs @@ -12,7 +12,7 @@ //[current] known-bug: #108498 //[current] failure-status: 101 //[current] normalize-stderr-test: "DefId\(.*?\]::" -> "DefId(" -//[current] normalize-stderr-test: "(?m)^note: .*\n" -> "" +//[current] normalize-stderr-test: "(?m)note: .*$" -> "" //[current] normalize-stderr-test: "(?m)^ *\d+: .*\n" -> "" //[current] normalize-stderr-test: "(?m)^ *at .*\n" -> "" diff --git a/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query_2.rs b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query_2.rs new file mode 100644 index 00000000000..9d7e647dd94 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query_2.rs @@ -0,0 +1,18 @@ +// The canonical query `Projection(<get_rpit as FnOnce>::Output = Opaque)` +// is the *only* site that defines `Opaque` in MIR typeck. +// +// check-pass + +#![feature(type_alias_impl_trait)] + +type Opaque = impl Sized; + +fn get_rpit() -> impl Sized {} + +fn query(_: impl FnOnce() -> Opaque) {} + +fn test(_: Opaque) { + query(get_rpit); +} + +fn main() {} diff --git a/tests/ui/typeck/bad-index-due-to-nested.stderr b/tests/ui/typeck/bad-index-due-to-nested.stderr index f9cdb280e27..0b705d467ff 100644 --- a/tests/ui/typeck/bad-index-due-to-nested.stderr +++ b/tests/ui/typeck/bad-index-due-to-nested.stderr @@ -40,7 +40,7 @@ error[E0308]: mismatched types --> $DIR/bad-index-due-to-nested.rs:20:9 | LL | fn index<'a, K, V>(map: &'a HashMap<K, V>, k: K) -> &'a V { - | - this type parameter + | - found this type parameter LL | map[k] | ^ expected `&K`, found type parameter `K` | @@ -55,7 +55,7 @@ error[E0308]: mismatched types --> $DIR/bad-index-due-to-nested.rs:20:5 | LL | fn index<'a, K, V>(map: &'a HashMap<K, V>, k: K) -> &'a V { - | - this type parameter ----- expected `&'a V` because of return type + | - found this type parameter ----- expected `&'a V` because of return type LL | map[k] | ^^^^^^ expected `&V`, found type parameter `V` | diff --git a/tests/ui/typeck/issue-107087.stderr b/tests/ui/typeck/issue-107087.stderr index 70f19320802..8921e3f7694 100644 --- a/tests/ui/typeck/issue-107087.stderr +++ b/tests/ui/typeck/issue-107087.stderr @@ -2,7 +2,7 @@ error[E0223]: ambiguous associated type --> $DIR/issue-107087.rs:16:5 | LL | A::B::<>::C - | ^^^^^^^^ help: use the fully-qualified path: `<A<_> as Foo>::B` + | ^^^^^^^^ help: use fully-qualified syntax: `<A<_> as Foo>::B` error: aborting due to previous error diff --git a/tests/ui/typeck/issue-110052.stderr b/tests/ui/typeck/issue-110052.stderr index 0c15c03a740..75374fa6121 100644 --- a/tests/ui/typeck/issue-110052.stderr +++ b/tests/ui/typeck/issue-110052.stderr @@ -2,7 +2,7 @@ error[E0223]: ambiguous associated type --> $DIR/issue-110052.rs:6:30 | LL | for<'iter> dyn Validator<<&'iter I>::Item>:, - | ^^^^^^^^^^^^^^^^ help: use the fully-qualified path: `<&'iter I as IntoIterator>::Item` + | ^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<&'iter I as IntoIterator>::Item` error: aborting due to previous error diff --git a/tests/ui/typeck/issue-13853.stderr b/tests/ui/typeck/issue-13853.stderr index 8ecb8b68016..0683c782933 100644 --- a/tests/ui/typeck/issue-13853.stderr +++ b/tests/ui/typeck/issue-13853.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-13853.rs:14:9 | LL | fn nodes<'a, I: Iterator<Item=&'a N>>(&self) -> I - | - this type parameter - expected `I` because of return type + | - expected this type parameter - expected `I` because of return type ... LL | self.iter() | ^^^^^^^^^^^ expected type parameter `I`, found `Iter<'_, N>` diff --git a/tests/ui/unboxed-closures/unboxed-closures-type-mismatch-closure-from-another-scope.rs b/tests/ui/unboxed-closures/unboxed-closures-type-mismatch-closure-from-another-scope.rs new file mode 100644 index 00000000000..157383fede1 --- /dev/null +++ b/tests/ui/unboxed-closures/unboxed-closures-type-mismatch-closure-from-another-scope.rs @@ -0,0 +1,23 @@ +fn test() { + let x = match **x { //~ ERROR + Some(&a) if { panic!() } => {} + }; + let mut p = &x; + + { + let mut closure = expect_sig(|p, y| *p = y); + closure(&mut p, &y); //~ ERROR + //~^ ERROR + } + + deref(p); //~ ERROR +} + +fn expect_sig<F>(f: F) -> F +where + F: FnMut(&mut &i32, &i32), +{ + f +} + +fn main() {} diff --git a/tests/ui/unboxed-closures/unboxed-closures-type-mismatch-closure-from-another-scope.stderr b/tests/ui/unboxed-closures/unboxed-closures-type-mismatch-closure-from-another-scope.stderr new file mode 100644 index 00000000000..1470c32d7de --- /dev/null +++ b/tests/ui/unboxed-closures/unboxed-closures-type-mismatch-closure-from-another-scope.stderr @@ -0,0 +1,44 @@ +error[E0425]: cannot find value `x` in this scope + --> $DIR/unboxed-closures-type-mismatch-closure-from-another-scope.rs:2:21 + | +LL | let x = match **x { + | ^ not found in this scope + +error[E0425]: cannot find value `y` in this scope + --> $DIR/unboxed-closures-type-mismatch-closure-from-another-scope.rs:9:26 + | +LL | closure(&mut p, &y); + | ^ help: a local variable with a similar name exists: `p` + +error[E0308]: mismatched types + --> $DIR/unboxed-closures-type-mismatch-closure-from-another-scope.rs:9:17 + | +LL | closure(&mut p, &y); + | ------- ^^^^^^ expected `&mut &i32`, found `&mut &()` + | | + | arguments to this function are incorrect + | + = note: expected mutable reference `&mut &i32` + found mutable reference `&mut &()` +note: closure parameter defined here + --> $DIR/unboxed-closures-type-mismatch-closure-from-another-scope.rs:8:39 + | +LL | let mut closure = expect_sig(|p, y| *p = y); + | ^ + +error[E0425]: cannot find function `deref` in this scope + --> $DIR/unboxed-closures-type-mismatch-closure-from-another-scope.rs:13:5 + | +LL | deref(p); + | ^^^^^ not found in this scope + | +help: use the `.` operator to call the method `Deref::deref` on `&&()` + | +LL - deref(p); +LL + p.deref(); + | + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0308, E0425. +For more information about an error, try `rustc --explain E0308`. |
