diff options
Diffstat (limited to 'tests')
1326 files changed, 9109 insertions, 4185 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..03cc46cdcde 100644 --- a/tests/codegen/async-fn-debug-awaitee-field.rs +++ b/tests/codegen/async-fn-debug-awaitee-field.rs @@ -1,9 +1,9 @@ -// This test makes sure that the generator field capturing the awaitee in a `.await` expression +// This test makes sure that the coroutine field capturing the awaitee in a `.await` expression // is called "__awaitee" in debuginfo. This name must not be changed since debuggers and debugger // 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/async-fn-debug-msvc.rs b/tests/codegen/async-fn-debug-msvc.rs index 73c652c9dd1..707a0d27740 100644 --- a/tests/codegen/async-fn-debug-msvc.rs +++ b/tests/codegen/async-fn-debug-msvc.rs @@ -1,4 +1,4 @@ -// Verify debuginfo for generators: +// Verify debuginfo for coroutines: // - Each variant points to the file and line of its yield point // - The discriminants are marked artificial // - Other fields are not marked artificial diff --git a/tests/codegen/generator-debug-msvc.rs b/tests/codegen/coroutine-debug-msvc.rs index 9d70ccdef03..6d16e7576c1 100644 --- a/tests/codegen/generator-debug-msvc.rs +++ b/tests/codegen/coroutine-debug-msvc.rs @@ -1,4 +1,4 @@ -// Verify debuginfo for generators: +// Verify debuginfo for coroutines: // - Each variant points to the file and line of its yield point // - The discriminants are marked artificial // - Other fields are not marked artificial @@ -7,10 +7,10 @@ // compile-flags: -C debuginfo=2 // only-msvc -#![feature(generators, generator_trait)] -use std::ops::Generator; +#![feature(coroutines, coroutine_trait)] +use std::ops::Coroutine; -fn generator_test() -> impl Generator<Yield = i32, Return = ()> { +fn coroutine_test() -> impl Coroutine<Yield = i32, Return = ()> { || { yield 0; let s = String::from("foo"); @@ -20,7 +20,7 @@ fn generator_test() -> impl Generator<Yield = i32, Return = ()> { // FIXME: No way to reliably check the filename. -// CHECK-DAG: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<generator_debug_msvc::generator_test::generator_env$0>" +// CHECK-DAG: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<coroutine_debug_msvc::coroutine_test::coroutine_env$0>" // CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant0", scope: [[GEN]], // For brevity, we only check the struct name and members of the last variant. // CHECK-SAME: file: [[FILE:![0-9]*]], line: 14, @@ -55,5 +55,5 @@ fn generator_test() -> impl Generator<Yield = i32, Return = ()> { // CHECK-NOT: flags: DIFlagArtificial fn main() { - let _dummy = generator_test(); + let _dummy = coroutine_test(); } diff --git a/tests/codegen/generator-debug.rs b/tests/codegen/coroutine-debug.rs index 3ec860f2cbc..b060f3bfac7 100644 --- a/tests/codegen/generator-debug.rs +++ b/tests/codegen/coroutine-debug.rs @@ -1,4 +1,4 @@ -// Verify debuginfo for generators: +// Verify debuginfo for coroutines: // - Each variant points to the file and line of its yield point // - The discriminants are marked artificial // - Other fields are not marked artificial @@ -7,10 +7,10 @@ // compile-flags: -C debuginfo=2 --edition=2018 // ignore-msvc -#![feature(generators, generator_trait)] -use std::ops::Generator; +#![feature(coroutines, coroutine_trait)] +use std::ops::Coroutine; -fn generator_test() -> impl Generator<Yield = i32, Return = ()> { +fn coroutine_test() -> impl Coroutine<Yield = i32, Return = ()> { || { yield 0; let s = String::from("foo"); @@ -20,8 +20,8 @@ fn generator_test() -> impl Generator<Yield = i32, Return = ()> { // FIXME: No way to reliably check the filename. -// CHECK-DAG: [[GEN_FN:!.*]] = !DINamespace(name: "generator_test" -// CHECK-DAG: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "{generator_env#0}", scope: [[GEN_FN]] +// CHECK-DAG: [[GEN_FN:!.*]] = !DINamespace(name: "coroutine_test" +// CHECK-DAG: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "{coroutine_env#0}", scope: [[GEN_FN]] // CHECK: [[VARIANT:!.*]] = !DICompositeType(tag: DW_TAG_variant_part, scope: [[GEN]], // CHECK-NOT: flags: DIFlagArtificial // CHECK-SAME: discriminator: [[DISC:![0-9]*]] @@ -58,5 +58,5 @@ fn generator_test() -> impl Generator<Yield = i32, Return = ()> { // CHECK-SAME: flags: DIFlagArtificial fn main() { - let _dummy = generator_test(); + let _dummy = coroutine_test(); } 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/fn_sig_into_try.cov-map b/tests/coverage-map/fn_sig_into_try.cov-map new file mode 100644 index 00000000000..4672e7c1ce9 --- /dev/null +++ b/tests/coverage-map/fn_sig_into_try.cov-map @@ -0,0 +1,53 @@ +Function name: fn_sig_into_try::a +Raw bytes (9): 0x[01, 01, 00, 01, 01, 0a, 01, 04, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 10, 1) to (start + 4, 2) + +Function name: fn_sig_into_try::b +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 10, 01, 02, 0f, 00, 02, 0f, 00, 10, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 16, 1) to (start + 2, 15) +- Code(Zero) at (prev + 2, 15) to (start + 0, 16) +- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 12) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) + = (c1 + (c0 - c1)) + +Function name: fn_sig_into_try::c +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 16, 01, 02, 17, 00, 02, 17, 00, 18, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 22, 1) to (start + 2, 23) +- Code(Zero) at (prev + 2, 23) to (start + 0, 24) +- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 12) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) + = (c1 + (c0 - c1)) + +Function name: fn_sig_into_try::d +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 1c, 01, 03, 0f, 00, 03, 0f, 00, 10, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 28, 1) to (start + 3, 15) +- Code(Zero) at (prev + 3, 15) to (start + 0, 16) +- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 12) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) + = (c1 + (c0 - c1)) + diff --git a/tests/coverage-map/fn_sig_into_try.rs b/tests/coverage-map/fn_sig_into_try.rs new file mode 100644 index 00000000000..92850c8a188 --- /dev/null +++ b/tests/coverage-map/fn_sig_into_try.rs @@ -0,0 +1,41 @@ +#![feature(coverage_attribute)] +// compile-flags: --edition=2021 + +// Regression test for inconsistent handling of function signature spans that +// are followed by code using the `?` operator. +// +// For each of these similar functions, the line containing the function +// signature should be handled in the same way. + +fn a() -> Option<i32> +{ + Some(7i32); + Some(0) +} + +fn b() -> Option<i32> +{ + Some(7i32)?; + Some(0) +} + +fn c() -> Option<i32> +{ + let _ = Some(7i32)?; + Some(0) +} + +fn d() -> Option<i32> +{ + let _: () = (); + Some(7i32)?; + Some(0) +} + +#[coverage(off)] +fn main() { + a(); + b(); + c(); + d(); +} diff --git a/tests/coverage-map/status-quo/generator.cov-map b/tests/coverage-map/status-quo/coroutine.cov-map index 75704bcc223..2f4936d9ab8 100644 --- a/tests/coverage-map/status-quo/generator.cov-map +++ b/tests/coverage-map/status-quo/coroutine.cov-map @@ -1,4 +1,4 @@ -Function name: generator::get_u32 +Function name: coroutine::get_u32 Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 0b, 01, 01, 0b, 05, 01, 0e, 00, 13, 02, 00, 1d, 00, 3c, 07, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 @@ -13,7 +13,7 @@ Number of file 0 mappings: 4 - Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) = (c1 + (c0 - c1)) -Function name: generator::main +Function name: coroutine::main Raw bytes (65): 0x[01, 01, 08, 05, 07, 09, 0d, 11, 15, 1e, 19, 11, 15, 15, 19, 1e, 19, 11, 15, 09, 01, 0f, 01, 02, 16, 01, 07, 0b, 00, 2e, 11, 01, 2b, 00, 2d, 03, 01, 0e, 00, 35, 11, 02, 0b, 00, 2e, 1e, 01, 22, 00, 27, 1a, 00, 2c, 00, 2e, 17, 01, 0e, 00, 35, 1a, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 @@ -42,7 +42,7 @@ Number of file 0 mappings: 9 - Code(Expression(6, Sub)) at (prev + 2, 1) to (start + 0, 2) = ((c4 - c5) - c6) -Function name: generator::main::{closure#0} +Function name: coroutine::main::{closure#0} Raw bytes (14): 0x[01, 01, 00, 02, 01, 11, 1c, 01, 1f, 05, 02, 10, 01, 06] Number of files: 1 - file 0 => global file 1 diff --git a/tests/run-coverage/generator.rs b/tests/coverage-map/status-quo/coroutine.rs index 4319991021e..86d19af6f4f 100644 --- a/tests/run-coverage/generator.rs +++ b/tests/coverage-map/status-quo/coroutine.rs @@ -1,11 +1,11 @@ -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; // The following implementation of a function called from a `yield` statement // (apparently requiring the Result and the `String` type or constructor) -// creates conditions where the `generator::StateTransform` MIR transform will +// creates conditions where the `coroutine::StateTransform` MIR transform will // drop all `Counter` `Coverage` statements from a MIR. `simplify.rs` has logic // to handle this condition, and still report dead block coverage. fn get_u32(val: bool) -> Result<u32, String> { @@ -14,17 +14,17 @@ fn get_u32(val: bool) -> Result<u32, String> { fn main() { let is_true = std::env::args().len() == 1; - let mut generator = || { + let mut coroutine = || { yield get_u32(is_true); return "foo"; }; - match Pin::new(&mut generator).resume(()) { - GeneratorState::Yielded(Ok(1)) => {} + match Pin::new(&mut coroutine).resume(()) { + CoroutineState::Yielded(Ok(1)) => {} _ => panic!("unexpected return from resume"), } - match Pin::new(&mut generator).resume(()) { - GeneratorState::Complete("foo") => {} + match Pin::new(&mut coroutine).resume(()) { + CoroutineState::Complete("foo") => {} _ => panic!("unexpected return from resume"), } } diff --git a/tests/coverage-map/status-quo/inline-dead.cov-map b/tests/coverage-map/status-quo/inline-dead.cov-map index 483f7ef79c6..06b64da5723 100644 --- a/tests/coverage-map/status-quo/inline-dead.cov-map +++ b/tests/coverage-map/status-quo/inline-dead.cov-map @@ -31,13 +31,15 @@ Number of file 0 mappings: 2 - Code(Counter(0)) at (prev + 7, 6) to (start + 2, 2) Function name: inline_dead::main::{closure#0} -Raw bytes (16): 0x[01, 01, 01, 01, 05, 02, 00, 09, 0d, 00, 0e, 03, 02, 05, 00, 06] +Raw bytes (23): 0x[01, 01, 02, 09, 06, 01, 05, 03, 01, 07, 17, 00, 18, 00, 02, 0d, 00, 0e, 03, 02, 05, 00, 06] Number of files: 1 - file 0 => global file 1 -Number of expressions: 1 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 2 -- Code(Zero) at (prev + 9, 13) to (start + 0, 14) +Number of expressions: 2 +- expression 0 operands: lhs = Counter(2), rhs = Expression(1, Sub) +- expression 1 operands: lhs = Counter(0), rhs = Counter(1) +Number of file 0 mappings: 3 +- Code(Counter(0)) at (prev + 7, 23) to (start + 0, 24) +- Code(Zero) at (prev + 2, 13) to (start + 0, 14) - Code(Expression(0, Add)) at (prev + 2, 5) to (start + 0, 6) - = (c0 + c1) + = (c2 + (c0 - c1)) diff --git a/tests/coverage-map/status-quo/issue-84561.cov-map b/tests/coverage-map/status-quo/issue-84561.cov-map index fe098fd396c..76340b1a78c 100644 --- a/tests/coverage-map/status-quo/issue-84561.cov-map +++ b/tests/coverage-map/status-quo/issue-84561.cov-map @@ -1,22 +1,21 @@ 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] +Raw bytes (29): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 88, 01, 05, 01, 25, 05, 01, 25, 00, 26, 02, 01, 09, 00, 0f, 07, 01, 05, 00, 06] Number of files: 1 - file 0 => global file 1 Number of expressions: 2 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) - expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 -- Code(Counter(0)) at (prev + 137, 9) to (start + 0, 37) -- Code(Counter(1)) at (prev + 0, 37) to (start + 0, 38) +- Code(Counter(0)) at (prev + 136, 5) to (start + 1, 37) +- Code(Counter(1)) at (prev + 1, 37) to (start + 0, 38) - Code(Expression(0, Sub)) at (prev + 1, 9) to (start + 0, 15) = (c0 - c1) - Code(Expression(1, Add)) at (prev + 1, 5) to (start + 0, 6) diff --git a/tests/coverage-map/status-quo/yield.rs b/tests/coverage-map/status-quo/yield.rs index 361275c9215..b7e2ba31b59 100644 --- a/tests/coverage-map/status-quo/yield.rs +++ b/tests/coverage-map/status-quo/yield.rs @@ -1,37 +1,37 @@ -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] #![allow(unused_assignments)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; fn main() { - let mut generator = || { + let mut coroutine = || { yield 1; return "foo"; }; - match Pin::new(&mut generator).resume(()) { - GeneratorState::Yielded(1) => {} + match Pin::new(&mut coroutine).resume(()) { + CoroutineState::Yielded(1) => {} _ => panic!("unexpected value from resume"), } - match Pin::new(&mut generator).resume(()) { - GeneratorState::Complete("foo") => {} + match Pin::new(&mut coroutine).resume(()) { + CoroutineState::Complete("foo") => {} _ => panic!("unexpected value from resume"), } - let mut generator = || { + let mut coroutine = || { yield 1; yield 2; yield 3; return "foo"; }; - match Pin::new(&mut generator).resume(()) { - GeneratorState::Yielded(1) => {} + match Pin::new(&mut coroutine).resume(()) { + CoroutineState::Yielded(1) => {} _ => panic!("unexpected value from resume"), } - match Pin::new(&mut generator).resume(()) { - GeneratorState::Yielded(2) => {} + match Pin::new(&mut coroutine).resume(()) { + CoroutineState::Yielded(2) => {} _ => panic!("unexpected value from resume"), } } diff --git a/tests/debuginfo/generator-locals.rs b/tests/debuginfo/coroutine-locals.rs index fd46c1a8b4d..e5eb1022ff4 100644 --- a/tests/debuginfo/generator-locals.rs +++ b/tests/debuginfo/coroutine-locals.rs @@ -54,10 +54,10 @@ // lldbg-check:(int) $7 = 6 // lldbr-check:(int) c = 6 -#![feature(omit_gdb_pretty_printer_section, generators, generator_trait)] +#![feature(omit_gdb_pretty_printer_section, coroutines, coroutine_trait)] #![omit_gdb_pretty_printer_section] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; fn main() { diff --git a/tests/debuginfo/generator-objects.rs b/tests/debuginfo/coroutine-objects.rs index 11c4ae2f659..3e658b2136e 100644 --- a/tests/debuginfo/generator-objects.rs +++ b/tests/debuginfo/coroutine-objects.rs @@ -2,7 +2,7 @@ // min-gdb-version: 8.2 // LLDB without native Rust support cannot read DW_TAG_variant_part, -// so it prints nothing for generators. But those tests are kept to +// so it prints nothing for coroutines. But those tests are kept to // ensure that LLDB won't crash at least (like #57822). // compile-flags:-g @@ -11,62 +11,62 @@ // gdb-command:run // gdb-command:print b -// gdb-check:$1 = generator_objects::main::{generator_env#0}::Unresumed{_ref__a: 0x[...]} +// gdb-check:$1 = coroutine_objects::main::{coroutine_env#0}::Unresumed{_ref__a: 0x[...]} // gdb-command:continue // gdb-command:print b -// gdb-check:$2 = generator_objects::main::{generator_env#0}::Suspend0{c: 6, d: 7, _ref__a: 0x[...]} +// gdb-check:$2 = coroutine_objects::main::{coroutine_env#0}::Suspend0{c: 6, d: 7, _ref__a: 0x[...]} // gdb-command:continue // gdb-command:print b -// gdb-check:$3 = generator_objects::main::{generator_env#0}::Suspend1{c: 7, d: 8, _ref__a: 0x[...]} +// gdb-check:$3 = coroutine_objects::main::{coroutine_env#0}::Suspend1{c: 7, d: 8, _ref__a: 0x[...]} // gdb-command:continue // gdb-command:print b -// gdb-check:$4 = generator_objects::main::{generator_env#0}::Returned{_ref__a: 0x[...]} +// gdb-check:$4 = coroutine_objects::main::{coroutine_env#0}::Returned{_ref__a: 0x[...]} // === LLDB TESTS ================================================================================== // lldb-command:run // lldb-command:print b -// lldbg-check:(generator_objects::main::{generator_env#0}) $0 = +// lldbg-check:(coroutine_objects::main::{coroutine_env#0}) $0 = // lldb-command:continue // lldb-command:print b -// lldbg-check:(generator_objects::main::{generator_env#0}) $1 = +// lldbg-check:(coroutine_objects::main::{coroutine_env#0}) $1 = // lldb-command:continue // lldb-command:print b -// lldbg-check:(generator_objects::main::{generator_env#0}) $2 = +// lldbg-check:(coroutine_objects::main::{coroutine_env#0}) $2 = // lldb-command:continue // lldb-command:print b -// lldbg-check:(generator_objects::main::{generator_env#0}) $3 = +// lldbg-check:(coroutine_objects::main::{coroutine_env#0}) $3 = // === CDB TESTS =================================================================================== // cdb-command: g // cdb-command: dx b -// cdb-check: b : Unresumed [Type: enum2$<generator_objects::main::generator_env$0>] +// cdb-check: b : Unresumed [Type: enum2$<coroutine_objects::main::coroutine_env$0>] // cdb-check: [+0x[...]] _ref__a : 0x[...] : 5 [Type: int *] // cdb-command: g // cdb-command: dx b -// cdb-check: b : Suspend0 [Type: enum2$<generator_objects::main::generator_env$0>] +// cdb-check: b : Suspend0 [Type: enum2$<coroutine_objects::main::coroutine_env$0>] // cdb-check: [+0x[...]] c : 6 [Type: int] // cdb-check: [+0x[...]] d : 7 [Type: int] // cdb-check: [+0x[...]] _ref__a : 0x[...] : 5 [Type: int *] // cdb-command: g // cdb-command: dx b -// cdb-check: b : Suspend1 [Type: enum2$<generator_objects::main::generator_env$0>] +// cdb-check: b : Suspend1 [Type: enum2$<coroutine_objects::main::coroutine_env$0>] // cdb-check: [+0x[...]] c : 7 [Type: int] // cdb-check: [+0x[...]] d : 8 [Type: int] // cdb-check: [+0x[...]] _ref__a : 0x[...] : 6 [Type: int *] // cdb-command: g // cdb-command: dx b -// cdb-check: b : Returned [Type: enum2$<generator_objects::main::generator_env$0>] +// cdb-check: b : Returned [Type: enum2$<coroutine_objects::main::coroutine_env$0>] // cdb-check: [+0x[...]] _ref__a : 0x[...] : 6 [Type: int *] -#![feature(omit_gdb_pretty_printer_section, generators, generator_trait)] +#![feature(omit_gdb_pretty_printer_section, coroutines, coroutine_trait)] #![omit_gdb_pretty_printer_section] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; fn main() { diff --git a/tests/debuginfo/function-names.rs b/tests/debuginfo/function-names.rs index d9aa03fee62..d29b3ea76b7 100644 --- a/tests/debuginfo/function-names.rs +++ b/tests/debuginfo/function-names.rs @@ -31,8 +31,8 @@ // gdb-check:[...]static fn function_names::main::{closure#0}(*mut function_names::main::{closure_env#0}); // gdb-check:[...]static fn function_names::{impl#2}::impl_function::{closure#0}<i32, i32>(*mut function_names::{impl#2}::impl_function::{closure_env#0}<i32, i32>); -// Generator -// Generators don't seem to appear in GDB's symbol table. +// Coroutine +// Coroutines don't seem to appear in GDB's symbol table. // Const generic parameter // gdb-command:info functions -q function_names::const_generic_fn.* @@ -69,9 +69,9 @@ // cdb-check:[...] a!function_names::main::closure$0 (void) // cdb-check:[...] a!function_names::generic_func::closure$0<i32> (void) -// Generator -// cdb-command:x a!function_names::*::generator* -// cdb-check:[...] a!function_names::main::generator$1 (void) +// Coroutine +// cdb-command:x a!function_names::*::coroutine* +// cdb-check:[...] a!function_names::main::coroutine$1 (void) // Const generic parameter // cdb-command:x a!function_names::const_generic_fn* @@ -83,10 +83,10 @@ #![allow(unused_variables)] #![feature(omit_gdb_pretty_printer_section)] #![omit_gdb_pretty_printer_section] -#![feature(adt_const_params, generators, generator_trait)] +#![feature(adt_const_params, coroutines, coroutine_trait)] #![allow(incomplete_features)] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; use Mod1::TestTrait2; @@ -110,12 +110,12 @@ fn main() { let closure = || TestStruct1; closure(); - // Generator - let mut generator = || { + // Coroutine + let mut coroutine = || { yield; return; }; - Pin::new(&mut generator).resume(()); + Pin::new(&mut coroutine).resume(()); // Const generic functions const_generic_fn_bool::<false>(); diff --git a/tests/debuginfo/issue-57822.rs b/tests/debuginfo/issue-57822.rs index 62e7eb13c2d..a12a562a033 100644 --- a/tests/debuginfo/issue-57822.rs +++ b/tests/debuginfo/issue-57822.rs @@ -1,5 +1,5 @@ // This test makes sure that the LLDB pretty printer does not throw an exception -// for nested closures and generators. +// for nested closures and coroutines. // Require a gdb that can read DW_TAG_variant_part. // min-gdb-version: 8.2 @@ -14,7 +14,7 @@ // gdb-check:$1 = issue_57822::main::{closure_env#1} {f: issue_57822::main::{closure_env#0} {x: 1}} // gdb-command:print b -// gdb-check:$2 = issue_57822::main::{generator_env#3}::Unresumed{a: issue_57822::main::{generator_env#2}::Unresumed{y: 2}} +// gdb-check:$2 = issue_57822::main::{coroutine_env#3}::Unresumed{a: issue_57822::main::{coroutine_env#2}::Unresumed{y: 2}} // === LLDB TESTS ================================================================================== @@ -24,12 +24,12 @@ // lldbg-check:(issue_57822::main::{closure_env#1}) $0 = { f = { x = 1 } } // lldb-command:print b -// lldbg-check:(issue_57822::main::{generator_env#3}) $1 = +// lldbg-check:(issue_57822::main::{coroutine_env#3}) $1 = -#![feature(omit_gdb_pretty_printer_section, generators, generator_trait)] +#![feature(omit_gdb_pretty_printer_section, coroutines, coroutine_trait)] #![omit_gdb_pretty_printer_section] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; fn main() { diff --git a/tests/mir-opt/README.md b/tests/mir-opt/README.md index 0721d9f7019..39a7b5aea12 100644 --- a/tests/mir-opt/README.md +++ b/tests/mir-opt/README.md @@ -49,3 +49,21 @@ This exists mainly for completeness and is rarely useful. ``` // EMIT_MIR $file_name_of_some_mir_dump.before.mir ``` + +# FileCheck directives + +The LLVM FileCheck tool is used to verify the contents of output MIR against `CHECK` directives +present in the test file. This works on the runtime MIR, generated by `--emit=mir`, and not +on the output of a individual passes. + +Use `// skip-filecheck` to prevent FileCheck from running. + +To check MIR for function `foo`, start with a `// CHECK-LABEL fn foo(` directive. + +`{{regex}}` syntax allows to match `regex`. + +`[[name:regex]]` syntax allows to bind `name` to a string matching `regex`, and refer to it +as `[[name]]` in later directives, `regex` should be written not to match a leading space. +Use `[[my_local:_.*]]` to name a local, and `[[my_bb:bb.*]]` to name a block. + +Documentation for FileCheck is available here: https://www.llvm.org/docs/CommandGuide/FileCheck.html diff --git a/tests/mir-opt/address_of.address_of_reborrow.SimplifyCfg-initial.after.mir b/tests/mir-opt/address_of.address_of_reborrow.SimplifyCfg-initial.after.mir index 61aa89e445f..76938c14e1e 100644 --- a/tests/mir-opt/address_of.address_of_reborrow.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/address_of.address_of_reborrow.SimplifyCfg-initial.after.mir @@ -1,36 +1,36 @@ // MIR for `address_of_reborrow` after SimplifyCfg-initial | User Type Annotations -| 0: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:7:5: 7:18, inferred_ty: *const [i32; 10] -| 1: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:9:5: 9:25, inferred_ty: *const dyn std::marker::Send -| 2: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:13:12: 13:20, inferred_ty: *const [i32; 10] -| 3: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:13:12: 13:20, inferred_ty: *const [i32; 10] -| 4: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:14:12: 14:28, inferred_ty: *const [i32; 10] -| 5: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:14:12: 14:28, inferred_ty: *const [i32; 10] -| 6: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:15:12: 15:27, inferred_ty: *const dyn std::marker::Send -| 7: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:15:12: 15:27, inferred_ty: *const dyn std::marker::Send -| 8: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:16:12: 16:24, inferred_ty: *const [i32] -| 9: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:16:12: 16:24, inferred_ty: *const [i32] -| 10: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:18:5: 18:18, inferred_ty: *const [i32; 10] -| 11: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:20:5: 20:25, inferred_ty: *const dyn std::marker::Send -| 12: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:23:12: 23:20, inferred_ty: *const [i32; 10] -| 13: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:23:12: 23:20, inferred_ty: *const [i32; 10] -| 14: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:24:12: 24:28, inferred_ty: *const [i32; 10] -| 15: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:24:12: 24:28, inferred_ty: *const [i32; 10] -| 16: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:25:12: 25:27, inferred_ty: *const dyn std::marker::Send -| 17: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:25:12: 25:27, inferred_ty: *const dyn std::marker::Send -| 18: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:26:12: 26:24, inferred_ty: *const [i32] -| 19: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:26:12: 26:24, inferred_ty: *const [i32] -| 20: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:28:5: 28:16, inferred_ty: *mut [i32; 10] -| 21: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:30:5: 30:23, inferred_ty: *mut dyn std::marker::Send -| 22: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:33:12: 33:18, inferred_ty: *mut [i32; 10] -| 23: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:33:12: 33:18, inferred_ty: *mut [i32; 10] -| 24: user_ty: Canonical { value: Ty(*mut [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:34:12: 34:26, inferred_ty: *mut [i32; 10] -| 25: user_ty: Canonical { value: Ty(*mut [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:34:12: 34:26, inferred_ty: *mut [i32; 10] -| 26: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:35:12: 35:25, inferred_ty: *mut dyn std::marker::Send -| 27: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:35:12: 35:25, inferred_ty: *mut dyn std::marker::Send -| 28: user_ty: Canonical { value: Ty(*mut [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:36:12: 36:22, inferred_ty: *mut [i32] -| 29: user_ty: Canonical { value: Ty(*mut [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:36:12: 36:22, inferred_ty: *mut [i32] +| 0: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:8:5: 8:18, inferred_ty: *const [i32; 10] +| 1: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:10:5: 10:25, inferred_ty: *const dyn std::marker::Send +| 2: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:14:12: 14:20, inferred_ty: *const [i32; 10] +| 3: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:14:12: 14:20, inferred_ty: *const [i32; 10] +| 4: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:15:12: 15:28, inferred_ty: *const [i32; 10] +| 5: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:15:12: 15:28, inferred_ty: *const [i32; 10] +| 6: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:16:12: 16:27, inferred_ty: *const dyn std::marker::Send +| 7: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:16:12: 16:27, inferred_ty: *const dyn std::marker::Send +| 8: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:17:12: 17:24, inferred_ty: *const [i32] +| 9: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:17:12: 17:24, inferred_ty: *const [i32] +| 10: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:19:5: 19:18, inferred_ty: *const [i32; 10] +| 11: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:21:5: 21:25, inferred_ty: *const dyn std::marker::Send +| 12: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:24:12: 24:20, inferred_ty: *const [i32; 10] +| 13: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:24:12: 24:20, inferred_ty: *const [i32; 10] +| 14: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:25:12: 25:28, inferred_ty: *const [i32; 10] +| 15: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:25:12: 25:28, inferred_ty: *const [i32; 10] +| 16: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:26:12: 26:27, inferred_ty: *const dyn std::marker::Send +| 17: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:26:12: 26:27, inferred_ty: *const dyn std::marker::Send +| 18: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:27:12: 27:24, inferred_ty: *const [i32] +| 19: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:27:12: 27:24, inferred_ty: *const [i32] +| 20: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:29:5: 29:16, inferred_ty: *mut [i32; 10] +| 21: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:31:5: 31:23, inferred_ty: *mut dyn std::marker::Send +| 22: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:34:12: 34:18, inferred_ty: *mut [i32; 10] +| 23: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:34:12: 34:18, inferred_ty: *mut [i32; 10] +| 24: user_ty: Canonical { value: Ty(*mut [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:35:12: 35:26, inferred_ty: *mut [i32; 10] +| 25: user_ty: Canonical { value: Ty(*mut [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:35:12: 35:26, inferred_ty: *mut [i32; 10] +| 26: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:36:12: 36:25, inferred_ty: *mut dyn std::marker::Send +| 27: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:36:12: 36:25, inferred_ty: *mut dyn std::marker::Send +| 28: user_ty: Canonical { value: Ty(*mut [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:37:12: 37:22, inferred_ty: *mut [i32] +| 29: user_ty: Canonical { value: Ty(*mut [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:37:12: 37:22, inferred_ty: *mut [i32] | fn address_of_reborrow() -> () { let mut _0: (); diff --git a/tests/mir-opt/address_of.rs b/tests/mir-opt/address_of.rs index c4bea5613e4..57a317a4a90 100644 --- a/tests/mir-opt/address_of.rs +++ b/tests/mir-opt/address_of.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR address_of.address_of_reborrow.SimplifyCfg-initial.after.mir fn address_of_reborrow() { diff --git a/tests/mir-opt/array_index_is_temporary.rs b/tests/mir-opt/array_index_is_temporary.rs index 950429fb6bc..f5edc68905b 100644 --- a/tests/mir-opt/array_index_is_temporary.rs +++ b/tests/mir-opt/array_index_is_temporary.rs @@ -1,3 +1,4 @@ +// unit-test: SimplifyCfg-elaborate-drops // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Retagging (from Stacked Borrows) relies on the array index being a fresh // temporary, so that side-effects cannot change it. @@ -11,6 +12,12 @@ unsafe fn foo(z: *mut usize) -> u32 { // EMIT_MIR array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir fn main() { + // CHECK-LABEL: fn main( + // CHECK: debug x => [[x:_.*]]; + // CHECK: debug y => [[y:_.*]]; + // CHECK: [[y]] = const 1_usize; + // CHECK: [[tmp:_.*]] = [[y]]; + // CHECK: [[x]][[[tmp]]] = let mut x = [42, 43, 44]; let mut y = 1; let z: *mut usize = &mut y; diff --git a/tests/mir-opt/asm_unwind_panic_abort.rs b/tests/mir-opt/asm_unwind_panic_abort.rs index ad8f9398e7f..a80dcb385b3 100644 --- a/tests/mir-opt/asm_unwind_panic_abort.rs +++ b/tests/mir-opt/asm_unwind_panic_abort.rs @@ -9,6 +9,9 @@ // EMIT_MIR asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir fn main() { + // CHECK-LABEL: fn main( + // CHECK: asm!( + // CHECK-SAME: unwind terminate(abi) unsafe { std::arch::asm!("", options(may_unwind)); } diff --git a/tests/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir b/tests/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir index 75070ffda11..5df6633880e 100644 --- a/tests/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir @@ -1,8 +1,8 @@ // MIR for `main` after SimplifyCfg-initial | User Type Annotations -| 0: user_ty: Canonical { value: Ty(std::option::Option<std::boxed::Box<u32>>), max_universe: U0, variables: [] }, span: $DIR/basic_assignment.rs:20:17: 20:33, inferred_ty: std::option::Option<std::boxed::Box<u32>> -| 1: user_ty: Canonical { value: Ty(std::option::Option<std::boxed::Box<u32>>), max_universe: U0, variables: [] }, span: $DIR/basic_assignment.rs:20:17: 20:33, inferred_ty: std::option::Option<std::boxed::Box<u32>> +| 0: user_ty: Canonical { value: Ty(std::option::Option<std::boxed::Box<u32>>), max_universe: U0, variables: [] }, span: $DIR/basic_assignment.rs:38:17: 38:33, inferred_ty: std::option::Option<std::boxed::Box<u32>> +| 1: user_ty: Canonical { value: Ty(std::option::Option<std::boxed::Box<u32>>), max_universe: U0, variables: [] }, span: $DIR/basic_assignment.rs:38:17: 38:33, inferred_ty: std::option::Option<std::boxed::Box<u32>> | fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/basic_assignment.rs b/tests/mir-opt/basic_assignment.rs index 92434e44aa9..30a41098888 100644 --- a/tests/mir-opt/basic_assignment.rs +++ b/tests/mir-opt/basic_assignment.rs @@ -1,3 +1,4 @@ +// unit-test: ElaborateDrops // needs-unwind // this tests move up progration, which is not yet implemented @@ -10,6 +11,23 @@ // destruction. fn main() { + // CHECK-LABEL: fn main( + // CHECK: debug nodrop_x => [[nodrop_x:_.*]]; + // CHECK: debug nodrop_y => [[nodrop_y:_.*]]; + // CHECK: debug drop_x => [[drop_x:_.*]]; + // CHECK: debug drop_y => [[drop_y:_.*]]; + // CHECK-NOT: drop([[nodrop_x]]) + // CHECK-NOT: drop([[nodrop_y]]) + // CHECK-NOT: drop([[drop_x]]) + // CHECK: [[drop_tmp:_.*]] = move [[drop_x]]; + // CHECK-NOT: drop([[drop_x]]) + // CHECK-NOT: drop([[drop_tmp]]) + // CHECK: [[drop_y]] = move [[drop_tmp]]; + // CHECK-NOT: drop([[drop_x]]) + // CHECK-NOT: drop([[drop_tmp]]) + // CHECK: drop([[drop_y]]) + // CHECK-NOT: drop([[drop_x]]) + // CHECK-NOT: drop([[drop_tmp]]) let nodrop_x = false; let nodrop_y; diff --git a/tests/mir-opt/bool_compare.rs b/tests/mir-opt/bool_compare.rs deleted file mode 100644 index 080f7f72d11..00000000000 --- a/tests/mir-opt/bool_compare.rs +++ /dev/null @@ -1,28 +0,0 @@ -// unit-test: InstSimplify - -// EMIT_MIR bool_compare.opt1.InstSimplify.diff -fn opt1(x: bool) -> u32 { - if x != true { 0 } else { 1 } -} - -// EMIT_MIR bool_compare.opt2.InstSimplify.diff -fn opt2(x: bool) -> u32 { - if true != x { 0 } else { 1 } -} - -// EMIT_MIR bool_compare.opt3.InstSimplify.diff -fn opt3(x: bool) -> u32 { - if x == false { 0 } else { 1 } -} - -// EMIT_MIR bool_compare.opt4.InstSimplify.diff -fn opt4(x: bool) -> u32 { - if false == x { 0 } else { 1 } -} - -fn main() { - opt1(false); - opt2(false); - opt3(false); - opt4(false); -} diff --git a/tests/mir-opt/box_expr.main.ElaborateDrops.before.panic-abort.mir b/tests/mir-opt/box_expr.main.ElaborateDrops.before.panic-abort.mir deleted file mode 100644 index 1c7ef7f8345..00000000000 --- a/tests/mir-opt/box_expr.main.ElaborateDrops.before.panic-abort.mir +++ /dev/null @@ -1,71 +0,0 @@ -// MIR for `main` before ElaborateDrops - -fn main() -> () { - let mut _0: (); - let _1: std::boxed::Box<S>; - let mut _2: usize; - let mut _3: usize; - let mut _4: *mut u8; - let mut _5: std::boxed::Box<S>; - let _6: (); - let mut _7: std::boxed::Box<S>; - scope 1 { - debug x => _1; - } - scope 2 { - } - - bb0: { - StorageLive(_1); - _2 = SizeOf(S); - _3 = AlignOf(S); - _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> [return: bb1, unwind: bb9]; - } - - bb1: { - StorageLive(_5); - _5 = ShallowInitBox(move _4, S); - (*_5) = S::new() -> [return: bb2, unwind: bb8]; - } - - bb2: { - _1 = move _5; - drop(_5) -> [return: bb3, unwind: bb9]; - } - - bb3: { - StorageDead(_5); - StorageLive(_6); - StorageLive(_7); - _7 = move _1; - _6 = std::mem::drop::<Box<S>>(move _7) -> [return: bb4, unwind: bb6]; - } - - bb4: { - StorageDead(_7); - StorageDead(_6); - _0 = const (); - drop(_1) -> [return: bb5, unwind: bb9]; - } - - bb5: { - StorageDead(_1); - return; - } - - bb6 (cleanup): { - drop(_7) -> [return: bb7, unwind terminate(cleanup)]; - } - - bb7 (cleanup): { - drop(_1) -> [return: bb9, unwind terminate(cleanup)]; - } - - bb8 (cleanup): { - drop(_5) -> [return: bb9, unwind terminate(cleanup)]; - } - - bb9 (cleanup): { - resume; - } -} diff --git a/tests/mir-opt/box_expr.main.ElaborateDrops.before.panic-unwind.mir b/tests/mir-opt/box_expr.main.ElaborateDrops.before.panic-unwind.mir deleted file mode 100644 index 4ad1c2de129..00000000000 --- a/tests/mir-opt/box_expr.main.ElaborateDrops.before.panic-unwind.mir +++ /dev/null @@ -1,71 +0,0 @@ -// MIR for `main` before ElaborateDrops - -fn main() -> () { - let mut _0: (); - let _1: std::boxed::Box<S>; - let mut _2: usize; - let mut _3: usize; - let mut _4: *mut u8; - let mut _5: std::boxed::Box<S>; - let _6: (); - let mut _7: std::boxed::Box<S>; - scope 1 { - debug x => _1; - } - scope 2 { - } - - bb0: { - StorageLive(_1); - _2 = SizeOf(S); - _3 = AlignOf(S); - _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> [return: bb1, unwind continue]; - } - - bb1: { - StorageLive(_5); - _5 = ShallowInitBox(move _4, S); - (*_5) = S::new() -> [return: bb2, unwind: bb8]; - } - - bb2: { - _1 = move _5; - drop(_5) -> [return: bb3, unwind continue]; - } - - bb3: { - StorageDead(_5); - StorageLive(_6); - StorageLive(_7); - _7 = move _1; - _6 = std::mem::drop::<Box<S>>(move _7) -> [return: bb4, unwind: bb6]; - } - - bb4: { - StorageDead(_7); - StorageDead(_6); - _0 = const (); - drop(_1) -> [return: bb5, unwind continue]; - } - - bb5: { - StorageDead(_1); - return; - } - - bb6 (cleanup): { - drop(_7) -> [return: bb7, unwind terminate(cleanup)]; - } - - bb7 (cleanup): { - drop(_1) -> [return: bb9, unwind terminate(cleanup)]; - } - - bb8 (cleanup): { - drop(_5) -> [return: bb9, unwind terminate(cleanup)]; - } - - bb9 (cleanup): { - resume; - } -} diff --git a/tests/mir-opt/box_expr.main.ElaborateDrops.diff b/tests/mir-opt/box_expr.main.ElaborateDrops.diff new file mode 100644 index 00000000000..88b12f19e64 --- /dev/null +++ b/tests/mir-opt/box_expr.main.ElaborateDrops.diff @@ -0,0 +1,89 @@ +- // MIR for `main` before ElaborateDrops ++ // MIR for `main` after ElaborateDrops + + fn main() -> () { + let mut _0: (); + let _1: std::boxed::Box<S>; + let mut _2: usize; + let mut _3: usize; + let mut _4: *mut u8; + let mut _5: std::boxed::Box<S>; + let _6: (); + let mut _7: std::boxed::Box<S>; ++ let mut _8: &mut std::boxed::Box<S>; ++ let mut _9: (); + scope 1 { + debug x => _1; + } + scope 2 { + } + + bb0: { + StorageLive(_1); + _2 = SizeOf(S); + _3 = AlignOf(S); + _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageLive(_5); + _5 = ShallowInitBox(move _4, S); + (*_5) = S::new() -> [return: bb2, unwind: bb8]; + } + + bb2: { + _1 = move _5; +- drop(_5) -> [return: bb3, unwind continue]; ++ goto -> bb3; + } + + bb3: { + StorageDead(_5); + StorageLive(_6); + StorageLive(_7); + _7 = move _1; + _6 = std::mem::drop::<Box<S>>(move _7) -> [return: bb4, unwind: bb6]; + } + + bb4: { + StorageDead(_7); + StorageDead(_6); + _0 = const (); +- drop(_1) -> [return: bb5, unwind continue]; ++ goto -> bb5; + } + + bb5: { + StorageDead(_1); + return; + } + + bb6 (cleanup): { +- drop(_7) -> [return: bb7, unwind terminate(cleanup)]; ++ goto -> bb7; + } + + bb7 (cleanup): { +- drop(_1) -> [return: bb9, unwind terminate(cleanup)]; ++ goto -> bb9; + } + + bb8 (cleanup): { +- drop(_5) -> [return: bb9, unwind terminate(cleanup)]; ++ goto -> bb11; + } + + bb9 (cleanup): { + resume; ++ } ++ ++ bb10 (cleanup): { ++ _8 = &mut _5; ++ _9 = <Box<S> as Drop>::drop(move _8) -> [return: bb9, unwind terminate(cleanup)]; ++ } ++ ++ bb11 (cleanup): { ++ goto -> bb10; + } + } + diff --git a/tests/mir-opt/box_expr.rs b/tests/mir-opt/box_expr.rs index 780420bda9f..0421e232ae4 100644 --- a/tests/mir-opt/box_expr.rs +++ b/tests/mir-opt/box_expr.rs @@ -1,9 +1,22 @@ -// EMIT_MIR_FOR_EACH_PANIC_STRATEGY +// unit-test: ElaborateDrops +// needs-unwind #![feature(rustc_attrs, stmt_expr_attributes)] -// EMIT_MIR box_expr.main.ElaborateDrops.before.mir +// EMIT_MIR box_expr.main.ElaborateDrops.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: [[box:_.*]] = ShallowInitBox( + // CHECK: [[ptr:_.*]] = ((([[box]].0: std::ptr::Unique<S>).0: std::ptr::NonNull<S>).0: *const S); + // CHECK: (*[[ptr]]) = S::new() -> [return: [[ret:bb.*]], unwind: [[unwind:bb.*]]]; + // CHECK: [[ret]]: { + // CHECK: [[box2:_.*]] = move [[box]]; + // CHECK: [[box3:_.*]] = move [[box2]]; + // CHECK: std::mem::drop::<Box<S>>(move [[box3]]) + // CHECK: [[unwind]] (cleanup): { + // CHECK: [[boxref:_.*]] = &mut [[box]]; + // CHECK: <Box<S> as Drop>::drop(move [[boxref]]) + let x = #[rustc_box] Box::new(S::new()); drop(x); diff --git a/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.a-{closure#0}.coroutine_resume.0.mir index 98b1befc3bf..8b22743d2b0 100644 --- a/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/building/async_await.a-{closure#0}.coroutine_resume.0.mir @@ -1,5 +1,5 @@ -// MIR for `a::{closure#0}` 0 generator_resume -/* generator_layout = GeneratorLayout { +// MIR for `a::{closure#0}` 0 coroutine_resume +/* coroutine_layout = CoroutineLayout { field_tys: {}, variant_fields: { Unresumed(0): [], @@ -9,7 +9,7 @@ storage_conflicts: BitMatrix(0x0) {}, } */ -fn a::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:11:14: 11:16}>, _2: &mut Context<'_>) -> Poll<()> { +fn a::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:12:14: 12:16}>, _2: &mut Context<'_>) -> Poll<()> { debug _task_context => _4; let mut _0: std::task::Poll<()>; let mut _3: (); @@ -17,7 +17,7 @@ fn a::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:11:14: 11:16}> let mut _5: u32; bb0: { - _5 = discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:11:14: 11:16}))); + _5 = discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:12:14: 12:16}))); switchInt(move _5) -> [0: bb1, 1: bb4, otherwise: bb5]; } @@ -29,7 +29,7 @@ fn a::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:11:14: 11:16}> bb2: { _0 = Poll::<()>::Ready(move _3); - discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:11:14: 11:16}))) = 1; + discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:12:14: 12:16}))) = 1; return; } diff --git a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir index 15330b13cc2..f64b540c3a5 100644 --- a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir @@ -1,38 +1,38 @@ -// MIR for `b::{closure#0}` 0 generator_resume -/* generator_layout = GeneratorLayout { +// MIR for `b::{closure#0}` 0 coroutine_resume +/* coroutine_layout = CoroutineLayout { field_tys: { - _0: GeneratorSavedTy { - ty: Generator( + _0: CoroutineSavedTy { + ty: Coroutine( DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), [ std::future::ResumeTy, (), (), - GeneratorWitness(DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), []), + CoroutineWitness(DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), []), (), ], Static, ), source_info: SourceInfo { - span: $DIR/async_await.rs:15:9: 15:14 (#8), + span: $DIR/async_await.rs:16:9: 16:14 (#8), scope: scope[0], }, ignore_for_traits: false, }, - _1: GeneratorSavedTy { - ty: Generator( + _1: CoroutineSavedTy { + ty: Coroutine( DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), [ std::future::ResumeTy, (), (), - GeneratorWitness(DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), []), + CoroutineWitness(DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), []), (), ], Static, ), source_info: SourceInfo { - span: $DIR/async_await.rs:16:9: 16:14 (#10), + span: $DIR/async_await.rs:17:9: 17:14 (#10), scope: scope[0], }, ignore_for_traits: false, @@ -51,19 +51,19 @@ }, } */ -fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, _2: &mut Context<'_>) -> Poll<()> { +fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:15:18: 18:2}>, _2: &mut Context<'_>) -> Poll<()> { debug _task_context => _38; let mut _0: std::task::Poll<()>; let _3: (); - let mut _4: {async fn body@$DIR/async_await.rs:11:14: 11:16}; - let mut _5: {async fn body@$DIR/async_await.rs:11:14: 11:16}; - let mut _6: {async fn body@$DIR/async_await.rs:11:14: 11:16}; + let mut _4: {async fn body@$DIR/async_await.rs:12:14: 12:16}; + let mut _5: {async fn body@$DIR/async_await.rs:12:14: 12:16}; + let mut _6: {async fn body@$DIR/async_await.rs:12:14: 12:16}; let mut _7: (); let _8: (); let mut _9: std::task::Poll<()>; - let mut _10: std::pin::Pin<&mut {async fn body@$DIR/async_await.rs:11:14: 11:16}>; - let mut _11: &mut {async fn body@$DIR/async_await.rs:11:14: 11:16}; - let mut _12: &mut {async fn body@$DIR/async_await.rs:11:14: 11:16}; + let mut _10: std::pin::Pin<&mut {async fn body@$DIR/async_await.rs:12:14: 12:16}>; + let mut _11: &mut {async fn body@$DIR/async_await.rs:12:14: 12:16}; + let mut _12: &mut {async fn body@$DIR/async_await.rs:12:14: 12:16}; let mut _13: &mut std::task::Context<'_>; let mut _14: &mut std::task::Context<'_>; let mut _15: &mut std::task::Context<'_>; @@ -71,14 +71,14 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, let mut _18: !; let mut _19: &mut std::task::Context<'_>; let mut _20: (); - let mut _21: {async fn body@$DIR/async_await.rs:11:14: 11:16}; - let mut _22: {async fn body@$DIR/async_await.rs:11:14: 11:16}; - let mut _23: {async fn body@$DIR/async_await.rs:11:14: 11:16}; + let mut _21: {async fn body@$DIR/async_await.rs:12:14: 12:16}; + let mut _22: {async fn body@$DIR/async_await.rs:12:14: 12:16}; + let mut _23: {async fn body@$DIR/async_await.rs:12:14: 12:16}; let _24: (); let mut _25: std::task::Poll<()>; - let mut _26: std::pin::Pin<&mut {async fn body@$DIR/async_await.rs:11:14: 11:16}>; - let mut _27: &mut {async fn body@$DIR/async_await.rs:11:14: 11:16}; - let mut _28: &mut {async fn body@$DIR/async_await.rs:11:14: 11:16}; + let mut _26: std::pin::Pin<&mut {async fn body@$DIR/async_await.rs:12:14: 12:16}>; + let mut _27: &mut {async fn body@$DIR/async_await.rs:12:14: 12:16}; + let mut _28: &mut {async fn body@$DIR/async_await.rs:12:14: 12:16}; let mut _29: &mut std::task::Context<'_>; let mut _30: &mut std::task::Context<'_>; let mut _31: &mut std::task::Context<'_>; @@ -90,7 +90,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, let mut _38: &mut std::task::Context<'_>; let mut _39: u32; scope 1 { - debug __awaitee => (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#3).0: {async fn body@$DIR/async_await.rs:11:14: 11:16}); + debug __awaitee => (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2})) as variant#3).0: {async fn body@$DIR/async_await.rs:12:14: 12:16}); let _17: (); scope 2 { } @@ -99,7 +99,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, } } scope 4 { - debug __awaitee => (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#4).0: {async fn body@$DIR/async_await.rs:11:14: 11:16}); + debug __awaitee => (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2})) as variant#4).0: {async fn body@$DIR/async_await.rs:12:14: 12:16}); let _33: (); scope 5 { } @@ -109,7 +109,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, } bb0: { - _39 = discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2}))); + _39 = discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2}))); switchInt(move _39) -> [0: bb1, 1: bb29, 3: bb27, 4: bb28, otherwise: bb30]; } @@ -122,13 +122,13 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, } bb2: { - _4 = <{async fn body@$DIR/async_await.rs:11:14: 11:16} as IntoFuture>::into_future(move _5) -> [return: bb3, unwind unreachable]; + _4 = <{async fn body@$DIR/async_await.rs:12:14: 12:16} as IntoFuture>::into_future(move _5) -> [return: bb3, unwind unreachable]; } bb3: { StorageDead(_5); nop; - (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#3).0: {async fn body@$DIR/async_await.rs:11:14: 11:16}) = move _4; + (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2})) as variant#3).0: {async fn body@$DIR/async_await.rs:12:14: 12:16}) = move _4; goto -> bb4; } @@ -138,9 +138,9 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, StorageLive(_10); StorageLive(_11); StorageLive(_12); - _12 = &mut (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#3).0: {async fn body@$DIR/async_await.rs:11:14: 11:16}); + _12 = &mut (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2})) as variant#3).0: {async fn body@$DIR/async_await.rs:12:14: 12:16}); _11 = &mut (*_12); - _10 = Pin::<&mut {async fn body@$DIR/async_await.rs:11:14: 11:16}>::new_unchecked(move _11) -> [return: bb5, unwind unreachable]; + _10 = Pin::<&mut {async fn body@$DIR/async_await.rs:12:14: 12:16}>::new_unchecked(move _11) -> [return: bb5, unwind unreachable]; } bb5: { @@ -156,7 +156,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, bb6: { _13 = &mut (*_14); StorageDead(_15); - _9 = <{async fn body@$DIR/async_await.rs:11:14: 11:16} as Future>::poll(move _10, move _13) -> [return: bb7, unwind unreachable]; + _9 = <{async fn body@$DIR/async_await.rs:12:14: 12:16} as Future>::poll(move _10, move _13) -> [return: bb7, unwind unreachable]; } bb7: { @@ -176,7 +176,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, StorageLive(_20); _20 = (); _0 = Poll::<()>::Pending; - discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2}))) = 3; + discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2}))) = 3; return; } @@ -193,7 +193,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, StorageDead(_12); StorageDead(_9); StorageDead(_8); - drop((((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#3).0: {async fn body@$DIR/async_await.rs:11:14: 11:16})) -> [return: bb12, unwind unreachable]; + drop((((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2})) as variant#3).0: {async fn body@$DIR/async_await.rs:12:14: 12:16})) -> [return: bb12, unwind unreachable]; } bb11: { @@ -218,13 +218,13 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, } bb14: { - _21 = <{async fn body@$DIR/async_await.rs:11:14: 11:16} as IntoFuture>::into_future(move _22) -> [return: bb15, unwind unreachable]; + _21 = <{async fn body@$DIR/async_await.rs:12:14: 12:16} as IntoFuture>::into_future(move _22) -> [return: bb15, unwind unreachable]; } bb15: { StorageDead(_22); nop; - (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#4).0: {async fn body@$DIR/async_await.rs:11:14: 11:16}) = move _21; + (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2})) as variant#4).0: {async fn body@$DIR/async_await.rs:12:14: 12:16}) = move _21; goto -> bb16; } @@ -234,9 +234,9 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, StorageLive(_26); StorageLive(_27); StorageLive(_28); - _28 = &mut (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#4).0: {async fn body@$DIR/async_await.rs:11:14: 11:16}); + _28 = &mut (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2})) as variant#4).0: {async fn body@$DIR/async_await.rs:12:14: 12:16}); _27 = &mut (*_28); - _26 = Pin::<&mut {async fn body@$DIR/async_await.rs:11:14: 11:16}>::new_unchecked(move _27) -> [return: bb17, unwind unreachable]; + _26 = Pin::<&mut {async fn body@$DIR/async_await.rs:12:14: 12:16}>::new_unchecked(move _27) -> [return: bb17, unwind unreachable]; } bb17: { @@ -252,7 +252,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, bb18: { _29 = &mut (*_30); StorageDead(_31); - _25 = <{async fn body@$DIR/async_await.rs:11:14: 11:16} as Future>::poll(move _26, move _29) -> [return: bb19, unwind unreachable]; + _25 = <{async fn body@$DIR/async_await.rs:12:14: 12:16} as Future>::poll(move _26, move _29) -> [return: bb19, unwind unreachable]; } bb19: { @@ -272,7 +272,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, StorageLive(_36); _36 = (); _0 = Poll::<()>::Pending; - discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2}))) = 4; + discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2}))) = 4; return; } @@ -285,7 +285,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, StorageDead(_28); StorageDead(_25); StorageDead(_24); - drop((((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#4).0: {async fn body@$DIR/async_await.rs:11:14: 11:16})) -> [return: bb23, unwind unreachable]; + drop((((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2})) as variant#4).0: {async fn body@$DIR/async_await.rs:12:14: 12:16})) -> [return: bb23, unwind unreachable]; } bb22: { @@ -308,7 +308,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, bb25: { _0 = Poll::<()>::Ready(move _37); - discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2}))) = 1; + discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2}))) = 1; return; } diff --git a/tests/mir-opt/building/async_await.rs b/tests/mir-opt/building/async_await.rs index 0b991e3b8f8..abdeafef6e4 100644 --- a/tests/mir-opt/building/async_await.rs +++ b/tests/mir-opt/building/async_await.rs @@ -1,4 +1,5 @@ -// This test makes sure that the generator MIR pass eliminates all calls to +// skip-filecheck +// This test makes sure that the coroutine MIR pass eliminates all calls to // `get_context`, and that the MIR argument type for an async fn and all locals // related to `yield` are `&mut Context`, and its return type is `Poll`. @@ -7,10 +8,10 @@ #![crate_type = "lib"] -// EMIT_MIR async_await.a-{closure#0}.generator_resume.0.mir +// EMIT_MIR async_await.a-{closure#0}.coroutine_resume.0.mir async fn a() {} -// EMIT_MIR async_await.b-{closure#0}.generator_resume.0.mir +// EMIT_MIR async_await.b-{closure#0}.coroutine_resume.0.mir pub async fn b() { a().await; a().await diff --git a/tests/mir-opt/building/custom/aggregate_exprs.rs b/tests/mir-opt/building/custom/aggregate_exprs.rs index 554c9c03ba4..d581886247f 100644 --- a/tests/mir-opt/building/custom/aggregate_exprs.rs +++ b/tests/mir-opt/building/custom/aggregate_exprs.rs @@ -1,3 +1,4 @@ +// skip-filecheck #![feature(custom_mir, core_intrinsics)] extern crate core; diff --git a/tests/mir-opt/building/custom/arbitrary_let.rs b/tests/mir-opt/building/custom/arbitrary_let.rs index 776df3151ff..f8ee8504e32 100644 --- a/tests/mir-opt/building/custom/arbitrary_let.rs +++ b/tests/mir-opt/building/custom/arbitrary_let.rs @@ -1,3 +1,4 @@ +// skip-filecheck #![feature(custom_mir, core_intrinsics)] extern crate core; diff --git a/tests/mir-opt/building/custom/arrays.rs b/tests/mir-opt/building/custom/arrays.rs index 8e0a1fd7a43..fe6abc54687 100644 --- a/tests/mir-opt/building/custom/arrays.rs +++ b/tests/mir-opt/building/custom/arrays.rs @@ -1,3 +1,4 @@ +// skip-filecheck #![feature(custom_mir, core_intrinsics, inline_const)] extern crate core; diff --git a/tests/mir-opt/building/custom/as_cast.rs b/tests/mir-opt/building/custom/as_cast.rs index b4b5ac6aa3b..92aea64db07 100644 --- a/tests/mir-opt/building/custom/as_cast.rs +++ b/tests/mir-opt/building/custom/as_cast.rs @@ -1,3 +1,4 @@ +// skip-filecheck #![feature(custom_mir, core_intrinsics)] extern crate core; diff --git a/tests/mir-opt/building/custom/composite_return.rs b/tests/mir-opt/building/custom/composite_return.rs index 701d6b1ab71..33c903fa0f8 100644 --- a/tests/mir-opt/building/custom/composite_return.rs +++ b/tests/mir-opt/building/custom/composite_return.rs @@ -1,3 +1,4 @@ +// skip-filecheck #![feature(custom_mir, core_intrinsics)] extern crate core; diff --git a/tests/mir-opt/building/custom/consts.rs b/tests/mir-opt/building/custom/consts.rs index 16d10eb5968..42abf5019e5 100644 --- a/tests/mir-opt/building/custom/consts.rs +++ b/tests/mir-opt/building/custom/consts.rs @@ -1,3 +1,4 @@ +// skip-filecheck #![feature(custom_mir, core_intrinsics, inline_const)] extern crate core; 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/building/custom/debuginfo.rs b/tests/mir-opt/building/custom/debuginfo.rs index bfdc3d3eacd..3671a1ef061 100644 --- a/tests/mir-opt/building/custom/debuginfo.rs +++ b/tests/mir-opt/building/custom/debuginfo.rs @@ -1,3 +1,4 @@ +// skip-filecheck #![feature(custom_mir, core_intrinsics)] extern crate core; diff --git a/tests/mir-opt/building/custom/enums.rs b/tests/mir-opt/building/custom/enums.rs index eca5b792ec0..6aab1503c0a 100644 --- a/tests/mir-opt/building/custom/enums.rs +++ b/tests/mir-opt/building/custom/enums.rs @@ -1,3 +1,4 @@ +// skip-filecheck #![feature(custom_mir, core_intrinsics)] extern crate core; diff --git a/tests/mir-opt/building/custom/operators.rs b/tests/mir-opt/building/custom/operators.rs index db7a48317d9..91bdf2b9113 100644 --- a/tests/mir-opt/building/custom/operators.rs +++ b/tests/mir-opt/building/custom/operators.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: --crate-type=lib #![feature(custom_mir, core_intrinsics, inline_const)] use std::intrinsics::mir::*; diff --git a/tests/mir-opt/building/custom/projections.rs b/tests/mir-opt/building/custom/projections.rs index 3c155deae4b..ac23fe59097 100644 --- a/tests/mir-opt/building/custom/projections.rs +++ b/tests/mir-opt/building/custom/projections.rs @@ -1,3 +1,4 @@ +// skip-filecheck #![feature(custom_mir, core_intrinsics)] extern crate core; diff --git a/tests/mir-opt/building/custom/references.rs b/tests/mir-opt/building/custom/references.rs index f87f6664c7a..04afe6e6494 100644 --- a/tests/mir-opt/building/custom/references.rs +++ b/tests/mir-opt/building/custom/references.rs @@ -1,3 +1,4 @@ +// skip-filecheck #![feature(custom_mir, core_intrinsics)] extern crate core; diff --git a/tests/mir-opt/building/custom/simple_assign.rs b/tests/mir-opt/building/custom/simple_assign.rs index db041aab239..8442272291e 100644 --- a/tests/mir-opt/building/custom/simple_assign.rs +++ b/tests/mir-opt/building/custom/simple_assign.rs @@ -1,3 +1,4 @@ +// skip-filecheck #![feature(custom_mir, core_intrinsics)] extern crate core; diff --git a/tests/mir-opt/building/custom/terminators.rs b/tests/mir-opt/building/custom/terminators.rs index 123118f654e..9e442e0f98a 100644 --- a/tests/mir-opt/building/custom/terminators.rs +++ b/tests/mir-opt/building/custom/terminators.rs @@ -1,3 +1,4 @@ +// skip-filecheck #![feature(custom_mir, core_intrinsics)] extern crate core; diff --git a/tests/mir-opt/building/enum_cast.rs b/tests/mir-opt/building/enum_cast.rs index 431b5c708b9..df8e397c8fe 100644 --- a/tests/mir-opt/building/enum_cast.rs +++ b/tests/mir-opt/building/enum_cast.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR enum_cast.foo.built.after.mir // EMIT_MIR enum_cast.bar.built.after.mir // EMIT_MIR enum_cast.boo.built.after.mir diff --git a/tests/mir-opt/building/issue_101867.main.built.after.mir b/tests/mir-opt/building/issue_101867.main.built.after.mir index 915c5ef112c..fb60f0f0c2b 100644 --- a/tests/mir-opt/building/issue_101867.main.built.after.mir +++ b/tests/mir-opt/building/issue_101867.main.built.after.mir @@ -1,8 +1,8 @@ // MIR for `main` after built | User Type Annotations -| 0: user_ty: Canonical { value: Ty(std::option::Option<u8>), max_universe: U0, variables: [] }, span: $DIR/issue_101867.rs:3:12: 3:22, inferred_ty: std::option::Option<u8> -| 1: user_ty: Canonical { value: Ty(std::option::Option<u8>), max_universe: U0, variables: [] }, span: $DIR/issue_101867.rs:3:12: 3:22, inferred_ty: std::option::Option<u8> +| 0: user_ty: Canonical { value: Ty(std::option::Option<u8>), max_universe: U0, variables: [] }, span: $DIR/issue_101867.rs:4:12: 4:22, inferred_ty: std::option::Option<u8> +| 1: user_ty: Canonical { value: Ty(std::option::Option<u8>), max_universe: U0, variables: [] }, span: $DIR/issue_101867.rs:4:12: 4:22, inferred_ty: std::option::Option<u8> | fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/building/issue_101867.rs b/tests/mir-opt/building/issue_101867.rs index a32d8cb3714..f8a531e8982 100644 --- a/tests/mir-opt/building/issue_101867.rs +++ b/tests/mir-opt/building/issue_101867.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR issue_101867.main.built.after.mir fn main() { let x: Option<u8> = Some(1); diff --git a/tests/mir-opt/building/issue_110508.rs b/tests/mir-opt/building/issue_110508.rs index bcbb1c29830..e597cd5d06b 100644 --- a/tests/mir-opt/building/issue_110508.rs +++ b/tests/mir-opt/building/issue_110508.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR issue_110508.{impl#0}-BAR.built.after.mir // EMIT_MIR issue_110508.{impl#0}-SELF_BAR.built.after.mir diff --git a/tests/mir-opt/building/issue_110508.{impl#0}-BAR.built.after.mir b/tests/mir-opt/building/issue_110508.{impl#0}-BAR.built.after.mir index 5fc6d911af3..c3d28fae518 100644 --- a/tests/mir-opt/building/issue_110508.{impl#0}-BAR.built.after.mir +++ b/tests/mir-opt/building/issue_110508.{impl#0}-BAR.built.after.mir @@ -1,6 +1,6 @@ -// MIR for `<impl at $DIR/issue_110508.rs:8:1: 8:9>::BAR` after built +// MIR for `<impl at $DIR/issue_110508.rs:9:1: 9:9>::BAR` after built -const <impl at $DIR/issue_110508.rs:8:1: 8:9>::BAR: Foo = { +const <impl at $DIR/issue_110508.rs:9:1: 9:9>::BAR: Foo = { let mut _0: Foo; let mut _1: (); diff --git a/tests/mir-opt/building/issue_110508.{impl#0}-SELF_BAR.built.after.mir b/tests/mir-opt/building/issue_110508.{impl#0}-SELF_BAR.built.after.mir index 1a892559971..177518c30af 100644 --- a/tests/mir-opt/building/issue_110508.{impl#0}-SELF_BAR.built.after.mir +++ b/tests/mir-opt/building/issue_110508.{impl#0}-SELF_BAR.built.after.mir @@ -1,6 +1,6 @@ -// MIR for `<impl at $DIR/issue_110508.rs:8:1: 8:9>::SELF_BAR` after built +// MIR for `<impl at $DIR/issue_110508.rs:9:1: 9:9>::SELF_BAR` after built -const <impl at $DIR/issue_110508.rs:8:1: 8:9>::SELF_BAR: Foo = { +const <impl at $DIR/issue_110508.rs:9:1: 9:9>::SELF_BAR: Foo = { let mut _0: Foo; let mut _1: (); diff --git a/tests/mir-opt/building/issue_49232.rs b/tests/mir-opt/building/issue_49232.rs index 7e9f0de81f7..ac06e02778f 100644 --- a/tests/mir-opt/building/issue_49232.rs +++ b/tests/mir-opt/building/issue_49232.rs @@ -1,3 +1,4 @@ +// skip-filecheck // We must mark a variable whose initialization fails due to an // abort statement as StorageDead. diff --git a/tests/mir-opt/building/logical_or_in_conditional.rs b/tests/mir-opt/building/logical_or_in_conditional.rs index ae159f7e122..00e666ed94f 100644 --- a/tests/mir-opt/building/logical_or_in_conditional.rs +++ b/tests/mir-opt/building/logical_or_in_conditional.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -Z validate-mir #![feature(let_chains)] struct Droppy(u8); diff --git a/tests/mir-opt/building/match_false_edges.rs b/tests/mir-opt/building/match_false_edges.rs index ddfcc149319..839eda40c85 100644 --- a/tests/mir-opt/building/match_false_edges.rs +++ b/tests/mir-opt/building/match_false_edges.rs @@ -1,3 +1,4 @@ +// skip-filecheck fn guard() -> bool { false } diff --git a/tests/mir-opt/building/receiver_ptr_mutability.main.built.after.mir b/tests/mir-opt/building/receiver_ptr_mutability.main.built.after.mir index fed5e68c3c9..e07c2b6fa9d 100644 --- a/tests/mir-opt/building/receiver_ptr_mutability.main.built.after.mir +++ b/tests/mir-opt/building/receiver_ptr_mutability.main.built.after.mir @@ -1,10 +1,10 @@ // MIR for `main` after built | User Type Annotations -| 0: user_ty: Canonical { value: Ty(*mut Test), max_universe: U0, variables: [] }, span: $DIR/receiver_ptr_mutability.rs:14:14: 14:23, inferred_ty: *mut Test -| 1: user_ty: Canonical { value: Ty(*mut Test), max_universe: U0, variables: [] }, span: $DIR/receiver_ptr_mutability.rs:14:14: 14:23, inferred_ty: *mut Test -| 2: user_ty: Canonical { value: Ty(&&&&*mut Test), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/receiver_ptr_mutability.rs:18:18: 18:31, inferred_ty: &&&&*mut Test -| 3: user_ty: Canonical { value: Ty(&&&&*mut Test), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/receiver_ptr_mutability.rs:18:18: 18:31, inferred_ty: &&&&*mut Test +| 0: user_ty: Canonical { value: Ty(*mut Test), max_universe: U0, variables: [] }, span: $DIR/receiver_ptr_mutability.rs:15:14: 15:23, inferred_ty: *mut Test +| 1: user_ty: Canonical { value: Ty(*mut Test), max_universe: U0, variables: [] }, span: $DIR/receiver_ptr_mutability.rs:15:14: 15:23, inferred_ty: *mut Test +| 2: user_ty: Canonical { value: Ty(&&&&*mut Test), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/receiver_ptr_mutability.rs:19:18: 19:31, inferred_ty: &&&&*mut Test +| 3: user_ty: Canonical { value: Ty(&&&&*mut Test), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/receiver_ptr_mutability.rs:19:18: 19:31, inferred_ty: &&&&*mut Test | fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/building/receiver_ptr_mutability.rs b/tests/mir-opt/building/receiver_ptr_mutability.rs index 668530968fe..4bb3b4cade5 100644 --- a/tests/mir-opt/building/receiver_ptr_mutability.rs +++ b/tests/mir-opt/building/receiver_ptr_mutability.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR receiver_ptr_mutability.main.built.after.mir #![feature(arbitrary_self_types)] diff --git a/tests/mir-opt/building/shifts.rs b/tests/mir-opt/building/shifts.rs index 4b63a00a304..c94a142d336 100644 --- a/tests/mir-opt/building/shifts.rs +++ b/tests/mir-opt/building/shifts.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -C debug-assertions=yes // EMIT_MIR shifts.shift_signed.built.after.mir diff --git a/tests/mir-opt/building/simple_match.rs b/tests/mir-opt/building/simple_match.rs index 0ef97dde636..4f0a3046a06 100644 --- a/tests/mir-opt/building/simple_match.rs +++ b/tests/mir-opt/building/simple_match.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Test that we don't generate unnecessarily large MIR for very simple matches diff --git a/tests/mir-opt/building/storage_live_dead_in_statics.rs b/tests/mir-opt/building/storage_live_dead_in_statics.rs index 79f709148e3..1f569211854 100644 --- a/tests/mir-opt/building/storage_live_dead_in_statics.rs +++ b/tests/mir-opt/building/storage_live_dead_in_statics.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Check that when we compile the static `XXX` into MIR, we do not // generate `StorageStart` or `StorageEnd` statements. diff --git a/tests/mir-opt/building/uniform_array_move_out.rs b/tests/mir-opt/building/uniform_array_move_out.rs index 4ba107c8704..0682891611d 100644 --- a/tests/mir-opt/building/uniform_array_move_out.rs +++ b/tests/mir-opt/building/uniform_array_move_out.rs @@ -1,3 +1,4 @@ +// skip-filecheck #![feature(stmt_expr_attributes, rustc_attrs)] // EMIT_MIR uniform_array_move_out.move_out_from_end.built.after.mir 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/byte_slice.rs b/tests/mir-opt/byte_slice.rs index 48e9c48c120..813d9ccfdc2 100644 --- a/tests/mir-opt/byte_slice.rs +++ b/tests/mir-opt/byte_slice.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -Z mir-opt-level=0 // EMIT_MIR byte_slice.main.SimplifyCfg-elaborate-drops.after.mir diff --git a/tests/mir-opt/casts.redundant.PreCodegen.after.mir b/tests/mir-opt/casts.redundant.PreCodegen.after.mir deleted file mode 100644 index 2084f44f248..00000000000 --- a/tests/mir-opt/casts.redundant.PreCodegen.after.mir +++ /dev/null @@ -1,14 +0,0 @@ -// MIR for `redundant` after PreCodegen - -fn redundant(_1: *const &u8) -> *const &u8 { - debug x => _1; - let mut _0: *const &u8; - scope 1 (inlined generic_cast::<&u8, &u8>) { - debug x => _1; - } - - bb0: { - _0 = _1; - return; - } -} diff --git a/tests/mir-opt/casts.roundtrip.PreCodegen.after.mir b/tests/mir-opt/casts.roundtrip.PreCodegen.after.mir deleted file mode 100644 index f0c35fe9782..00000000000 --- a/tests/mir-opt/casts.roundtrip.PreCodegen.after.mir +++ /dev/null @@ -1,15 +0,0 @@ -// MIR for `roundtrip` after PreCodegen - -fn roundtrip(_1: *const u8) -> *const u8 { - debug x => _1; - let mut _0: *const u8; - let mut _2: *mut u8; - - bb0: { - StorageLive(_2); - _2 = _1 as *mut u8 (PtrToPtr); - _0 = move _2 as *const u8 (PointerCoercion(MutToConstPointer)); - StorageDead(_2); - return; - } -} diff --git a/tests/mir-opt/casts.rs b/tests/mir-opt/casts.rs deleted file mode 100644 index 413b0e09d3f..00000000000 --- a/tests/mir-opt/casts.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![crate_type = "lib"] - -// EMIT_MIR casts.redundant.InstSimplify.diff -// EMIT_MIR casts.redundant.PreCodegen.after.mir -pub fn redundant<'a, 'b: 'a>(x: *const &'a u8) -> *const &'a u8 { - generic_cast::<&'a u8, &'b u8>(x) as *const &'a u8 -} - -#[inline] -fn generic_cast<T, U>(x: *const T) -> *const U { - x as *const U -} - -// EMIT_MIR casts.roundtrip.PreCodegen.after.mir -pub fn roundtrip(x: *const u8) -> *const u8 { - x as *mut u8 as *const u8 -} 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_allocation.rs b/tests/mir-opt/const_allocation.rs index 91a2455eb83..577c61aeb7d 100644 --- a/tests/mir-opt/const_allocation.rs +++ b/tests/mir-opt/const_allocation.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // ignore-endian-big // EMIT_MIR_FOR_EACH_BIT_WIDTH 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_allocation2.rs b/tests/mir-opt/const_allocation2.rs index f2870aa47c5..0fcfaad842c 100644 --- a/tests/mir-opt/const_allocation2.rs +++ b/tests/mir-opt/const_allocation2.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // ignore-endian-big // EMIT_MIR_FOR_EACH_BIT_WIDTH 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_allocation3.rs b/tests/mir-opt/const_allocation3.rs index da3fd089b02..b8c9f50977e 100644 --- a/tests/mir-opt/const_allocation3.rs +++ b/tests/mir-opt/const_allocation3.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // ignore-endian-big // EMIT_MIR_FOR_EACH_BIT_WIDTH diff --git a/tests/mir-opt/const_debuginfo.rs b/tests/mir-opt/const_debuginfo.rs index a188da38526..d8ae08a0723 100644 --- a/tests/mir-opt/const_debuginfo.rs +++ b/tests/mir-opt/const_debuginfo.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -C overflow-checks=no -Zunsound-mir-opts struct Point { diff --git a/tests/mir-opt/const_goto.rs b/tests/mir-opt/const_goto.rs index 6f84f186b31..93cb71c3a0f 100644 --- a/tests/mir-opt/const_goto.rs +++ b/tests/mir-opt/const_goto.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstGoto pub enum Foo { diff --git a/tests/mir-opt/const_goto_const_eval_fail.rs b/tests/mir-opt/const_goto_const_eval_fail.rs index b2357663a90..869f916001c 100644 --- a/tests/mir-opt/const_goto_const_eval_fail.rs +++ b/tests/mir-opt/const_goto_const_eval_fail.rs @@ -1,3 +1,4 @@ +// skip-filecheck #![feature(min_const_generics)] #![crate_type = "lib"] diff --git a/tests/mir-opt/const_goto_storage.rs b/tests/mir-opt/const_goto_storage.rs index 459599c73eb..9d43da23990 100644 --- a/tests/mir-opt/const_goto_storage.rs +++ b/tests/mir-opt/const_goto_storage.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstGoto // EMIT_MIR const_goto_storage.match_nested_if.ConstGoto.diff 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_promotion_extern_static.rs b/tests/mir-opt/const_promotion_extern_static.rs index e4261cfe504..edc3a522338 100644 --- a/tests/mir-opt/const_promotion_extern_static.rs +++ b/tests/mir-opt/const_promotion_extern_static.rs @@ -1,3 +1,4 @@ +// skip-filecheck // ignore-endian-big extern "C" { static X: i32; diff --git a/tests/mir-opt/const_prop/address_of_pair.rs b/tests/mir-opt/const_prop/address_of_pair.rs index 43dc9bae625..169469a0739 100644 --- a/tests/mir-opt/const_prop/address_of_pair.rs +++ b/tests/mir-opt/const_prop/address_of_pair.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // EMIT_MIR address_of_pair.fn0.ConstProp.diff diff --git a/tests/mir-opt/const_prop/aggregate.rs b/tests/mir-opt/const_prop/aggregate.rs index 62cd3dd6889..2e043af08bf 100644 --- a/tests/mir-opt/const_prop/aggregate.rs +++ b/tests/mir-opt/const_prop/aggregate.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // compile-flags: -O diff --git a/tests/mir-opt/const_prop/array_index.rs b/tests/mir-opt/const_prop/array_index.rs index f85d23b9789..3bd2321653d 100644 --- a/tests/mir-opt/const_prop/array_index.rs +++ b/tests/mir-opt/const_prop/array_index.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // EMIT_MIR_FOR_EACH_BIT_WIDTH diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.rs b/tests/mir-opt/const_prop/bad_op_div_by_zero.rs index 963084bf7e5..ab41f64a573 100644 --- a/tests/mir-opt/const_prop/bad_op_div_by_zero.rs +++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // EMIT_MIR bad_op_div_by_zero.main.ConstProp.diff diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs b/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs index 9d7d2aa1044..e747b21cf9b 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR bad_op_mod_by_zero.main.ConstProp.diff diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs index d6b1a93f304..38c97a4cf0e 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_BIT_WIDTH diff --git a/tests/mir-opt/const_prop/boolean_identities.rs b/tests/mir-opt/const_prop/boolean_identities.rs index c7b609949cd..781cce8c7dd 100644 --- a/tests/mir-opt/const_prop/boolean_identities.rs +++ b/tests/mir-opt/const_prop/boolean_identities.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // compile-flags: -O -Zmir-opt-level=4 diff --git a/tests/mir-opt/const_prop/boxes.rs b/tests/mir-opt/const_prop/boxes.rs index 78599174b42..c6807ece199 100644 --- a/tests/mir-opt/const_prop/boxes.rs +++ b/tests/mir-opt/const_prop/boxes.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // compile-flags: -O // EMIT_MIR_FOR_EACH_PANIC_STRATEGY diff --git a/tests/mir-opt/const_prop/cast.rs b/tests/mir-opt/const_prop/cast.rs index 984086eda48..3d543badace 100644 --- a/tests/mir-opt/const_prop/cast.rs +++ b/tests/mir-opt/const_prop/cast.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // EMIT_MIR cast.main.ConstProp.diff 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/checked_add.rs b/tests/mir-opt/const_prop/checked_add.rs index fd40876cbc2..6a53aced091 100644 --- a/tests/mir-opt/const_prop/checked_add.rs +++ b/tests/mir-opt/const_prop/checked_add.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // compile-flags: -C overflow-checks=on diff --git a/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs b/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs index c92831f926d..5bd4731bf08 100644 --- a/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs +++ b/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp #[inline(never)] diff --git a/tests/mir-opt/const_prop/control_flow_simplification.rs b/tests/mir-opt/const_prop/control_flow_simplification.rs index 21d727b3e50..5fc13e20275 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.rs +++ b/tests/mir-opt/const_prop/control_flow_simplification.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // compile-flags: -Zmir-opt-level=1 diff --git a/tests/mir-opt/const_prop/discriminant.rs b/tests/mir-opt/const_prop/discriminant.rs index fdd67ca8ac4..11405f38bdc 100644 --- a/tests/mir-opt/const_prop/discriminant.rs +++ b/tests/mir-opt/const_prop/discriminant.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // compile-flags: -O 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/indirect.rs b/tests/mir-opt/const_prop/indirect.rs index 72af6cd95b8..0e6e1d78d1e 100644 --- a/tests/mir-opt/const_prop/indirect.rs +++ b/tests/mir-opt/const_prop/indirect.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // compile-flags: -C overflow-checks=on 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/inherit_overflow.rs b/tests/mir-opt/const_prop/inherit_overflow.rs index 6ebd364121a..41989462deb 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.rs +++ b/tests/mir-opt/const_prop/inherit_overflow.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // compile-flags: -Zmir-enable-passes=+Inline diff --git a/tests/mir-opt/const_prop/invalid_constant.rs b/tests/mir-opt/const_prop/invalid_constant.rs index bdbc5a1990e..ff6b31a1ee2 100644 --- a/tests/mir-opt/const_prop/invalid_constant.rs +++ b/tests/mir-opt/const_prop/invalid_constant.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // compile-flags: -Zmir-enable-passes=+RemoveZsts // Verify that we can pretty print invalid constants. 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_66971.rs b/tests/mir-opt/const_prop/issue_66971.rs index a0242ec633f..386c95b5b69 100644 --- a/tests/mir-opt/const_prop/issue_66971.rs +++ b/tests/mir-opt/const_prop/issue_66971.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // compile-flags: -Z mir-opt-level=3 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/issue_67019.rs b/tests/mir-opt/const_prop/issue_67019.rs index 66b577f5b5f..2f61298bb98 100644 --- a/tests/mir-opt/const_prop/issue_67019.rs +++ b/tests/mir-opt/const_prop/issue_67019.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // compile-flags: -Z mir-opt-level=3 diff --git a/tests/mir-opt/const_prop/large_array_index.rs b/tests/mir-opt/const_prop/large_array_index.rs index d226bd54671..d98d166ff7c 100644 --- a/tests/mir-opt/const_prop/large_array_index.rs +++ b/tests/mir-opt/const_prop/large_array_index.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_BIT_WIDTH diff --git a/tests/mir-opt/const_prop/mult_by_zero.rs b/tests/mir-opt/const_prop/mult_by_zero.rs index 7bd30975a73..47e15205ea9 100644 --- a/tests/mir-opt/const_prop/mult_by_zero.rs +++ b/tests/mir-opt/const_prop/mult_by_zero.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // EMIT_MIR mult_by_zero.test.ConstProp.diff diff --git a/tests/mir-opt/const_prop/mutable_variable.rs b/tests/mir-opt/const_prop/mutable_variable.rs index 95987ef7fa9..175d63d46f5 100644 --- a/tests/mir-opt/const_prop/mutable_variable.rs +++ b/tests/mir-opt/const_prop/mutable_variable.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // EMIT_MIR mutable_variable.main.ConstProp.diff 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_aggregate.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate.rs index a145c035438..f926771ae38 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate.rs +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // EMIT_MIR mutable_variable_aggregate.main.ConstProp.diff diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs index 3099e659f3f..a81aa7b4979 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // EMIT_MIR mutable_variable_aggregate_mut_ref.main.ConstProp.diff diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs index 30ea5714ae4..54a5d922321 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp 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_no_prop.rs b/tests/mir-opt/const_prop/mutable_variable_no_prop.rs index e51c6223555..a7aeeccd861 100644 --- a/tests/mir-opt/const_prop/mutable_variable_no_prop.rs +++ b/tests/mir-opt/const_prop/mutable_variable_no_prop.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp static mut STATIC: u32 = 0x42424242; 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/mutable_variable_unprop_assign.rs b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs index 4e7c0597a29..6bdb136a949 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp diff --git a/tests/mir-opt/const_prop/offset_of.rs b/tests/mir-opt/const_prop/offset_of.rs index 164db59572b..21911f8dbb5 100644 --- a/tests/mir-opt/const_prop/offset_of.rs +++ b/tests/mir-opt/const_prop/offset_of.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // EMIT_MIR_FOR_EACH_PANIC_STRATEGY 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/read_immutable_static.rs b/tests/mir-opt/const_prop/read_immutable_static.rs index fb8f9fe996a..a8d8cfacc7c 100644 --- a/tests/mir-opt/const_prop/read_immutable_static.rs +++ b/tests/mir-opt/const_prop/read_immutable_static.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp static FOO: u8 = 2; diff --git a/tests/mir-opt/const_prop/ref_deref.rs b/tests/mir-opt/const_prop/ref_deref.rs index 76e56916af0..f2fa024f722 100644 --- a/tests/mir-opt/const_prop/ref_deref.rs +++ b/tests/mir-opt/const_prop/ref_deref.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // EMIT_MIR ref_deref.main.ConstProp.diff diff --git a/tests/mir-opt/const_prop/ref_deref_project.rs b/tests/mir-opt/const_prop/ref_deref_project.rs index 04fc7f8daa1..1b9e0acb2c0 100644 --- a/tests/mir-opt/const_prop/ref_deref_project.rs +++ b/tests/mir-opt/const_prop/ref_deref_project.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // EMIT_MIR ref_deref_project.main.ConstProp.diff diff --git a/tests/mir-opt/const_prop/reify_fn_ptr.rs b/tests/mir-opt/const_prop/reify_fn_ptr.rs index 5f63820669b..da7de80c5f4 100644 --- a/tests/mir-opt/const_prop/reify_fn_ptr.rs +++ b/tests/mir-opt/const_prop/reify_fn_ptr.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // EMIT_MIR reify_fn_ptr.main.ConstProp.diff diff --git a/tests/mir-opt/const_prop/repeat.rs b/tests/mir-opt/const_prop/repeat.rs index fb8b825ee36..92194d6bb58 100644 --- a/tests/mir-opt/const_prop/repeat.rs +++ b/tests/mir-opt/const_prop/repeat.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_BIT_WIDTH 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/return_place.rs b/tests/mir-opt/const_prop/return_place.rs index 0576b02a845..1263de7931f 100644 --- a/tests/mir-opt/const_prop/return_place.rs +++ b/tests/mir-opt/const_prop/return_place.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -C overflow-checks=on diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.rs b/tests/mir-opt/const_prop/scalar_literal_propagation.rs index dfe41e6145b..9dcddf7c770 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.rs +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR scalar_literal_propagation.main.ConstProp.diff diff --git a/tests/mir-opt/const_prop/slice_len.rs b/tests/mir-opt/const_prop/slice_len.rs index e91724536f9..3b551b6b173 100644 --- a/tests/mir-opt/const_prop/slice_len.rs +++ b/tests/mir-opt/const_prop/slice_len.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // compile-flags: -Zmir-enable-passes=+InstSimplify diff --git a/tests/mir-opt/const_prop/switch_int.rs b/tests/mir-opt/const_prop/switch_int.rs index bf708c8298e..7ec56e11e85 100644 --- a/tests/mir-opt/const_prop/switch_int.rs +++ b/tests/mir-opt/const_prop/switch_int.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // compile-flags: -Zmir-enable-passes=+SimplifyConstCondition-after-const-prop // EMIT_MIR_FOR_EACH_PANIC_STRATEGY diff --git a/tests/mir-opt/const_prop/transmute.rs b/tests/mir-opt/const_prop/transmute.rs index 762c421715a..99988d05994 100644 --- a/tests/mir-opt/const_prop/transmute.rs +++ b/tests/mir-opt/const_prop/transmute.rs @@ -7,55 +7,77 @@ use std::mem::transmute; // EMIT_MIR transmute.less_as_i8.ConstProp.diff pub fn less_as_i8() -> i8 { + // CHECK-LABEL: fn less_as_i8( + // CHECK: _0 = const -1_i8; unsafe { transmute(std::cmp::Ordering::Less) } } // EMIT_MIR transmute.from_char.ConstProp.diff pub fn from_char() -> i32 { + // CHECK-LABEL: fn from_char( + // CHECK: _0 = const 82_i32; unsafe { transmute('R') } } // EMIT_MIR transmute.valid_char.ConstProp.diff pub fn valid_char() -> char { + // CHECK-LABEL: fn valid_char( + // CHECK: _0 = const 'R'; unsafe { transmute(0x52_u32) } } // EMIT_MIR transmute.invalid_char.ConstProp.diff pub unsafe fn invalid_char() -> char { + // CHECK-LABEL: fn invalid_char( + // CHECK: _0 = const {transmute(0x7fffffff): char}; unsafe { transmute(i32::MAX) } } // EMIT_MIR transmute.invalid_bool.ConstProp.diff pub unsafe fn invalid_bool() -> bool { + // CHECK-LABEL: fn invalid_bool( + // CHECK: _0 = const {transmute(0xff): bool}; unsafe { transmute(-1_i8) } } // EMIT_MIR transmute.undef_union_as_integer.ConstProp.diff pub unsafe fn undef_union_as_integer() -> u32 { + // CHECK-LABEL: fn undef_union_as_integer( + // CHECK: _1 = Union32 { + // CHECK: _0 = move _1 as u32 (Transmute); union Union32 { value: u32, unit: () } unsafe { transmute(Union32 { unit: () }) } } // EMIT_MIR transmute.unreachable_direct.ConstProp.diff pub unsafe fn unreachable_direct() -> ! { + // CHECK-LABEL: fn unreachable_direct( + // CHECK: [[unit:_.*]] = (); + // CHECK: move [[unit]] as Never (Transmute); let x: Never = unsafe { transmute(()) }; match x {} } // EMIT_MIR transmute.unreachable_ref.ConstProp.diff pub unsafe fn unreachable_ref() -> ! { + // CHECK-LABEL: fn unreachable_ref( + // CHECK: = const {0x1 as &Never}; let x: &Never = unsafe { transmute(1_usize) }; match *x {} } // EMIT_MIR transmute.unreachable_mut.ConstProp.diff pub unsafe fn unreachable_mut() -> ! { + // CHECK-LABEL: fn unreachable_mut( + // CHECK: = const {0x1 as &mut Never}; let x: &mut Never = unsafe { transmute(1_usize) }; match *x {} } // EMIT_MIR transmute.unreachable_box.ConstProp.diff pub unsafe fn unreachable_box() -> ! { + // CHECK-LABEL: fn unreachable_box( + // CHECK: = const Box::<Never>( let x: Box<Never> = unsafe { transmute(1_usize) }; match *x {} } 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/const_prop/tuple_literal_propagation.rs b/tests/mir-opt/const_prop/tuple_literal_propagation.rs index 5890a343f26..e0bc6e1be37 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.rs +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR tuple_literal_propagation.main.ConstProp.diff diff --git a/tests/mir-opt/const_prop/while_let_loops.rs b/tests/mir-opt/const_prop/while_let_loops.rs index 595a94b88be..39081c3550a 100644 --- a/tests/mir-opt/const_prop/while_let_loops.rs +++ b/tests/mir-opt/const_prop/while_let_loops.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp // EMIT_MIR while_let_loops.change_loop_body.ConstProp.diff diff --git a/tests/mir-opt/const_prop_miscompile.rs b/tests/mir-opt/const_prop_miscompile.rs index dbbe5ee0840..00696535ac1 100644 --- a/tests/mir-opt/const_prop_miscompile.rs +++ b/tests/mir-opt/const_prop_miscompile.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ConstProp #![feature(raw_ref_op)] diff --git a/tests/mir-opt/copy-prop/borrowed_local.rs b/tests/mir-opt/copy-prop/borrowed_local.rs index bf94dc57d33..c6b8ad3571f 100644 --- a/tests/mir-opt/copy-prop/borrowed_local.rs +++ b/tests/mir-opt/copy-prop/borrowed_local.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: CopyProp diff --git a/tests/mir-opt/copy-prop/branch.rs b/tests/mir-opt/copy-prop/branch.rs index c8af1aa7bf9..2785089579f 100644 --- a/tests/mir-opt/copy-prop/branch.rs +++ b/tests/mir-opt/copy-prop/branch.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY //! Tests that we bail out when there are multiple assignments to the same local. // unit-test: CopyProp diff --git a/tests/mir-opt/copy-prop/calls.rs b/tests/mir-opt/copy-prop/calls.rs index c1f86f1f412..2970f5f0b8d 100644 --- a/tests/mir-opt/copy-prop/calls.rs +++ b/tests/mir-opt/copy-prop/calls.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Check that CopyProp does propagate return values of call terminators. // unit-test: CopyProp // needs-unwind diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.rs b/tests/mir-opt/copy-prop/copy_propagation_arg.rs index 671860da50d..83bbefe09ed 100644 --- a/tests/mir-opt/copy-prop/copy_propagation_arg.rs +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Check that CopyProp does not propagate an assignment to a function argument // (doing so can break usages of the original argument value) diff --git a/tests/mir-opt/copy-prop/custom_move_arg.rs b/tests/mir-opt/copy-prop/custom_move_arg.rs index d1c5ffdff0d..2077874ee9a 100644 --- a/tests/mir-opt/copy-prop/custom_move_arg.rs +++ b/tests/mir-opt/copy-prop/custom_move_arg.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: CopyProp diff --git a/tests/mir-opt/copy-prop/cycle.rs b/tests/mir-opt/copy-prop/cycle.rs index 56ec7539734..58e049fde4b 100644 --- a/tests/mir-opt/copy-prop/cycle.rs +++ b/tests/mir-opt/copy-prop/cycle.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY //! Tests that cyclic assignments don't hang CopyProp, and result in reasonable code. // unit-test: CopyProp diff --git a/tests/mir-opt/copy-prop/dead_stores_79191.rs b/tests/mir-opt/copy-prop/dead_stores_79191.rs index 4260d35b194..81306ab613a 100644 --- a/tests/mir-opt/copy-prop/dead_stores_79191.rs +++ b/tests/mir-opt/copy-prop/dead_stores_79191.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: CopyProp diff --git a/tests/mir-opt/copy-prop/dead_stores_better.rs b/tests/mir-opt/copy-prop/dead_stores_better.rs index c5962db6a40..7addf6af23b 100644 --- a/tests/mir-opt/copy-prop/dead_stores_better.rs +++ b/tests/mir-opt/copy-prop/dead_stores_better.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // This is a copy of the `dead_stores_79191` test, except that we turn on DSE. This demonstrates // that that pass enables this one to do more optimizations. diff --git a/tests/mir-opt/copy-prop/issue_107511.rs b/tests/mir-opt/copy-prop/issue_107511.rs index ce6fcc17b57..53fd9366276 100644 --- a/tests/mir-opt/copy-prop/issue_107511.rs +++ b/tests/mir-opt/copy-prop/issue_107511.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: CopyProp diff --git a/tests/mir-opt/copy-prop/move_arg.rs b/tests/mir-opt/copy-prop/move_arg.rs index a3a04e57bc1..fc2932a65dd 100644 --- a/tests/mir-opt/copy-prop/move_arg.rs +++ b/tests/mir-opt/copy-prop/move_arg.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Test that we do not move multiple times from the same local. // unit-test: CopyProp diff --git a/tests/mir-opt/copy-prop/move_projection.rs b/tests/mir-opt/copy-prop/move_projection.rs index f94addb5629..8629d535bcf 100644 --- a/tests/mir-opt/copy-prop/move_projection.rs +++ b/tests/mir-opt/copy-prop/move_projection.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: CopyProp diff --git a/tests/mir-opt/copy-prop/mutate_through_pointer.rs b/tests/mir-opt/copy-prop/mutate_through_pointer.rs index 753787089b5..e36a10846a6 100644 --- a/tests/mir-opt/copy-prop/mutate_through_pointer.rs +++ b/tests/mir-opt/copy-prop/mutate_through_pointer.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: CopyProp // // This attempts to mutate `a` via a pointer derived from `addr_of!(a)`. That is UB diff --git a/tests/mir-opt/copy-prop/non_dominate.rs b/tests/mir-opt/copy-prop/non_dominate.rs index c0ea838e1c8..c26ac444e5c 100644 --- a/tests/mir-opt/copy-prop/non_dominate.rs +++ b/tests/mir-opt/copy-prop/non_dominate.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: CopyProp #![feature(custom_mir, core_intrinsics)] diff --git a/tests/mir-opt/copy-prop/partial_init.rs b/tests/mir-opt/copy-prop/partial_init.rs index f5ab9974f71..44cc203de0d 100644 --- a/tests/mir-opt/copy-prop/partial_init.rs +++ b/tests/mir-opt/copy-prop/partial_init.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: CopyProp // Verify that we do not ICE on partial initializations. diff --git a/tests/mir-opt/copy-prop/reborrow.rs b/tests/mir-opt/copy-prop/reborrow.rs index c37ba5e5c4c..57c4fb8ade9 100644 --- a/tests/mir-opt/copy-prop/reborrow.rs +++ b/tests/mir-opt/copy-prop/reborrow.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Check that CopyProp considers reborrows as not mutating the pointer. // unit-test: CopyProp diff --git a/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-abort.mir b/tests/mir-opt/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-abort.mir index d8bea14204d..25bffbe2488 100644 --- a/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-abort.mir +++ b/tests/mir-opt/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-abort.mir @@ -1,10 +1,10 @@ -// MIR for `main::{closure#0}` 0 generator_drop -/* generator_layout = GeneratorLayout { +// MIR for `main::{closure#0}` 0 coroutine_drop +/* coroutine_layout = CoroutineLayout { field_tys: { - _0: GeneratorSavedTy { + _0: CoroutineSavedTy { ty: std::string::String, source_info: SourceInfo { - span: $DIR/generator_drop_cleanup.rs:11:13: 11:15 (#0), + span: $DIR/coroutine_drop_cleanup.rs:12:13: 12:15 (#0), scope: scope[0], }, ignore_for_traits: false, @@ -21,7 +21,7 @@ }, } */ -fn main::{closure#0}(_1: *mut {generator@$DIR/generator_drop_cleanup.rs:10:15: 10:17}) -> () { +fn main::{closure#0}(_1: *mut {coroutine@$DIR/coroutine_drop_cleanup.rs:11:15: 11:17}) -> () { let mut _0: (); let mut _2: (); let _3: std::string::String; diff --git a/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-unwind.mir b/tests/mir-opt/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-unwind.mir index d8b27eda8f2..2eac754b15c 100644 --- a/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-unwind.mir +++ b/tests/mir-opt/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-unwind.mir @@ -1,10 +1,10 @@ -// MIR for `main::{closure#0}` 0 generator_drop -/* generator_layout = GeneratorLayout { +// MIR for `main::{closure#0}` 0 coroutine_drop +/* coroutine_layout = CoroutineLayout { field_tys: { - _0: GeneratorSavedTy { + _0: CoroutineSavedTy { ty: std::string::String, source_info: SourceInfo { - span: $DIR/generator_drop_cleanup.rs:11:13: 11:15 (#0), + span: $DIR/coroutine_drop_cleanup.rs:12:13: 12:15 (#0), scope: scope[0], }, ignore_for_traits: false, @@ -21,7 +21,7 @@ }, } */ -fn main::{closure#0}(_1: *mut {generator@$DIR/generator_drop_cleanup.rs:10:15: 10:17}) -> () { +fn main::{closure#0}(_1: *mut {coroutine@$DIR/coroutine_drop_cleanup.rs:11:15: 11:17}) -> () { let mut _0: (); let mut _2: (); let _3: std::string::String; diff --git a/tests/mir-opt/coroutine_drop_cleanup.rs b/tests/mir-opt/coroutine_drop_cleanup.rs new file mode 100644 index 00000000000..69984c737fe --- /dev/null +++ b/tests/mir-opt/coroutine_drop_cleanup.rs @@ -0,0 +1,15 @@ +// skip-filecheck +#![feature(coroutines, coroutine_trait)] + +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY + +// Regression test for #58892, coroutine drop shims should not have blocks +// spuriously marked as cleanup + +// EMIT_MIR coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.mir +fn main() { + let gen = || { + let _s = String::new(); + yield; + }; +} diff --git a/tests/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-abort.mir b/tests/mir-opt/coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-abort.mir index 4587282de93..8369a3e60dd 100644 --- a/tests/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-abort.mir +++ b/tests/mir-opt/coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-abort.mir @@ -1,6 +1,6 @@ // MIR for `main::{closure#0}` before StateTransform -fn main::{closure#0}(_1: {generator@$DIR/generator_storage_dead_unwind.rs:22:16: 22:18}, _2: ()) -> () +fn main::{closure#0}(_1: {coroutine@$DIR/coroutine_storage_dead_unwind.rs:23:16: 23:18}, _2: ()) -> () yields () { let mut _0: (); @@ -78,6 +78,6 @@ yields () } bb8: { - generator_drop; + coroutine_drop; } } diff --git a/tests/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-unwind.mir b/tests/mir-opt/coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-unwind.mir index 38026f65bbd..1773db1abff 100644 --- a/tests/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-unwind.mir +++ b/tests/mir-opt/coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-unwind.mir @@ -1,6 +1,6 @@ // MIR for `main::{closure#0}` before StateTransform -fn main::{closure#0}(_1: {generator@$DIR/generator_storage_dead_unwind.rs:22:16: 22:18}, _2: ()) -> () +fn main::{closure#0}(_1: {coroutine@$DIR/coroutine_storage_dead_unwind.rs:23:16: 23:18}, _2: ()) -> () yields () { let mut _0: (); @@ -78,7 +78,7 @@ yields () } bb8: { - generator_drop; + coroutine_drop; } bb9 (cleanup): { diff --git a/tests/mir-opt/generator_storage_dead_unwind.rs b/tests/mir-opt/coroutine_storage_dead_unwind.rs index 664f7ef67e3..253be1ff698 100644 --- a/tests/mir-opt/generator_storage_dead_unwind.rs +++ b/tests/mir-opt/coroutine_storage_dead_unwind.rs @@ -1,11 +1,12 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// Test that we generate StorageDead on unwind paths for generators. +// Test that we generate StorageDead on unwind paths for coroutines. // // Basic block and local names can safely change, but the StorageDead statements // should not go away. -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] struct Foo(i32); @@ -17,7 +18,7 @@ struct Bar(i32); fn take<T>(_x: T) {} -// EMIT_MIR generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir +// EMIT_MIR coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir fn main() { let _gen = || { let a = Foo(5); diff --git a/tests/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir b/tests/mir-opt/coroutine_tiny.main-{closure#0}.coroutine_resume.0.mir index ac7549f93b1..17b99c87c39 100644 --- a/tests/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/coroutine_tiny.main-{closure#0}.coroutine_resume.0.mir @@ -1,10 +1,10 @@ -// MIR for `main::{closure#0}` 0 generator_resume -/* generator_layout = GeneratorLayout { +// MIR for `main::{closure#0}` 0 coroutine_resume +/* coroutine_layout = CoroutineLayout { field_tys: { - _0: GeneratorSavedTy { + _0: CoroutineSavedTy { ty: HasDrop, source_info: SourceInfo { - span: $DIR/generator_tiny.rs:20:13: 20:15 (#0), + span: $DIR/coroutine_tiny.rs:21:13: 21:15 (#0), scope: scope[0], }, ignore_for_traits: false, @@ -21,9 +21,9 @@ }, } */ -fn main::{closure#0}(_1: Pin<&mut {generator@$DIR/generator_tiny.rs:19:16: 19:24}>, _2: u8) -> GeneratorState<(), ()> { +fn main::{closure#0}(_1: Pin<&mut {coroutine@$DIR/coroutine_tiny.rs:20:16: 20:24}>, _2: u8) -> CoroutineState<(), ()> { debug _x => _10; - let mut _0: std::ops::GeneratorState<(), ()>; + let mut _0: std::ops::CoroutineState<(), ()>; let _3: HasDrop; let mut _4: !; let mut _5: (); @@ -34,18 +34,18 @@ fn main::{closure#0}(_1: Pin<&mut {generator@$DIR/generator_tiny.rs:19:16: 19:24 let _10: u8; let mut _11: u32; scope 1 { - debug _d => (((*(_1.0: &mut {generator@$DIR/generator_tiny.rs:19:16: 19:24})) as variant#3).0: HasDrop); + debug _d => (((*(_1.0: &mut {coroutine@$DIR/coroutine_tiny.rs:20:16: 20:24})) as variant#3).0: HasDrop); } bb0: { - _11 = discriminant((*(_1.0: &mut {generator@$DIR/generator_tiny.rs:19:16: 19:24}))); + _11 = discriminant((*(_1.0: &mut {coroutine@$DIR/coroutine_tiny.rs:20:16: 20:24}))); switchInt(move _11) -> [0: bb1, 3: bb5, otherwise: bb6]; } bb1: { _10 = move _2; nop; - (((*(_1.0: &mut {generator@$DIR/generator_tiny.rs:19:16: 19:24})) as variant#3).0: HasDrop) = HasDrop; + (((*(_1.0: &mut {coroutine@$DIR/coroutine_tiny.rs:20:16: 20:24})) as variant#3).0: HasDrop) = HasDrop; StorageLive(_4); goto -> bb2; } @@ -54,8 +54,8 @@ fn main::{closure#0}(_1: Pin<&mut {generator@$DIR/generator_tiny.rs:19:16: 19:24 StorageLive(_6); StorageLive(_7); _7 = (); - _0 = GeneratorState::<(), ()>::Yielded(move _7); - discriminant((*(_1.0: &mut {generator@$DIR/generator_tiny.rs:19:16: 19:24}))) = 3; + _0 = CoroutineState::<(), ()>::Yielded(move _7); + discriminant((*(_1.0: &mut {coroutine@$DIR/coroutine_tiny.rs:20:16: 20:24}))) = 3; return; } diff --git a/tests/mir-opt/generator_tiny.rs b/tests/mir-opt/coroutine_tiny.rs index 7dad63a61d6..0fd785b28f8 100644 --- a/tests/mir-opt/generator_tiny.rs +++ b/tests/mir-opt/coroutine_tiny.rs @@ -1,10 +1,11 @@ -//! Tests that generators that cannot return or unwind don't have unnecessary +// skip-filecheck +//! Tests that coroutines that cannot return or unwind don't have unnecessary //! panic branches. // compile-flags: -C panic=abort // no-prefer-dynamic -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] struct HasDrop; @@ -14,7 +15,7 @@ impl Drop for HasDrop { fn callee() {} -// EMIT_MIR generator_tiny.main-{closure#0}.generator_resume.0.mir +// EMIT_MIR coroutine_tiny.main-{closure#0}.coroutine_resume.0.mir fn main() { let _gen = |_x: u8| { let _d = HasDrop; diff --git a/tests/mir-opt/dataflow-const-prop/array_index.rs b/tests/mir-opt/dataflow-const-prop/array_index.rs index ddb3646ca9b..3d420f93007 100644 --- a/tests/mir-opt/dataflow-const-prop/array_index.rs +++ b/tests/mir-opt/dataflow-const-prop/array_index.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: DataflowConstProp // EMIT_MIR_FOR_EACH_BIT_WIDTH diff --git a/tests/mir-opt/dataflow-const-prop/boolean_identities.rs b/tests/mir-opt/dataflow-const-prop/boolean_identities.rs index 9e911e85b88..2605c7019e6 100644 --- a/tests/mir-opt/dataflow-const-prop/boolean_identities.rs +++ b/tests/mir-opt/dataflow-const-prop/boolean_identities.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: DataflowConstProp // EMIT_MIR boolean_identities.test.DataflowConstProp.diff diff --git a/tests/mir-opt/dataflow-const-prop/cast.rs b/tests/mir-opt/dataflow-const-prop/cast.rs index 484403f7f0e..c87872609dc 100644 --- a/tests/mir-opt/dataflow-const-prop/cast.rs +++ b/tests/mir-opt/dataflow-const-prop/cast.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: DataflowConstProp // EMIT_MIR cast.main.DataflowConstProp.diff diff --git a/tests/mir-opt/dataflow-const-prop/checked.rs b/tests/mir-opt/dataflow-const-prop/checked.rs index 1c301460f5d..b41ac0b3d2a 100644 --- a/tests/mir-opt/dataflow-const-prop/checked.rs +++ b/tests/mir-opt/dataflow-const-prop/checked.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: DataflowConstProp // compile-flags: -Coverflow-checks=on 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/default_boxed_slice.rs b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs index dfeccd3eb94..1bb052736c0 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: DataflowConstProp // compile-flags: -Zmir-enable-passes=+ConstProp,+Inline // ignore-debug assertions change the output MIR diff --git a/tests/mir-opt/dataflow-const-prop/enum.rs b/tests/mir-opt/dataflow-const-prop/enum.rs index 5a10e9e883d..e35c0e6e85b 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.rs +++ b/tests/mir-opt/dataflow-const-prop/enum.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: DataflowConstProp // EMIT_MIR_FOR_EACH_BIT_WIDTH 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/if.rs b/tests/mir-opt/dataflow-const-prop/if.rs index 34fc35790c1..72aabbccf56 100644 --- a/tests/mir-opt/dataflow-const-prop/if.rs +++ b/tests/mir-opt/dataflow-const-prop/if.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: DataflowConstProp // EMIT_MIR if.main.DataflowConstProp.diff diff --git a/tests/mir-opt/dataflow-const-prop/inherit_overflow.rs b/tests/mir-opt/dataflow-const-prop/inherit_overflow.rs index 964c58966f0..664cbcb2c25 100644 --- a/tests/mir-opt/dataflow-const-prop/inherit_overflow.rs +++ b/tests/mir-opt/dataflow-const-prop/inherit_overflow.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: DataflowConstProp // compile-flags: -Zmir-enable-passes=+Inline diff --git a/tests/mir-opt/dataflow-const-prop/issue_81605.rs b/tests/mir-opt/dataflow-const-prop/issue_81605.rs index d75e2a28bef..7c5eceb8a2b 100644 --- a/tests/mir-opt/dataflow-const-prop/issue_81605.rs +++ b/tests/mir-opt/dataflow-const-prop/issue_81605.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: DataflowConstProp // EMIT_MIR issue_81605.f.DataflowConstProp.diff diff --git a/tests/mir-opt/dataflow-const-prop/large_array_index.rs b/tests/mir-opt/dataflow-const-prop/large_array_index.rs index af13c7d1020..d611a54ba71 100644 --- a/tests/mir-opt/dataflow-const-prop/large_array_index.rs +++ b/tests/mir-opt/dataflow-const-prop/large_array_index.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: DataflowConstProp // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_BIT_WIDTH diff --git a/tests/mir-opt/dataflow-const-prop/mult_by_zero.rs b/tests/mir-opt/dataflow-const-prop/mult_by_zero.rs index dbea1480445..16a45c8e9fb 100644 --- a/tests/mir-opt/dataflow-const-prop/mult_by_zero.rs +++ b/tests/mir-opt/dataflow-const-prop/mult_by_zero.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: DataflowConstProp // EMIT_MIR mult_by_zero.test.DataflowConstProp.diff diff --git a/tests/mir-opt/dataflow-const-prop/offset_of.rs b/tests/mir-opt/dataflow-const-prop/offset_of.rs index ccc90790e52..e71b3f59eca 100644 --- a/tests/mir-opt/dataflow-const-prop/offset_of.rs +++ b/tests/mir-opt/dataflow-const-prop/offset_of.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: DataflowConstProp // EMIT_MIR_FOR_EACH_PANIC_STRATEGY diff --git a/tests/mir-opt/dataflow-const-prop/ref_without_sb.rs b/tests/mir-opt/dataflow-const-prop/ref_without_sb.rs index 4ac0a5b3298..2851c0590ad 100644 --- a/tests/mir-opt/dataflow-const-prop/ref_without_sb.rs +++ b/tests/mir-opt/dataflow-const-prop/ref_without_sb.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: DataflowConstProp diff --git a/tests/mir-opt/dataflow-const-prop/repeat.rs b/tests/mir-opt/dataflow-const-prop/repeat.rs index 9fa353e44c5..b8244819481 100644 --- a/tests/mir-opt/dataflow-const-prop/repeat.rs +++ b/tests/mir-opt/dataflow-const-prop/repeat.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: DataflowConstProp // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_BIT_WIDTH diff --git a/tests/mir-opt/dataflow-const-prop/repr_transparent.rs b/tests/mir-opt/dataflow-const-prop/repr_transparent.rs index 4ce0ca4dff4..8cbed6fbb62 100644 --- a/tests/mir-opt/dataflow-const-prop/repr_transparent.rs +++ b/tests/mir-opt/dataflow-const-prop/repr_transparent.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: DataflowConstProp // The struct has scalar ABI, but is not a scalar type. diff --git a/tests/mir-opt/dataflow-const-prop/self_assign.rs b/tests/mir-opt/dataflow-const-prop/self_assign.rs index 8de2195f93b..c5866c4a9fd 100644 --- a/tests/mir-opt/dataflow-const-prop/self_assign.rs +++ b/tests/mir-opt/dataflow-const-prop/self_assign.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: DataflowConstProp // EMIT_MIR self_assign.main.DataflowConstProp.diff diff --git a/tests/mir-opt/dataflow-const-prop/self_assign_add.rs b/tests/mir-opt/dataflow-const-prop/self_assign_add.rs index e3282762459..cfe1458e44b 100644 --- a/tests/mir-opt/dataflow-const-prop/self_assign_add.rs +++ b/tests/mir-opt/dataflow-const-prop/self_assign_add.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: DataflowConstProp // EMIT_MIR self_assign_add.main.DataflowConstProp.diff diff --git a/tests/mir-opt/dataflow-const-prop/sibling_ptr.rs b/tests/mir-opt/dataflow-const-prop/sibling_ptr.rs index 87842f347e4..68aff528695 100644 --- a/tests/mir-opt/dataflow-const-prop/sibling_ptr.rs +++ b/tests/mir-opt/dataflow-const-prop/sibling_ptr.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // This attempts to modify `x.1` via a pointer derived from `addr_of_mut!(x.0)`. // According to Miri, that is UB. However, T-opsem has not finalized that diff --git a/tests/mir-opt/dataflow-const-prop/slice_len.rs b/tests/mir-opt/dataflow-const-prop/slice_len.rs index 41367e48497..86266ef5d4e 100644 --- a/tests/mir-opt/dataflow-const-prop/slice_len.rs +++ b/tests/mir-opt/dataflow-const-prop/slice_len.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: DataflowConstProp // compile-flags: -Zmir-enable-passes=+InstSimplify 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/dataflow-const-prop/struct.rs b/tests/mir-opt/dataflow-const-prop/struct.rs index e92a1676d3f..7b0646a5356 100644 --- a/tests/mir-opt/dataflow-const-prop/struct.rs +++ b/tests/mir-opt/dataflow-const-prop/struct.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: DataflowConstProp // EMIT_MIR_FOR_EACH_BIT_WIDTH diff --git a/tests/mir-opt/dataflow-const-prop/terminator.rs b/tests/mir-opt/dataflow-const-prop/terminator.rs index 114dbeca5ac..92a42f22c21 100644 --- a/tests/mir-opt/dataflow-const-prop/terminator.rs +++ b/tests/mir-opt/dataflow-const-prop/terminator.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: DataflowConstProp diff --git a/tests/mir-opt/dataflow-const-prop/transmute.rs b/tests/mir-opt/dataflow-const-prop/transmute.rs index c25e33ab0b6..02e4f1e5013 100644 --- a/tests/mir-opt/dataflow-const-prop/transmute.rs +++ b/tests/mir-opt/dataflow-const-prop/transmute.rs @@ -7,55 +7,77 @@ use std::mem::transmute; // EMIT_MIR transmute.less_as_i8.DataflowConstProp.diff pub fn less_as_i8() -> i8 { + // CHECK-LABEL: fn less_as_i8( + // FIXME-CHECK: _0 = const -1_i8; unsafe { transmute(std::cmp::Ordering::Less) } } // EMIT_MIR transmute.from_char.DataflowConstProp.diff pub fn from_char() -> i32 { + // CHECK-LABEL: fn from_char( + // CHECK: _0 = const 82_i32; unsafe { transmute('R') } } // EMIT_MIR transmute.valid_char.DataflowConstProp.diff pub fn valid_char() -> char { + // CHECK-LABEL: fn valid_char( + // CHECK: _0 = const 'R'; unsafe { transmute(0x52_u32) } } // EMIT_MIR transmute.invalid_char.DataflowConstProp.diff pub unsafe fn invalid_char() -> char { + // CHECK-LABEL: fn invalid_char( + // CHECK: _0 = const {transmute(0x7fffffff): char}; unsafe { transmute(i32::MAX) } } // EMIT_MIR transmute.invalid_bool.DataflowConstProp.diff pub unsafe fn invalid_bool() -> bool { + // CHECK-LABEL: fn invalid_bool( + // CHECK: _0 = const {transmute(0xff): bool}; unsafe { transmute(-1_i8) } } // EMIT_MIR transmute.undef_union_as_integer.DataflowConstProp.diff pub unsafe fn undef_union_as_integer() -> u32 { + // CHECK-LABEL: fn undef_union_as_integer( + // CHECK: _1 = Union32 { + // CHECK: _0 = move _1 as u32 (Transmute); union Union32 { value: u32, unit: () } unsafe { transmute(Union32 { unit: () }) } } // EMIT_MIR transmute.unreachable_direct.DataflowConstProp.diff pub unsafe fn unreachable_direct() -> ! { + // CHECK-LABEL: fn unreachable_direct( + // CHECK: [[unit:_.*]] = (); + // CHECK: move [[unit]] as Never (Transmute); let x: Never = unsafe { transmute(()) }; match x {} } // EMIT_MIR transmute.unreachable_ref.DataflowConstProp.diff pub unsafe fn unreachable_ref() -> ! { + // CHECK-LABEL: fn unreachable_ref( + // CHECK: = const {0x1 as &Never}; let x: &Never = unsafe { transmute(1_usize) }; match *x {} } // EMIT_MIR transmute.unreachable_mut.DataflowConstProp.diff pub unsafe fn unreachable_mut() -> ! { + // CHECK-LABEL: fn unreachable_mut( + // CHECK: = const {0x1 as &mut Never}; let x: &mut Never = unsafe { transmute(1_usize) }; match *x {} } // EMIT_MIR transmute.unreachable_box.DataflowConstProp.diff pub unsafe fn unreachable_box() -> ! { + // CHECK-LABEL: fn unreachable_box( + // CHECK: = const Box::<Never>( let x: Box<Never> = unsafe { transmute(1_usize) }; match *x {} } diff --git a/tests/mir-opt/dataflow-const-prop/tuple.rs b/tests/mir-opt/dataflow-const-prop/tuple.rs index 92c70eab0ff..c63ce8b140f 100644 --- a/tests/mir-opt/dataflow-const-prop/tuple.rs +++ b/tests/mir-opt/dataflow-const-prop/tuple.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: DataflowConstProp // EMIT_MIR tuple.main.DataflowConstProp.diff diff --git a/tests/mir-opt/dead-store-elimination/call_arg_copy.rs b/tests/mir-opt/dead-store-elimination/call_arg_copy.rs index f09cdee1482..dcd15fb2b09 100644 --- a/tests/mir-opt/dead-store-elimination/call_arg_copy.rs +++ b/tests/mir-opt/dead-store-elimination/call_arg_copy.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: DeadStoreElimination // compile-flags: -Zmir-enable-passes=+CopyProp diff --git a/tests/mir-opt/dead-store-elimination/cycle.rs b/tests/mir-opt/dead-store-elimination/cycle.rs index e3def2f65da..8896f5ff345 100644 --- a/tests/mir-opt/dead-store-elimination/cycle.rs +++ b/tests/mir-opt/dead-store-elimination/cycle.rs @@ -1,3 +1,4 @@ +// skip-filecheck // This example is interesting because the non-transitive version of `MaybeLiveLocals` would // report that *all* of these stores are live. // diff --git a/tests/mir-opt/dead-store-elimination/place_mention.rs b/tests/mir-opt/dead-store-elimination/place_mention.rs index 59dc74454a4..4813cf7ee2b 100644 --- a/tests/mir-opt/dead-store-elimination/place_mention.rs +++ b/tests/mir-opt/dead-store-elimination/place_mention.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: DeadStoreElimination // compile-flags: -Zmir-keep-place-mention diff --git a/tests/mir-opt/dead-store-elimination/provenance_soundness.rs b/tests/mir-opt/dead-store-elimination/provenance_soundness.rs index 11314e99098..24ffbe980eb 100644 --- a/tests/mir-opt/dead-store-elimination/provenance_soundness.rs +++ b/tests/mir-opt/dead-store-elimination/provenance_soundness.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: DeadStoreElimination // compile-flags: -Zmir-emit-retag diff --git a/tests/mir-opt/deduplicate_blocks.rs b/tests/mir-opt/deduplicate_blocks.rs index 0c38c7f215e..d3b89102f0c 100644 --- a/tests/mir-opt/deduplicate_blocks.rs +++ b/tests/mir-opt/deduplicate_blocks.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: DeduplicateBlocks diff --git a/tests/mir-opt/deref-patterns/string.rs b/tests/mir-opt/deref-patterns/string.rs index 3a99c44aa0e..0c8385b5c48 100644 --- a/tests/mir-opt/deref-patterns/string.rs +++ b/tests/mir-opt/deref-patterns/string.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -Z mir-opt-level=0 -C panic=abort #![feature(string_deref_patterns)] diff --git a/tests/mir-opt/derefer_complex_case.rs b/tests/mir-opt/derefer_complex_case.rs index cc619879ef3..6097d8739fb 100644 --- a/tests/mir-opt/derefer_complex_case.rs +++ b/tests/mir-opt/derefer_complex_case.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: Derefer // EMIT_MIR derefer_complex_case.main.Derefer.diff // EMIT_MIR_FOR_EACH_PANIC_STRATEGY diff --git a/tests/mir-opt/derefer_inline_test.rs b/tests/mir-opt/derefer_inline_test.rs index 7ac330e5102..713c051f44a 100644 --- a/tests/mir-opt/derefer_inline_test.rs +++ b/tests/mir-opt/derefer_inline_test.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: Derefer // EMIT_MIR derefer_inline_test.main.Derefer.diff // EMIT_MIR_FOR_EACH_PANIC_STRATEGY diff --git a/tests/mir-opt/derefer_terminator_test.rs b/tests/mir-opt/derefer_terminator_test.rs index 164aa733a24..3780ff5df7d 100644 --- a/tests/mir-opt/derefer_terminator_test.rs +++ b/tests/mir-opt/derefer_terminator_test.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: Derefer // EMIT_MIR derefer_terminator_test.main.Derefer.diff // EMIT_MIR_FOR_EACH_PANIC_STRATEGY diff --git a/tests/mir-opt/derefer_test.rs b/tests/mir-opt/derefer_test.rs index fad0fe8eb6f..171925bb19d 100644 --- a/tests/mir-opt/derefer_test.rs +++ b/tests/mir-opt/derefer_test.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: Derefer // EMIT_MIR derefer_test.main.Derefer.diff fn main() { diff --git a/tests/mir-opt/derefer_test_multiple.rs b/tests/mir-opt/derefer_test_multiple.rs index 0b3888b07ab..ac778a9c9b7 100644 --- a/tests/mir-opt/derefer_test_multiple.rs +++ b/tests/mir-opt/derefer_test_multiple.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: Derefer // EMIT_MIR derefer_test_multiple.main.Derefer.diff fn main () { diff --git a/tests/mir-opt/dest-prop/branch.rs b/tests/mir-opt/dest-prop/branch.rs index 5007aafb62f..d8c74a0aa91 100644 --- a/tests/mir-opt/dest-prop/branch.rs +++ b/tests/mir-opt/dest-prop/branch.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY //! Tests that assignment in both branches of an `if` are eliminated. // unit-test: DestinationPropagation diff --git a/tests/mir-opt/dest-prop/copy_propagation_arg.rs b/tests/mir-opt/dest-prop/copy_propagation_arg.rs index 1f8d588925c..435cf07ab0c 100644 --- a/tests/mir-opt/dest-prop/copy_propagation_arg.rs +++ b/tests/mir-opt/dest-prop/copy_propagation_arg.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Check that DestinationPropagation does not propagate an assignment to a function argument // (doing so can break usages of the original argument value) diff --git a/tests/mir-opt/dest-prop/cycle.rs b/tests/mir-opt/dest-prop/cycle.rs index 9bc0cb05a35..77cff062cc4 100644 --- a/tests/mir-opt/dest-prop/cycle.rs +++ b/tests/mir-opt/dest-prop/cycle.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY //! Tests that cyclic assignments don't hang DestinationPropagation, and result in reasonable code. // unit-test: DestinationPropagation diff --git a/tests/mir-opt/dest-prop/dead_stores_79191.rs b/tests/mir-opt/dest-prop/dead_stores_79191.rs index 2f95ba0e326..a6fd542d3b5 100644 --- a/tests/mir-opt/dest-prop/dead_stores_79191.rs +++ b/tests/mir-opt/dest-prop/dead_stores_79191.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: DestinationPropagation diff --git a/tests/mir-opt/dest-prop/dead_stores_better.rs b/tests/mir-opt/dest-prop/dead_stores_better.rs index e67653c57e4..c9895f35cf1 100644 --- a/tests/mir-opt/dest-prop/dead_stores_better.rs +++ b/tests/mir-opt/dest-prop/dead_stores_better.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // This is a copy of the `dead_stores_79191` test, except that we turn on DSE. This demonstrates // that that pass enables this one to do more optimizations. diff --git a/tests/mir-opt/dest-prop/simple.rs b/tests/mir-opt/dest-prop/simple.rs index 0bcb2924f1d..03d20962690 100644 --- a/tests/mir-opt/dest-prop/simple.rs +++ b/tests/mir-opt/dest-prop/simple.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY //! Copy of `nrvo-simple.rs`, to ensure that full dest-prop handles it too. // unit-test: DestinationPropagation 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/dest-prop/union.rs b/tests/mir-opt/dest-prop/union.rs index 4bc6f28c6c2..6d3e6d7fa76 100644 --- a/tests/mir-opt/dest-prop/union.rs +++ b/tests/mir-opt/dest-prop/union.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY //! Tests that we can propagate into places that are projections into unions // compile-flags: -Zunsound-mir-opts diff --git a/tests/mir-opt/dest-prop/unreachable.rs b/tests/mir-opt/dest-prop/unreachable.rs index e950dbbf5c9..a47d2a0c8e2 100644 --- a/tests/mir-opt/dest-prop/unreachable.rs +++ b/tests/mir-opt/dest-prop/unreachable.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Check that unreachable code is removed after the destination propagation. // Regression test for issue #105428. diff --git a/tests/mir-opt/dont_inline_type_id.rs b/tests/mir-opt/dont_inline_type_id.rs index d8a56636094..788c2f55dc0 100644 --- a/tests/mir-opt/dont_inline_type_id.rs +++ b/tests/mir-opt/dont_inline_type_id.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: Inline // compile-flags: --crate-type=lib -C panic=abort diff --git a/tests/mir-opt/dont_yeet_assert.rs b/tests/mir-opt/dont_yeet_assert.rs deleted file mode 100644 index 38cc5a293e8..00000000000 --- a/tests/mir-opt/dont_yeet_assert.rs +++ /dev/null @@ -1,11 +0,0 @@ -// compile-flags: --crate-type=lib -// unit-test: InstSimplify - -#![feature(core_intrinsics)] - -// Want to make sure this assertion isn't compiled away in generic code. - -// EMIT_MIR dont_yeet_assert.generic.InstSimplify.diff -pub fn generic<T>() { - core::intrinsics::assert_mem_uninitialized_valid::<&T>(); -} diff --git a/tests/mir-opt/early_otherwise_branch.rs b/tests/mir-opt/early_otherwise_branch.rs index 7be9fbd0326..b48516c5aa1 100644 --- a/tests/mir-opt/early_otherwise_branch.rs +++ b/tests/mir-opt/early_otherwise_branch.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: EarlyOtherwiseBranch // EMIT_MIR early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff fn opt1(x: Option<u32>, y: Option<u32>) -> u32 { diff --git a/tests/mir-opt/early_otherwise_branch_3_element_tuple.rs b/tests/mir-opt/early_otherwise_branch_3_element_tuple.rs index 76055e1330f..2a0fba9bea4 100644 --- a/tests/mir-opt/early_otherwise_branch_3_element_tuple.rs +++ b/tests/mir-opt/early_otherwise_branch_3_element_tuple.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: EarlyOtherwiseBranch // EMIT_MIR early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff diff --git a/tests/mir-opt/early_otherwise_branch_68867.rs b/tests/mir-opt/early_otherwise_branch_68867.rs index a6a56f3a95d..f27527b96ab 100644 --- a/tests/mir-opt/early_otherwise_branch_68867.rs +++ b/tests/mir-opt/early_otherwise_branch_68867.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: EarlyOtherwiseBranch // FIXME: This test was broken by the derefer change. diff --git a/tests/mir-opt/early_otherwise_branch_noopt.rs b/tests/mir-opt/early_otherwise_branch_noopt.rs index ef766bbd4a6..351640c27c5 100644 --- a/tests/mir-opt/early_otherwise_branch_noopt.rs +++ b/tests/mir-opt/early_otherwise_branch_noopt.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: EarlyOtherwiseBranch // must not optimize as it does not follow the pattern of diff --git a/tests/mir-opt/early_otherwise_branch_soundness.rs b/tests/mir-opt/early_otherwise_branch_soundness.rs index cd458923245..02c25a1bd59 100644 --- a/tests/mir-opt/early_otherwise_branch_soundness.rs +++ b/tests/mir-opt/early_otherwise_branch_soundness.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: EarlyOtherwiseBranch // Tests various cases that the `early_otherwise_branch` opt should *not* optimize 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.rs b/tests/mir-opt/enum_opt.rs index 2768d708049..7738c431040 100644 --- a/tests/mir-opt/enum_opt.rs +++ b/tests/mir-opt/enum_opt.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: EnumSizeOpt // EMIT_MIR_FOR_EACH_BIT_WIDTH // compile-flags: -Zunsound-mir-opts 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/equal_true.opt.InstSimplify.diff b/tests/mir-opt/equal_true.opt.InstSimplify.diff deleted file mode 100644 index 88a51000c93..00000000000 --- a/tests/mir-opt/equal_true.opt.InstSimplify.diff +++ /dev/null @@ -1,36 +0,0 @@ -- // MIR for `opt` before InstSimplify -+ // MIR for `opt` after InstSimplify - - fn opt(_1: bool) -> i32 { - debug x => _1; - let mut _0: i32; - let mut _2: bool; - let mut _3: bool; - - bb0: { - StorageLive(_2); - StorageLive(_3); - _3 = _1; -- _2 = Eq(move _3, const true); -+ _2 = move _3; - switchInt(move _2) -> [0: bb2, otherwise: bb1]; - } - - bb1: { - StorageDead(_3); - _0 = const 0_i32; - goto -> bb3; - } - - bb2: { - StorageDead(_3); - _0 = const 1_i32; - goto -> bb3; - } - - bb3: { - StorageDead(_2); - return; - } - } - diff --git a/tests/mir-opt/equal_true.rs b/tests/mir-opt/equal_true.rs deleted file mode 100644 index fbb5d8d37db..00000000000 --- a/tests/mir-opt/equal_true.rs +++ /dev/null @@ -1,11 +0,0 @@ -// unit-test InstSimplify - -// EMIT_MIR equal_true.opt.InstSimplify.diff - -fn opt(x: bool) -> i32 { - if x == true { 0 } else { 1 } -} - -fn main() { - opt(true); -} diff --git a/tests/mir-opt/exponential_or.rs b/tests/mir-opt/exponential_or.rs index 0b8be8385dd..89963b9bdf4 100644 --- a/tests/mir-opt/exponential_or.rs +++ b/tests/mir-opt/exponential_or.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Test that simple or-patterns don't get expanded to exponentially large CFGs // EMIT_MIR exponential_or.match_tuple.SimplifyCfg-initial.after.mir diff --git a/tests/mir-opt/fn_ptr_shim.rs b/tests/mir-opt/fn_ptr_shim.rs index 64fbdc9ded1..c82260baefe 100644 --- a/tests/mir-opt/fn_ptr_shim.rs +++ b/tests/mir-opt/fn_ptr_shim.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -Zmir-opt-level=0 // Tests that the `<fn() as Fn>` shim does not create a `Call` terminator with a `Self` callee 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/funky_arms.rs b/tests/mir-opt/funky_arms.rs index 79fd9457ce1..14aad039946 100644 --- a/tests/mir-opt/funky_arms.rs +++ b/tests/mir-opt/funky_arms.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: --crate-type lib -Cdebug-assertions=no diff --git a/tests/mir-opt/generator_drop_cleanup.rs b/tests/mir-opt/generator_drop_cleanup.rs deleted file mode 100644 index 7e0d7bb59a5..00000000000 --- a/tests/mir-opt/generator_drop_cleanup.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![feature(generators, generator_trait)] - -// EMIT_MIR_FOR_EACH_PANIC_STRATEGY - -// Regression test for #58892, generator drop shims should not have blocks -// spuriously marked as cleanup - -// EMIT_MIR generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir -fn main() { - let gen = || { - let _s = String::new(); - yield; - }; -} diff --git a/tests/mir-opt/graphviz.rs b/tests/mir-opt/graphviz.rs index 6906b86c2a5..61b5a2fb3d8 100644 --- a/tests/mir-opt/graphviz.rs +++ b/tests/mir-opt/graphviz.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Test graphviz output // compile-flags: -Z dump-mir-graphviz diff --git a/tests/mir-opt/gvn.rs b/tests/mir-opt/gvn.rs index a85e2ae368b..fd24edc676c 100644 --- a/tests/mir-opt/gvn.rs +++ b/tests/mir-opt/gvn.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY diff --git a/tests/mir-opt/if_condition_int.rs b/tests/mir-opt/if_condition_int.rs index 398311e6bb8..a3dd74d9a37 100644 --- a/tests/mir-opt/if_condition_int.rs +++ b/tests/mir-opt/if_condition_int.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: SimplifyComparisonIntegral // EMIT_MIR if_condition_int.opt_u32.SimplifyComparisonIntegral.diff // EMIT_MIR if_condition_int.opt_negative.SimplifyComparisonIntegral.diff diff --git a/tests/mir-opt/inline/asm_unwind.rs b/tests/mir-opt/inline/asm_unwind.rs index 573ae1ba68d..0cf21fda72f 100644 --- a/tests/mir-opt/inline/asm_unwind.rs +++ b/tests/mir-opt/inline/asm_unwind.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Tests inlining of `may_unwind` inline assembly. // // EMIT_MIR_FOR_EACH_PANIC_STRATEGY diff --git a/tests/mir-opt/inline/caller_with_trivial_bound.rs b/tests/mir-opt/inline/caller_with_trivial_bound.rs index a8f101d488c..3829cbdd302 100644 --- a/tests/mir-opt/inline/caller_with_trivial_bound.rs +++ b/tests/mir-opt/inline/caller_with_trivial_bound.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // needs-unwind diff --git a/tests/mir-opt/inline/cycle.rs b/tests/mir-opt/inline/cycle.rs index 1b74d818451..3e4f0683435 100644 --- a/tests/mir-opt/inline/cycle.rs +++ b/tests/mir-opt/inline/cycle.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -Zinline-mir-hint-threshold=1000 diff --git a/tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs index 971223c72ca..4147325ec44 100644 --- a/tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs +++ b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -Zmir-enable-passes=+Inline --crate-type=lib diff --git a/tests/mir-opt/inline/dyn_trait.rs b/tests/mir-opt/inline/dyn_trait.rs index 0faeec0bbab..7b41b1e1171 100644 --- a/tests/mir-opt/inline/dyn_trait.rs +++ b/tests/mir-opt/inline/dyn_trait.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![crate_type = "lib"] diff --git a/tests/mir-opt/inline/exponential_runtime.rs b/tests/mir-opt/inline/exponential_runtime.rs index cfa9ff210f8..6d3af8b9c57 100644 --- a/tests/mir-opt/inline/exponential_runtime.rs +++ b/tests/mir-opt/inline/exponential_runtime.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Checks that code with exponential runtime does not have exponential behavior in inlining. diff --git a/tests/mir-opt/inline/inline_any_operand.rs b/tests/mir-opt/inline/inline_any_operand.rs index fb0de020f73..e131cd6ef7e 100644 --- a/tests/mir-opt/inline/inline_any_operand.rs +++ b/tests/mir-opt/inline/inline_any_operand.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -Z span_free_formats // Tests that MIR inliner works for any operand diff --git a/tests/mir-opt/inline/inline_async.rs b/tests/mir-opt/inline/inline_async.rs index 5c838159b98..1de87e1e43c 100644 --- a/tests/mir-opt/inline/inline_async.rs +++ b/tests/mir-opt/inline/inline_async.rs @@ -1,4 +1,5 @@ -// Checks that inliner doesn't introduce cycles when optimizing generators. +// skip-filecheck +// Checks that inliner doesn't introduce cycles when optimizing coroutines. // The outcome of optimization is not verfied, just the absence of the cycle. // Regression test for #76181. // diff --git a/tests/mir-opt/inline/inline_box_fn.rs b/tests/mir-opt/inline/inline_box_fn.rs index 348f0e77f92..f6a90b92c91 100644 --- a/tests/mir-opt/inline/inline_box_fn.rs +++ b/tests/mir-opt/inline/inline_box_fn.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: Inline // compile-flags: --crate-type=lib diff --git a/tests/mir-opt/inline/inline_closure.rs b/tests/mir-opt/inline/inline_closure.rs index 715fd0138a7..bd4c84ff0ca 100644 --- a/tests/mir-opt/inline/inline_closure.rs +++ b/tests/mir-opt/inline/inline_closure.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -Z span_free_formats // Tests that MIR inliner can handle closure arguments. (#45894) diff --git a/tests/mir-opt/inline/inline_closure_borrows_arg.rs b/tests/mir-opt/inline/inline_closure_borrows_arg.rs index d76bc33f52e..a5cc7d10365 100644 --- a/tests/mir-opt/inline/inline_closure_borrows_arg.rs +++ b/tests/mir-opt/inline/inline_closure_borrows_arg.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -Z span_free_formats -Zunsound-mir-opts // Tests that MIR inliner can handle closure arguments, diff --git a/tests/mir-opt/inline/inline_closure_captures.rs b/tests/mir-opt/inline/inline_closure_captures.rs index 52b6817e401..0d95564e5dd 100644 --- a/tests/mir-opt/inline/inline_closure_captures.rs +++ b/tests/mir-opt/inline/inline_closure_captures.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -Z span_free_formats // Tests that MIR inliner can handle closure captures. diff --git a/tests/mir-opt/inline/inline_compatibility.rs b/tests/mir-opt/inline/inline_compatibility.rs index 1527fea1c93..52f4debf5db 100644 --- a/tests/mir-opt/inline/inline_compatibility.rs +++ b/tests/mir-opt/inline/inline_compatibility.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Checks that only functions with compatible attributes are inlined. // // only-x86_64 diff --git a/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff index 06ee8c464d5..357d95f7c22 100644 --- a/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff @@ -3,27 +3,27 @@ fn main() -> () { let mut _0: (); - let _1: std::ops::GeneratorState<i32, bool>; - let mut _2: std::pin::Pin<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>; - let mut _3: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}; - let mut _4: {generator@$DIR/inline_generator.rs:16:5: 16:8}; + let _1: std::ops::CoroutineState<i32, bool>; + let mut _2: std::pin::Pin<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>; + let mut _3: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}; + let mut _4: {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}; + let mut _5: bool; scope 1 { debug _r => _1; } + scope 2 (inlined g) { + } -+ scope 3 (inlined Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new) { ++ scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new) { + debug pointer => _3; + scope 4 { -+ scope 5 (inlined Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new_unchecked) { ++ scope 5 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new_unchecked) { + debug pointer => _3; + } + } + } + scope 6 (inlined g::{closure#0}) { + debug a => _5; -+ let mut _6: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}; ++ let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}; + let mut _7: u32; + let mut _8: i32; + } @@ -34,22 +34,22 @@ StorageLive(_3); StorageLive(_4); - _4 = g() -> [return: bb1, unwind unreachable]; -+ _4 = {generator@$DIR/inline_generator.rs:16:5: 16:8 (#0)}; ++ _4 = {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8 (#0)}; + _3 = &mut _4; -+ _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}> { pointer: move _3 }; ++ _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}> { pointer: move _3 }; + StorageDead(_3); + StorageLive(_5); + _5 = const false; + StorageLive(_6); + StorageLive(_7); -+ _6 = (_2.0: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}); ++ _6 = (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}); + _7 = discriminant((*_6)); + switchInt(move _7) -> [0: bb3, 1: bb7, 3: bb8, otherwise: bb9]; } bb1: { - _3 = &mut _4; -- _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new(move _3) -> [return: bb2, unwind unreachable]; +- _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new(move _3) -> [return: bb2, unwind unreachable]; + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); @@ -59,7 +59,7 @@ bb2: { - StorageDead(_3); -- _1 = <{generator@$DIR/inline_generator.rs:16:5: 16:8} as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind unreachable]; +- _1 = <{coroutine@$DIR/inline_coroutine.rs:17:5: 17:8} as Coroutine<bool>>::resume(move _2, const false) -> [return: bb3, unwind unreachable]; + StorageDead(_4); + _0 = const (); + StorageDead(_1); @@ -88,19 +88,19 @@ + } + + bb6: { -+ _1 = GeneratorState::<i32, bool>::Yielded(move _8); ++ _1 = CoroutineState::<i32, bool>::Yielded(move _8); + discriminant((*_6)) = 3; + goto -> bb1; + } + + bb7: { -+ assert(const false, "generator resumed after completion") -> [success: bb7, unwind unreachable]; ++ assert(const false, "coroutine resumed after completion") -> [success: bb7, unwind unreachable]; + } + + bb8: { + StorageLive(_8); + StorageDead(_8); -+ _1 = GeneratorState::<i32, bool>::Complete(_5); ++ _1 = CoroutineState::<i32, bool>::Complete(_5); + discriminant((*_6)) = 1; + goto -> bb1; + } diff --git a/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff index da29ba5f50d..e7d02096838 100644 --- a/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff @@ -3,27 +3,27 @@ fn main() -> () { let mut _0: (); - let _1: std::ops::GeneratorState<i32, bool>; - let mut _2: std::pin::Pin<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>; - let mut _3: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}; - let mut _4: {generator@$DIR/inline_generator.rs:16:5: 16:8}; + let _1: std::ops::CoroutineState<i32, bool>; + let mut _2: std::pin::Pin<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>; + let mut _3: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}; + let mut _4: {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}; + let mut _5: bool; scope 1 { debug _r => _1; } + scope 2 (inlined g) { + } -+ scope 3 (inlined Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new) { ++ scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new) { + debug pointer => _3; + scope 4 { -+ scope 5 (inlined Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new_unchecked) { ++ scope 5 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new_unchecked) { + debug pointer => _3; + } + } + } + scope 6 (inlined g::{closure#0}) { + debug a => _5; -+ let mut _6: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}; ++ let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}; + let mut _7: u32; + let mut _8: i32; + } @@ -37,20 +37,20 @@ - } - - bb1: { -+ _4 = {generator@$DIR/inline_generator.rs:16:5: 16:8 (#0)}; ++ _4 = {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8 (#0)}; _3 = &mut _4; -- _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new(move _3) -> [return: bb2, unwind: bb5]; +- _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new(move _3) -> [return: bb2, unwind: bb5]; - } - - bb2: { -+ _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}> { pointer: move _3 }; ++ _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}> { pointer: move _3 }; StorageDead(_3); -- _1 = <{generator@$DIR/inline_generator.rs:16:5: 16:8} as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind: bb5]; +- _1 = <{coroutine@$DIR/inline_coroutine.rs:17:5: 17:8} as Coroutine<bool>>::resume(move _2, const false) -> [return: bb3, unwind: bb5]; + StorageLive(_5); + _5 = const false; + StorageLive(_6); + StorageLive(_7); -+ _6 = (_2.0: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}); ++ _6 = (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}); + _7 = discriminant((*_6)); + switchInt(move _7) -> [0: bb5, 1: bb9, 3: bb10, otherwise: bb11]; } @@ -100,19 +100,19 @@ + } + + bb8: { -+ _1 = GeneratorState::<i32, bool>::Yielded(move _8); ++ _1 = CoroutineState::<i32, bool>::Yielded(move _8); + discriminant((*_6)) = 3; + goto -> bb1; + } + + bb9: { -+ assert(const false, "generator resumed after completion") -> [success: bb9, unwind: bb3]; ++ assert(const false, "coroutine resumed after completion") -> [success: bb9, unwind: bb3]; + } + + bb10: { + StorageLive(_8); + StorageDead(_8); -+ _1 = GeneratorState::<i32, bool>::Complete(_5); ++ _1 = CoroutineState::<i32, bool>::Complete(_5); + discriminant((*_6)) = 1; + goto -> bb1; + } diff --git a/tests/mir-opt/inline/inline_generator.rs b/tests/mir-opt/inline/inline_coroutine.rs index 2d71458c174..d021cdac28e 100644 --- a/tests/mir-opt/inline/inline_generator.rs +++ b/tests/mir-opt/inline/inline_coroutine.rs @@ -1,17 +1,18 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -Zinline-mir-hint-threshold=1000 -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; -// EMIT_MIR inline_generator.main.Inline.diff +// EMIT_MIR inline_coroutine.main.Inline.diff fn main() { let _r = Pin::new(&mut g()).resume(false); } #[inline] -pub fn g() -> impl Generator<bool> { +pub fn g() -> impl Coroutine<bool> { #[inline] |a| { yield if a { 7 } else { 13 } } } diff --git a/tests/mir-opt/inline/inline_cycle.rs b/tests/mir-opt/inline/inline_cycle.rs index 42a6914c965..e3dd082556b 100644 --- a/tests/mir-opt/inline/inline_cycle.rs +++ b/tests/mir-opt/inline/inline_cycle.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Check that inliner handles various forms of recursion and doesn't fall into // an infinite inlining cycle. The particular outcome of inlining is not diff --git a/tests/mir-opt/inline/inline_cycle_generic.rs b/tests/mir-opt/inline/inline_cycle_generic.rs index ef261b04c80..667bf7f9254 100644 --- a/tests/mir-opt/inline/inline_cycle_generic.rs +++ b/tests/mir-opt/inline/inline_cycle_generic.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Check that inliner handles various forms of recursion and doesn't fall into // an infinite inlining cycle. The particular outcome of inlining is not diff --git a/tests/mir-opt/inline/inline_diverging.rs b/tests/mir-opt/inline/inline_diverging.rs index e01c4c1dd02..9e50b1ead2b 100644 --- a/tests/mir-opt/inline/inline_diverging.rs +++ b/tests/mir-opt/inline/inline_diverging.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Tests inlining of diverging calls. // // EMIT_MIR_FOR_EACH_PANIC_STRATEGY diff --git a/tests/mir-opt/inline/inline_instruction_set.rs b/tests/mir-opt/inline/inline_instruction_set.rs index 5dfb04943e3..4ac4d462f82 100644 --- a/tests/mir-opt/inline/inline_instruction_set.rs +++ b/tests/mir-opt/inline/inline_instruction_set.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Checks that only functions with the compatible instruction_set attributes are inlined. // // A function is "compatible" when the *callee* has the same attribute or no attribute. diff --git a/tests/mir-opt/inline/inline_into_box_place.rs b/tests/mir-opt/inline/inline_into_box_place.rs index 56f174e515b..b755692afc2 100644 --- a/tests/mir-opt/inline/inline_into_box_place.rs +++ b/tests/mir-opt/inline/inline_into_box_place.rs @@ -1,3 +1,4 @@ +// skip-filecheck // ignore-endian-big // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // ignore-debug MIR alignment checks in std alter the diff, breaking the test diff --git a/tests/mir-opt/inline/inline_options.rs b/tests/mir-opt/inline/inline_options.rs index b247ecd0bc0..394a8c4945c 100644 --- a/tests/mir-opt/inline/inline_options.rs +++ b/tests/mir-opt/inline/inline_options.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Checks that inlining threshold can be controlled with // inline-mir-threshold and inline-hint-threshold options. diff --git a/tests/mir-opt/inline/inline_retag.rs b/tests/mir-opt/inline/inline_retag.rs index c6950f26925..f695b9f22e6 100644 --- a/tests/mir-opt/inline/inline_retag.rs +++ b/tests/mir-opt/inline/inline_retag.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -Z span_free_formats -Z mir-emit-retag // Tests that MIR inliner fixes up `Retag`'s `fn_entry` flag diff --git a/tests/mir-opt/inline/inline_shims.rs b/tests/mir-opt/inline/inline_shims.rs index eafbb962efb..a223c2d2614 100644 --- a/tests/mir-opt/inline/inline_shims.rs +++ b/tests/mir-opt/inline/inline_shims.rs @@ -3,11 +3,15 @@ // EMIT_MIR inline_shims.clone.Inline.diff pub fn clone<A, B>(f: fn(A, B)) -> fn(A, B) { + // CHECK-LABEL: fn clone( + // CHECK: (inlined <fn(A, B) as Clone>::clone - shim(fn(A, B))) f.clone() } // EMIT_MIR inline_shims.drop.Inline.diff pub fn drop<A, B>(a: *mut Vec<A>, b: *mut Option<B>) { + // CHECK-LABEL: fn drop( + // CHECK: (inlined std::ptr::drop_in_place::<Option<B>> - shim(Some(Option<B>))) unsafe { std::ptr::drop_in_place(a) } unsafe { std::ptr::drop_in_place(b) } } diff --git a/tests/mir-opt/inline/inline_specialization.rs b/tests/mir-opt/inline/inline_specialization.rs index 0311531dc3f..eb0cf891dad 100644 --- a/tests/mir-opt/inline/inline_specialization.rs +++ b/tests/mir-opt/inline/inline_specialization.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![feature(specialization)] diff --git a/tests/mir-opt/inline/inline_trait_method.rs b/tests/mir-opt/inline/inline_trait_method.rs index a9d2168c2ec..8a95adf3713 100644 --- a/tests/mir-opt/inline/inline_trait_method.rs +++ b/tests/mir-opt/inline/inline_trait_method.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -Z span_free_formats diff --git a/tests/mir-opt/inline/inline_trait_method_2.rs b/tests/mir-opt/inline/inline_trait_method_2.rs index 62ec7ebde6a..e87609a8c7e 100644 --- a/tests/mir-opt/inline/inline_trait_method_2.rs +++ b/tests/mir-opt/inline/inline_trait_method_2.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -Z span_free_formats -Z mir-opt-level=4 diff --git a/tests/mir-opt/inline/issue_106141.rs b/tests/mir-opt/inline/issue_106141.rs index eed1d89172c..592b4d9b723 100644 --- a/tests/mir-opt/inline/issue_106141.rs +++ b/tests/mir-opt/inline/issue_106141.rs @@ -1,14 +1,21 @@ +// Verify that we do not ICE inlining a function which uses _0 as an index. // EMIT_MIR_FOR_EACH_PANIC_STRATEGY + pub fn outer() -> usize { + // CHECK-LABEL: fn outer( + // CHECK: = {{.*}}[_0]; inner() } +#[inline(never)] fn index() -> usize { loop {} } #[inline] fn inner() -> usize { + // CHECK-LABEL: fn inner( + // CHECK: = {{.*}}[_0]; let buffer = &[true]; let index = index(); if buffer[index] { diff --git a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs index 94f926d3964..da779fed76f 100644 --- a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs +++ b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR issue_58867_inline_as_ref_as_mut.a.Inline.after.mir pub fn a<T>(x: &mut [T]) -> &mut [T] { x.as_mut() diff --git a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir index 4d170c41f97..d28c0441f63 100644 --- a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir +++ b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir @@ -2,8 +2,8 @@ fn main() -> () { let mut _0: (); - let _1: {closure@$DIR/issue_76997_inline_scopes_parenting.rs:5:13: 5:16}; - let mut _2: &{closure@$DIR/issue_76997_inline_scopes_parenting.rs:5:13: 5:16}; + let _1: {closure@$DIR/issue_76997_inline_scopes_parenting.rs:6:13: 6:16}; + let mut _2: &{closure@$DIR/issue_76997_inline_scopes_parenting.rs:6:13: 6:16}; let mut _3: ((),); let mut _4: (); let mut _5: (); @@ -19,7 +19,7 @@ fn main() -> () { bb0: { StorageLive(_1); - _1 = {closure@$DIR/issue_76997_inline_scopes_parenting.rs:5:13: 5:16}; + _1 = {closure@$DIR/issue_76997_inline_scopes_parenting.rs:6:13: 6:16}; StorageLive(_2); _2 = &_1; StorageLive(_3); diff --git a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs index 76d806acc63..c7147d42df9 100644 --- a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs +++ b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Tests that MIR inliner can handle `SourceScopeData` parenting correctly. (#76997) // EMIT_MIR issue_76997_inline_scopes_parenting.main.Inline.after.mir 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/inline/issue_78442.rs b/tests/mir-opt/inline/issue_78442.rs index d956e62414c..f83ed70d0db 100644 --- a/tests/mir-opt/inline/issue_78442.rs +++ b/tests/mir-opt/inline/issue_78442.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -Z mir-opt-level=3 -Z inline-mir // EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![crate_type = "lib"] diff --git a/tests/mir-opt/inline/polymorphic_recursion.rs b/tests/mir-opt/inline/polymorphic_recursion.rs index 7388722b776..f71e382e867 100644 --- a/tests/mir-opt/inline/polymorphic_recursion.rs +++ b/tests/mir-opt/inline/polymorphic_recursion.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Make sure that the MIR inliner does not loop indefinitely on polymorphic recursion. // compile-flags: --crate-type lib diff --git a/tests/mir-opt/inline/unchecked_shifts.rs b/tests/mir-opt/inline/unchecked_shifts.rs index 22f84e44a64..67666f2f713 100644 --- a/tests/mir-opt/inline/unchecked_shifts.rs +++ b/tests/mir-opt/inline/unchecked_shifts.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![crate_type = "lib"] #![feature(unchecked_math)] diff --git a/tests/mir-opt/inline/unit_test.rs b/tests/mir-opt/inline/unit_test.rs new file mode 100644 index 00000000000..0d877bb10b4 --- /dev/null +++ b/tests/mir-opt/inline/unit_test.rs @@ -0,0 +1,19 @@ +// Check that `-Zmir-enable-passes=+Inline` does not ICE because of stolen MIR. +// unit-test: Inline +// skip-filecheck +#![crate_type = "lib"] + +// Randomize `def_path_hash` by defining them under a module with different names +macro_rules! emit { + ($($m:ident)*) => {$( + pub mod $m { + pub fn main() { + let func = || 123u8; + func(); + } + } + )*}; +} + +// Increase the chance of triggering the bug +emit!(m00 m01 m02 m03 m04 m05 m06 m07 m08 m09 m10 m11 m12 m13 m14 m15 m16 m17 m18 m19); diff --git a/tests/mir-opt/inline/unsized_argument.rs b/tests/mir-opt/inline/unsized_argument.rs index b2c51407fd5..22c88b83f9b 100644 --- a/tests/mir-opt/inline/unsized_argument.rs +++ b/tests/mir-opt/inline/unsized_argument.rs @@ -1,3 +1,4 @@ +// skip-filecheck // needs-unwind #![feature(unsized_fn_params)] diff --git a/tests/mir-opt/inline/unwrap_unchecked.rs b/tests/mir-opt/inline/unwrap_unchecked.rs index f28aef7a808..f8964eba227 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.rs +++ b/tests/mir-opt/inline/unwrap_unchecked.rs @@ -1,3 +1,4 @@ +// skip-filecheck #![crate_type = "lib"] // EMIT_MIR_FOR_EACH_PANIC_STRATEGY diff --git a/tests/mir-opt/inline_generically_if_sized.rs b/tests/mir-opt/inline_generically_if_sized.rs index 1acfff7a56b..1a7512a4b8d 100644 --- a/tests/mir-opt/inline_generically_if_sized.rs +++ b/tests/mir-opt/inline_generically_if_sized.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: Inline // compile-flags: --crate-type=lib -C panic=abort diff --git a/tests/mir-opt/instrument_coverage.bar.InstrumentCoverage.diff b/tests/mir-opt/instrument_coverage.bar.InstrumentCoverage.diff index 28a7ffda371..1ef6b69ef5b 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:21:1 - 23: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..14b4833a515 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:12:1 - 12:11; ++ coverage Expression(0) => /the/src/instrument_coverage.rs:13:5 - 14:17; ++ coverage Expression(1) => /the/src/instrument_coverage.rs:15:13 - 15:18; ++ coverage Expression(1) => /the/src/instrument_coverage.rs:18:1 - 18:2; ++ coverage Counter(1) => /the/src/instrument_coverage.rs:16:10 - 16: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/instrument_coverage.rs b/tests/mir-opt/instrument_coverage.rs index 7f6a0a0eb09..f131fc0a324 100644 --- a/tests/mir-opt/instrument_coverage.rs +++ b/tests/mir-opt/instrument_coverage.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Test that `-C instrument-coverage` injects Coverage statements. The Coverage Counter statements // are later converted into LLVM instrprof.increment intrinsics, during codegen. diff --git a/tests/mir-opt/bool_compare.opt3.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.eq_false.InstSimplify.diff index 034d5e44013..5c09963d433 100644 --- a/tests/mir-opt/bool_compare.opt3.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/bool_compare.eq_false.InstSimplify.diff @@ -1,7 +1,7 @@ -- // MIR for `opt3` before InstSimplify -+ // MIR for `opt3` after InstSimplify +- // MIR for `eq_false` before InstSimplify ++ // MIR for `eq_false` after InstSimplify - fn opt3(_1: bool) -> u32 { + fn eq_false(_1: bool) -> u32 { debug x => _1; let mut _0: u32; let mut _2: bool; diff --git a/tests/mir-opt/instsimplify/bool_compare.eq_true.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.eq_true.InstSimplify.diff new file mode 100644 index 00000000000..a80133b0eb0 --- /dev/null +++ b/tests/mir-opt/instsimplify/bool_compare.eq_true.InstSimplify.diff @@ -0,0 +1,36 @@ +- // MIR for `eq_true` before InstSimplify ++ // MIR for `eq_true` after InstSimplify + + fn eq_true(_1: bool) -> u32 { + debug x => _1; + let mut _0: u32; + let mut _2: bool; + let mut _3: bool; + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = _1; +- _2 = Eq(move _3, const true); ++ _2 = move _3; + switchInt(move _2) -> [0: bb2, otherwise: bb1]; + } + + bb1: { + StorageDead(_3); + _0 = const 0_u32; + goto -> bb3; + } + + bb2: { + StorageDead(_3); + _0 = const 1_u32; + goto -> bb3; + } + + bb3: { + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/bool_compare.opt4.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.false_eq.InstSimplify.diff index d3096da6c5a..8235d5263bb 100644 --- a/tests/mir-opt/bool_compare.opt4.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/bool_compare.false_eq.InstSimplify.diff @@ -1,7 +1,7 @@ -- // MIR for `opt4` before InstSimplify -+ // MIR for `opt4` after InstSimplify +- // MIR for `false_eq` before InstSimplify ++ // MIR for `false_eq` after InstSimplify - fn opt4(_1: bool) -> u32 { + fn false_eq(_1: bool) -> u32 { debug x => _1; let mut _0: u32; let mut _2: bool; diff --git a/tests/mir-opt/instsimplify/bool_compare.false_ne.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.false_ne.InstSimplify.diff new file mode 100644 index 00000000000..77d076c6c14 --- /dev/null +++ b/tests/mir-opt/instsimplify/bool_compare.false_ne.InstSimplify.diff @@ -0,0 +1,36 @@ +- // MIR for `false_ne` before InstSimplify ++ // MIR for `false_ne` after InstSimplify + + fn false_ne(_1: bool) -> u32 { + debug x => _1; + let mut _0: u32; + let mut _2: bool; + let mut _3: bool; + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = _1; +- _2 = Ne(const false, move _3); ++ _2 = move _3; + switchInt(move _2) -> [0: bb2, otherwise: bb1]; + } + + bb1: { + StorageDead(_3); + _0 = const 0_u32; + goto -> bb3; + } + + bb2: { + StorageDead(_3); + _0 = const 1_u32; + goto -> bb3; + } + + bb3: { + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/not_equal_false.opt.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.ne_false.InstSimplify.diff index 1342966aa15..2362b11297e 100644 --- a/tests/mir-opt/not_equal_false.opt.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/bool_compare.ne_false.InstSimplify.diff @@ -1,7 +1,7 @@ -- // MIR for `opt` before InstSimplify -+ // MIR for `opt` after InstSimplify +- // MIR for `ne_false` before InstSimplify ++ // MIR for `ne_false` after InstSimplify - fn opt(_1: bool) -> u32 { + fn ne_false(_1: bool) -> u32 { debug x => _1; let mut _0: u32; let mut _2: bool; diff --git a/tests/mir-opt/bool_compare.opt1.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.ne_true.InstSimplify.diff index 657c11516a1..6ccbd2fb7a1 100644 --- a/tests/mir-opt/bool_compare.opt1.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/bool_compare.ne_true.InstSimplify.diff @@ -1,7 +1,7 @@ -- // MIR for `opt1` before InstSimplify -+ // MIR for `opt1` after InstSimplify +- // MIR for `ne_true` before InstSimplify ++ // MIR for `ne_true` after InstSimplify - fn opt1(_1: bool) -> u32 { + fn ne_true(_1: bool) -> u32 { debug x => _1; let mut _0: u32; let mut _2: bool; diff --git a/tests/mir-opt/instsimplify/bool_compare.rs b/tests/mir-opt/instsimplify/bool_compare.rs new file mode 100644 index 00000000000..77f427b0d7c --- /dev/null +++ b/tests/mir-opt/instsimplify/bool_compare.rs @@ -0,0 +1,68 @@ +// unit-test: InstSimplify + +// EMIT_MIR bool_compare.eq_true.InstSimplify.diff +fn eq_true(x: bool) -> u32 { + // CHECK-LABEL: fn eq_true( + // CHECK-NOT: Eq( + if x == true { 0 } else { 1 } +} + +// EMIT_MIR bool_compare.true_eq.InstSimplify.diff +fn true_eq(x: bool) -> u32 { + // CHECK-LABEL: fn true_eq( + // CHECK-NOT: Eq( + if true == x { 0 } else { 1 } +} + +// EMIT_MIR bool_compare.ne_true.InstSimplify.diff +fn ne_true(x: bool) -> u32 { + // CHECK-LABEL: fn ne_true( + // CHECK: Not( + if x != true { 0 } else { 1 } +} + +// EMIT_MIR bool_compare.true_ne.InstSimplify.diff +fn true_ne(x: bool) -> u32 { + // CHECK-LABEL: fn true_ne( + // CHECK: Not( + if true != x { 0 } else { 1 } +} + +// EMIT_MIR bool_compare.eq_false.InstSimplify.diff +fn eq_false(x: bool) -> u32 { + // CHECK-LABEL: fn eq_false( + // CHECK: Not( + if x == false { 0 } else { 1 } +} + +// EMIT_MIR bool_compare.false_eq.InstSimplify.diff +fn false_eq(x: bool) -> u32 { + // CHECK-LABEL: fn false_eq( + // CHECK: Not( + if false == x { 0 } else { 1 } +} + +// EMIT_MIR bool_compare.ne_false.InstSimplify.diff +fn ne_false(x: bool) -> u32 { + // CHECK-LABEL: fn ne_false( + // CHECK-NOT: Ne( + if x != false { 0 } else { 1 } +} + +// EMIT_MIR bool_compare.false_ne.InstSimplify.diff +fn false_ne(x: bool) -> u32 { + // CHECK-LABEL: fn false_ne( + // CHECK-NOT: Ne( + if false != x { 0 } else { 1 } +} + +fn main() { + eq_true(false); + true_eq(false); + ne_true(false); + true_ne(false); + eq_false(false); + false_eq(false); + ne_false(false); + false_ne(false); +} diff --git a/tests/mir-opt/instsimplify/bool_compare.true_eq.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.true_eq.InstSimplify.diff new file mode 100644 index 00000000000..18675329a2e --- /dev/null +++ b/tests/mir-opt/instsimplify/bool_compare.true_eq.InstSimplify.diff @@ -0,0 +1,36 @@ +- // MIR for `true_eq` before InstSimplify ++ // MIR for `true_eq` after InstSimplify + + fn true_eq(_1: bool) -> u32 { + debug x => _1; + let mut _0: u32; + let mut _2: bool; + let mut _3: bool; + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = _1; +- _2 = Eq(const true, move _3); ++ _2 = move _3; + switchInt(move _2) -> [0: bb2, otherwise: bb1]; + } + + bb1: { + StorageDead(_3); + _0 = const 0_u32; + goto -> bb3; + } + + bb2: { + StorageDead(_3); + _0 = const 1_u32; + goto -> bb3; + } + + bb3: { + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/bool_compare.opt2.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.true_ne.InstSimplify.diff index bc8be62bd49..dc91cf8a5c4 100644 --- a/tests/mir-opt/bool_compare.opt2.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/bool_compare.true_ne.InstSimplify.diff @@ -1,7 +1,7 @@ -- // MIR for `opt2` before InstSimplify -+ // MIR for `opt2` after InstSimplify +- // MIR for `true_ne` before InstSimplify ++ // MIR for `true_ne` after InstSimplify - fn opt2(_1: bool) -> u32 { + fn true_ne(_1: bool) -> u32 { debug x => _1; let mut _0: u32; let mut _2: bool; diff --git a/tests/mir-opt/casts.redundant.InstSimplify.diff b/tests/mir-opt/instsimplify/casts.redundant.InstSimplify.diff index f5ea78aecbe..1c417d4346d 100644 --- a/tests/mir-opt/casts.redundant.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/casts.redundant.InstSimplify.diff @@ -7,15 +7,19 @@ let mut _2: *const &u8; let mut _3: *const &u8; scope 1 (inlined generic_cast::<&u8, &u8>) { - debug x => _1; + debug x => _3; + let mut _4: *const &u8; } bb0: { StorageLive(_2); StorageLive(_3); _3 = _1; -- _2 = _3 as *const &u8 (PtrToPtr); -+ _2 = _3; + StorageLive(_4); + _4 = _3; +- _2 = move _4 as *const &u8 (PtrToPtr); ++ _2 = move _4; + StorageDead(_4); StorageDead(_3); _0 = _2; StorageDead(_2); diff --git a/tests/mir-opt/instsimplify/casts.roundtrip.InstSimplify.diff b/tests/mir-opt/instsimplify/casts.roundtrip.InstSimplify.diff new file mode 100644 index 00000000000..1ae9d45e66c --- /dev/null +++ b/tests/mir-opt/instsimplify/casts.roundtrip.InstSimplify.diff @@ -0,0 +1,21 @@ +- // MIR for `roundtrip` before InstSimplify ++ // MIR for `roundtrip` after InstSimplify + + fn roundtrip(_1: *const u8) -> *const u8 { + debug x => _1; + let mut _0: *const u8; + let mut _2: *mut u8; + let mut _3: *const u8; + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = _1; + _2 = move _3 as *mut u8 (PtrToPtr); + _0 = move _2 as *const u8 (PointerCoercion(MutToConstPointer)); + StorageDead(_3); + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/instsimplify/casts.rs b/tests/mir-opt/instsimplify/casts.rs new file mode 100644 index 00000000000..18bab524c64 --- /dev/null +++ b/tests/mir-opt/instsimplify/casts.rs @@ -0,0 +1,25 @@ +// unit-test: InstSimplify +// compile-flags: -Zinline-mir +#![crate_type = "lib"] + +#[inline(always)] +fn generic_cast<T, U>(x: *const T) -> *const U { + x as *const U +} + +// EMIT_MIR casts.redundant.InstSimplify.diff +pub fn redundant<'a, 'b: 'a>(x: *const &'a u8) -> *const &'a u8 { + // CHECK-LABEL: fn redundant( + // CHECK: inlined generic_cast + // CHECK-NOT: as + generic_cast::<&'a u8, &'b u8>(x) as *const &'a u8 +} + +// EMIT_MIR casts.roundtrip.InstSimplify.diff +pub fn roundtrip(x: *const u8) -> *const u8 { + // CHECK-LABEL: fn roundtrip( + // CHECK: _3 = _1; + // CHECK: _2 = move _3 as *mut u8 (PtrToPtr); + // CHECK: _0 = move _2 as *const u8 (PointerCoercion(MutToConstPointer)); + x as *mut u8 as *const u8 +} diff --git a/tests/mir-opt/combine_array_len.norm2.InstSimplify.panic-abort.diff b/tests/mir-opt/instsimplify/combine_array_len.norm2.InstSimplify.panic-abort.diff index 3e7d0ce51e2..3e7d0ce51e2 100644 --- a/tests/mir-opt/combine_array_len.norm2.InstSimplify.panic-abort.diff +++ b/tests/mir-opt/instsimplify/combine_array_len.norm2.InstSimplify.panic-abort.diff diff --git a/tests/mir-opt/combine_array_len.norm2.InstSimplify.panic-unwind.diff b/tests/mir-opt/instsimplify/combine_array_len.norm2.InstSimplify.panic-unwind.diff index 4833c1089e3..4833c1089e3 100644 --- a/tests/mir-opt/combine_array_len.norm2.InstSimplify.panic-unwind.diff +++ b/tests/mir-opt/instsimplify/combine_array_len.norm2.InstSimplify.panic-unwind.diff diff --git a/tests/mir-opt/combine_array_len.rs b/tests/mir-opt/instsimplify/combine_array_len.rs index e971ab4781e..3b6795bc943 100644 --- a/tests/mir-opt/combine_array_len.rs +++ b/tests/mir-opt/instsimplify/combine_array_len.rs @@ -1,8 +1,10 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: InstSimplify -// EMIT_MIR combine_array_len.norm2.InstSimplify.diff +// EMIT_MIR combine_array_len.norm2.InstSimplify.diff fn norm2(x: [f32; 2]) -> f32 { + // CHECK-LABEL: fn norm2( + // CHECK-NOT: Len( let a = x[0]; let b = x[1]; a*a + b*b diff --git a/tests/mir-opt/combine_clone_of_primitives.rs b/tests/mir-opt/instsimplify/combine_clone_of_primitives.rs index c19f9ee105f..2adbe778d23 100644 --- a/tests/mir-opt/combine_clone_of_primitives.rs +++ b/tests/mir-opt/instsimplify/combine_clone_of_primitives.rs @@ -2,7 +2,6 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR combine_clone_of_primitives.{impl#0}-clone.InstSimplify.diff - #[derive(Clone)] struct MyThing<T> { v: T, @@ -10,6 +9,11 @@ struct MyThing<T> { a: [f32; 3], } +// CHECK-LABEL: ::clone( +// CHECK: <T as Clone>::clone( +// CHECK-NOT: <u64 as Clone>::clone( +// CHECK-NOT: <[f32; 3] as Clone>::clone( + fn main() { let x = MyThing::<i16> { v: 2, i: 3, a: [0.0; 3] }; let y = x.clone(); diff --git a/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-abort.diff b/tests/mir-opt/instsimplify/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-abort.diff index 124c2dc7e4b..48586f8b334 100644 --- a/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-abort.diff +++ b/tests/mir-opt/instsimplify/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-abort.diff @@ -1,7 +1,7 @@ -- // MIR for `<impl at $DIR/combine_clone_of_primitives.rs:6:10: 6:15>::clone` before InstSimplify -+ // MIR for `<impl at $DIR/combine_clone_of_primitives.rs:6:10: 6:15>::clone` after InstSimplify +- // MIR for `<impl at $DIR/combine_clone_of_primitives.rs:5:10: 5:15>::clone` before InstSimplify ++ // MIR for `<impl at $DIR/combine_clone_of_primitives.rs:5:10: 5:15>::clone` after InstSimplify - fn <impl at $DIR/combine_clone_of_primitives.rs:6:10: 6:15>::clone(_1: &MyThing<T>) -> MyThing<T> { + fn <impl at $DIR/combine_clone_of_primitives.rs:5:10: 5:15>::clone(_1: &MyThing<T>) -> MyThing<T> { debug self => _1; let mut _0: MyThing<T>; let mut _2: T; diff --git a/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-unwind.diff b/tests/mir-opt/instsimplify/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-unwind.diff index f2b87221f2b..a57266e9c12 100644 --- a/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-unwind.diff +++ b/tests/mir-opt/instsimplify/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-unwind.diff @@ -1,7 +1,7 @@ -- // MIR for `<impl at $DIR/combine_clone_of_primitives.rs:6:10: 6:15>::clone` before InstSimplify -+ // MIR for `<impl at $DIR/combine_clone_of_primitives.rs:6:10: 6:15>::clone` after InstSimplify +- // MIR for `<impl at $DIR/combine_clone_of_primitives.rs:5:10: 5:15>::clone` before InstSimplify ++ // MIR for `<impl at $DIR/combine_clone_of_primitives.rs:5:10: 5:15>::clone` after InstSimplify - fn <impl at $DIR/combine_clone_of_primitives.rs:6:10: 6:15>::clone(_1: &MyThing<T>) -> MyThing<T> { + fn <impl at $DIR/combine_clone_of_primitives.rs:5:10: 5:15>::clone(_1: &MyThing<T>) -> MyThing<T> { debug self => _1; let mut _0: MyThing<T>; let mut _2: T; diff --git a/tests/mir-opt/combine_transmutes.adt_transmutes.InstSimplify.diff b/tests/mir-opt/instsimplify/combine_transmutes.adt_transmutes.InstSimplify.diff index cb623e83f52..cb623e83f52 100644 --- a/tests/mir-opt/combine_transmutes.adt_transmutes.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/combine_transmutes.adt_transmutes.InstSimplify.diff diff --git a/tests/mir-opt/combine_transmutes.identity_transmutes.InstSimplify.diff b/tests/mir-opt/instsimplify/combine_transmutes.identity_transmutes.InstSimplify.diff index 58ae5919071..58ae5919071 100644 --- a/tests/mir-opt/combine_transmutes.identity_transmutes.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/combine_transmutes.identity_transmutes.InstSimplify.diff diff --git a/tests/mir-opt/combine_transmutes.integer_transmutes.InstSimplify.diff b/tests/mir-opt/instsimplify/combine_transmutes.integer_transmutes.InstSimplify.diff index 8eff802dd3c..8eff802dd3c 100644 --- a/tests/mir-opt/combine_transmutes.integer_transmutes.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/combine_transmutes.integer_transmutes.InstSimplify.diff diff --git a/tests/mir-opt/combine_transmutes.rs b/tests/mir-opt/instsimplify/combine_transmutes.rs index 403f9356ce2..b8e15da905b 100644 --- a/tests/mir-opt/combine_transmutes.rs +++ b/tests/mir-opt/instsimplify/combine_transmutes.rs @@ -10,6 +10,10 @@ use std::mem::{MaybeUninit, ManuallyDrop, transmute}; // EMIT_MIR combine_transmutes.identity_transmutes.InstSimplify.diff pub unsafe fn identity_transmutes() { + // CHECK-LABEL: fn identity_transmutes( + // CHECK-NOT: as i32 (Transmute); + // CHECK-NOT: as Vec<i32> (Transmute); + // These are nops and should be removed let _a = transmute::<i32, i32>(1); let _a = transmute::<Vec<i32>, Vec<i32>>(Vec::new()); @@ -18,6 +22,16 @@ pub unsafe fn identity_transmutes() { #[custom_mir(dialect = "runtime", phase = "initial")] // EMIT_MIR combine_transmutes.integer_transmutes.InstSimplify.diff pub unsafe fn integer_transmutes() { + // CHECK-LABEL: fn integer_transmutes( + // CHECK-NOT: _i32 as u32 (Transmute); + // CHECK: _i32 as u32 (IntToInt); + // CHECK: _i32 as i64 (Transmute); + // CHECK-NOT: _u64 as i64 (Transmute); + // CHECK: _u64 as i64 (IntToInt); + // CHECK: _u64 as u32 (Transmute); + // CHECK-NOT: _isize as usize (Transmute); + // CHECK: _isize as usize (IntToInt); + mir! { { let A = CastTransmute::<i32, u32>(1); // Can be a cast @@ -32,6 +46,14 @@ pub unsafe fn integer_transmutes() { // EMIT_MIR combine_transmutes.adt_transmutes.InstSimplify.diff pub unsafe fn adt_transmutes() { + // CHECK-LABEL: fn adt_transmutes( + // CHECK: as u8 (Transmute); + // CHECK: ({{_.*}}.0: i16); + // CHECK: as u16 (Transmute); + // CHECK: as u32 (Transmute); + // CHECK: as i32 (Transmute); + // CHECK: ({{_.*}}.1: std::mem::ManuallyDrop<std::string::String>); + let _a: u8 = transmute(Some(std::num::NonZeroU8::MAX)); let _a: i16 = transmute(std::num::Wrapping(0_i16)); let _a: u16 = transmute(std::num::Wrapping(0_i16)); diff --git a/tests/mir-opt/instsimplify_duplicate_switch_targets.assert_zero.InstSimplify.diff b/tests/mir-opt/instsimplify/duplicate_switch_targets.assert_zero.InstSimplify.diff index e2b45c882d6..e2b45c882d6 100644 --- a/tests/mir-opt/instsimplify_duplicate_switch_targets.assert_zero.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/duplicate_switch_targets.assert_zero.InstSimplify.diff diff --git a/tests/mir-opt/instsimplify_duplicate_switch_targets.rs b/tests/mir-opt/instsimplify/duplicate_switch_targets.rs index 3e280a40fda..e40bc7edaac 100644 --- a/tests/mir-opt/instsimplify_duplicate_switch_targets.rs +++ b/tests/mir-opt/instsimplify/duplicate_switch_targets.rs @@ -1,13 +1,15 @@ +// unit-test: InstSimplify + #![feature(custom_mir, core_intrinsics)] #![crate_type = "lib"] use std::intrinsics::mir::*; -// unit-test: InstSimplify - -// EMIT_MIR instsimplify_duplicate_switch_targets.assert_zero.InstSimplify.diff +// EMIT_MIR duplicate_switch_targets.assert_zero.InstSimplify.diff #[custom_mir(dialect = "runtime", phase = "post-cleanup")] pub unsafe fn assert_zero(x: u8) -> u8 { + // CHECK-LABEL: fn assert_zero( + // CHECK: switchInt({{.*}}) -> [0: {{bb.*}}, otherwise: {{bb.*}}] mir!( { match x { diff --git a/tests/mir-opt/intrinsic_asserts.generic.InstSimplify.diff b/tests/mir-opt/instsimplify/intrinsic_asserts.generic.InstSimplify.diff index efa52798e65..2ecacb5e39f 100644 --- a/tests/mir-opt/intrinsic_asserts.generic.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/intrinsic_asserts.generic.InstSimplify.diff @@ -8,25 +8,25 @@ let _3: (); bb0: { - nop; + StorageLive(_1); _1 = assert_inhabited::<T>() -> [return: bb1, unwind unreachable]; } bb1: { - nop; - nop; + StorageDead(_1); + StorageLive(_2); _2 = assert_zero_valid::<T>() -> [return: bb2, unwind unreachable]; } bb2: { - nop; - nop; + StorageDead(_2); + StorageLive(_3); _3 = assert_mem_uninitialized_valid::<T>() -> [return: bb3, unwind unreachable]; } bb3: { - nop; - nop; + StorageDead(_3); + _0 = const (); return; } } diff --git a/tests/mir-opt/dont_yeet_assert.generic.InstSimplify.diff b/tests/mir-opt/instsimplify/intrinsic_asserts.generic_ref.InstSimplify.diff index 98d9d24af34..d29af0945f7 100644 --- a/tests/mir-opt/dont_yeet_assert.generic.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/intrinsic_asserts.generic_ref.InstSimplify.diff @@ -1,7 +1,7 @@ -- // MIR for `generic` before InstSimplify -+ // MIR for `generic` after InstSimplify +- // MIR for `generic_ref` before InstSimplify ++ // MIR for `generic_ref` after InstSimplify - fn generic() -> () { + fn generic_ref() -> () { let mut _0: (); let _1: (); diff --git a/tests/mir-opt/intrinsic_asserts.panics.InstSimplify.diff b/tests/mir-opt/instsimplify/intrinsic_asserts.panics.InstSimplify.diff index 46e05337809..1be386acfcc 100644 --- a/tests/mir-opt/intrinsic_asserts.panics.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/intrinsic_asserts.panics.InstSimplify.diff @@ -8,28 +8,28 @@ let _3: (); bb0: { - nop; + StorageLive(_1); - _1 = assert_inhabited::<Never>() -> [return: bb1, unwind unreachable]; + _1 = assert_inhabited::<Never>() -> unwind unreachable; } bb1: { - nop; - nop; + StorageDead(_1); + StorageLive(_2); - _2 = assert_zero_valid::<&u8>() -> [return: bb2, unwind unreachable]; + _2 = assert_zero_valid::<&u8>() -> unwind unreachable; } bb2: { - nop; - nop; + StorageDead(_2); + StorageLive(_3); - _3 = assert_mem_uninitialized_valid::<&u8>() -> [return: bb3, unwind unreachable]; + _3 = assert_mem_uninitialized_valid::<&u8>() -> unwind unreachable; } bb3: { - nop; - nop; + StorageDead(_3); + _0 = const (); return; } } diff --git a/tests/mir-opt/intrinsic_asserts.removable.InstSimplify.diff b/tests/mir-opt/instsimplify/intrinsic_asserts.removable.InstSimplify.diff index 70c3e8830f4..f2e69783842 100644 --- a/tests/mir-opt/intrinsic_asserts.removable.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/intrinsic_asserts.removable.InstSimplify.diff @@ -8,28 +8,28 @@ let _3: (); bb0: { - nop; + StorageLive(_1); - _1 = assert_inhabited::<()>() -> [return: bb1, unwind unreachable]; + goto -> bb1; } bb1: { - nop; - nop; + StorageDead(_1); + StorageLive(_2); - _2 = assert_zero_valid::<u8>() -> [return: bb2, unwind unreachable]; + goto -> bb2; } bb2: { - nop; - nop; + StorageDead(_2); + StorageLive(_3); - _3 = assert_mem_uninitialized_valid::<u8>() -> [return: bb3, unwind unreachable]; + goto -> bb3; } bb3: { - nop; - nop; + StorageDead(_3); + _0 = const (); return; } } diff --git a/tests/mir-opt/intrinsic_asserts.rs b/tests/mir-opt/instsimplify/intrinsic_asserts.rs index 302d4bda188..43998b2dbf0 100644 --- a/tests/mir-opt/intrinsic_asserts.rs +++ b/tests/mir-opt/instsimplify/intrinsic_asserts.rs @@ -1,9 +1,15 @@ +// unit-test: InstSimplify + #![crate_type = "lib"] #![feature(core_intrinsics)] // All these assertions pass, so all the intrinsic calls should be deleted. // EMIT_MIR intrinsic_asserts.removable.InstSimplify.diff pub fn removable() { + // CHECK-LABEL: fn removable( + // CHECK-NOT: assert_inhabited + // CHECK-NOT: assert_zero_valid + // CHECK-NOT: assert_mem_uninitialized_valid core::intrinsics::assert_inhabited::<()>(); core::intrinsics::assert_zero_valid::<u8>(); core::intrinsics::assert_mem_uninitialized_valid::<u8>(); @@ -14,6 +20,10 @@ enum Never {} // These assertions all diverge, so their target blocks should become None. // EMIT_MIR intrinsic_asserts.panics.InstSimplify.diff pub fn panics() { + // CHECK-LABEL: fn panics( + // CHECK: assert_inhabited::<Never>() -> unwind + // CHECK: assert_zero_valid::<&u8>() -> unwind + // CHECK: assert_mem_uninitialized_valid::<&u8>() -> unwind core::intrinsics::assert_inhabited::<Never>(); core::intrinsics::assert_zero_valid::<&u8>(); core::intrinsics::assert_mem_uninitialized_valid::<&u8>(); @@ -22,7 +32,19 @@ pub fn panics() { // Whether or not these asserts pass isn't known, so they shouldn't be modified. // EMIT_MIR intrinsic_asserts.generic.InstSimplify.diff pub fn generic<T>() { + // CHECK-LABEL: fn generic( + // CHECK: assert_inhabited::<T>() -> [return: + // CHECK: assert_zero_valid::<T>() -> [return: + // CHECK: assert_mem_uninitialized_valid::<T>() -> [return: core::intrinsics::assert_inhabited::<T>(); core::intrinsics::assert_zero_valid::<T>(); core::intrinsics::assert_mem_uninitialized_valid::<T>(); } + +// Whether or not these asserts pass isn't known, so they shouldn't be modified. +// EMIT_MIR intrinsic_asserts.generic_ref.InstSimplify.diff +pub fn generic_ref<T>() { + // CHECK-LABEL: fn generic_ref( + // CHECK: assert_mem_uninitialized_valid::<&T>() -> [return: + core::intrinsics::assert_mem_uninitialized_valid::<&T>(); +} diff --git a/tests/mir-opt/issue_101973.rs b/tests/mir-opt/issue_101973.rs index 01b342f4dc3..3de325bc170 100644 --- a/tests/mir-opt/issue_101973.rs +++ b/tests/mir-opt/issue_101973.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -O -C debug-assertions=on // This needs inlining followed by ConstProp to reproduce, so we cannot use "unit-test". diff --git a/tests/mir-opt/issue_104451_unwindable_intrinsics.rs b/tests/mir-opt/issue_104451_unwindable_intrinsics.rs index 54112627e4e..cd068f12236 100644 --- a/tests/mir-opt/issue_104451_unwindable_intrinsics.rs +++ b/tests/mir-opt/issue_104451_unwindable_intrinsics.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Check that `UnwindAction::Unreachable` is not generated for unwindable intrinsics. // EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![feature(core_intrinsics)] diff --git a/tests/mir-opt/issue_38669.rs b/tests/mir-opt/issue_38669.rs index db3f89472c9..9da4c89bb12 100644 --- a/tests/mir-opt/issue_38669.rs +++ b/tests/mir-opt/issue_38669.rs @@ -1,3 +1,4 @@ +// skip-filecheck // check that we don't StorageDead booleans before they are used // EMIT_MIR issue_38669.main.SimplifyCfg-initial.after.mir diff --git a/tests/mir-opt/issue_41110.rs b/tests/mir-opt/issue_41110.rs index d8665b23d26..38602d5eaef 100644 --- a/tests/mir-opt/issue_41110.rs +++ b/tests/mir-opt/issue_41110.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // check that we don't emit multiple drop flags when they are not needed. diff --git a/tests/mir-opt/issue_41697.rs b/tests/mir-opt/issue_41697.rs index cbd8633a345..92d382c3940 100644 --- a/tests/mir-opt/issue_41697.rs +++ b/tests/mir-opt/issue_41697.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Regression test for #41697. Using dump-mir was triggering // artificial cycles: during type-checking, we had to get the MIR for // the constant expressions in `[u8; 2]`, which in turn would trigger diff --git a/tests/mir-opt/issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir b/tests/mir-opt/issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir index 0b48e58dabd..7dafeabaacc 100644 --- a/tests/mir-opt/issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir +++ b/tests/mir-opt/issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir @@ -1,6 +1,6 @@ -// MIR for `<impl at $DIR/issue_41697.rs:18:1: 18:23>::{constant#0}` after SimplifyCfg-promote-consts +// MIR for `<impl at $DIR/issue_41697.rs:19:1: 19:23>::{constant#0}` after SimplifyCfg-promote-consts -<impl at $DIR/issue_41697.rs:18:1: 18:23>::{constant#0}: usize = { +<impl at $DIR/issue_41697.rs:19:1: 19:23>::{constant#0}: usize = { let mut _0: usize; let mut _1: (usize, bool); diff --git a/tests/mir-opt/issue_41888.rs b/tests/mir-opt/issue_41888.rs index 9b16caf92fe..70b20218633 100644 --- a/tests/mir-opt/issue_41888.rs +++ b/tests/mir-opt/issue_41888.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // check that we clear the "ADT master drop flag" even when there are // no fields to be dropped. diff --git a/tests/mir-opt/issue_62289.rs b/tests/mir-opt/issue_62289.rs index fece6bb7cf5..40e8352cff4 100644 --- a/tests/mir-opt/issue_62289.rs +++ b/tests/mir-opt/issue_62289.rs @@ -1,3 +1,4 @@ +// skip-filecheck // check that we don't forget to drop the Box if we early return before // initializing it // EMIT_MIR_FOR_EACH_PANIC_STRATEGY diff --git a/tests/mir-opt/issue_72181.rs b/tests/mir-opt/issue_72181.rs index 6a32d4bbee2..226709bab2f 100644 --- a/tests/mir-opt/issue_72181.rs +++ b/tests/mir-opt/issue_72181.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -Z mir-opt-level=1 // Regression test for #72181, this ICE requires `-Z mir-opt-level=1` flags. diff --git a/tests/mir-opt/issue_72181_1.main.built.after.mir b/tests/mir-opt/issue_72181_1.main.built.after.mir index f5ab5b526df..d35aada95f8 100644 --- a/tests/mir-opt/issue_72181_1.main.built.after.mir +++ b/tests/mir-opt/issue_72181_1.main.built.after.mir @@ -1,8 +1,8 @@ // MIR for `main` after built | User Type Annotations -| 0: user_ty: Canonical { value: Ty(Void), max_universe: U0, variables: [] }, span: $DIR/issue_72181_1.rs:16:12: 16:16, inferred_ty: Void -| 1: user_ty: Canonical { value: Ty(Void), max_universe: U0, variables: [] }, span: $DIR/issue_72181_1.rs:16:12: 16:16, inferred_ty: Void +| 0: user_ty: Canonical { value: Ty(Void), max_universe: U0, variables: [] }, span: $DIR/issue_72181_1.rs:17:12: 17:16, inferred_ty: Void +| 1: user_ty: Canonical { value: Ty(Void), max_universe: U0, variables: [] }, span: $DIR/issue_72181_1.rs:17:12: 17:16, inferred_ty: Void | fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/issue_72181_1.rs b/tests/mir-opt/issue_72181_1.rs index 8ae2599ec73..f9ee33ef991 100644 --- a/tests/mir-opt/issue_72181_1.rs +++ b/tests/mir-opt/issue_72181_1.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -Z mir-opt-level=1 // Regression test for #72181, this ICE requires `-Z mir-opt-level=1` flags. diff --git a/tests/mir-opt/issue_76432.rs b/tests/mir-opt/issue_76432.rs index 2a8e1283b0c..f0f12c535c5 100644 --- a/tests/mir-opt/issue_76432.rs +++ b/tests/mir-opt/issue_76432.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -Zmir-enable-passes=-NormalizeArrayLen // Check that we do not insert StorageDead at each target if StorageDead was never seen diff --git a/tests/mir-opt/issue_78192.rs b/tests/mir-opt/issue_78192.rs index 95142a3e463..b08c3615e8b 100644 --- a/tests/mir-opt/issue_78192.rs +++ b/tests/mir-opt/issue_78192.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -Zmir-opt-level=1 -Zinline-mir pub fn f<T>(a: &T) -> *const T { let b: &*const T = &(a as *const T); diff --git a/tests/mir-opt/issue_91633.rs b/tests/mir-opt/issue_91633.rs index 9127cacc97c..047a0cd9bdb 100644 --- a/tests/mir-opt/issue_91633.rs +++ b/tests/mir-opt/issue_91633.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -Z mir-opt-level=0 // EMIT_MIR issue_91633.hey.built.after.mir fn hey<T> (it: &[T]) 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..188b53d28d7 100644 --- a/tests/mir-opt/issue_99325.main.built.after.32bit.mir +++ b/tests/mir-opt/issue_99325.main.built.after.32bit.mir @@ -1,8 +1,8 @@ // MIR for `main` after built | User Type Annotations -| 0: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserArgs { args: [&*b"AAAA"], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:12:16: 12:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} -| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserArgs { args: [UnevaluatedConst { def: DefId(0:8 ~ issue_99325[22bb]::main::{constant#1}), args: [] }: &ReStatic [u8; 4_usize]], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:13:16: 13:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} +| 0: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserArgs { args: [&*b"AAAA"], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:13:16: 13:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} +| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserArgs { args: [UnevaluatedConst { def: DefId(0:8 ~ issue_99325[22bb]::main::{constant#1}), args: [] }: &ReStatic [u8; 4_usize]], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:14:16: 14:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} | fn main() -> () { let mut _0: (); @@ -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..188b53d28d7 100644 --- a/tests/mir-opt/issue_99325.main.built.after.64bit.mir +++ b/tests/mir-opt/issue_99325.main.built.after.64bit.mir @@ -1,8 +1,8 @@ // MIR for `main` after built | User Type Annotations -| 0: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserArgs { args: [&*b"AAAA"], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:12:16: 12:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} -| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserArgs { args: [UnevaluatedConst { def: DefId(0:8 ~ issue_99325[22bb]::main::{constant#1}), args: [] }: &ReStatic [u8; 4_usize]], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:13:16: 13:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} +| 0: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserArgs { args: [&*b"AAAA"], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:13:16: 13:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} +| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserArgs { args: [UnevaluatedConst { def: DefId(0:8 ~ issue_99325[22bb]::main::{constant#1}), args: [] }: &ReStatic [u8; 4_usize]], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:14:16: 14:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} | fn main() -> () { let mut _0: (); @@ -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.rs b/tests/mir-opt/issue_99325.rs index 3603228a502..2638b69e2ee 100644 --- a/tests/mir-opt/issue_99325.rs +++ b/tests/mir-opt/issue_99325.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_BIT_WIDTH #![feature(adt_const_params)] diff --git a/tests/mir-opt/issues/issue_59352.rs b/tests/mir-opt/issues/issue_59352.rs index 7cadf8f227f..1cbeaec28bb 100644 --- a/tests/mir-opt/issues/issue_59352.rs +++ b/tests/mir-opt/issues/issue_59352.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // This test is a mirror of codegen/issue-59352.rs. // The LLVM inliner doesn't inline `char::method::is_digit()` and so it doesn't recognize this case diff --git a/tests/mir-opt/issues/issue_75439.rs b/tests/mir-opt/issues/issue_75439.rs index 4c749a150c0..0ab496e474d 100644 --- a/tests/mir-opt/issues/issue_75439.rs +++ b/tests/mir-opt/issues/issue_75439.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR issue_75439.foo.MatchBranchSimplification.diff // ignore-endian-big diff --git a/tests/mir-opt/loop_test.rs b/tests/mir-opt/loop_test.rs index 7ded5b5757f..81a0d9df0a0 100644 --- a/tests/mir-opt/loop_test.rs +++ b/tests/mir-opt/loop_test.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -Z identify_regions // Tests to make sure we correctly generate falseUnwind edges in loops diff --git a/tests/mir-opt/lower_array_len.rs b/tests/mir-opt/lower_array_len.rs index 7d69e175921..effd83b6af0 100644 --- a/tests/mir-opt/lower_array_len.rs +++ b/tests/mir-opt/lower_array_len.rs @@ -4,6 +4,9 @@ // EMIT_MIR lower_array_len.array_bound.NormalizeArrayLen.diff pub fn array_bound<const N: usize>(index: usize, slice: &[u8; N]) -> u8 { + // CHECK-LABEL: fn array_bound( + // CHECK: [[len:_.*]] = const N; + // CHECK: Lt(move {{_.*}}, move [[len]]); if index < slice.len() { slice[index] } else { @@ -13,6 +16,9 @@ pub fn array_bound<const N: usize>(index: usize, slice: &[u8; N]) -> u8 { // EMIT_MIR lower_array_len.array_bound_mut.NormalizeArrayLen.diff pub fn array_bound_mut<const N: usize>(index: usize, slice: &mut [u8; N]) -> u8 { + // CHECK-LABEL: fn array_bound_mut( + // CHECK: [[len:_.*]] = const N; + // CHECK: Lt(move {{_.*}}, move [[len]]); if index < slice.len() { slice[index] } else { @@ -24,16 +30,22 @@ pub fn array_bound_mut<const N: usize>(index: usize, slice: &mut [u8; N]) -> u8 // EMIT_MIR lower_array_len.array_len.NormalizeArrayLen.diff pub fn array_len<const N: usize>(arr: &[u8; N]) -> usize { + // CHECK-LABEL: fn array_len( + // CHECK: _0 = const N; arr.len() } // EMIT_MIR lower_array_len.array_len_by_value.NormalizeArrayLen.diff pub fn array_len_by_value<const N: usize>(arr: [u8; N]) -> usize { + // CHECK-LABEL: fn array_len_by_value( + // CHECK: _0 = const N; arr.len() } // EMIT_MIR lower_array_len.array_len_reborrow.NormalizeArrayLen.diff pub fn array_len_reborrow<const N: usize>(mut arr: [u8; N]) -> usize { + // CHECK-LABEL: fn array_len_reborrow( + // CHECK: _0 = const N; let arr: &mut [_] = &mut arr; let arr = &*arr; arr.len() @@ -41,6 +53,8 @@ pub fn array_len_reborrow<const N: usize>(mut arr: [u8; N]) -> usize { // EMIT_MIR lower_array_len.array_len_raw.NormalizeArrayLen.diff pub fn array_len_raw<const N: usize>(arr: [u8; N]) -> usize { + // CHECK-LABEL: fn array_len_raw( + // CHECK: _0 = const N; let arr: &[_] = &arr; let arr = std::ptr::addr_of!(*arr); unsafe { &*arr }.len() diff --git a/tests/mir-opt/lower_intrinsics.rs b/tests/mir-opt/lower_intrinsics.rs index 0758e9b775b..913605cc2b2 100644 --- a/tests/mir-opt/lower_intrinsics.rs +++ b/tests/mir-opt/lower_intrinsics.rs @@ -6,6 +6,10 @@ // EMIT_MIR lower_intrinsics.wrapping.LowerIntrinsics.diff pub fn wrapping(a: i32, b: i32) { + // CHECK-LABEL: fn wrapping( + // CHECK: {{_.*}} = Add( + // CHECK: {{_.*}} = Sub( + // CHECK: {{_.*}} = Mul( let _x = core::intrinsics::wrapping_add(a, b); let _y = core::intrinsics::wrapping_sub(a, b); let _z = core::intrinsics::wrapping_mul(a, b); @@ -13,6 +17,14 @@ pub fn wrapping(a: i32, b: i32) { // EMIT_MIR lower_intrinsics.unchecked.LowerIntrinsics.diff pub unsafe fn unchecked(a: i32, b: i32) { + // CHECK-LABEL: fn unchecked( + // CHECK: {{_.*}} = AddUnchecked( + // CHECK: {{_.*}} = SubUnchecked( + // CHECK: {{_.*}} = MulUnchecked( + // CHECK: {{_.*}} = Div( + // CHECK: {{_.*}} = Rem( + // CHECK: {{_.*}} = ShlUnchecked( + // CHECK: {{_.*}} = ShrUnchecked( let _a = core::intrinsics::unchecked_add(a, b); let _b = core::intrinsics::unchecked_sub(a, b); let _c = core::intrinsics::unchecked_mul(a, b); @@ -24,26 +36,39 @@ pub unsafe fn unchecked(a: i32, b: i32) { // EMIT_MIR lower_intrinsics.size_of.LowerIntrinsics.diff pub fn size_of<T>() -> usize { + // CHECK-LABEL: fn size_of( + // CHECK: {{_.*}} = SizeOf(T); core::intrinsics::size_of::<T>() } // EMIT_MIR lower_intrinsics.align_of.LowerIntrinsics.diff pub fn align_of<T>() -> usize { + // CHECK-LABEL: fn align_of( + // CHECK: {{_.*}} = AlignOf(T); core::intrinsics::min_align_of::<T>() } // EMIT_MIR lower_intrinsics.forget.LowerIntrinsics.diff pub fn forget<T>(t: T) { + // CHECK-LABEL: fn forget( + // CHECK-NOT: Drop( + // CHECK: return; + // CHECK-NOT: Drop( core::intrinsics::forget(t) } // EMIT_MIR lower_intrinsics.unreachable.LowerIntrinsics.diff pub fn unreachable() -> ! { + // CHECK-LABEL: fn unreachable( + // CHECK: unreachable; unsafe { core::intrinsics::unreachable() }; } // EMIT_MIR lower_intrinsics.non_const.LowerIntrinsics.diff pub fn non_const<T>() -> usize { + // CHECK-LABEL: fn non_const( + // CHECK: SizeOf(T); + // Check that lowering works with non-const operand as a func. let size_of_t = core::intrinsics::size_of::<T>; size_of_t() @@ -51,33 +76,55 @@ pub fn non_const<T>() -> usize { // EMIT_MIR lower_intrinsics.transmute_inhabited.LowerIntrinsics.diff pub fn transmute_inhabited(c: std::cmp::Ordering) -> i8 { + // CHECK-LABEL: fn transmute_inhabited( + // CHECK: {{_.*}} = {{.*}} as i8 (Transmute); + unsafe { std::mem::transmute(c) } } // EMIT_MIR lower_intrinsics.transmute_uninhabited.LowerIntrinsics.diff pub unsafe fn transmute_uninhabited(u: ()) -> Never { + // CHECK-LABEL: fn transmute_uninhabited( + // CHECK: {{_.*}} = {{.*}} as Never (Transmute); + // CHECK: unreachable; + unsafe { std::mem::transmute::<(), Never>(u) } } // EMIT_MIR lower_intrinsics.transmute_ref_dst.LowerIntrinsics.diff pub unsafe fn transmute_ref_dst<T: ?Sized>(u: &T) -> *const T { + // CHECK-LABEL: fn transmute_ref_dst( + // CHECK: {{_.*}} = {{.*}} as *const T (Transmute); + unsafe { std::mem::transmute(u) } } // EMIT_MIR lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff pub unsafe fn transmute_to_ref_uninhabited() -> ! { + // CHECK-LABEL: fn transmute_to_ref_uninhabited( + // CHECK: {{_.*}} = {{.*}} as &Never (Transmute); + // CHECK: unreachable; + let x: &Never = std::mem::transmute(1usize); match *x {} } // EMIT_MIR lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff pub unsafe fn transmute_to_mut_uninhabited() -> ! { + // CHECK-LABEL: fn transmute_to_mut_uninhabited( + // CHECK: {{_.*}} = {{.*}} as &mut Never (Transmute); + // CHECK: unreachable; + let x: &mut Never = std::mem::transmute(1usize); match *x {} } // EMIT_MIR lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff pub unsafe fn transmute_to_box_uninhabited() -> ! { + // CHECK-LABEL: fn transmute_to_box_uninhabited( + // CHECK: {{_.*}} = {{.*}} as std::boxed::Box<Never> (Transmute); + // CHECK: unreachable; + let x: Box<Never> = std::mem::transmute(1usize); match *x {} } @@ -90,6 +137,12 @@ pub enum E { // EMIT_MIR lower_intrinsics.discriminant.LowerIntrinsics.diff pub fn discriminant<T>(t: T) { + // CHECK-LABEL: fn discriminant( + // CHECK: {{_.*}} = discriminant( + // CHECK: {{_.*}} = discriminant( + // CHECK: {{_.*}} = discriminant( + // CHECK: {{_.*}} = discriminant( + core::intrinsics::discriminant_value(&t); core::intrinsics::discriminant_value(&0); core::intrinsics::discriminant_value(&()); @@ -104,6 +157,9 @@ extern "rust-intrinsic" { // EMIT_MIR lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.diff pub fn f_copy_nonoverlapping() { + // CHECK-LABEL: fn f_copy_nonoverlapping( + // CHECK: copy_nonoverlapping({{.*}}); + let src = (); let mut dst = (); unsafe { @@ -113,6 +169,9 @@ pub fn f_copy_nonoverlapping() { // EMIT_MIR lower_intrinsics.assume.LowerIntrinsics.diff pub fn assume() { + // CHECK-LABEL: fn assume( + // CHECK: assume({{.*}}); + unsafe { std::intrinsics::assume(true); } @@ -120,6 +179,11 @@ pub fn assume() { // EMIT_MIR lower_intrinsics.with_overflow.LowerIntrinsics.diff pub fn with_overflow(a: i32, b: i32) { + // CHECK-LABEL: fn with_overflow( + // CHECK: CheckedAdd( + // CHECK: CheckedSub( + // CHECK: CheckedMul( + let _x = core::intrinsics::add_with_overflow(a, b); let _y = core::intrinsics::sub_with_overflow(a, b); let _z = core::intrinsics::mul_with_overflow(a, b); @@ -127,16 +191,32 @@ pub fn with_overflow(a: i32, b: i32) { // EMIT_MIR lower_intrinsics.read_via_copy_primitive.LowerIntrinsics.diff pub fn read_via_copy_primitive(r: &i32) -> i32 { + // CHECK-LABEL: fn read_via_copy_primitive( + // CHECK: [[tmp:_.*]] = &raw const (*_1); + // CHECK: _0 = (*[[tmp]]); + // CHECK: return; + unsafe { core::intrinsics::read_via_copy(r) } } // EMIT_MIR lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.diff pub fn read_via_copy_uninhabited(r: &Never) -> Never { + // CHECK-LABEL: fn read_via_copy_uninhabited( + // CHECK: [[tmp:_.*]] = &raw const (*_1); + // CHECK: _0 = (*[[tmp]]); + // CHECK: unreachable; + unsafe { core::intrinsics::read_via_copy(r) } } // EMIT_MIR lower_intrinsics.write_via_move_string.LowerIntrinsics.diff pub fn write_via_move_string(r: &mut String, v: String) { + // CHECK-LABEL: fn write_via_move_string( + // CHECK: [[ptr:_.*]] = &raw mut (*_1); + // CHECK: [[tmp:_.*]] = move _2; + // CHECK: (*[[ptr]]) = move [[tmp]]; + // CHECK: return; + unsafe { core::intrinsics::write_via_move(r, v) } } @@ -144,6 +224,10 @@ pub enum Never {} // EMIT_MIR lower_intrinsics.option_payload.LowerIntrinsics.diff pub fn option_payload(o: &Option<usize>, p: &Option<String>) { + // CHECK-LABEL: fn option_payload( + // CHECK: {{_.*}} = &raw const (((*{{_.*}}) as Some).0: usize); + // CHECK: {{_.*}} = &raw const (((*{{_.*}}) as Some).0: std::string::String); + unsafe { let _x = core::intrinsics::option_payload_ptr(o); let _y = core::intrinsics::option_payload_ptr(p); @@ -152,5 +236,8 @@ pub fn option_payload(o: &Option<usize>, p: &Option<String>) { // EMIT_MIR lower_intrinsics.ptr_offset.LowerIntrinsics.diff pub unsafe fn ptr_offset(p: *const i32, d: isize) -> *const i32 { + // CHECK-LABEL: fn ptr_offset( + // CHECK: _0 = Offset( + core::intrinsics::offset(p, d) } diff --git a/tests/mir-opt/lower_slice_len.rs b/tests/mir-opt/lower_slice_len.rs index b0c512aec89..7b967a16588 100644 --- a/tests/mir-opt/lower_slice_len.rs +++ b/tests/mir-opt/lower_slice_len.rs @@ -1,8 +1,10 @@ -// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: LowerSliceLenCalls +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR lower_slice_len.bound.LowerSliceLenCalls.diff pub fn bound(index: usize, slice: &[u8]) -> u8 { + // CHECK-LABEL: fn bound( + // CHECK-NOT: ::len( if index < slice.len() { slice[index] } else { diff --git a/tests/mir-opt/match_arm_scopes.rs b/tests/mir-opt/match_arm_scopes.rs index e0249de8601..43746e99398 100644 --- a/tests/mir-opt/match_arm_scopes.rs +++ b/tests/mir-opt/match_arm_scopes.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Test that StorageDead and Drops are generated properly for bindings in // matches: diff --git a/tests/mir-opt/match_test.rs b/tests/mir-opt/match_test.rs index 3a21077905b..e465289e427 100644 --- a/tests/mir-opt/match_test.rs +++ b/tests/mir-opt/match_test.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Make sure redundant testing paths in `match` expressions are sorted out. #![feature(exclusive_range_pattern)] diff --git a/tests/mir-opt/matches_reduce_branches.rs b/tests/mir-opt/matches_reduce_branches.rs index a81d5f7b4e8..13db7973414 100644 --- a/tests/mir-opt/matches_reduce_branches.rs +++ b/tests/mir-opt/matches_reduce_branches.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: MatchBranchSimplification diff --git a/tests/mir-opt/matches_u8.rs b/tests/mir-opt/matches_u8.rs index 422c3a95e8e..47c4ffee024 100644 --- a/tests/mir-opt/matches_u8.rs +++ b/tests/mir-opt/matches_u8.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: MatchBranchSimplification diff --git a/tests/mir-opt/multiple_return_terminators.rs b/tests/mir-opt/multiple_return_terminators.rs index a2b902d1483..f33243ecf73 100644 --- a/tests/mir-opt/multiple_return_terminators.rs +++ b/tests/mir-opt/multiple_return_terminators.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -Z mir-opt-level=4 // EMIT_MIR multiple_return_terminators.test.MultipleReturnTerminators.diff diff --git a/tests/mir-opt/nll/named_lifetimes_basic.rs b/tests/mir-opt/nll/named_lifetimes_basic.rs index 843716033ca..5a9312de284 100644 --- a/tests/mir-opt/nll/named_lifetimes_basic.rs +++ b/tests/mir-opt/nll/named_lifetimes_basic.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Basic test for named lifetime translation. Check that we // instantiate the types that appear in function arguments with // suitable variables and that we setup the outlives relationship diff --git a/tests/mir-opt/nll/named_lifetimes_basic.use_x.nll.0.mir b/tests/mir-opt/nll/named_lifetimes_basic.use_x.nll.0.mir index 1d6b8307390..49f0a43295a 100644 --- a/tests/mir-opt/nll/named_lifetimes_basic.use_x.nll.0.mir +++ b/tests/mir-opt/nll/named_lifetimes_basic.use_x.nll.0.mir @@ -24,14 +24,14 @@ | '?2 live at {bb0[0..=1]} | '?3 live at {bb0[0..=1]} | '?4 live at {bb0[0..=1]} -| '?1: '?5 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:26: 12:27) ($DIR/named_lifetimes_basic.rs:12:26: 12:27 (#0) -| '?1: '?7 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:54: 12:55) ($DIR/named_lifetimes_basic.rs:12:54: 12:55 (#0) -| '?2: '?6 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:42: 12:43) ($DIR/named_lifetimes_basic.rs:12:42: 12:43 (#0) -| '?3: '?8 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:66: 12:67) ($DIR/named_lifetimes_basic.rs:12:66: 12:67 (#0) -| '?5: '?1 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:26: 12:27) ($DIR/named_lifetimes_basic.rs:12:26: 12:27 (#0) -| '?6: '?2 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:42: 12:43) ($DIR/named_lifetimes_basic.rs:12:42: 12:43 (#0) -| '?7: '?1 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:54: 12:55) ($DIR/named_lifetimes_basic.rs:12:54: 12:55 (#0) -| '?8: '?3 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:66: 12:67) ($DIR/named_lifetimes_basic.rs:12:66: 12:67 (#0) +| '?1: '?5 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:13:26: 13:27) ($DIR/named_lifetimes_basic.rs:13:26: 13:27 (#0) +| '?1: '?7 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:13:54: 13:55) ($DIR/named_lifetimes_basic.rs:13:54: 13:55 (#0) +| '?2: '?6 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:13:42: 13:43) ($DIR/named_lifetimes_basic.rs:13:42: 13:43 (#0) +| '?3: '?8 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:13:66: 13:67) ($DIR/named_lifetimes_basic.rs:13:66: 13:67 (#0) +| '?5: '?1 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:13:26: 13:27) ($DIR/named_lifetimes_basic.rs:13:26: 13:27 (#0) +| '?6: '?2 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:13:42: 13:43) ($DIR/named_lifetimes_basic.rs:13:42: 13:43 (#0) +| '?7: '?1 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:13:54: 13:55) ($DIR/named_lifetimes_basic.rs:13:54: 13:55 (#0) +| '?8: '?3 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:13:66: 13:67) ($DIR/named_lifetimes_basic.rs:13:66: 13:67 (#0) | fn use_x(_1: &'?5 mut i32, _2: &'?6 u32, _3: &'?7 u32, _4: &'?8 u32) -> bool { debug w => _1; diff --git a/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir b/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir index c581d0f8471..ad456600b0a 100644 --- a/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir +++ b/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir @@ -17,8 +17,8 @@ | '?2 live at {bb1[0]} | '?3 live at {bb1[1..=3]} | '?4 live at {bb1[4..=7], bb2[0..=2]} -| '?2: '?3 due to Assignment at Single(bb1[0]) ($DIR/region_subtyping_basic.rs:18:13: 18:18 (#0) -| '?3: '?4 due to Assignment at Single(bb1[3]) ($DIR/region_subtyping_basic.rs:19:13: 19:14 (#0) +| '?2: '?3 due to Assignment at Single(bb1[0]) ($DIR/region_subtyping_basic.rs:19:13: 19:18 (#0) +| '?3: '?4 due to Assignment at Single(bb1[3]) ($DIR/region_subtyping_basic.rs:20:13: 20:14 (#0) | fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir b/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir index 48243e34d08..a15d47cd66f 100644 --- a/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir +++ b/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir @@ -17,8 +17,8 @@ | '?2 live at {bb1[0]} | '?3 live at {bb1[1..=3]} | '?4 live at {bb1[4..=7], bb2[0..=2]} -| '?2: '?3 due to Assignment at Single(bb1[0]) ($DIR/region_subtyping_basic.rs:18:13: 18:18 (#0) -| '?3: '?4 due to Assignment at Single(bb1[3]) ($DIR/region_subtyping_basic.rs:19:13: 19:14 (#0) +| '?2: '?3 due to Assignment at Single(bb1[0]) ($DIR/region_subtyping_basic.rs:19:13: 19:18 (#0) +| '?3: '?4 due to Assignment at Single(bb1[3]) ($DIR/region_subtyping_basic.rs:20:13: 20:14 (#0) | fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/nll/region_subtyping_basic.rs b/tests/mir-opt/nll/region_subtyping_basic.rs index 64332f302e8..83f756acdc3 100644 --- a/tests/mir-opt/nll/region_subtyping_basic.rs +++ b/tests/mir-opt/nll/region_subtyping_basic.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Basic test for liveness constraints: the region (`R1`) that appears // in the type of `p` includes the points after `&v[0]` up to (but not // including) the call to `use_x`. The `else` branch is not included. diff --git a/tests/mir-opt/no_drop_for_inactive_variant.rs b/tests/mir-opt/no_drop_for_inactive_variant.rs index adbd1f353fc..dd20e4a548e 100644 --- a/tests/mir-opt/no_drop_for_inactive_variant.rs +++ b/tests/mir-opt/no_drop_for_inactive_variant.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Ensure that there are no drop terminators in `unwrap<T>` (except the one along the cleanup diff --git a/tests/mir-opt/no_spurious_drop_after_call.rs b/tests/mir-opt/no_spurious_drop_after_call.rs index 71f050502cb..cd7b8fb7942 100644 --- a/tests/mir-opt/no_spurious_drop_after_call.rs +++ b/tests/mir-opt/no_spurious_drop_after_call.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Test that after the call to `std::mem::drop` we do not generate a diff --git a/tests/mir-opt/not_equal_false.rs b/tests/mir-opt/not_equal_false.rs deleted file mode 100644 index e0560732900..00000000000 --- a/tests/mir-opt/not_equal_false.rs +++ /dev/null @@ -1,10 +0,0 @@ -// unit-test: InstSimplify -// EMIT_MIR not_equal_false.opt.InstSimplify.diff - -fn opt(x: bool) -> u32 { - if x != false { 0 } else { 1 } -} - -fn main() { - opt(false); -} diff --git a/tests/mir-opt/nrvo_miscompile_111005.rs b/tests/mir-opt/nrvo_miscompile_111005.rs index a9f391b79d5..aff037ae4f2 100644 --- a/tests/mir-opt/nrvo_miscompile_111005.rs +++ b/tests/mir-opt/nrvo_miscompile_111005.rs @@ -1,3 +1,4 @@ +// skip-filecheck // This is a miscompilation, #111005 to track // unit-test: RenameReturnPlace diff --git a/tests/mir-opt/nrvo_simple.rs b/tests/mir-opt/nrvo_simple.rs index 9e822ed51d4..5b403c560a7 100644 --- a/tests/mir-opt/nrvo_simple.rs +++ b/tests/mir-opt/nrvo_simple.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: RenameReturnPlace diff --git a/tests/mir-opt/packed_struct_drop_aligned.rs b/tests/mir-opt/packed_struct_drop_aligned.rs index f88a683535c..079c4e68f50 100644 --- a/tests/mir-opt/packed_struct_drop_aligned.rs +++ b/tests/mir-opt/packed_struct_drop_aligned.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY diff --git a/tests/mir-opt/pre-codegen/chained_comparison.rs b/tests/mir-opt/pre-codegen/chained_comparison.rs index 43030041983..d1d400af22f 100644 --- a/tests/mir-opt/pre-codegen/chained_comparison.rs +++ b/tests/mir-opt/pre-codegen/chained_comparison.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=2 #![crate_type = "lib"] diff --git a/tests/mir-opt/pre-codegen/checked_ops.rs b/tests/mir-opt/pre-codegen/checked_ops.rs index 23d78e98777..d386219f4a6 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.rs +++ b/tests/mir-opt/pre-codegen/checked_ops.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=2 // needs-unwind // only-x86_64 diff --git a/tests/mir-opt/pre-codegen/duplicate_switch_targets.rs b/tests/mir-opt/pre-codegen/duplicate_switch_targets.rs index d8af6b14dad..b1a00d29372 100644 --- a/tests/mir-opt/pre-codegen/duplicate_switch_targets.rs +++ b/tests/mir-opt/pre-codegen/duplicate_switch_targets.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=0 // ignore-debug: standard library debug assertions add a panic that breaks this optimization diff --git a/tests/mir-opt/pre-codegen/intrinsics.rs b/tests/mir-opt/pre-codegen/intrinsics.rs index e32e04384c4..565bd89e571 100644 --- a/tests/mir-opt/pre-codegen/intrinsics.rs +++ b/tests/mir-opt/pre-codegen/intrinsics.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 // only-64bit diff --git a/tests/mir-opt/pre-codegen/loops.rs b/tests/mir-opt/pre-codegen/loops.rs index f3ba409229d..7f9c26f4fff 100644 --- a/tests/mir-opt/pre-codegen/loops.rs +++ b/tests/mir-opt/pre-codegen/loops.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -O -Zmir-opt-level=2 -g // needs-unwind diff --git a/tests/mir-opt/pre-codegen/mem_replace.rs b/tests/mir-opt/pre-codegen/mem_replace.rs index a139848bab2..18c4653d4c6 100644 --- a/tests/mir-opt/pre-codegen/mem_replace.rs +++ b/tests/mir-opt/pre-codegen/mem_replace.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 // only-64bit // ignore-debug the standard library debug assertions leak into this test 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/optimizes_into_variable.rs b/tests/mir-opt/pre-codegen/optimizes_into_variable.rs index 704f8f887e3..bb089ea4455 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.rs +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -C overflow-checks=on diff --git a/tests/mir-opt/pre-codegen/range_iter.rs b/tests/mir-opt/pre-codegen/range_iter.rs index 9552144787d..80b1a5b2fa5 100644 --- a/tests/mir-opt/pre-codegen/range_iter.rs +++ b/tests/mir-opt/pre-codegen/range_iter.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 // only-64bit // EMIT_MIR_FOR_EACH_PANIC_STRATEGY diff --git a/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir index 80a470c9482..af5d385a979 100644 --- a/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir @@ -3,9 +3,9 @@ fn ezmap(_1: Option<i32>) -> Option<i32> { debug x => _1; let mut _0: std::option::Option<i32>; - scope 1 (inlined map::<i32, i32, {closure@$DIR/simple_option_map.rs:17:12: 17:15}>) { + scope 1 (inlined map::<i32, i32, {closure@$DIR/simple_option_map.rs:18:12: 18:15}>) { debug slf => _1; - debug f => const ZeroSized: {closure@$DIR/simple_option_map.rs:17:12: 17:15}; + debug f => const ZeroSized: {closure@$DIR/simple_option_map.rs:18:12: 18:15}; let mut _2: isize; let _3: i32; let mut _4: i32; diff --git a/tests/mir-opt/pre-codegen/simple_option_map.rs b/tests/mir-opt/pre-codegen/simple_option_map.rs index d4f28dda6c6..35f9ab3e154 100644 --- a/tests/mir-opt/pre-codegen/simple_option_map.rs +++ b/tests/mir-opt/pre-codegen/simple_option_map.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 // only-64bit diff --git a/tests/mir-opt/pre-codegen/slice_filter.rs b/tests/mir-opt/pre-codegen/slice_filter.rs index aba951acdd0..483e5876615 100644 --- a/tests/mir-opt/pre-codegen/slice_filter.rs +++ b/tests/mir-opt/pre-codegen/slice_filter.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=2 // ignore-debug: standard library debug assertions add a panic that breaks this optimization diff --git a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir index b35d3a105ba..548767dca0d 100644 --- a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir @@ -1,6 +1,6 @@ // MIR for `variant_a::{closure#0}` after PreCodegen -fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2: &&(usize, usize, usize, usize)) -> bool { +fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:8:25: 8:39}, _2: &&(usize, usize, usize, usize)) -> bool { let mut _0: bool; let mut _3: &(usize, usize, usize, usize); let _4: &usize; diff --git a/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir index 80c8cebff45..e2ed1d101dc 100644 --- a/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir @@ -1,6 +1,6 @@ // MIR for `variant_b::{closure#0}` after PreCodegen -fn variant_b::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:11:25: 11:41}, _2: &&(usize, usize, usize, usize)) -> bool { +fn variant_b::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:12:25: 12:41}, _2: &&(usize, usize, usize, usize)) -> bool { let mut _0: bool; let mut _3: &(usize, usize, usize, usize); let _4: usize; diff --git a/tests/mir-opt/pre-codegen/slice_index.rs b/tests/mir-opt/pre-codegen/slice_index.rs index 57ffb07e294..5225fc5c6e1 100644 --- a/tests/mir-opt/pre-codegen/slice_index.rs +++ b/tests/mir-opt/pre-codegen/slice_index.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 // only-64bit // ignore-debug the standard library debug assertions leak into this test diff --git a/tests/mir-opt/pre-codegen/slice_iter.rs b/tests/mir-opt/pre-codegen/slice_iter.rs index 1790056369c..10a5c3070d8 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.rs +++ b/tests/mir-opt/pre-codegen/slice_iter.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 // only-64bit // ignore-debug the standard library debug assertions leak into this test 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..485dc9179ce 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 @@ -1,21 +1,18 @@ // MIR for `outer` after PreCodegen 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 - - 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) } + debug v => _1; // in scope 0 at $DIR/spans.rs:10:14: 10:15 + let mut _0: u8; // return place in scope 0 at $DIR/spans.rs:10:24: 10:26 + let mut _2: &u8; // in scope 0 at $DIR/spans.rs:11:11: 11:13 + scope 1 (inlined inner) { // at $DIR/spans.rs:11:5: 11:14 + debug x => _2; // in scope 1 at $DIR/spans.rs:14:14: 14:15 } - bb1: { - StorageDead(_2); // scope 0 at $DIR/spans.rs:10:13: 10:14 - return; // scope 0 at $DIR/spans.rs:11:2: 11:2 + bb0: { + StorageLive(_2); // scope 0 at $DIR/spans.rs:11:11: 11:13 + _2 = &_1; // scope 0 at $DIR/spans.rs:11:11: 11:13 + _0 = _1; // scope 1 at $DIR/spans.rs:15:5: 15:7 + StorageDead(_2); // scope 0 at $DIR/spans.rs:11:13: 11:14 + return; // scope 0 at $DIR/spans.rs:12:2: 12: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..485dc9179ce 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 @@ -1,21 +1,18 @@ // MIR for `outer` after PreCodegen 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 - - 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) } + debug v => _1; // in scope 0 at $DIR/spans.rs:10:14: 10:15 + let mut _0: u8; // return place in scope 0 at $DIR/spans.rs:10:24: 10:26 + let mut _2: &u8; // in scope 0 at $DIR/spans.rs:11:11: 11:13 + scope 1 (inlined inner) { // at $DIR/spans.rs:11:5: 11:14 + debug x => _2; // in scope 1 at $DIR/spans.rs:14:14: 14:15 } - bb1: { - StorageDead(_2); // scope 0 at $DIR/spans.rs:10:13: 10:14 - return; // scope 0 at $DIR/spans.rs:11:2: 11:2 + bb0: { + StorageLive(_2); // scope 0 at $DIR/spans.rs:11:11: 11:13 + _2 = &_1; // scope 0 at $DIR/spans.rs:11:11: 11:13 + _0 = _1; // scope 1 at $DIR/spans.rs:15:5: 15:7 + StorageDead(_2); // scope 0 at $DIR/spans.rs:11:13: 11:14 + return; // scope 0 at $DIR/spans.rs:12:2: 12:2 } } diff --git a/tests/mir-opt/pre-codegen/spans.rs b/tests/mir-opt/pre-codegen/spans.rs index 295eb0476db..aa36648ce39 100644 --- a/tests/mir-opt/pre-codegen/spans.rs +++ b/tests/mir-opt/pre-codegen/spans.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Test that the comments we emit in MIR opts are accurate. // // EMIT_MIR_FOR_EACH_PANIC_STRATEGY diff --git a/tests/mir-opt/pre-codegen/try_identity.rs b/tests/mir-opt/pre-codegen/try_identity.rs index a227c82d6a3..b6e4eaad7e1 100644 --- a/tests/mir-opt/pre-codegen/try_identity.rs +++ b/tests/mir-opt/pre-codegen/try_identity.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 // only-64bit diff --git a/tests/mir-opt/reference_prop.rs b/tests/mir-opt/reference_prop.rs index 610660131b1..36134e019ad 100644 --- a/tests/mir-opt/reference_prop.rs +++ b/tests/mir-opt/reference_prop.rs @@ -8,16 +8,31 @@ fn opaque(_: impl Sized) {} fn reference_propagation<'a, T: Copy>(single: &'a T, mut multiple: &'a T) { + // CHECK-LABEL: fn reference_propagation( + // Propagation through a reference. { + // CHECK: bb0: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[b:_.*]] = &[[a]]; + // CHECK: [[c:_.*]] = [[a]]; + let a = 5_usize; let b = &a; // This borrow is only used once. let c = *b; // This should be optimized. opaque(()); // We use opaque to separate cases into basic blocks in the MIR. } - // Propagation through a two references. + // Propagation through two references. { + // CHECK: bb1: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[a2:_.*]] = const 7_usize; + // CHECK: [[b:_.*]] = &[[a]]; + // CHECK: [[btmp:_.*]] = &[[a2]]; + // CHECK: [[b]] = move [[btmp]]; + // CHECK: [[c:_.*]] = (*[[b]]); + let a = 5_usize; let a2 = 7_usize; let mut b = &a; @@ -29,6 +44,12 @@ fn reference_propagation<'a, T: Copy>(single: &'a T, mut multiple: &'a T) { // Propagation through a borrowed reference. { + // CHECK: bb2: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[b:_.*]] = &[[a]]; + // CHECK: [[d:_.*]] = &[[b]]; + // CHECK: [[c:_.*]] = (*[[b]]); + let a = 5_usize; let b = &a; let d = &b; @@ -36,8 +57,14 @@ fn reference_propagation<'a, T: Copy>(single: &'a T, mut multiple: &'a T) { opaque(d); // prevent `d` from being removed. } - // Propagation through a borrowed reference. + // Propagation through a mutably borrowed reference. { + // CHECK: bb3: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[b:_.*]] = &[[a]]; + // CHECK: [[d:_.*]] = &raw mut [[b]]; + // CHECK: [[c:_.*]] = (*[[b]]); + let a = 5_usize; let mut b = &a; let d = &raw mut b; @@ -47,6 +74,11 @@ fn reference_propagation<'a, T: Copy>(single: &'a T, mut multiple: &'a T) { // Propagation through an escaping borrow. { + // CHECK: bb4: { + // CHECK: [[a:_.*]] = const 7_usize; + // CHECK: [[b:_.*]] = &[[a]]; + // CHECK: [[c:_.*]] = [[a]]; + let a = 7_usize; let b = &a; let c = *b; @@ -55,6 +87,14 @@ fn reference_propagation<'a, T: Copy>(single: &'a T, mut multiple: &'a T) { // Propagation through a transitively escaping borrow. { + // CHECK: bb5: { + // CHECK: [[a:_.*]] = const 7_usize; + // CHECK: [[b1:_.*]] = &[[a]]; + // CHECK: [[c:_.*]] = [[a]]; + // CHECK: [[b2:_.*]] = [[b1]]; + // CHECK: [[c2:_.*]] = [[a]]; + // CHECK: [[b3:_.*]] = [[b2]]; + let a = 7_usize; let b1 = &a; let c = *b1; @@ -68,6 +108,10 @@ fn reference_propagation<'a, T: Copy>(single: &'a T, mut multiple: &'a T) { // Propagation a reborrow of an argument. { + // CHECK: bb6: { + // CHECK-NOT: {{_.*}} = &(*_1); + // CHECK: [[b:_.*]] = (*_1); + let a = &*single; let b = *a; // This should be optimized as `*single`. opaque(()); @@ -75,6 +119,12 @@ fn reference_propagation<'a, T: Copy>(single: &'a T, mut multiple: &'a T) { // Propagation a reborrow of a mutated argument. { + // CHECK: bb7: { + // CHECK: [[a:_.*]] = &(*_2); + // CHECK: [[tmp:_.*]] = &(*_1); + // CHECK: _2 = move [[tmp]]; + // CHECK: [[b:_.*]] = (*[[a]]); + let a = &*multiple; multiple = &*single; let b = *a; // This should not be optimized. @@ -83,6 +133,13 @@ fn reference_propagation<'a, T: Copy>(single: &'a T, mut multiple: &'a T) { // Fixed-point propagation through a borrowed reference. { + // CHECK: bb8: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[b:_.*]] = &[[a]]; + // CHECK: [[d:_.*]] = &[[b]]; + // FIXME this could be [[a]] + // CHECK: [[c:_.*]] = (*[[b]]); + let a = 5_usize; let b = &a; let d = &b; // first round promotes debuginfo for `d` @@ -90,8 +147,15 @@ fn reference_propagation<'a, T: Copy>(single: &'a T, mut multiple: &'a T) { opaque(()); } - // Fixed-point propagation through a borrowed reference. + // Fixed-point propagation through a mutably borrowed reference. { + // CHECK: bb9: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[b:_.*]] = &[[a]]; + // CHECK: [[d:_.*]] = &mut [[b]]; + // FIXME this could be [[a]] + // CHECK: [[c:_.*]] = (*[[b]]); + let a = 5_usize; let mut b = &a; let d = &mut b; // first round promotes debuginfo for `d` @@ -101,16 +165,31 @@ fn reference_propagation<'a, T: Copy>(single: &'a T, mut multiple: &'a T) { } fn reference_propagation_mut<'a, T: Copy>(single: &'a mut T, mut multiple: &'a mut T) { + // CHECK-LABEL: fn reference_propagation_mut( + // Propagation through a reference. { + // CHECK: bb0: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[b:_.*]] = &mut [[a]]; + // CHECK: [[c:_.*]] = [[a]]; + let mut a = 5_usize; let b = &mut a; // This borrow is only used once. let c = *b; // This should be optimized. opaque(()); } - // Propagation through a two references. + // Propagation through two references. { + // CHECK: bb1: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[a2:_.*]] = const 7_usize; + // CHECK: [[b:_.*]] = &mut [[a]]; + // CHECK: [[btmp:_.*]] = &mut [[a2]]; + // CHECK: [[b]] = move [[btmp]]; + // CHECK: [[c:_.*]] = (*[[b]]); + let mut a = 5_usize; let mut a2 = 7_usize; let mut b = &mut a; @@ -122,6 +201,12 @@ fn reference_propagation_mut<'a, T: Copy>(single: &'a mut T, mut multiple: &'a m // Propagation through a borrowed reference. { + // CHECK: bb2: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[b:_.*]] = &mut [[a]]; + // CHECK: [[d:_.*]] = &[[b]]; + // CHECK: [[c:_.*]] = (*[[b]]); + let mut a = 5_usize; let b = &mut a; let d = &b; @@ -129,8 +214,14 @@ fn reference_propagation_mut<'a, T: Copy>(single: &'a mut T, mut multiple: &'a m opaque(d); // prevent `d` from being removed. } - // Propagation through a borrowed reference. + // Propagation through a mutably borrowed reference. { + // CHECK: bb3: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[b:_.*]] = &mut [[a]]; + // CHECK: [[d:_.*]] = &raw mut [[b]]; + // CHECK: [[c:_.*]] = (*[[b]]); + let mut a = 5_usize; let mut b = &mut a; let d = &raw mut b; @@ -140,6 +231,11 @@ fn reference_propagation_mut<'a, T: Copy>(single: &'a mut T, mut multiple: &'a m // Propagation through an escaping borrow. { + // CHECK: bb4: { + // CHECK: [[a:_.*]] = const 7_usize; + // CHECK: [[b:_.*]] = &mut [[a]]; + // CHECK: [[c:_.*]] = (*[[b]]); + let mut a = 7_usize; let b = &mut a; let c = *b; @@ -148,6 +244,14 @@ fn reference_propagation_mut<'a, T: Copy>(single: &'a mut T, mut multiple: &'a m // Propagation through a transitively escaping borrow. { + // CHECK: bb5: { + // CHECK: [[a:_.*]] = const 7_usize; + // CHECK: [[b1:_.*]] = &mut [[a]]; + // CHECK: [[c:_.*]] = (*[[b1]]); + // CHECK: [[b2:_.*]] = move [[b1]]; + // CHECK: [[c2:_.*]] = (*[[b2]]); + // CHECK: [[b3:_.*]] = move [[b2]]; + let mut a = 7_usize; let b1 = &mut a; let c = *b1; @@ -161,6 +265,10 @@ fn reference_propagation_mut<'a, T: Copy>(single: &'a mut T, mut multiple: &'a m // Propagation a reborrow of an argument. { + // CHECK: bb6: { + // CHECK-NOT: {{_.*}} = &(*_1); + // CHECK: [[b:_.*]] = (*_1); + let a = &mut *single; let b = *a; // This should be optimized as `*single`. opaque(()); @@ -168,6 +276,12 @@ fn reference_propagation_mut<'a, T: Copy>(single: &'a mut T, mut multiple: &'a m // Propagation a reborrow of a mutated argument. { + // CHECK: bb7: { + // CHECK: [[a:_.*]] = &mut (*_2); + // CHECK: [[tmp:_.*]] = &mut (*_1); + // CHECK: _2 = move [[tmp]]; + // CHECK: [[b:_.*]] = (*[[a]]); + let a = &mut *multiple; multiple = &mut *single; let b = *a; // This should not be optimized. @@ -176,6 +290,13 @@ fn reference_propagation_mut<'a, T: Copy>(single: &'a mut T, mut multiple: &'a m // Fixed-point propagation through a borrowed reference. { + // CHECK: bb8: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[b:_.*]] = &mut [[a]]; + // CHECK: [[d:_.*]] = &[[b]]; + // FIXME this could be [[a]] + // CHECK: [[c:_.*]] = (*[[b]]); + let mut a = 5_usize; let b = &mut a; let d = &b; // first round promotes debuginfo for `d` @@ -183,8 +304,15 @@ fn reference_propagation_mut<'a, T: Copy>(single: &'a mut T, mut multiple: &'a m opaque(()); } - // Fixed-point propagation through a borrowed reference. + // Fixed-point propagation through a mutably borrowed reference. { + // CHECK: bb9: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[b:_.*]] = &mut [[a]]; + // CHECK: [[d:_.*]] = &mut [[b]]; + // FIXME this could be [[a]] + // CHECK: [[c:_.*]] = (*[[b]]); + let mut a = 5_usize; let mut b = &mut a; let d = &mut b; // first round promotes debuginfo for `d` @@ -194,16 +322,31 @@ fn reference_propagation_mut<'a, T: Copy>(single: &'a mut T, mut multiple: &'a m } fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *const T) { + // CHECK-LABEL: fn reference_propagation_const_ptr( + // Propagation through a reference. unsafe { + // CHECK: bb0: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[b:_.*]] = &raw const [[a]]; + // CHECK: [[c:_.*]] = [[a]]; + let a = 5_usize; let b = &raw const a; // This borrow is only used once. let c = *b; // This should be optimized. opaque(()); } - // Propagation through a two references. + // Propagation through two references. unsafe { + // CHECK: bb1: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[a2:_.*]] = const 7_usize; + // CHECK: [[b:_.*]] = &raw const [[a]]; + // CHECK: [[btmp:_.*]] = &raw const [[a2]]; + // CHECK: [[b]] = move [[btmp]]; + // CHECK: [[c:_.*]] = (*[[b]]); + let a = 5_usize; let a2 = 7_usize; let mut b = &raw const a; @@ -215,6 +358,12 @@ fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *con // Propagation through a borrowed reference. unsafe { + // CHECK: bb2: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[b:_.*]] = &raw const [[a]]; + // CHECK: [[d:_.*]] = &[[b]]; + // CHECK: [[c:_.*]] = (*[[b]]); + let a = 5_usize; let b = &raw const a; let d = &b; @@ -222,8 +371,14 @@ fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *con opaque(d); // prevent `d` from being removed. } - // Propagation through a borrowed reference. + // Propagation through a mutably borrowed reference. unsafe { + // CHECK: bb3: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[b:_.*]] = &raw const [[a]]; + // CHECK: [[d:_.*]] = &raw mut [[b]]; + // CHECK: [[c:_.*]] = (*[[b]]); + let a = 5_usize; let mut b = &raw const a; let d = &raw mut b; @@ -233,6 +388,11 @@ fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *con // Propagation through an escaping borrow. unsafe { + // CHECK: bb4: { + // CHECK: [[a:_.*]] = const 7_usize; + // CHECK: [[b:_.*]] = &raw const [[a]]; + // CHECK: [[c:_.*]] = [[a]]; + let a = 7_usize; let b = &raw const a; let c = *b; @@ -241,6 +401,14 @@ fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *con // Propagation through a transitively escaping borrow. unsafe { + // CHECK: bb5: { + // CHECK: [[a:_.*]] = const 7_usize; + // CHECK: [[b1:_.*]] = &raw const [[a]]; + // CHECK: [[c:_.*]] = [[a]]; + // CHECK: [[b2:_.*]] = [[b1]]; + // CHECK: [[c2:_.*]] = [[a]]; + // CHECK: [[b3:_.*]] = [[b2]]; + let a = 7_usize; let b1 = &raw const a; let c = *b1; @@ -254,6 +422,10 @@ fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *con // Propagation a reborrow of an argument. unsafe { + // CHECK: bb6: { + // CHECK-NOT: {{_.*}} = &(*_1); + // CHECK: [[b:_.*]] = (*_1); + let a = &raw const *single; let b = *a; // This should be optimized as `*single`. opaque(()); @@ -261,6 +433,12 @@ fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *con // Propagation a reborrow of a mutated argument. unsafe { + // CHECK: bb7: { + // CHECK: [[a:_.*]] = &raw const (*_2); + // CHECK: [[tmp:_.*]] = &raw const (*_1); + // CHECK: _2 = move [[tmp]]; + // CHECK: [[b:_.*]] = (*[[a]]); + let a = &raw const *multiple; multiple = &raw const *single; let b = *a; // This should not be optimized. @@ -269,6 +447,12 @@ fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *con // Propagation through a reborrow. unsafe { + // CHECK: bb8: { + // CHECK: [[a:_.*]] = const 13_usize; + // CHECK: [[b:_.*]] = &raw const [[a]]; + // CHECK: [[d:_.*]] = &raw const [[a]]; + // CHECK: [[c:_.*]] = [[a]]; + let a = 13_usize; let b = &raw const a; let c = &raw const *b; @@ -278,6 +462,13 @@ fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *con // Fixed-point propagation through a borrowed reference. unsafe { + // CHECK: bb9: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[b:_.*]] = &raw const [[a]]; + // CHECK: [[d:_.*]] = &[[b]]; + // FIXME this could be [[a]] + // CHECK: [[c:_.*]] = (*[[b]]); + let a = 5_usize; let b = &raw const a; let d = &b; // first round promotes debuginfo for `d` @@ -287,6 +478,13 @@ fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *con // Fixed-point propagation through a borrowed reference. unsafe { + // CHECK: bb10: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[b:_.*]] = &raw const [[a]]; + // CHECK: [[d:_.*]] = &mut [[b]]; + // FIXME this could be [[a]] + // CHECK: [[c:_.*]] = (*[[b]]); + let a = 5_usize; let mut b = &raw const a; let d = &mut b; // first round promotes debuginfo for `d` @@ -296,16 +494,31 @@ fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *con } fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T) { + // CHECK-LABEL: fn reference_propagation_mut_ptr( + // Propagation through a reference. unsafe { + // CHECK: bb0: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[b:_.*]] = &raw mut [[a]]; + // CHECK: [[c:_.*]] = [[a]]; + let mut a = 5_usize; let b = &raw mut a; // This borrow is only used once. let c = *b; // This should be optimized. opaque(()); } - // Propagation through a two references. + // Propagation through two references. unsafe { + // CHECK: bb1: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[a2:_.*]] = const 7_usize; + // CHECK: [[b:_.*]] = &raw mut [[a]]; + // CHECK: [[btmp:_.*]] = &raw mut [[a2]]; + // CHECK: [[b]] = move [[btmp]]; + // CHECK: [[c:_.*]] = (*[[b]]); + let mut a = 5_usize; let mut a2 = 7_usize; let mut b = &raw mut a; @@ -317,6 +530,12 @@ fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T) // Propagation through a borrowed reference. unsafe { + // CHECK: bb2: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[b:_.*]] = &raw mut [[a]]; + // CHECK: [[d:_.*]] = &[[b]]; + // CHECK: [[c:_.*]] = (*[[b]]); + let mut a = 5_usize; let b = &raw mut a; let d = &b; @@ -324,8 +543,14 @@ fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T) opaque(d); // prevent `d` from being removed. } - // Propagation through a borrowed reference. + // Propagation through a mutably borrowed reference. unsafe { + // CHECK: bb3: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[b:_.*]] = &raw mut [[a]]; + // CHECK: [[d:_.*]] = &raw mut [[b]]; + // CHECK: [[c:_.*]] = (*[[b]]); + let mut a = 5_usize; let mut b = &raw mut a; let d = &raw mut b; @@ -335,6 +560,11 @@ fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T) // Propagation through an escaping borrow. unsafe { + // CHECK: bb4: { + // CHECK: [[a:_.*]] = const 7_usize; + // CHECK: [[b:_.*]] = &raw mut [[a]]; + // CHECK: [[c:_.*]] = (*[[b]]); + let mut a = 7_usize; let b = &raw mut a; let c = *b; @@ -343,6 +573,14 @@ fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T) // Propagation through a transitively escaping borrow. unsafe { + // CHECK: bb5: { + // CHECK: [[a:_.*]] = const 7_usize; + // CHECK: [[b1:_.*]] = &raw mut [[a]]; + // CHECK: [[c:_.*]] = (*[[b1]]); + // CHECK: [[b2:_.*]] = [[b1]]; + // CHECK: [[c2:_.*]] = (*[[b2]]); + // CHECK: [[b3:_.*]] = [[b2]]; + let mut a = 7_usize; let b1 = &raw mut a; let c = *b1; @@ -356,6 +594,10 @@ fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T) // Propagation a reborrow of an argument. unsafe { + // CHECK: bb6: { + // CHECK-NOT: {{_.*}} = &(*_1); + // CHECK: [[b:_.*]] = (*_1); + let a = &raw mut *single; let b = *a; // This should be optimized as `*single`. opaque(()); @@ -363,6 +605,12 @@ fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T) // Propagation a reborrow of a mutated argument. unsafe { + // CHECK: bb7: { + // CHECK: [[a:_.*]] = &raw mut (*_2); + // CHECK: [[tmp:_.*]] = &raw mut (*_1); + // CHECK: _2 = move [[tmp]]; + // CHECK: [[b:_.*]] = (*[[a]]); + let a = &raw mut *multiple; multiple = &raw mut *single; let b = *a; // This should not be optimized. @@ -371,6 +619,13 @@ fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T) // Fixed-point propagation through a borrowed reference. unsafe { + // CHECK: bb8: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[b:_.*]] = &raw mut [[a]]; + // CHECK: [[d:_.*]] = &[[b]]; + // FIXME this could be [[a]] + // CHECK: [[c:_.*]] = (*[[b]]); + let mut a = 5_usize; let b = &raw mut a; let d = &b; // first round promotes debuginfo for `d` @@ -378,8 +633,15 @@ fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T) opaque(()); } - // Fixed-point propagation through a borrowed reference. + // Fixed-point propagation through a mutably borrowed reference. unsafe { + // CHECK: bb9: { + // CHECK: [[a:_.*]] = const 5_usize; + // CHECK: [[b:_.*]] = &raw mut [[a]]; + // CHECK: [[d:_.*]] = &mut [[b]]; + // FIXME this could be [[a]] + // CHECK: [[c:_.*]] = (*[[b]]); + let mut a = 5_usize; let mut b = &raw mut a; let d = &mut b; // first round promotes debuginfo for `d` @@ -390,8 +652,13 @@ fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T) #[custom_mir(dialect = "runtime", phase = "post-cleanup")] fn read_through_raw(x: &mut usize) -> usize { - use std::intrinsics::mir::*; + // CHECK-LABEL: read_through_raw + // CHECK: bb0: { + // CHECK-NEXT: _0 = (*_1); + // CHECK-NEXT: _0 = (*_1); + // CHECK-NEXT: return; + use std::intrinsics::mir::*; mir!( let r1: &mut usize; let r2: &mut usize; @@ -413,8 +680,10 @@ fn read_through_raw(x: &mut usize) -> usize { #[custom_mir(dialect = "runtime", phase = "post-cleanup")] fn multiple_storage() { - use std::intrinsics::mir::*; + // CHECK-LABEL: multiple_storage + // CHECK: _3 = (*_2); + use std::intrinsics::mir::*; mir!( let x: i32; { @@ -437,8 +706,10 @@ fn multiple_storage() { #[custom_mir(dialect = "runtime", phase = "post-cleanup")] fn dominate_storage() { - use std::intrinsics::mir::*; + // CHECK-LABEL: dominate_storage + // CHECK: _5 = (*_2); + use std::intrinsics::mir::*; mir!( let x: i32; let r: &i32; @@ -465,8 +736,10 @@ fn dominate_storage() { #[custom_mir(dialect = "runtime", phase = "post-cleanup")] fn maybe_dead(m: bool) { - use std::intrinsics::mir::*; + // CHECK-LABEL: fn maybe_dead( + // CHECK: (*_5) = const 7_i32; + use std::intrinsics::mir::*; mir!( let x: i32; let y: i32; @@ -506,6 +779,9 @@ fn maybe_dead(m: bool) { } fn mut_raw_then_mut_shr() -> (i32, i32) { + // CHECK-LABEL: fn mut_raw_then_mut_shr( + // CHECK-NOT: (*{{_.*}}) + let mut x = 2; let xref = &mut x; let xraw = &mut *xref as *mut _; @@ -517,6 +793,18 @@ fn mut_raw_then_mut_shr() -> (i32, i32) { } fn unique_with_copies() { + // CHECK-LABEL: fn unique_with_copies( + // CHECK: [[a:_.*]] = const 0_i32; + // CHECK: [[x:_.*]] = &raw mut [[a]]; + // CHECK-NOT: [[a]] + // CHECK: [[tmp:_.*]] = (*[[x]]); + // CHECK-NEXT: opaque::<i32>(move [[tmp]]) + // CHECK-NOT: [[a]] + // CHECK: StorageDead([[a]]); + // CHECK-NOT: [[a]] + // CHECK: [[tmp:_.*]] = (*[[x]]); + // CHECK-NEXT: opaque::<i32>(move [[tmp]]) + let y = { let mut a = 0; let x = &raw mut a; @@ -529,6 +817,17 @@ fn unique_with_copies() { } fn debuginfo() { + // CHECK-LABEL: fn debuginfo( + // FIXME: This features waits for DWARF implicit pointers in LLVM. + // CHECK: debug ref_mut_u8 => _{{.*}}; + // CHECK: debug field => _{{.*}}; + // CHECK: debug reborrow => _{{.*}}; + // CHECK: debug variant_field => _{{.*}}; + // CHECK: debug constant_index => _{{.*}}; + // CHECK: debug subslice => _{{.*}}; + // CHECK: debug constant_index_from_end => _{{.*}}; + // CHECK: debug multiple_borrow => _{{.*}}; + struct T(u8); let ref_mut_u8 = &mut 5_u8; @@ -551,6 +850,10 @@ fn debuginfo() { } fn many_debuginfo() { + // CHECK-LABEL: fn many_debuginfo( + // FIXME: This features waits for DWARF implicit pointers in LLVM. + // CHECK: debug many_borrow => _{{.*}}; + let a = 0; // Verify that we do not ICE on deeply nested borrows. diff --git a/tests/mir-opt/remove_fake_borrows.rs b/tests/mir-opt/remove_fake_borrows.rs index f0ee98f777c..21c7b46ee1a 100644 --- a/tests/mir-opt/remove_fake_borrows.rs +++ b/tests/mir-opt/remove_fake_borrows.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Test that the fake borrows for matches are removed after borrow checking. // EMIT_MIR_FOR_EACH_PANIC_STRATEGY diff --git a/tests/mir-opt/remove_never_const.rs b/tests/mir-opt/remove_never_const.rs index 160cc955534..c144edaffaf 100644 --- a/tests/mir-opt/remove_never_const.rs +++ b/tests/mir-opt/remove_never_const.rs @@ -1,3 +1,4 @@ +// skip-filecheck // This was originally a regression test for #66975 - ensure that we do not generate never typed // consts in codegen. We also have tests for this that catches the error, see // tests/ui/consts/const-eval/index-out-of-bounds-never-type.rs. diff --git a/tests/mir-opt/remove_storage_markers.rs b/tests/mir-opt/remove_storage_markers.rs index 330264461d7..6666ff3b726 100644 --- a/tests/mir-opt/remove_storage_markers.rs +++ b/tests/mir-opt/remove_storage_markers.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: RemoveStorageMarkers diff --git a/tests/mir-opt/remove_unneeded_drops.rs b/tests/mir-opt/remove_unneeded_drops.rs index 178d0924c5e..cad79e0aa0c 100644 --- a/tests/mir-opt/remove_unneeded_drops.rs +++ b/tests/mir-opt/remove_unneeded_drops.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR remove_unneeded_drops.opt.RemoveUnneededDrops.diff fn opt(x: bool) { diff --git a/tests/mir-opt/remove_zsts.rs b/tests/mir-opt/remove_zsts.rs index 1cf7ad6e366..e33a272fe16 100644 --- a/tests/mir-opt/remove_zsts.rs +++ b/tests/mir-opt/remove_zsts.rs @@ -1,3 +1,4 @@ +// skip-filecheck union Foo { x: (), y: u64, diff --git a/tests/mir-opt/retag.rs b/tests/mir-opt/retag.rs index e0696de4df3..1e4b017dad5 100644 --- a/tests/mir-opt/retag.rs +++ b/tests/mir-opt/retag.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: AddRetag // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // ignore-tidy-linelength diff --git a/tests/mir-opt/retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.panic-abort.mir b/tests/mir-opt/retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.panic-abort.mir index d7247744074..285db435f5a 100644 --- a/tests/mir-opt/retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.panic-abort.mir +++ b/tests/mir-opt/retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.panic-abort.mir @@ -1,6 +1,6 @@ -// MIR for `<impl at $DIR/retag.rs:12:1: 12:10>::foo` after SimplifyCfg-elaborate-drops +// MIR for `<impl at $DIR/retag.rs:13:1: 13:10>::foo` after SimplifyCfg-elaborate-drops -fn <impl at $DIR/retag.rs:12:1: 12:10>::foo(_1: &Test, _2: &mut i32) -> &mut i32 { +fn <impl at $DIR/retag.rs:13:1: 13:10>::foo(_1: &Test, _2: &mut i32) -> &mut i32 { debug self => _1; debug x => _2; let mut _0: &mut i32; diff --git a/tests/mir-opt/retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.panic-unwind.mir b/tests/mir-opt/retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.panic-unwind.mir index d7247744074..285db435f5a 100644 --- a/tests/mir-opt/retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.panic-unwind.mir +++ b/tests/mir-opt/retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.panic-unwind.mir @@ -1,6 +1,6 @@ -// MIR for `<impl at $DIR/retag.rs:12:1: 12:10>::foo` after SimplifyCfg-elaborate-drops +// MIR for `<impl at $DIR/retag.rs:13:1: 13:10>::foo` after SimplifyCfg-elaborate-drops -fn <impl at $DIR/retag.rs:12:1: 12:10>::foo(_1: &Test, _2: &mut i32) -> &mut i32 { +fn <impl at $DIR/retag.rs:13:1: 13:10>::foo(_1: &Test, _2: &mut i32) -> &mut i32 { debug self => _1; debug x => _2; let mut _0: &mut i32; diff --git a/tests/mir-opt/retag.{impl#0}-foo_shr.SimplifyCfg-elaborate-drops.after.panic-abort.mir b/tests/mir-opt/retag.{impl#0}-foo_shr.SimplifyCfg-elaborate-drops.after.panic-abort.mir index de3eb0d52cf..9ad607b2fe2 100644 --- a/tests/mir-opt/retag.{impl#0}-foo_shr.SimplifyCfg-elaborate-drops.after.panic-abort.mir +++ b/tests/mir-opt/retag.{impl#0}-foo_shr.SimplifyCfg-elaborate-drops.after.panic-abort.mir @@ -1,6 +1,6 @@ -// MIR for `<impl at $DIR/retag.rs:12:1: 12:10>::foo_shr` after SimplifyCfg-elaborate-drops +// MIR for `<impl at $DIR/retag.rs:13:1: 13:10>::foo_shr` after SimplifyCfg-elaborate-drops -fn <impl at $DIR/retag.rs:12:1: 12:10>::foo_shr(_1: &Test, _2: &i32) -> &i32 { +fn <impl at $DIR/retag.rs:13:1: 13:10>::foo_shr(_1: &Test, _2: &i32) -> &i32 { debug self => _1; debug x => _2; let mut _0: &i32; diff --git a/tests/mir-opt/retag.{impl#0}-foo_shr.SimplifyCfg-elaborate-drops.after.panic-unwind.mir b/tests/mir-opt/retag.{impl#0}-foo_shr.SimplifyCfg-elaborate-drops.after.panic-unwind.mir index de3eb0d52cf..9ad607b2fe2 100644 --- a/tests/mir-opt/retag.{impl#0}-foo_shr.SimplifyCfg-elaborate-drops.after.panic-unwind.mir +++ b/tests/mir-opt/retag.{impl#0}-foo_shr.SimplifyCfg-elaborate-drops.after.panic-unwind.mir @@ -1,6 +1,6 @@ -// MIR for `<impl at $DIR/retag.rs:12:1: 12:10>::foo_shr` after SimplifyCfg-elaborate-drops +// MIR for `<impl at $DIR/retag.rs:13:1: 13:10>::foo_shr` after SimplifyCfg-elaborate-drops -fn <impl at $DIR/retag.rs:12:1: 12:10>::foo_shr(_1: &Test, _2: &i32) -> &i32 { +fn <impl at $DIR/retag.rs:13:1: 13:10>::foo_shr(_1: &Test, _2: &i32) -> &i32 { debug self => _1; debug x => _2; let mut _0: &i32; diff --git a/tests/mir-opt/return_an_array.rs b/tests/mir-opt/return_an_array.rs index bea3c317c89..09146a824fc 100644 --- a/tests/mir-opt/return_an_array.rs +++ b/tests/mir-opt/return_an_array.rs @@ -1,3 +1,4 @@ +// skip-filecheck // this tests move up progration, which is not yet implemented fn foo() -> [u8; 1024] { diff --git a/tests/mir-opt/separate_const_switch.rs b/tests/mir-opt/separate_const_switch.rs index d333d4b6be2..3f43cdf4350 100644 --- a/tests/mir-opt/separate_const_switch.rs +++ b/tests/mir-opt/separate_const_switch.rs @@ -1,3 +1,4 @@ +// skip-filecheck #![feature(control_flow_enum)] #![feature(try_trait_v2)] diff --git a/tests/mir-opt/simplify_arm.rs b/tests/mir-opt/simplify_arm.rs index 4c471ce0468..e933cb987d8 100644 --- a/tests/mir-opt/simplify_arm.rs +++ b/tests/mir-opt/simplify_arm.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -Z mir-opt-level=3 -Zunsound-mir-opts // EMIT_MIR simplify_arm.id.SimplifyArmIdentity.diff // EMIT_MIR simplify_arm.id.SimplifyBranchSame.diff diff --git a/tests/mir-opt/simplify_arm_identity.rs b/tests/mir-opt/simplify_arm_identity.rs index e122cd50e00..1b546c3938e 100644 --- a/tests/mir-opt/simplify_arm_identity.rs +++ b/tests/mir-opt/simplify_arm_identity.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Checks that `SimplifyArmIdentity` is not applied if enums have incompatible layouts. // Regression test for issue #66856. // diff --git a/tests/mir-opt/simplify_cfg.rs b/tests/mir-opt/simplify_cfg.rs index cf7eac4403a..a87aaca544c 100644 --- a/tests/mir-opt/simplify_cfg.rs +++ b/tests/mir-opt/simplify_cfg.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Test that the goto chain starting from bb0 is collapsed. // compile-flags: -Cpanic=abort // no-prefer-dynamic diff --git a/tests/mir-opt/simplify_duplicate_unreachable_blocks.rs b/tests/mir-opt/simplify_duplicate_unreachable_blocks.rs index e2578407fea..5c4277898cd 100644 --- a/tests/mir-opt/simplify_duplicate_unreachable_blocks.rs +++ b/tests/mir-opt/simplify_duplicate_unreachable_blocks.rs @@ -1,3 +1,4 @@ +// skip-filecheck #![feature(custom_mir, core_intrinsics)] #![crate_type = "lib"] diff --git a/tests/mir-opt/simplify_if.rs b/tests/mir-opt/simplify_if.rs index fff23b3ce7f..19b5806f720 100644 --- a/tests/mir-opt/simplify_if.rs +++ b/tests/mir-opt/simplify_if.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY #[inline(never)] fn noop() {} diff --git a/tests/mir-opt/simplify_locals.rs b/tests/mir-opt/simplify_locals.rs index 7bbc0481c68..d4052e521de 100644 --- a/tests/mir-opt/simplify_locals.rs +++ b/tests/mir-opt/simplify_locals.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: SimplifyLocals-before-const-prop diff --git a/tests/mir-opt/simplify_locals_fixedpoint.rs b/tests/mir-opt/simplify_locals_fixedpoint.rs index 4da18b7fe58..b0c6e2d8eb5 100644 --- a/tests/mir-opt/simplify_locals_fixedpoint.rs +++ b/tests/mir-opt/simplify_locals_fixedpoint.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -Zmir-opt-level=1 diff --git a/tests/mir-opt/simplify_locals_removes_unused_consts.rs b/tests/mir-opt/simplify_locals_removes_unused_consts.rs index 1e404c3a48c..42879254d71 100644 --- a/tests/mir-opt/simplify_locals_removes_unused_consts.rs +++ b/tests/mir-opt/simplify_locals_removes_unused_consts.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: SimplifyLocals-before-const-prop // compile-flags: -C overflow-checks=no diff --git a/tests/mir-opt/simplify_locals_removes_unused_discriminant_reads.rs b/tests/mir-opt/simplify_locals_removes_unused_discriminant_reads.rs index de65857412c..615b972209c 100644 --- a/tests/mir-opt/simplify_locals_removes_unused_discriminant_reads.rs +++ b/tests/mir-opt/simplify_locals_removes_unused_discriminant_reads.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: SimplifyLocals-before-const-prop fn map(x: Option<Box<()>>) -> Option<Box<()>> { diff --git a/tests/mir-opt/simplify_match.rs b/tests/mir-opt/simplify_match.rs index 5d8e94b0935..eb385005cd9 100644 --- a/tests/mir-opt/simplify_match.rs +++ b/tests/mir-opt/simplify_match.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY #[inline(never)] fn noop() {} diff --git a/tests/mir-opt/simplify_try_if_let.rs b/tests/mir-opt/simplify_try_if_let.rs index fba67de4033..3a59d78500c 100644 --- a/tests/mir-opt/simplify_try_if_let.rs +++ b/tests/mir-opt/simplify_try_if_let.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -Zmir-opt-level=1 -Zunsound-mir-opts // ignore-test // FIXME: the pass is unsound and causes ICEs in the MIR validator diff --git a/tests/mir-opt/slice_drop_shim.rs b/tests/mir-opt/slice_drop_shim.rs index 344c1af2c91..cac0a349128 100644 --- a/tests/mir-opt/slice_drop_shim.rs +++ b/tests/mir-opt/slice_drop_shim.rs @@ -1,3 +1,4 @@ +// skip-filecheck // compile-flags: -Zmir-opt-level=0 diff --git a/tests/mir-opt/spanview_block.main.built.after.html b/tests/mir-opt/spanview_block.main.built.after.html index 56f4e4f9370..54ef00f56f3 100644 --- a/tests/mir-opt/spanview_block.main.built.after.html +++ b/tests/mir-opt/spanview_block.main.built.after.html @@ -60,8 +60,8 @@ </style> </head> <body> -<div class="code" style="counter-reset: line 4"><span class="line"><span class="code" style="--layer: 0">fn main() </span><span><span class="code even" style="--layer: 1" title="0: $DIR/spanview_block.rs:5:11: 5:13: - 5:11-5:13: Assign: _0 = const () - 5:13-5:13: Return: return"><span class="annotation">0⦊</span>{}<span class="annotation">⦉0</span></span></span></span></div> +<div class="code" style="counter-reset: line 5"><span class="line"><span class="code" style="--layer: 0">fn main() </span><span><span class="code even" style="--layer: 1" title="0: $DIR/spanview_block.rs:6:11: 6:13: + 6:11-6:13: Assign: _0 = const () + 6:13-6:13: Return: return"><span class="annotation">0⦊</span>{}<span class="annotation">⦉0</span></span></span></span></div> </body> </html> diff --git a/tests/mir-opt/spanview_block.rs b/tests/mir-opt/spanview_block.rs index 0ecf35ad6a2..e8bc3d16348 100644 --- a/tests/mir-opt/spanview_block.rs +++ b/tests/mir-opt/spanview_block.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Test spanview block output // compile-flags: -Z dump-mir-spanview=block diff --git a/tests/mir-opt/spanview_statement.main.built.after.html b/tests/mir-opt/spanview_statement.main.built.after.html index 91af08d80a8..5e782b05f3b 100644 --- a/tests/mir-opt/spanview_statement.main.built.after.html +++ b/tests/mir-opt/spanview_statement.main.built.after.html @@ -60,8 +60,8 @@ </style> </head> <body> -<div class="code" style="counter-reset: line 4"><span class="line"><span class="code" style="--layer: 0">fn main() </span><span><span class="code even" style="--layer: 1" title="0[0]: $DIR/spanview_statement.rs:5:11: 5:13: - 5:11-5:13: Assign: _0 = const ()"><span class="annotation">0[0]⦊</span>{}<span class="annotation">⦉0[0]</span></span></span><span><span class="code odd" style="--layer: 1" title="0:Return: $DIR/spanview_statement.rs:5:13: 5:13: - 5:13-5:13: Return: return"><span class="annotation">0:Return⦊</span>‸<span class="annotation">⦉0:Return</span></span></span></span></div> +<div class="code" style="counter-reset: line 5"><span class="line"><span class="code" style="--layer: 0">fn main() </span><span><span class="code even" style="--layer: 1" title="0[0]: $DIR/spanview_statement.rs:6:11: 6:13: + 6:11-6:13: Assign: _0 = const ()"><span class="annotation">0[0]⦊</span>{}<span class="annotation">⦉0[0]</span></span></span><span><span class="code odd" style="--layer: 1" title="0:Return: $DIR/spanview_statement.rs:6:13: 6:13: + 6:13-6:13: Return: return"><span class="annotation">0:Return⦊</span>‸<span class="annotation">⦉0:Return</span></span></span></span></div> </body> </html> diff --git a/tests/mir-opt/spanview_statement.rs b/tests/mir-opt/spanview_statement.rs index 457052617b7..d547e6cb1e0 100644 --- a/tests/mir-opt/spanview_statement.rs +++ b/tests/mir-opt/spanview_statement.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Test spanview output (the default value for `-Z dump-mir-spanview` is "statement") // compile-flags: -Z dump-mir-spanview diff --git a/tests/mir-opt/spanview_terminator.main.built.after.html b/tests/mir-opt/spanview_terminator.main.built.after.html index 1f42faedd1e..2a651489e23 100644 --- a/tests/mir-opt/spanview_terminator.main.built.after.html +++ b/tests/mir-opt/spanview_terminator.main.built.after.html @@ -60,7 +60,7 @@ </style> </head> <body> -<div class="code" style="counter-reset: line 4"><span class="line"><span class="code" style="--layer: 0">fn main() {}</span><span><span class="code even" style="--layer: 1" title="0:Return: $DIR/spanview_terminator.rs:5:13: 5:13: - 5:13-5:13: Return: return"><span class="annotation">0:Return⦊</span>‸<span class="annotation">⦉0:Return</span></span></span></span></div> +<div class="code" style="counter-reset: line 5"><span class="line"><span class="code" style="--layer: 0">fn main() {}</span><span><span class="code even" style="--layer: 1" title="0:Return: $DIR/spanview_terminator.rs:6:13: 6:13: + 6:13-6:13: Return: return"><span class="annotation">0:Return⦊</span>‸<span class="annotation">⦉0:Return</span></span></span></span></div> </body> </html> diff --git a/tests/mir-opt/spanview_terminator.rs b/tests/mir-opt/spanview_terminator.rs index 76fced188f1..a2c68b98ef5 100644 --- a/tests/mir-opt/spanview_terminator.rs +++ b/tests/mir-opt/spanview_terminator.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Test spanview terminator output // compile-flags: -Z dump-mir-spanview=terminator diff --git a/tests/mir-opt/sroa/lifetimes.rs b/tests/mir-opt/sroa/lifetimes.rs index 2356d212f3f..cc5c0c9bbcd 100644 --- a/tests/mir-opt/sroa/lifetimes.rs +++ b/tests/mir-opt/sroa/lifetimes.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ScalarReplacementOfAggregates // compile-flags: -Cpanic=abort // no-prefer-dynamic diff --git a/tests/mir-opt/sroa/structs.rs b/tests/mir-opt/sroa/structs.rs index 7946eeaeae4..73563e12c94 100644 --- a/tests/mir-opt/sroa/structs.rs +++ b/tests/mir-opt/sroa/structs.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: ScalarReplacementOfAggregates // compile-flags: -Cpanic=abort // no-prefer-dynamic diff --git a/tests/mir-opt/ssa_unreachable_116212.rs b/tests/mir-opt/ssa_unreachable_116212.rs index f588665876c..9f1cf223e26 100644 --- a/tests/mir-opt/ssa_unreachable_116212.rs +++ b/tests/mir-opt/ssa_unreachable_116212.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Regression test for issue #116212. #![feature(never_type)] diff --git a/tests/mir-opt/storage_ranges.main.nll.0.mir b/tests/mir-opt/storage_ranges.main.nll.0.mir index 13732daa7ad..782efd5acc6 100644 --- a/tests/mir-opt/storage_ranges.main.nll.0.mir +++ b/tests/mir-opt/storage_ranges.main.nll.0.mir @@ -15,7 +15,7 @@ | '?1 live at {bb0[0..=22]} | '?2 live at {bb0[10]} | '?3 live at {bb0[11]} -| '?2: '?3 due to Assignment at Single(bb0[10]) ($DIR/storage_ranges.rs:6:17: 6:25 (#0) +| '?2: '?3 due to Assignment at Single(bb0[10]) ($DIR/storage_ranges.rs:7:17: 7:25 (#0) | fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/storage_ranges.rs b/tests/mir-opt/storage_ranges.rs index 996051a2941..5a68d568465 100644 --- a/tests/mir-opt/storage_ranges.rs +++ b/tests/mir-opt/storage_ranges.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR storage_ranges.main.nll.0.mir fn main() { diff --git a/tests/mir-opt/switch_to_self.rs b/tests/mir-opt/switch_to_self.rs index 6678e4b3bd2..fc270fd33cf 100644 --- a/tests/mir-opt/switch_to_self.rs +++ b/tests/mir-opt/switch_to_self.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Test that MatchBranchSimplification doesn't ICE on a SwitchInt where // one of the targets is the block that the SwitchInt terminates. #![crate_type = "lib"] diff --git a/tests/mir-opt/tls_access.rs b/tests/mir-opt/tls_access.rs index 19344c86862..450dd9b4730 100644 --- a/tests/mir-opt/tls_access.rs +++ b/tests/mir-opt/tls_access.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR tls_access.main.PreCodegen.after.mir // compile-flags: -Zmir-opt-level=0 diff --git a/tests/mir-opt/uninhabited_enum.rs b/tests/mir-opt/uninhabited_enum.rs index 19db548157a..8816f31f9df 100644 --- a/tests/mir-opt/uninhabited_enum.rs +++ b/tests/mir-opt/uninhabited_enum.rs @@ -1,3 +1,4 @@ +// skip-filecheck #![feature(never_type)] pub enum Void {} diff --git a/tests/mir-opt/uninhabited_enum_branching.rs b/tests/mir-opt/uninhabited_enum_branching.rs index 0ef604c3088..96ae84eca50 100644 --- a/tests/mir-opt/uninhabited_enum_branching.rs +++ b/tests/mir-opt/uninhabited_enum_branching.rs @@ -1,3 +1,4 @@ +// skip-filecheck enum Empty { } // test matching an enum with uninhabited variants diff --git a/tests/mir-opt/uninhabited_enum_branching2.rs b/tests/mir-opt/uninhabited_enum_branching2.rs index e22e94314d9..751f2ae01f8 100644 --- a/tests/mir-opt/uninhabited_enum_branching2.rs +++ b/tests/mir-opt/uninhabited_enum_branching2.rs @@ -1,3 +1,4 @@ +// skip-filecheck enum Empty { } // test matching an enum with uninhabited variants diff --git a/tests/mir-opt/uninhabited_fallthrough_elimination.rs b/tests/mir-opt/uninhabited_fallthrough_elimination.rs index 0853883f8b8..7dd41aea5ed 100644 --- a/tests/mir-opt/uninhabited_fallthrough_elimination.rs +++ b/tests/mir-opt/uninhabited_fallthrough_elimination.rs @@ -1,3 +1,4 @@ +// skip-filecheck enum Empty {} enum S { diff --git a/tests/mir-opt/unreachable.rs b/tests/mir-opt/unreachable.rs index 23fad4737fe..5c0df09b752 100644 --- a/tests/mir-opt/unreachable.rs +++ b/tests/mir-opt/unreachable.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY enum Empty {} diff --git a/tests/mir-opt/unreachable_diverging.rs b/tests/mir-opt/unreachable_diverging.rs index b7d308b8630..3713bcaea16 100644 --- a/tests/mir-opt/unreachable_diverging.rs +++ b/tests/mir-opt/unreachable_diverging.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY pub enum Empty {} diff --git a/tests/mir-opt/unusual_item_types.rs b/tests/mir-opt/unusual_item_types.rs index 6dad636416f..49b663b4f82 100644 --- a/tests/mir-opt/unusual_item_types.rs +++ b/tests/mir-opt/unusual_item_types.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Test that we don't ICE when trying to dump MIR for unusual item types and // that we don't create filenames containing `<` and `>` // compile-flags: -Zmir-opt-level=0 diff --git a/tests/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir b/tests/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir index e2edbfcd4fa..a5121ae550d 100644 --- a/tests/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir +++ b/tests/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir @@ -1,6 +1,6 @@ -// MIR for `<impl at $DIR/unusual_item_types.rs:9:1: 9:7>::ASSOCIATED_CONSTANT` after built +// MIR for `<impl at $DIR/unusual_item_types.rs:10:1: 10:7>::ASSOCIATED_CONSTANT` after built -const <impl at $DIR/unusual_item_types.rs:9:1: 9:7>::ASSOCIATED_CONSTANT: i32 = { +const <impl at $DIR/unusual_item_types.rs:10:1: 10:7>::ASSOCIATED_CONSTANT: i32 = { let mut _0: i32; bb0: { diff --git a/tests/mir-opt/while_storage.rs b/tests/mir-opt/while_storage.rs index d4fb54da575..3a3d451ee8d 100644 --- a/tests/mir-opt/while_storage.rs +++ b/tests/mir-opt/while_storage.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Test that we correctly generate StorageDead statements for while loop // conditions on all branches 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-coverage/generator.coverage b/tests/run-coverage/coroutine.coverage index daba2bea8b8..3a9791a0dbd 100644 --- a/tests/run-coverage/generator.coverage +++ b/tests/run-coverage/coroutine.coverage @@ -1,11 +1,11 @@ - LL| |#![feature(generators, generator_trait)] + LL| |#![feature(coroutines, coroutine_trait)] LL| | - LL| |use std::ops::{Generator, GeneratorState}; + LL| |use std::ops::{Coroutine, CoroutineState}; LL| |use std::pin::Pin; LL| | LL| |// The following implementation of a function called from a `yield` statement LL| |// (apparently requiring the Result and the `String` type or constructor) - LL| |// creates conditions where the `generator::StateTransform` MIR transform will + LL| |// creates conditions where the `coroutine::StateTransform` MIR transform will LL| |// drop all `Counter` `Coverage` statements from a MIR. `simplify.rs` has logic LL| |// to handle this condition, and still report dead block coverage. LL| 1|fn get_u32(val: bool) -> Result<u32, String> { @@ -15,17 +15,17 @@ LL| | LL| 1|fn main() { LL| 1| let is_true = std::env::args().len() == 1; - LL| 1| let mut generator = || { + LL| 1| let mut coroutine = || { LL| 1| yield get_u32(is_true); LL| 1| return "foo"; LL| 1| }; LL| | - LL| 1| match Pin::new(&mut generator).resume(()) { - LL| 1| GeneratorState::Yielded(Ok(1)) => {} + LL| 1| match Pin::new(&mut coroutine).resume(()) { + LL| 1| CoroutineState::Yielded(Ok(1)) => {} LL| 0| _ => panic!("unexpected return from resume"), LL| | } - LL| 1| match Pin::new(&mut generator).resume(()) { - LL| 1| GeneratorState::Complete("foo") => {} + LL| 1| match Pin::new(&mut coroutine).resume(()) { + LL| 1| CoroutineState::Complete("foo") => {} LL| 0| _ => panic!("unexpected return from resume"), LL| | } LL| 1|} diff --git a/tests/coverage-map/status-quo/generator.rs b/tests/run-coverage/coroutine.rs index 4319991021e..86d19af6f4f 100644 --- a/tests/coverage-map/status-quo/generator.rs +++ b/tests/run-coverage/coroutine.rs @@ -1,11 +1,11 @@ -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; // The following implementation of a function called from a `yield` statement // (apparently requiring the Result and the `String` type or constructor) -// creates conditions where the `generator::StateTransform` MIR transform will +// creates conditions where the `coroutine::StateTransform` MIR transform will // drop all `Counter` `Coverage` statements from a MIR. `simplify.rs` has logic // to handle this condition, and still report dead block coverage. fn get_u32(val: bool) -> Result<u32, String> { @@ -14,17 +14,17 @@ fn get_u32(val: bool) -> Result<u32, String> { fn main() { let is_true = std::env::args().len() == 1; - let mut generator = || { + let mut coroutine = || { yield get_u32(is_true); return "foo"; }; - match Pin::new(&mut generator).resume(()) { - GeneratorState::Yielded(Ok(1)) => {} + match Pin::new(&mut coroutine).resume(()) { + CoroutineState::Yielded(Ok(1)) => {} _ => panic!("unexpected return from resume"), } - match Pin::new(&mut generator).resume(()) { - GeneratorState::Complete("foo") => {} + match Pin::new(&mut coroutine).resume(()) { + CoroutineState::Complete("foo") => {} _ => panic!("unexpected return from resume"), } } diff --git a/tests/run-coverage/fn_sig_into_try.coverage b/tests/run-coverage/fn_sig_into_try.coverage new file mode 100644 index 00000000000..f1ddb1da780 --- /dev/null +++ b/tests/run-coverage/fn_sig_into_try.coverage @@ -0,0 +1,45 @@ + LL| |#![feature(coverage_attribute)] + LL| |// compile-flags: --edition=2021 + LL| | + LL| |// Regression test for inconsistent handling of function signature spans that + LL| |// are followed by code using the `?` operator. + LL| |// + LL| |// For each of these similar functions, the line containing the function + LL| |// signature should be handled in the same way. + LL| | + LL| 1|fn a() -> Option<i32> + LL| 1|{ + LL| 1| Some(7i32); + LL| 1| Some(0) + LL| 1|} + LL| | + LL| 1|fn b() -> Option<i32> + LL| 1|{ + LL| 1| Some(7i32)?; + ^0 + LL| 1| Some(0) + LL| 1|} + LL| | + LL| 1|fn c() -> Option<i32> + LL| 1|{ + LL| 1| let _ = Some(7i32)?; + ^0 + LL| 1| Some(0) + LL| 1|} + LL| | + LL| 1|fn d() -> Option<i32> + LL| 1|{ + LL| 1| let _: () = (); + LL| 1| Some(7i32)?; + ^0 + LL| 1| Some(0) + LL| 1|} + LL| | + LL| |#[coverage(off)] + LL| |fn main() { + LL| | a(); + LL| | b(); + LL| | c(); + LL| | d(); + LL| |} + diff --git a/tests/run-coverage/fn_sig_into_try.rs b/tests/run-coverage/fn_sig_into_try.rs new file mode 100644 index 00000000000..92850c8a188 --- /dev/null +++ b/tests/run-coverage/fn_sig_into_try.rs @@ -0,0 +1,41 @@ +#![feature(coverage_attribute)] +// compile-flags: --edition=2021 + +// Regression test for inconsistent handling of function signature spans that +// are followed by code using the `?` operator. +// +// For each of these similar functions, the line containing the function +// signature should be handled in the same way. + +fn a() -> Option<i32> +{ + Some(7i32); + Some(0) +} + +fn b() -> Option<i32> +{ + Some(7i32)?; + Some(0) +} + +fn c() -> Option<i32> +{ + let _ = Some(7i32)?; + Some(0) +} + +fn d() -> Option<i32> +{ + let _: () = (); + Some(7i32)?; + Some(0) +} + +#[coverage(off)] +fn main() { + a(); + b(); + c(); + d(); +} diff --git a/tests/run-coverage/issue-84561.coverage b/tests/run-coverage/issue-84561.coverage index 222f877d36a..e693866e277 100644 --- a/tests/run-coverage/issue-84561.coverage +++ b/tests/run-coverage/issue-84561.coverage @@ -135,7 +135,7 @@ LL| 0|} LL| | LL| |impl std::fmt::Debug for Foo { - LL| | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + LL| 7| fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { LL| 7| write!(f, "try and succeed")?; ^0 LL| 7| Ok(()) diff --git a/tests/run-coverage/yield.coverage b/tests/run-coverage/yield.coverage index 90c2641a7d6..d7e455f211e 100644 --- a/tests/run-coverage/yield.coverage +++ b/tests/run-coverage/yield.coverage @@ -1,37 +1,37 @@ - LL| |#![feature(generators, generator_trait)] + LL| |#![feature(coroutines, coroutine_trait)] LL| |#![allow(unused_assignments)] LL| | - LL| |use std::ops::{Generator, GeneratorState}; + LL| |use std::ops::{Coroutine, CoroutineState}; LL| |use std::pin::Pin; LL| | LL| 1|fn main() { - LL| 1| let mut generator = || { + LL| 1| let mut coroutine = || { LL| 1| yield 1; LL| 1| return "foo"; LL| 1| }; LL| | - LL| 1| match Pin::new(&mut generator).resume(()) { - LL| 1| GeneratorState::Yielded(1) => {} + LL| 1| match Pin::new(&mut coroutine).resume(()) { + LL| 1| CoroutineState::Yielded(1) => {} LL| 0| _ => panic!("unexpected value from resume"), LL| | } - LL| 1| match Pin::new(&mut generator).resume(()) { - LL| 1| GeneratorState::Complete("foo") => {} + LL| 1| match Pin::new(&mut coroutine).resume(()) { + LL| 1| CoroutineState::Complete("foo") => {} LL| 0| _ => panic!("unexpected value from resume"), LL| | } LL| | - LL| 1| let mut generator = || { + LL| 1| let mut coroutine = || { LL| 1| yield 1; LL| 1| yield 2; LL| 0| yield 3; LL| 0| return "foo"; LL| 0| }; LL| | - LL| 1| match Pin::new(&mut generator).resume(()) { - LL| 1| GeneratorState::Yielded(1) => {} + LL| 1| match Pin::new(&mut coroutine).resume(()) { + LL| 1| CoroutineState::Yielded(1) => {} LL| 0| _ => panic!("unexpected value from resume"), LL| | } - LL| 1| match Pin::new(&mut generator).resume(()) { - LL| 1| GeneratorState::Yielded(2) => {} + LL| 1| match Pin::new(&mut coroutine).resume(()) { + LL| 1| CoroutineState::Yielded(2) => {} LL| 0| _ => panic!("unexpected value from resume"), LL| | } LL| 1|} diff --git a/tests/run-coverage/yield.rs b/tests/run-coverage/yield.rs index 361275c9215..b7e2ba31b59 100644 --- a/tests/run-coverage/yield.rs +++ b/tests/run-coverage/yield.rs @@ -1,37 +1,37 @@ -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] #![allow(unused_assignments)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; fn main() { - let mut generator = || { + let mut coroutine = || { yield 1; return "foo"; }; - match Pin::new(&mut generator).resume(()) { - GeneratorState::Yielded(1) => {} + match Pin::new(&mut coroutine).resume(()) { + CoroutineState::Yielded(1) => {} _ => panic!("unexpected value from resume"), } - match Pin::new(&mut generator).resume(()) { - GeneratorState::Complete("foo") => {} + match Pin::new(&mut coroutine).resume(()) { + CoroutineState::Complete("foo") => {} _ => panic!("unexpected value from resume"), } - let mut generator = || { + let mut coroutine = || { yield 1; yield 2; yield 3; return "foo"; }; - match Pin::new(&mut generator).resume(()) { - GeneratorState::Yielded(1) => {} + match Pin::new(&mut coroutine).resume(()) { + CoroutineState::Yielded(1) => {} _ => panic!("unexpected value from resume"), } - match Pin::new(&mut generator).resume(()) { - GeneratorState::Yielded(2) => {} + match Pin::new(&mut coroutine).resume(()) { + CoroutineState::Yielded(2) => {} _ => panic!("unexpected value from resume"), } } 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/remap-path-prefix-dwarf/Makefile b/tests/run-make/remap-path-prefix-dwarf/Makefile index c9ede1b6027..8905a00ea28 100644 --- a/tests/run-make/remap-path-prefix-dwarf/Makefile +++ b/tests/run-make/remap-path-prefix-dwarf/Makefile @@ -3,17 +3,26 @@ # ignore-windows +include ../tools.mk + SRC_DIR := $(abspath .) SRC_DIR_PARENT := $(abspath ..) -include ../tools.mk +ifeq ($(UNAME),Darwin) + DEBUGINFOOPTS := -Csplit-debuginfo=off +else + DEBUGINFOOPTS := +endif all: \ abs_input_outside_working_dir \ rel_input_remap_working_dir \ + rel_input_remap_working_dir_scope \ rel_input_remap_working_dir_parent \ rel_input_remap_working_dir_child \ + rel_input_remap_working_dir_diagnostics \ abs_input_inside_working_dir \ + abs_input_inside_working_dir_scope \ abs_input_outside_working_dir # The compiler is called with an *ABSOLUTE PATH* as input, and that absolute path *is* within @@ -27,6 +36,17 @@ abs_input_inside_working_dir: # No weird duplication of remapped components (see #78479) "$(LLVM_BIN_DIR)"/llvm-dwarfdump $(TMPDIR)/abs_input_inside_working_dir.rlib | $(CGREP) -v "REMAPPED/REMAPPED" +# The compiler is called with an *ABSOLUTE PATH* as input, and that absolute path *is* within +# the working directory of the compiler. We are remapping the path that contains `src`. +abs_input_inside_working_dir_scope: + # We explicitly switch to a directory that *is* a prefix of the directory our + # source code is contained in. + cd $(SRC_DIR) && $(RUSTC) $(SRC_DIR)/src/quux.rs -o "$(TMPDIR)/abs_input_inside_working_dir_scope.rlib" -Cdebuginfo=2 --remap-path-prefix $(SRC_DIR)=REMAPPED -Zremap-path-scope=object $(DEBUGINFOOPTS) + # We expect the path to the main source file to be remapped. + "$(LLVM_BIN_DIR)"/llvm-dwarfdump $(TMPDIR)/abs_input_inside_working_dir_scope.rlib | $(CGREP) "REMAPPED/src/quux.rs" + # No weird duplication of remapped components (see #78479) + "$(LLVM_BIN_DIR)"/llvm-dwarfdump $(TMPDIR)/abs_input_inside_working_dir_scope.rlib | $(CGREP) -v "REMAPPED/REMAPPED" + # The compiler is called with an *ABSOLUTE PATH* as input, and that absolute path is *not* within # the working directory of the compiler. We are remapping both the path that contains `src` and # the working directory to the same thing. This setup corresponds to a workaround that is needed @@ -52,6 +72,21 @@ rel_input_remap_working_dir: # No weird duplication of remapped components (see #78479) "$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir.rlib" | $(CGREP) -v "REMAPPED/REMAPPED" +# The compiler is called with a *RELATIVE PATH* as input. We are remapping the working directory of +# the compiler, which naturally is an implicit prefix of our relative input path. Debuginfo will +# expand the relative path to an absolute path and we expect the working directory to be remapped +# in that expansion. +rel_input_remap_working_dir_scope: + cd $(SRC_DIR) && $(RUSTC) src/quux.rs -o "$(TMPDIR)/rel_input_remap_working_dir_scope.rlib" -Cdebuginfo=2 --remap-path-prefix "$(SRC_DIR)=REMAPPED" -Zremap-path-scope=object $(DEBUGINFOOPTS) + "$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir_scope.rlib" | $(CGREP) "REMAPPED/src/quux.rs" + # No weird duplication of remapped components (see #78479) + "$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir_scope.rlib" | $(CGREP) -v "REMAPPED/REMAPPED" + +rel_input_remap_working_dir_diagnostics: + cd $(SRC_DIR) && $(RUSTC) src/quux.rs -o "$(TMPDIR)/rel_input_remap_working_dir_scope.rlib" -Cdebuginfo=2 --remap-path-prefix "$(SRC_DIR)=REMAPPED" -Zremap-path-scope=diagnostics $(DEBUGINFOOPTS) + "$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir_scope.rlib" | $(CGREP) -v "REMAPPED/src/quux.rs" + "$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir_scope.rlib" | $(CGREP) -v "REMAPPED/REMAPPED" + # The compiler is called with a *RELATIVE PATH* as input. We are remapping a *SUB-DIRECTORY* of the # compiler's working directory. This test makes sure that that directory is remapped even though it # won't actually show up in this form in the compiler's SourceMap and instead is only constructed diff --git a/tests/run-make/remap-path-prefix/Makefile b/tests/run-make/remap-path-prefix/Makefile index 2a7378fdf9e..35f65240ff9 100644 --- a/tests/run-make/remap-path-prefix/Makefile +++ b/tests/run-make/remap-path-prefix/Makefile @@ -2,8 +2,38 @@ include ../tools.mk # ignore-windows +ifeq ($(UNAME),Darwin) + DEBUGINFOOPTS := -Csplit-debuginfo=off +else + DEBUGINFOOPTS := +endif + +all: remap remap-with-scope + # Checks if remapping works if the remap-from string contains path to the working directory plus more -all: +remap: $(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux --crate-type=lib --emit=metadata auxiliary/lib.rs grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1 ! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1 + +remap-with-scope: + $(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=object $(DEBUGINFOOPTS) --crate-type=lib --emit=metadata auxiliary/lib.rs + grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1 + ! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1 + + $(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=diagnostics $(DEBUGINFOOPTS) --crate-type=lib --emit=metadata auxiliary/lib.rs + ! grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1 + grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1 + + $(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=diagnostics,object $(DEBUGINFOOPTS) --crate-type=lib --emit=metadata auxiliary/lib.rs + grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1 + ! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1 + + $(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=split-debuginfo $(DEBUGINFOOPTS) --crate-type=lib --emit=metadata auxiliary/lib.rs + ! grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1 + grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1 + + # FIXME: We should test the split debuginfo files, but we don't currently a good infra for that + $(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=split-debuginfo -Zunstable-options -Csplit-debuginfo=packed --crate-type=lib --emit=metadata auxiliary/lib.rs + grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1 + ! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1 diff --git a/tests/run-make/split-debuginfo/Makefile b/tests/run-make/split-debuginfo/Makefile index 71e014c1f71..9e05c8dc179 100644 --- a/tests/run-make/split-debuginfo/Makefile +++ b/tests/run-make/split-debuginfo/Makefile @@ -104,7 +104,7 @@ packed-lto-single: ls $(TMPDIR)/*.dwp && exit 1 || exit 0 rm $(TMPDIR)/libbaz.rlib -packed-remapped: packed-remapped-split packed-remapped-single +packed-remapped: packed-remapped-split packed-remapped-single packed-remapped-scope packed-remapped-wrong-scope # - Debuginfo in `.dwo` files # - `.o` and binary refer to remapped `.dwo` paths which do not exist @@ -134,6 +134,36 @@ packed-remapped-single: rm $(TMPDIR)/foo.dwp rm $(TMPDIR)/$(call BIN,foo) +# - Debuginfo in `.o` files +# - `.o` and binary refer to remapped `.o` paths which do not exist +# - `.o` deleted +# - `.dwo` never created +# - `.dwp` present +packed-remapped-scope: + $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \ + -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \ + -Z remap-path-scope=split-debuginfo-path foo.rs -g + objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1 + ls $(TMPDIR)/*.o && exit 1 || exit 0 + ls $(TMPDIR)/*.dwo && exit 1 || exit 0 + rm $(TMPDIR)/foo.dwp + rm $(TMPDIR)/$(call BIN,foo) + +# - Debuginfo in `.o` files +# - `.o` and binary refer to remapped `.o` paths which do not exist +# - `.o` deleted +# - `.dwo` never created +# - `.dwp` present +packed-remapped-wrong-scope: + $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \ + -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \ + -Z remap-path-scope=macro foo.rs -g + objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (grep $(TMPDIR)) || exit 1 + ls $(TMPDIR)/*.o && exit 1 || exit 0 + ls $(TMPDIR)/*.dwo && exit 1 || exit 0 + rm $(TMPDIR)/foo.dwp + rm $(TMPDIR)/$(call BIN,foo) + packed-crosscrate: packed-crosscrate-split packed-crosscrate-single # - Debuginfo in `.dwo` files @@ -230,7 +260,7 @@ unpacked-lto-single: ls $(TMPDIR)/*.dwp && exit 1 || exit 0 rm $(TMPDIR)/libbaz.rlib -unpacked-remapped: unpacked-remapped-split unpacked-remapped-single +unpacked-remapped: unpacked-remapped-split unpacked-remapped-single unpacked-remapped-scope unpacked-remapped-wrong-scope # - Debuginfo in `.dwo` files # - `.o` and binary refer to remapped `.dwo` paths which do not exist @@ -260,6 +290,36 @@ unpacked-remapped-single: ls $(TMPDIR)/*.dwp && exit 1 || exit 0 rm $(TMPDIR)/$(call BIN,foo) +# - Debuginfo in `.o` files +# - `.o` and binary refer to remapped `.o` paths which do not exist +# - `.o` present +# - `.dwo` never created +# - `.dwp` never created +unpacked-remapped-scope: + $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \ + -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \ + -Z remap-path-scope=split-debuginfo-path foo.rs -g + objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1 + rm $(TMPDIR)/*.o + ls $(TMPDIR)/*.dwo && exit 1 || exit 0 + ls $(TMPDIR)/*.dwp && exit 1 || exit 0 + rm $(TMPDIR)/$(call BIN,foo) + +# - Debuginfo in `.o` files +# - `.o` and binary refer to remapped `.o` paths which do not exist +# - `.o` present +# - `.dwo` never created +# - `.dwp` never created +unpacked-remapped-wrong-scope: + $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \ + -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \ + -Z remap-path-scope=macro foo.rs -g + objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (grep $(TMPDIR)) || exit 1 + rm $(TMPDIR)/*.o + ls $(TMPDIR)/*.dwo && exit 1 || exit 0 + ls $(TMPDIR)/*.dwp && exit 1 || exit 0 + rm $(TMPDIR)/$(call BIN,foo) + unpacked-crosscrate: unpacked-crosscrate-split unpacked-crosscrate-single # - Debuginfo in `.dwo` files 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-ui/error-in-impl-trait/closure.rs b/tests/rustdoc-ui/error-in-impl-trait/closure.rs index f1fd85bb23c..628c61a6a1a 100644 --- a/tests/rustdoc-ui/error-in-impl-trait/closure.rs +++ b/tests/rustdoc-ui/error-in-impl-trait/closure.rs @@ -1,5 +1,5 @@ // check-pass -// manually desugared version of an `async fn` (but with a closure instead of a generator) +// manually desugared version of an `async fn` (but with a closure instead of a coroutine) pub fn a() -> impl Fn() -> u32 { || content::doesnt::matter() } 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/internal-lints/ty_tykind_usage.rs b/tests/ui-fulldeps/internal-lints/ty_tykind_usage.rs index 3f7429a5fcc..ae7f341fe4e 100644 --- a/tests/ui-fulldeps/internal-lints/ty_tykind_usage.rs +++ b/tests/ui-fulldeps/internal-lints/ty_tykind_usage.rs @@ -29,8 +29,8 @@ fn main() { TyKind::FnPtr(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Dynamic(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Closure(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Generator(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::GeneratorWitness(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Coroutine(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::CoroutineWitness(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Never => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Tuple(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Alias(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` diff --git a/tests/ui-fulldeps/internal-lints/ty_tykind_usage.stderr b/tests/ui-fulldeps/internal-lints/ty_tykind_usage.stderr index 1f49d6b6464..45b7c26faad 100644 --- a/tests/ui-fulldeps/internal-lints/ty_tykind_usage.stderr +++ b/tests/ui-fulldeps/internal-lints/ty_tykind_usage.stderr @@ -109,13 +109,13 @@ LL | TyKind::Closure(..) => (), error: usage of `ty::TyKind::<kind>` --> $DIR/ty_tykind_usage.rs:32:9 | -LL | TyKind::Generator(..) => (), +LL | TyKind::Coroutine(..) => (), | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` --> $DIR/ty_tykind_usage.rs:33:9 | -LL | TyKind::GeneratorWitness(..) => (), +LL | TyKind::CoroutineWitness(..) => (), | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` diff --git a/tests/ui-fulldeps/stable-mir/check_instance.rs b/tests/ui-fulldeps/stable-mir/check_instance.rs new file mode 100644 index 00000000000..288c163a6a3 --- /dev/null +++ b/tests/ui-fulldeps/stable-mir/check_instance.rs @@ -0,0 +1,115 @@ +// 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 mir::{mono::Instance, TerminatorKind::*}; +use stable_mir::ty::{TyKind, RigidTy}; +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())); + + for instance in instances { + test_body(instance.body()) + } + ControlFlow::Continue(()) +} + +/// Inspect the instance body +fn test_body(body: mir::Body) { + for term in body.blocks.iter().map(|bb| &bb.terminator) { + match &term.kind { + Call{ func, .. } => { + let TyKind::RigidTy(ty) = func.ty(&body.locals).kind() else { unreachable!() }; + let RigidTy::FnDef(def, args) = ty else { unreachable!() }; + let result = Instance::resolve(def, &args); + assert!(result.is_ok()); + } + Goto {..} | Assert{..} | SwitchInt{..} | Return | Drop {..} => { /* Do nothing */} + _ => { unreachable!("Unexpected terminator {term:?}") } + } + } +} + + +/// 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(), + "-Cpanic=abort".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() {{ + let v = vec![10]; + let dup = ty_param(&v); + assert_eq!(v, dup); + }} + + pub mod foo {{ + pub fn bar_mono(i: i32) -> i64 {{ + i as i64 + }} + }} + "# + )?; + Ok(()) +} diff --git a/tests/ui/asm/aarch64/interpolated-idents.stderr b/tests/ui/asm/aarch64/interpolated-idents.stderr index f6c50c2e1fd..74cb992f2ad 100644 --- a/tests/ui/asm/aarch64/interpolated-idents.stderr +++ b/tests/ui/asm/aarch64/interpolated-idents.stderr @@ -33,12 +33,7 @@ LL | asm!("", $in(x) x, $out(x) x, $lateout(x) x, $inout(x) x, $in LL | / m!(in out lateout inout inlateout const sym LL | | pure nomem readonly preserves_flags LL | | noreturn nostack options); - | | - - | |________________________________| - | |________________________________in this macro invocation - | |________________________________in this macro invocation - | |________________________________in this macro invocation - | in this macro invocation + | |________________________________- in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/asm/x86_64/interpolated-idents.stderr b/tests/ui/asm/x86_64/interpolated-idents.stderr index 80a8c8c77cf..a91bc768fc4 100644 --- a/tests/ui/asm/x86_64/interpolated-idents.stderr +++ b/tests/ui/asm/x86_64/interpolated-idents.stderr @@ -33,12 +33,7 @@ LL | asm!("", $in(x) x, $out(x) x, $lateout(x) x, $inout(x) x, $in LL | / m!(in out lateout inout inlateout const sym LL | | pure nomem readonly preserves_flags LL | | noreturn nostack att_syntax options); - | | - - | |___________________________________________| - | |___________________________________________in this macro invocation - | |___________________________________________in this macro invocation - | |___________________________________________in this macro invocation - | in this macro invocation + | |___________________________________________- in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) 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/generator-desc.rs b/tests/ui/async-await/coroutine-desc.rs index 50081201667..50081201667 100644 --- a/tests/ui/async-await/generator-desc.rs +++ b/tests/ui/async-await/coroutine-desc.rs diff --git a/tests/ui/async-await/generator-desc.stderr b/tests/ui/async-await/coroutine-desc.stderr index d3e951cfe49..e4cb0915a10 100644 --- a/tests/ui/async-await/generator-desc.stderr +++ b/tests/ui/async-await/coroutine-desc.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/generator-desc.rs:10:19 + --> $DIR/coroutine-desc.rs:10:19 | LL | fun(async {}, async {}); | --- -------- ^^^^^^^^ expected `async` block, found a different `async` block @@ -7,16 +7,16 @@ LL | fun(async {}, async {}); | | the expected `async` block | arguments to this function are incorrect | - = note: expected `async` block `{async block@$DIR/generator-desc.rs:10:9: 10:17}` - found `async` block `{async block@$DIR/generator-desc.rs:10:19: 10:27}` + = note: expected `async` block `{async block@$DIR/coroutine-desc.rs:10:9: 10:17}` + found `async` block `{async block@$DIR/coroutine-desc.rs:10:19: 10:27}` note: function defined here - --> $DIR/generator-desc.rs:8:4 + --> $DIR/coroutine-desc.rs:8:4 | LL | fn fun<F: Future<Output = ()>>(f1: F, f2: F) {} | ^^^ ----- error[E0308]: mismatched types - --> $DIR/generator-desc.rs:12:16 + --> $DIR/coroutine-desc.rs:12:16 | LL | fun(one(), two()); | --- ^^^^^ expected future, found a different future @@ -26,13 +26,13 @@ LL | fun(one(), two()); = help: consider `await`ing on both `Future`s = note: distinct uses of `impl Trait` result in different opaque types note: function defined here - --> $DIR/generator-desc.rs:8:4 + --> $DIR/coroutine-desc.rs:8:4 | LL | fn fun<F: Future<Output = ()>>(f1: F, f2: F) {} | ^^^ ----- error[E0308]: mismatched types - --> $DIR/generator-desc.rs:14:26 + --> $DIR/coroutine-desc.rs:14:26 | LL | fun((async || {})(), (async || {})()); | --- -- ^^^^^^^^^^^^^^^ expected `async` closure body, found a different `async` closure body @@ -40,10 +40,10 @@ LL | fun((async || {})(), (async || {})()); | | the expected `async` closure body | arguments to this function are incorrect | - = note: expected `async` closure body `{async closure body@$DIR/generator-desc.rs:14:19: 14:21}` - found `async` closure body `{async closure body@$DIR/generator-desc.rs:14:36: 14:38}` + = note: expected `async` closure body `{async closure body@$DIR/coroutine-desc.rs:14:19: 14:21}` + found `async` closure body `{async closure body@$DIR/coroutine-desc.rs:14:36: 14:38}` note: function defined here - --> $DIR/generator-desc.rs:8:4 + --> $DIR/coroutine-desc.rs:8:4 | LL | fn fun<F: Future<Output = ()>>(f1: F, f2: F) {} | ^^^ ----- diff --git a/tests/ui/async-await/generator-not-future.rs b/tests/ui/async-await/coroutine-not-future.rs index 37d7cfa6fb7..b18635fea39 100644 --- a/tests/ui/async-await/generator-not-future.rs +++ b/tests/ui/async-await/coroutine-not-future.rs @@ -1,42 +1,42 @@ // edition:2018 -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] use std::future::Future; -use std::ops::Generator; +use std::ops::Coroutine; async fn async_fn() {} fn returns_async_block() -> impl Future<Output = ()> { async {} } -fn returns_generator() -> impl Generator<(), Yield = (), Return = ()> { +fn returns_coroutine() -> impl Coroutine<(), Yield = (), Return = ()> { || { let _: () = yield (); } } fn takes_future(_f: impl Future<Output = ()>) {} -fn takes_generator<ResumeTy>(_g: impl Generator<ResumeTy, Yield = (), Return = ()>) {} +fn takes_coroutine<ResumeTy>(_g: impl Coroutine<ResumeTy, Yield = (), Return = ()>) {} fn main() { // okay: takes_future(async_fn()); takes_future(returns_async_block()); takes_future(async {}); - takes_generator(returns_generator()); - takes_generator(|| { + takes_coroutine(returns_coroutine()); + takes_coroutine(|| { let _: () = yield (); }); - // async futures are not generators: - takes_generator(async_fn()); + // async futures are not coroutines: + takes_coroutine(async_fn()); //~^ ERROR the trait bound - takes_generator(returns_async_block()); + takes_coroutine(returns_async_block()); //~^ ERROR the trait bound - takes_generator(async {}); + takes_coroutine(async {}); //~^ ERROR the trait bound - // generators are not futures: - takes_future(returns_generator()); + // coroutines are not futures: + takes_future(returns_coroutine()); //~^ ERROR is not a future takes_future(|ctx| { //~^ ERROR is not a future diff --git a/tests/ui/async-await/coroutine-not-future.stderr b/tests/ui/async-await/coroutine-not-future.stderr new file mode 100644 index 00000000000..130c5ef526b --- /dev/null +++ b/tests/ui/async-await/coroutine-not-future.stderr @@ -0,0 +1,81 @@ +error[E0277]: the trait bound `impl Future<Output = ()>: Coroutine<_>` is not satisfied + --> $DIR/coroutine-not-future.rs:31:21 + | +LL | takes_coroutine(async_fn()); + | --------------- ^^^^^^^^^^ the trait `Coroutine<_>` is not implemented for `impl Future<Output = ()>` + | | + | required by a bound introduced by this call + | +note: required by a bound in `takes_coroutine` + --> $DIR/coroutine-not-future.rs:18:39 + | +LL | fn takes_coroutine<ResumeTy>(_g: impl Coroutine<ResumeTy, Yield = (), Return = ()>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_coroutine` + +error[E0277]: the trait bound `impl Future<Output = ()>: Coroutine<_>` is not satisfied + --> $DIR/coroutine-not-future.rs:33:21 + | +LL | takes_coroutine(returns_async_block()); + | --------------- ^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine<_>` is not implemented for `impl Future<Output = ()>` + | | + | required by a bound introduced by this call + | +note: required by a bound in `takes_coroutine` + --> $DIR/coroutine-not-future.rs:18:39 + | +LL | fn takes_coroutine<ResumeTy>(_g: impl Coroutine<ResumeTy, Yield = (), Return = ()>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_coroutine` + +error[E0277]: the trait bound `{async block@$DIR/coroutine-not-future.rs:35:21: 35:29}: Coroutine<_>` is not satisfied + --> $DIR/coroutine-not-future.rs:35:21 + | +LL | takes_coroutine(async {}); + | --------------- ^^^^^^^^ the trait `Coroutine<_>` is not implemented for `{async block@$DIR/coroutine-not-future.rs:35:21: 35:29}` + | | + | required by a bound introduced by this call + | +note: required by a bound in `takes_coroutine` + --> $DIR/coroutine-not-future.rs:18:39 + | +LL | fn takes_coroutine<ResumeTy>(_g: impl Coroutine<ResumeTy, Yield = (), Return = ()>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_coroutine` + +error[E0277]: `impl Coroutine<Yield = (), Return = ()>` is not a future + --> $DIR/coroutine-not-future.rs:39:18 + | +LL | takes_future(returns_coroutine()); + | ------------ ^^^^^^^^^^^^^^^^^^^ `impl Coroutine<Yield = (), Return = ()>` is not a future + | | + | required by a bound introduced by this call + | + = help: the trait `Future` is not implemented for `impl Coroutine<Yield = (), Return = ()>` + = note: impl Coroutine<Yield = (), Return = ()> must be a future or must implement `IntoFuture` to be awaited +note: required by a bound in `takes_future` + --> $DIR/coroutine-not-future.rs:17:26 + | +LL | fn takes_future(_f: impl Future<Output = ()>) {} + | ^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_future` + +error[E0277]: `{coroutine@$DIR/coroutine-not-future.rs:41:18: 41:23}` is not a future + --> $DIR/coroutine-not-future.rs:41:18 + | +LL | takes_future(|ctx| { + | _____------------_^ + | | | + | | required by a bound introduced by this call +LL | | +LL | | ctx = yield (); +LL | | }); + | |_____^ `{coroutine@$DIR/coroutine-not-future.rs:41:18: 41:23}` is not a future + | + = help: the trait `Future` is not implemented for `{coroutine@$DIR/coroutine-not-future.rs:41:18: 41:23}` + = note: {coroutine@$DIR/coroutine-not-future.rs:41:18: 41:23} must be a future or must implement `IntoFuture` to be awaited +note: required by a bound in `takes_future` + --> $DIR/coroutine-not-future.rs:17:26 + | +LL | fn takes_future(_f: impl Future<Output = ()>) {} + | ^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_future` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/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/future-sizes/async-awaiting-fut.stdout b/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout index d63911b0d3c..b0447a58261 100644 --- a/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout +++ b/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout @@ -19,18 +19,18 @@ print-type-size variant `Suspend0`: 2052 bytes print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes print-type-size padding: 1 bytes print-type-size local `.fut`: 1025 bytes, alignment: 1 bytes -print-type-size local `..generator_field4`: 1 bytes +print-type-size local `..coroutine_field4`: 1 bytes print-type-size local `.__awaitee`: 1 bytes print-type-size variant `Suspend1`: 3076 bytes print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes print-type-size padding: 1026 bytes -print-type-size local `..generator_field4`: 1 bytes, alignment: 1 bytes +print-type-size local `..coroutine_field4`: 1 bytes, alignment: 1 bytes print-type-size local `.__awaitee`: 1025 bytes print-type-size variant `Suspend2`: 2052 bytes print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes print-type-size padding: 1 bytes print-type-size local `.fut`: 1025 bytes, alignment: 1 bytes -print-type-size local `..generator_field4`: 1 bytes +print-type-size local `..coroutine_field4`: 1 bytes print-type-size local `.__awaitee`: 1 bytes print-type-size variant `Returned`: 1025 bytes print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes diff --git a/tests/ui/async-await/generator-not-future.stderr b/tests/ui/async-await/generator-not-future.stderr deleted file mode 100644 index 540501b9826..00000000000 --- a/tests/ui/async-await/generator-not-future.stderr +++ /dev/null @@ -1,81 +0,0 @@ -error[E0277]: the trait bound `impl Future<Output = ()>: Generator<_>` is not satisfied - --> $DIR/generator-not-future.rs:31:21 - | -LL | takes_generator(async_fn()); - | --------------- ^^^^^^^^^^ the trait `Generator<_>` is not implemented for `impl Future<Output = ()>` - | | - | required by a bound introduced by this call - | -note: required by a bound in `takes_generator` - --> $DIR/generator-not-future.rs:18:39 - | -LL | fn takes_generator<ResumeTy>(_g: impl Generator<ResumeTy, Yield = (), Return = ()>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_generator` - -error[E0277]: the trait bound `impl Future<Output = ()>: Generator<_>` is not satisfied - --> $DIR/generator-not-future.rs:33:21 - | -LL | takes_generator(returns_async_block()); - | --------------- ^^^^^^^^^^^^^^^^^^^^^ the trait `Generator<_>` is not implemented for `impl Future<Output = ()>` - | | - | required by a bound introduced by this call - | -note: required by a bound in `takes_generator` - --> $DIR/generator-not-future.rs:18:39 - | -LL | fn takes_generator<ResumeTy>(_g: impl Generator<ResumeTy, Yield = (), Return = ()>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_generator` - -error[E0277]: the trait bound `{async block@$DIR/generator-not-future.rs:35:21: 35:29}: Generator<_>` is not satisfied - --> $DIR/generator-not-future.rs:35:21 - | -LL | takes_generator(async {}); - | --------------- ^^^^^^^^ the trait `Generator<_>` is not implemented for `{async block@$DIR/generator-not-future.rs:35:21: 35:29}` - | | - | required by a bound introduced by this call - | -note: required by a bound in `takes_generator` - --> $DIR/generator-not-future.rs:18:39 - | -LL | fn takes_generator<ResumeTy>(_g: impl Generator<ResumeTy, Yield = (), Return = ()>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_generator` - -error[E0277]: `impl Generator<Yield = (), Return = ()>` is not a future - --> $DIR/generator-not-future.rs:39:18 - | -LL | takes_future(returns_generator()); - | ------------ ^^^^^^^^^^^^^^^^^^^ `impl Generator<Yield = (), Return = ()>` is not a future - | | - | required by a bound introduced by this call - | - = help: the trait `Future` is not implemented for `impl Generator<Yield = (), Return = ()>` - = note: impl Generator<Yield = (), Return = ()> must be a future or must implement `IntoFuture` to be awaited -note: required by a bound in `takes_future` - --> $DIR/generator-not-future.rs:17:26 - | -LL | fn takes_future(_f: impl Future<Output = ()>) {} - | ^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_future` - -error[E0277]: `{generator@$DIR/generator-not-future.rs:41:18: 41:23}` is not a future - --> $DIR/generator-not-future.rs:41:18 - | -LL | takes_future(|ctx| { - | _____------------_^ - | | | - | | required by a bound introduced by this call -LL | | -LL | | ctx = yield (); -LL | | }); - | |_____^ `{generator@$DIR/generator-not-future.rs:41:18: 41:23}` is not a future - | - = help: the trait `Future` is not implemented for `{generator@$DIR/generator-not-future.rs:41:18: 41:23}` - = note: {generator@$DIR/generator-not-future.rs:41:18: 41:23} must be a future or must implement `IntoFuture` to be awaited -note: required by a bound in `takes_future` - --> $DIR/generator-not-future.rs:17:26 - | -LL | fn takes_future(_f: impl Future<Output = ()>) {} - | ^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_future` - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/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/issue-60709.rs b/tests/ui/async-await/issue-60709.rs index 61f6ed1b7b2..2cda40e9e11 100644 --- a/tests/ui/async-await/issue-60709.rs +++ b/tests/ui/async-await/issue-60709.rs @@ -1,5 +1,5 @@ // This used to compile the future down to ud2, due to uninhabited types being -// handled incorrectly in generators. +// handled incorrectly in coroutines. // compile-flags: -Copt-level=z -Cdebuginfo=2 --edition=2018 // run-pass diff --git a/tests/ui/async-await/issue-61793.rs b/tests/ui/async-await/issue-61793.rs index 9180e1d811a..bb861cf60b1 100644 --- a/tests/ui/async-await/issue-61793.rs +++ b/tests/ui/async-await/issue-61793.rs @@ -1,5 +1,5 @@ // This testcase used to ICE in codegen due to inconsistent field reordering -// in the generator state, claiming a ZST field was after a non-ZST field, +// in the coroutine state, claiming a ZST field was after a non-ZST field, // while those two fields were at the same offset (which is impossible). // That is, memory ordering of `(X, ())`, but offsets of `((), X)`. diff --git a/tests/ui/async-await/issue-62658.rs b/tests/ui/async-await/issue-62658.rs index d0af01e0c00..8e6d070ea3f 100644 --- a/tests/ui/async-await/issue-62658.rs +++ b/tests/ui/async-await/issue-62658.rs @@ -1,4 +1,4 @@ -// This test created a generator whose size was not rounded to a multiple of its +// This test created a coroutine whose size was not rounded to a multiple of its // alignment. This caused an assertion error in codegen. // build-pass diff --git a/tests/ui/async-await/issue-73137.rs b/tests/ui/async-await/issue-73137.rs index c43ce2cadba..2d16f193644 100644 --- a/tests/ui/async-await/issue-73137.rs +++ b/tests/ui/async-await/issue-73137.rs @@ -28,7 +28,7 @@ fn main() { a: async { 0 }.await, }; - // An error in the generator transform caused `b` to be overwritten with `a` when `b` was + // An error in the coroutine transform caused `b` to be overwritten with `a` when `b` was // borrowed. nop(&action.b); assert_ne!(0usize, unsafe { std::mem::transmute(action.b) }); diff --git a/tests/ui/async-await/issues/issue-51719.rs b/tests/ui/async-await/issues/issue-51719.rs index 09241f982aa..1cf388cd8ab 100644 --- a/tests/ui/async-await/issues/issue-51719.rs +++ b/tests/ui/async-await/issues/issue-51719.rs @@ -1,10 +1,10 @@ // edition:2018 // -// Tests that the .await syntax can't be used to make a generator +// Tests that the .await syntax can't be used to make a coroutine async fn foo() {} -fn make_generator() { +fn make_coroutine() { let _gen = || foo().await; //~^ ERROR `await` is only allowed inside `async` functions and blocks } diff --git a/tests/ui/async-await/issues/issue-59972.rs b/tests/ui/async-await/issues/issue-59972.rs index c2e24a96b1d..f60ec04c31e 100644 --- a/tests/ui/async-await/issues/issue-59972.rs +++ b/tests/ui/async-await/issues/issue-59972.rs @@ -1,4 +1,4 @@ -// Incorrect handling of uninhabited types could cause us to mark generator +// Incorrect handling of uninhabited types could cause us to mark coroutine // types as entirely uninhabited, when they were in fact constructible. This // caused us to hit "unreachable" code (illegal instruction on x86). diff --git a/tests/ui/async-await/issues/issue-60655-latebound-regions.rs b/tests/ui/async-await/issues/issue-60655-latebound-regions.rs index 66a3b07c3bd..ee28a2733ad 100644 --- a/tests/ui/async-await/issues/issue-60655-latebound-regions.rs +++ b/tests/ui/async-await/issues/issue-60655-latebound-regions.rs @@ -19,7 +19,7 @@ async fn async_nop(_: &u8) {} pub type ServeFut = impl Future<Output=()>; -// Late bound regions occur in the generator witness type here. +// Late bound regions occur in the coroutine witness type here. fn serve() -> ServeFut { async move { let x = 5; diff --git a/tests/ui/async-await/issues/issue-64477-2.rs b/tests/ui/async-await/issues/issue-64477-2.rs index 2360b57cc45..53ec3b06566 100644 --- a/tests/ui/async-await/issues/issue-64477-2.rs +++ b/tests/ui/async-await/issues/issue-64477-2.rs @@ -2,7 +2,7 @@ // // In the past, the code generated by `format!` produced temporaries in the surrounding scope that // borrowed the arguments through `&dyn Trait`. These temporaries do not implement `Send`, which -// meant that when `format!` was used in an async block, the resulting generator was not `Send`. +// meant that when `format!` was used in an async block, the resulting coroutine was not `Send`. // See https://github.com/rust-lang/rust/issues/64477#issuecomment-534669068 for details // and https://github.com/rust-lang/rust/issues/64477#issuecomment-531882958 for an example. // diff --git a/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-completion.rs b/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-completion.rs index 725caddae0b..9ed7a5d210e 100644 --- a/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-completion.rs +++ b/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-completion.rs @@ -1,4 +1,4 @@ -// issue 65419 - Attempting to run an async fn after completion mentions generators when it should +// issue 65419 - Attempting to run an async fn after completion mentions coroutines when it should // be talking about `async fn`s instead. // run-fail @@ -8,7 +8,7 @@ // ignore-wasm no panic or subprocess support // ignore-emscripten no panic or subprocess support -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] async fn foo() { } diff --git a/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs b/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs index 5909c3a5ecc..51e9a54e48a 100644 --- a/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs +++ b/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs @@ -1,4 +1,4 @@ -// issue 65419 - Attempting to run an async fn after completion mentions generators when it should +// issue 65419 - Attempting to run an async fn after completion mentions coroutines when it should // be talking about `async fn`s instead. Should also test what happens when it panics. // run-fail @@ -8,7 +8,7 @@ // edition:2018 // ignore-wasm no panic or subprocess support -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] use std::panic; diff --git a/tests/ui/async-await/issues/issue-65419/issue-65419-generator-resume-after-completion.rs b/tests/ui/async-await/issues/issue-65419/issue-65419-coroutine-resume-after-completion.rs index 9fc5667d684..e16b86f9579 100644 --- a/tests/ui/async-await/issues/issue-65419/issue-65419-generator-resume-after-completion.rs +++ b/tests/ui/async-await/issues/issue-65419/issue-65419-coroutine-resume-after-completion.rs @@ -1,17 +1,17 @@ -// issue 65419 - Attempting to run an `async fn` after completion mentions generators when it should -// be talking about `async fn`s instead. Regression test added to make sure generators still +// issue 65419 - Attempting to run an `async fn` after completion mentions coroutines when it should +// be talking about `async fn`s instead. Regression test added to make sure coroutines still // panic when resumed after completion. // run-fail -// error-pattern:generator resumed after completion +// error-pattern:coroutine resumed after completion // edition:2018 // ignore-wasm no panic or subprocess support // ignore-emscripten no panic or subprocess support -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] use std::{ - ops::Generator, + ops::Coroutine, pin::Pin, }; 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/non-trivial-drop.rs b/tests/ui/async-await/non-trivial-drop.rs index 3fed7c972a1..1004303d5c1 100644 --- a/tests/ui/async-await/non-trivial-drop.rs +++ b/tests/ui/async-await/non-trivial-drop.rs @@ -1,7 +1,7 @@ // build-pass // edition:2018 -#![feature(generators)] +#![feature(coroutines)] fn main() { foo(); 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/async-await/send-bound-async-closure.rs b/tests/ui/async-await/send-bound-async-closure.rs index 4e9e7309be0..2ec006da359 100644 --- a/tests/ui/async-await/send-bound-async-closure.rs +++ b/tests/ui/async-await/send-bound-async-closure.rs @@ -2,7 +2,7 @@ // check-pass // This test verifies that we do not create a query cycle when typechecking has several inference -// variables that point to the same generator interior type. +// variables that point to the same coroutine interior type. use std::future::Future; use std::pin::Pin; diff --git a/tests/ui/async-await/task-context-arg.rs b/tests/ui/async-await/task-context-arg.rs index 937723ca743..45b18d56b1c 100644 --- a/tests/ui/async-await/task-context-arg.rs +++ b/tests/ui/async-await/task-context-arg.rs @@ -10,7 +10,7 @@ use std::future::Future; // The compiler produces a closure as part of this function. That closure initially takes an -// argument _task_context. Later, when the MIR for that closure is transformed into a generator +// argument _task_context. Later, when the MIR for that closure is transformed into a coroutine // state machine, _task_context is demoted to not be an argument, but just part of an unnamed // argument. If we emit debug info saying that both _task_context and the unnamed argument are both // argument number 2, then LLVM will fail with "conflicting debug info for argument". See diff --git a/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs b/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs index d067ff44704..b52939ffc11 100644 --- a/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs +++ b/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs @@ -13,10 +13,10 @@ impl MarketMultiplier { } } -async fn buy_lock(generator: &Mutex<MarketMultiplier>) -> LockedMarket<'_> { +async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_> { //~^ ERROR struct takes 0 lifetime arguments but 1 lifetime argument was supplied //~^^ ERROR struct takes 1 generic argument but 0 generic arguments were supplied - LockedMarket(generator.lock().unwrap().buy()) + LockedMarket(coroutine.lock().unwrap().buy()) } struct LockedMarket<T>(T); diff --git a/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr b/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr index 73e0aaf1e45..516c1d065e6 100644 --- a/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr +++ b/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr @@ -1,7 +1,7 @@ error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supplied --> $DIR/issue-82126-mismatched-subst-and-hir.rs:16:59 | -LL | async fn buy_lock(generator: &Mutex<MarketMultiplier>) -> LockedMarket<'_> { +LL | async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_> { | ^^^^^^^^^^^^---- help: remove these generics | | | expected 0 lifetime arguments @@ -15,7 +15,7 @@ LL | struct LockedMarket<T>(T); error[E0107]: struct takes 1 generic argument but 0 generic arguments were supplied --> $DIR/issue-82126-mismatched-subst-and-hir.rs:16:59 | -LL | async fn buy_lock(generator: &Mutex<MarketMultiplier>) -> LockedMarket<'_> { +LL | async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_> { | ^^^^^^^^^^^^ expected 1 generic argument | note: struct defined here, with 1 generic parameter: `T` @@ -25,7 +25,7 @@ LL | struct LockedMarket<T>(T); | ^^^^^^^^^^^^ - help: add missing generic argument | -LL | async fn buy_lock(generator: &Mutex<MarketMultiplier>) -> LockedMarket<'_, T> { +LL | async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_, T> { | +++ error: aborting due to 2 previous errors 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/closures/infer-signature-from-impl.next.stderr b/tests/ui/closures/infer-signature-from-impl.next.stderr new file mode 100644 index 00000000000..97351706699 --- /dev/null +++ b/tests/ui/closures/infer-signature-from-impl.next.stderr @@ -0,0 +1,16 @@ +error[E0282]: type annotations needed + --> $DIR/infer-signature-from-impl.rs:17:16 + | +LL | needs_foo(|x| { + | ^ +LL | x.to_string(); + | - type must be known at this point + | +help: consider giving this closure parameter an explicit type + | +LL | needs_foo(|x: /* Type */| { + | ++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/closures/infer-signature-from-impl.rs b/tests/ui/closures/infer-signature-from-impl.rs new file mode 100644 index 00000000000..6e8c94177bf --- /dev/null +++ b/tests/ui/closures/infer-signature-from-impl.rs @@ -0,0 +1,20 @@ +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next +//[next] known-bug: trait-system-refactor-initiative#71 +//[current] check-pass + +trait Foo {} +fn needs_foo<T>(_: T) +where + Wrap<T>: Foo, +{ +} + +struct Wrap<T>(T); +impl<T> Foo for Wrap<T> where T: Fn(i32) {} + +fn main() { + needs_foo(|x| { + x.to_string(); + }); +} diff --git a/tests/ui/closures/issue-25439.rs b/tests/ui/closures/issue-25439.rs index 4f73ff3e38b..0269270b1b0 100644 --- a/tests/ui/closures/issue-25439.rs +++ b/tests/ui/closures/issue-25439.rs @@ -5,5 +5,5 @@ fn fix<F>(f: F) -> i32 where F: Fn(Helper<F>, i32) -> i32 { } fn main() { - fix(|_, x| x); //~ ERROR closure/generator type that references itself [E0644] + fix(|_, x| x); //~ ERROR closure/coroutine type that references itself [E0644] } diff --git a/tests/ui/closures/issue-25439.stderr b/tests/ui/closures/issue-25439.stderr index dadae23fdf3..5e889e6c184 100644 --- a/tests/ui/closures/issue-25439.stderr +++ b/tests/ui/closures/issue-25439.stderr @@ -1,4 +1,4 @@ -error[E0644]: closure/generator type that references itself +error[E0644]: closure/coroutine type that references itself --> $DIR/issue-25439.rs:8:9 | LL | fix(|_, x| x); diff --git a/tests/ui/coherence/coherence-with-generator.rs b/tests/ui/coherence/coherence-with-coroutine.rs index 5eb8dc2a468..21857d7fe66 100644 --- a/tests/ui/coherence/coherence-with-generator.rs +++ b/tests/ui/coherence/coherence-with-coroutine.rs @@ -1,13 +1,13 @@ // Test that encountering closures during coherence does not cause issues. -#![feature(type_alias_impl_trait, generators)] +#![feature(type_alias_impl_trait, coroutines)] #![cfg_attr(specialized, feature(specialization))] #![allow(incomplete_features)] // revisions: stock specialized // [specialized]check-pass -type OpaqueGenerator = impl Sized; -fn defining_use() -> OpaqueGenerator { +type OpaqueCoroutine = impl Sized; +fn defining_use() -> OpaqueCoroutine { || { for i in 0..10 { yield i; @@ -17,8 +17,8 @@ fn defining_use() -> OpaqueGenerator { struct Wrapper<T>(T); trait Trait {} -impl Trait for Wrapper<OpaqueGenerator> {} +impl Trait for Wrapper<OpaqueCoroutine> {} impl<T: Sync> Trait for Wrapper<T> {} -//[stock]~^ ERROR conflicting implementations of trait `Trait` for type `Wrapper<OpaqueGenerator>` +//[stock]~^ ERROR conflicting implementations of trait `Trait` for type `Wrapper<OpaqueCoroutine>` fn main() {} diff --git a/tests/ui/coherence/coherence-with-generator.stock.stderr b/tests/ui/coherence/coherence-with-coroutine.stock.stderr index 478ac491264..b2a9135c542 100644 --- a/tests/ui/coherence/coherence-with-generator.stock.stderr +++ b/tests/ui/coherence/coherence-with-coroutine.stock.stderr @@ -1,10 +1,10 @@ -error[E0119]: conflicting implementations of trait `Trait` for type `Wrapper<OpaqueGenerator>` - --> $DIR/coherence-with-generator.rs:21:1 +error[E0119]: conflicting implementations of trait `Trait` for type `Wrapper<OpaqueCoroutine>` + --> $DIR/coherence-with-coroutine.rs:21:1 | -LL | impl Trait for Wrapper<OpaqueGenerator> {} +LL | impl Trait for Wrapper<OpaqueCoroutine> {} | --------------------------------------- first implementation here LL | impl<T: Sync> Trait for Wrapper<T> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Wrapper<OpaqueGenerator>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Wrapper<OpaqueCoroutine>` error: aborting due to previous error 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/generator/addassign-yield.rs b/tests/ui/coroutine/addassign-yield.rs index 66f22bf31fc..919a559f85b 100644 --- a/tests/ui/generator/addassign-yield.rs +++ b/tests/ui/coroutine/addassign-yield.rs @@ -5,7 +5,7 @@ // is being used), we were failing to account for all types that might // possibly be live across a yield point. -#![feature(generators)] +#![feature(coroutines)] fn foo() { let _x = static || { diff --git a/tests/ui/coroutine/async-coroutine-issue-67158.rs b/tests/ui/coroutine/async-coroutine-issue-67158.rs new file mode 100644 index 00000000000..420454656d4 --- /dev/null +++ b/tests/ui/coroutine/async-coroutine-issue-67158.rs @@ -0,0 +1,6 @@ +#![feature(coroutines)] +// edition:2018 +// Regression test for #67158. +fn main() { + async { yield print!(":C") }; //~ ERROR `async` coroutines are not yet supported +} diff --git a/tests/ui/generator/async-generator-issue-67158.stderr b/tests/ui/coroutine/async-coroutine-issue-67158.stderr index 7270d188e8b..d583d3d5ea0 100644 --- a/tests/ui/generator/async-generator-issue-67158.stderr +++ b/tests/ui/coroutine/async-coroutine-issue-67158.stderr @@ -1,5 +1,5 @@ -error[E0727]: `async` generators are not yet supported - --> $DIR/async-generator-issue-67158.rs:5:13 +error[E0727]: `async` coroutines are not yet supported + --> $DIR/async-coroutine-issue-67158.rs:5:13 | LL | async { yield print!(":C") }; | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/generator/auto-trait-regions.rs b/tests/ui/coroutine/auto-trait-regions.rs index aa4218e13a4..5fce70e8e54 100644 --- a/tests/ui/generator/auto-trait-regions.rs +++ b/tests/ui/coroutine/auto-trait-regions.rs @@ -1,4 +1,4 @@ -#![feature(generators)] +#![feature(coroutines)] #![feature(auto_traits)] #![feature(negative_impls)] @@ -21,7 +21,7 @@ impl<'a> Foo for &'a OnlyFooIfRef {} fn assert_foo<T: Foo>(f: T) {} fn main() { - // Make sure 'static is erased for generator interiors so we can't match it in trait selection + // Make sure 'static is erased for coroutine interiors so we can't match it in trait selection let x: &'static _ = &OnlyFooIfStaticRef(No); let gen = move || { let x = x; @@ -40,7 +40,7 @@ fn main() { }; assert_foo(gen); // ok - // Disallow impls which relates lifetimes in the generator interior + // Disallow impls which relates lifetimes in the coroutine interior let gen = move || { let a = A(&mut true, &mut true, No); //~^ temporary value dropped while borrowed diff --git a/tests/ui/generator/auto-trait-regions.stderr b/tests/ui/coroutine/auto-trait-regions.stderr index a9a0bde2ba0..a9a0bde2ba0 100644 --- a/tests/ui/generator/auto-trait-regions.stderr +++ b/tests/ui/coroutine/auto-trait-regions.stderr diff --git a/tests/ui/coroutine/auxiliary/metadata-sufficient-for-layout.rs b/tests/ui/coroutine/auxiliary/metadata-sufficient-for-layout.rs new file mode 100644 index 00000000000..dc052185340 --- /dev/null +++ b/tests/ui/coroutine/auxiliary/metadata-sufficient-for-layout.rs @@ -0,0 +1,11 @@ +// compile-flags: --emit metadata +#![feature(coroutines, coroutine_trait)] + +use std::marker::Unpin; +use std::ops::Coroutine; + +pub fn g() -> impl Coroutine<(), Yield = (), Return = ()> { + || { + yield; + } +} diff --git a/tests/ui/coroutine/auxiliary/xcrate-reachable.rs b/tests/ui/coroutine/auxiliary/xcrate-reachable.rs new file mode 100644 index 00000000000..673153f0619 --- /dev/null +++ b/tests/ui/coroutine/auxiliary/xcrate-reachable.rs @@ -0,0 +1,14 @@ +#![feature(coroutines, coroutine_trait)] + +use std::ops::Coroutine; + +fn msg() -> u32 { + 0 +} + +pub fn foo() -> impl Coroutine<(), Yield = (), Return = u32> { + || { + yield; + return msg(); + } +} diff --git a/tests/ui/coroutine/auxiliary/xcrate.rs b/tests/ui/coroutine/auxiliary/xcrate.rs new file mode 100644 index 00000000000..f749a95ad35 --- /dev/null +++ b/tests/ui/coroutine/auxiliary/xcrate.rs @@ -0,0 +1,18 @@ +#![feature(coroutines, coroutine_trait)] + +use std::marker::Unpin; +use std::ops::Coroutine; + +pub fn foo() -> impl Coroutine<(), Yield = (), Return = ()> { + || { + if false { + yield; + } + } +} + +pub fn bar<T: 'static>(t: T) -> Box<Coroutine<(), Yield = T, Return = ()> + Unpin> { + Box::new(|| { + yield t; + }) +} diff --git a/tests/ui/generator/borrow-in-tail-expr.rs b/tests/ui/coroutine/borrow-in-tail-expr.rs index 540f5e3e1dd..c1497ad2911 100644 --- a/tests/ui/generator/borrow-in-tail-expr.rs +++ b/tests/ui/coroutine/borrow-in-tail-expr.rs @@ -1,6 +1,6 @@ // run-pass -#![feature(generators)] +#![feature(coroutines)] fn main() { let _a = || { diff --git a/tests/ui/generator/borrowing.rs b/tests/ui/coroutine/borrowing.rs index d36592583cd..778eed8bd0d 100644 --- a/tests/ui/generator/borrowing.rs +++ b/tests/ui/coroutine/borrowing.rs @@ -1,6 +1,6 @@ -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; fn main() { diff --git a/tests/ui/generator/borrowing.stderr b/tests/ui/coroutine/borrowing.stderr index 03a69fe3623..192ffaaa26b 100644 --- a/tests/ui/generator/borrowing.stderr +++ b/tests/ui/coroutine/borrowing.stderr @@ -5,11 +5,11 @@ LL | Pin::new(&mut || yield &a).resume(()) | ----------^ | | | | | borrowed value does not live long enough - | value captured here by generator + | value captured here by coroutine | a temporary with access to the borrow is created here ... LL | LL | }; - | -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for generator + | -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for coroutine | | | `a` dropped here while still borrowed | @@ -27,7 +27,7 @@ LL | let _b = { | -- borrow later stored here LL | let a = 3; LL | || { - | -- value captured here by generator + | -- value captured here by coroutine LL | yield &a | ^ borrowed value does not live long enough ... diff --git a/tests/ui/generator/clone-impl-async.rs b/tests/ui/coroutine/clone-impl-async.rs index 9e9b59d3633..e8e82f1994d 100644 --- a/tests/ui/generator/clone-impl-async.rs +++ b/tests/ui/coroutine/clone-impl-async.rs @@ -1,8 +1,8 @@ // edition:2021 -// gate-test-generator_clone -// Verifies that feature(generator_clone) doesn't allow async blocks to be cloned/copied. +// gate-test-coroutine_clone +// Verifies that feature(coroutine_clone) doesn't allow async blocks to be cloned/copied. -#![feature(generators, generator_clone)] +#![feature(coroutines, coroutine_clone)] use std::future::ready; diff --git a/tests/ui/generator/clone-impl-async.stderr b/tests/ui/coroutine/clone-impl-async.stderr index d172dff3abd..d172dff3abd 100644 --- a/tests/ui/generator/clone-impl-async.stderr +++ b/tests/ui/coroutine/clone-impl-async.stderr diff --git a/tests/ui/generator/clone-impl-static.rs b/tests/ui/coroutine/clone-impl-static.rs index 55ed0f281e0..9a165cf4672 100644 --- a/tests/ui/generator/clone-impl-static.rs +++ b/tests/ui/coroutine/clone-impl-static.rs @@ -1,7 +1,7 @@ -// gate-test-generator_clone -// Verifies that static generators cannot be cloned/copied. +// gate-test-coroutine_clone +// Verifies that static coroutines cannot be cloned/copied. -#![feature(generators, generator_clone)] +#![feature(coroutines, coroutine_clone)] fn main() { let gen = static move || { diff --git a/tests/ui/generator/clone-impl-static.stderr b/tests/ui/coroutine/clone-impl-static.stderr index 8b51824c7d2..8fa9fb12bf6 100644 --- a/tests/ui/generator/clone-impl-static.stderr +++ b/tests/ui/coroutine/clone-impl-static.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `{static generator@$DIR/clone-impl-static.rs:7:15: 7:29}: Copy` is not satisfied +error[E0277]: the trait bound `{static coroutine@$DIR/clone-impl-static.rs:7:15: 7:29}: Copy` is not satisfied --> $DIR/clone-impl-static.rs:10:16 | LL | check_copy(&gen); - | ---------- ^^^^ the trait `Copy` is not implemented for `{static generator@$DIR/clone-impl-static.rs:7:15: 7:29}` + | ---------- ^^^^ the trait `Copy` is not implemented for `{static coroutine@$DIR/clone-impl-static.rs:7:15: 7:29}` | | | required by a bound introduced by this call | @@ -12,11 +12,11 @@ note: required by a bound in `check_copy` LL | fn check_copy<T: Copy>(_x: &T) {} | ^^^^ required by this bound in `check_copy` -error[E0277]: the trait bound `{static generator@$DIR/clone-impl-static.rs:7:15: 7:29}: Clone` is not satisfied +error[E0277]: the trait bound `{static coroutine@$DIR/clone-impl-static.rs:7:15: 7:29}: Clone` is not satisfied --> $DIR/clone-impl-static.rs:12:17 | LL | check_clone(&gen); - | ----------- ^^^^ the trait `Clone` is not implemented for `{static generator@$DIR/clone-impl-static.rs:7:15: 7:29}` + | ----------- ^^^^ the trait `Clone` is not implemented for `{static coroutine@$DIR/clone-impl-static.rs:7:15: 7:29}` | | | required by a bound introduced by this call | diff --git a/tests/ui/generator/clone-impl.rs b/tests/ui/coroutine/clone-impl.rs index cbfd65a5309..eed6f851bd0 100644 --- a/tests/ui/generator/clone-impl.rs +++ b/tests/ui/coroutine/clone-impl.rs @@ -1,8 +1,8 @@ -// gate-test-generator_clone -// Verifies that non-static generators can be cloned/copied if all their upvars and locals held +// gate-test-coroutine_clone +// Verifies that non-static coroutines can be cloned/copied if all their upvars and locals held // across awaits can be cloned/copied. -#![feature(generators, generator_clone)] +#![feature(coroutines, coroutine_clone)] struct NonClone; diff --git a/tests/ui/generator/clone-impl.stderr b/tests/ui/coroutine/clone-impl.stderr index 870216398b1..82a6d0495c0 100644 --- a/tests/ui/generator/clone-impl.stderr +++ b/tests/ui/coroutine/clone-impl.stderr @@ -1,11 +1,11 @@ -error[E0277]: the trait bound `Vec<u32>: Copy` is not satisfied in `{generator@$DIR/clone-impl.rs:36:23: 36:30}` +error[E0277]: the trait bound `Vec<u32>: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:36:23: 36:30}` --> $DIR/clone-impl.rs:42:5 | LL | let gen_clone_0 = move || { - | ------- within this `{generator@$DIR/clone-impl.rs:36:23: 36:30}` + | ------- within this `{coroutine@$DIR/clone-impl.rs:36:23: 36:30}` ... LL | check_copy(&gen_clone_0); - | ^^^^^^^^^^ within `{generator@$DIR/clone-impl.rs:36:23: 36:30}`, the trait `Copy` is not implemented for `Vec<u32>` + | ^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:36:23: 36:30}`, the trait `Copy` is not implemented for `Vec<u32>` | note: captured value does not implement `Copy` --> $DIR/clone-impl.rs:40:14 @@ -18,16 +18,16 @@ note: required by a bound in `check_copy` LL | fn check_copy<T: Copy>(_x: &T) {} | ^^^^ required by this bound in `check_copy` -error[E0277]: the trait bound `Vec<char>: Copy` is not satisfied in `{generator@$DIR/clone-impl.rs:36:23: 36:30}` +error[E0277]: the trait bound `Vec<char>: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:36:23: 36:30}` --> $DIR/clone-impl.rs:42:5 | LL | let gen_clone_0 = move || { - | ------- within this `{generator@$DIR/clone-impl.rs:36:23: 36:30}` + | ------- within this `{coroutine@$DIR/clone-impl.rs:36:23: 36:30}` ... LL | check_copy(&gen_clone_0); - | ^^^^^^^^^^ within `{generator@$DIR/clone-impl.rs:36:23: 36:30}`, the trait `Copy` is not implemented for `Vec<char>` + | ^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:36:23: 36:30}`, the trait `Copy` is not implemented for `Vec<char>` | -note: generator does not implement `Copy` as this value is used across a yield +note: coroutine does not implement `Copy` as this value is used across a yield --> $DIR/clone-impl.rs:38:9 | LL | let v = vec!['a']; @@ -40,14 +40,14 @@ note: required by a bound in `check_copy` LL | fn check_copy<T: Copy>(_x: &T) {} | ^^^^ required by this bound in `check_copy` -error[E0277]: the trait bound `Vec<u32>: Copy` is not satisfied in `{generator@$DIR/clone-impl.rs:46:23: 46:30}` +error[E0277]: the trait bound `Vec<u32>: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:46:23: 46:30}` --> $DIR/clone-impl.rs:58:5 | LL | let gen_clone_1 = move || { - | ------- within this `{generator@$DIR/clone-impl.rs:46:23: 46:30}` + | ------- within this `{coroutine@$DIR/clone-impl.rs:46:23: 46:30}` ... LL | check_copy(&gen_clone_1); - | ^^^^^^^^^^ within `{generator@$DIR/clone-impl.rs:46:23: 46:30}`, the trait `Copy` is not implemented for `Vec<u32>` + | ^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:46:23: 46:30}`, the trait `Copy` is not implemented for `Vec<u32>` | note: captured value does not implement `Copy` --> $DIR/clone-impl.rs:56:14 @@ -60,16 +60,16 @@ note: required by a bound in `check_copy` LL | fn check_copy<T: Copy>(_x: &T) {} | ^^^^ required by this bound in `check_copy` -error[E0277]: the trait bound `Vec<char>: Copy` is not satisfied in `{generator@$DIR/clone-impl.rs:46:23: 46:30}` +error[E0277]: the trait bound `Vec<char>: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:46:23: 46:30}` --> $DIR/clone-impl.rs:58:5 | LL | let gen_clone_1 = move || { - | ------- within this `{generator@$DIR/clone-impl.rs:46:23: 46:30}` + | ------- within this `{coroutine@$DIR/clone-impl.rs:46:23: 46:30}` ... LL | check_copy(&gen_clone_1); - | ^^^^^^^^^^ within `{generator@$DIR/clone-impl.rs:46:23: 46:30}`, the trait `Copy` is not implemented for `Vec<char>` + | ^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:46:23: 46:30}`, the trait `Copy` is not implemented for `Vec<char>` | -note: generator does not implement `Copy` as this value is used across a yield +note: coroutine does not implement `Copy` as this value is used across a yield --> $DIR/clone-impl.rs:52:9 | LL | let v = vec!['a']; @@ -83,14 +83,14 @@ note: required by a bound in `check_copy` LL | fn check_copy<T: Copy>(_x: &T) {} | ^^^^ required by this bound in `check_copy` -error[E0277]: the trait bound `NonClone: Copy` is not satisfied in `{generator@$DIR/clone-impl.rs:62:25: 62:32}` +error[E0277]: the trait bound `NonClone: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:62:25: 62:32}` --> $DIR/clone-impl.rs:66:5 | LL | let gen_non_clone = move || { - | ------- within this `{generator@$DIR/clone-impl.rs:62:25: 62:32}` + | ------- within this `{coroutine@$DIR/clone-impl.rs:62:25: 62:32}` ... LL | check_copy(&gen_non_clone); - | ^^^^^^^^^^ within `{generator@$DIR/clone-impl.rs:62:25: 62:32}`, the trait `Copy` is not implemented for `NonClone` + | ^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:62:25: 62:32}`, the trait `Copy` is not implemented for `NonClone` | note: captured value does not implement `Copy` --> $DIR/clone-impl.rs:64:14 @@ -108,14 +108,14 @@ LL + #[derive(Copy)] LL | struct NonClone; | -error[E0277]: the trait bound `NonClone: Clone` is not satisfied in `{generator@$DIR/clone-impl.rs:62:25: 62:32}` +error[E0277]: the trait bound `NonClone: Clone` is not satisfied in `{coroutine@$DIR/clone-impl.rs:62:25: 62:32}` --> $DIR/clone-impl.rs:68:5 | LL | let gen_non_clone = move || { - | ------- within this `{generator@$DIR/clone-impl.rs:62:25: 62:32}` + | ------- within this `{coroutine@$DIR/clone-impl.rs:62:25: 62:32}` ... LL | check_clone(&gen_non_clone); - | ^^^^^^^^^^^ within `{generator@$DIR/clone-impl.rs:62:25: 62:32}`, the trait `Clone` is not implemented for `NonClone` + | ^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:62:25: 62:32}`, the trait `Clone` is not implemented for `NonClone` | note: captured value does not implement `Clone` --> $DIR/clone-impl.rs:64:14 diff --git a/tests/ui/generator/conditional-drop.rs b/tests/ui/coroutine/conditional-drop.rs index 0927df86927..634095c7acc 100644 --- a/tests/ui/generator/conditional-drop.rs +++ b/tests/ui/coroutine/conditional-drop.rs @@ -3,9 +3,9 @@ // revisions: default nomiropt //[nomiropt]compile-flags: -Z mir-opt-level=0 -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; use std::sync::atomic::{AtomicUsize, Ordering}; diff --git a/tests/ui/generator/control-flow.rs b/tests/ui/coroutine/control-flow.rs index 4f69c785560..709b135b2ee 100644 --- a/tests/ui/generator/control-flow.rs +++ b/tests/ui/coroutine/control-flow.rs @@ -3,19 +3,19 @@ // revisions: default nomiropt //[nomiropt]compile-flags: -Z mir-opt-level=0 -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] use std::marker::Unpin; -use std::ops::{GeneratorState, Generator}; +use std::ops::{CoroutineState, Coroutine}; use std::pin::Pin; fn finish<T>(mut amt: usize, mut t: T) -> T::Return - where T: Generator<(), Yield = ()> + Unpin, + where T: Coroutine<(), Yield = ()> + Unpin, { loop { match Pin::new(&mut t).resume(()) { - GeneratorState::Yielded(()) => amt = amt.checked_sub(1).unwrap(), - GeneratorState::Complete(ret) => { + CoroutineState::Yielded(()) => amt = amt.checked_sub(1).unwrap(), + CoroutineState::Complete(ret) => { assert_eq!(amt, 0); return ret } diff --git a/tests/ui/generator/generator-region-requirements.migrate.stderr b/tests/ui/coroutine/coroutine-region-requirements.migrate.stderr index 8a96d187f6b..8a96d187f6b 100644 --- a/tests/ui/generator/generator-region-requirements.migrate.stderr +++ b/tests/ui/coroutine/coroutine-region-requirements.migrate.stderr diff --git a/tests/ui/generator/generator-region-requirements.rs b/tests/ui/coroutine/coroutine-region-requirements.rs index 7269a79ca3f..8bc34fdd2f0 100644 --- a/tests/ui/generator/generator-region-requirements.rs +++ b/tests/ui/coroutine/coroutine-region-requirements.rs @@ -1,5 +1,5 @@ -#![feature(generators, generator_trait)] -use std::ops::{Generator, GeneratorState}; +#![feature(coroutines, coroutine_trait)] +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; fn dangle(x: &mut i32) -> &'static mut i32 { @@ -9,9 +9,9 @@ fn dangle(x: &mut i32) -> &'static mut i32 { }; loop { match Pin::new(&mut g).resume(()) { - GeneratorState::Complete(c) => return c, + CoroutineState::Complete(c) => return c, //~^ ERROR lifetime may not live long enough - GeneratorState::Yielded(_) => (), + CoroutineState::Yielded(_) => (), } } } diff --git a/tests/ui/generator/generator-region-requirements.stderr b/tests/ui/coroutine/coroutine-region-requirements.stderr index 87f60467287..ad3183e7612 100644 --- a/tests/ui/generator/generator-region-requirements.stderr +++ b/tests/ui/coroutine/coroutine-region-requirements.stderr @@ -1,10 +1,10 @@ error: lifetime may not live long enough - --> $DIR/generator-region-requirements.rs:12:51 + --> $DIR/coroutine-region-requirements.rs:12:51 | LL | fn dangle(x: &mut i32) -> &'static mut i32 { | - let's call the lifetime of this reference `'1` ... -LL | GeneratorState::Complete(c) => return c, +LL | CoroutineState::Complete(c) => return c, | ^ returning this value requires that `'1` must outlive `'static` error: aborting due to previous error diff --git a/tests/ui/generator/generator-resume-after-panic.rs b/tests/ui/coroutine/coroutine-resume-after-panic.rs index f2e67f1f750..5915f5ad9a9 100644 --- a/tests/ui/generator/generator-resume-after-panic.rs +++ b/tests/ui/coroutine/coroutine-resume-after-panic.rs @@ -1,14 +1,14 @@ // run-fail // needs-unwind -// error-pattern:generator resumed after panicking +// error-pattern:coroutine resumed after panicking // ignore-emscripten no processes -// Test that we get the correct message for resuming a panicked generator. +// Test that we get the correct message for resuming a panicked coroutine. -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] use std::{ - ops::Generator, + ops::Coroutine, pin::Pin, panic, }; diff --git a/tests/ui/generator/generator-with-nll.rs b/tests/ui/coroutine/coroutine-with-nll.rs index cee3e6d226c..28a3643fbc9 100644 --- a/tests/ui/generator/generator-with-nll.rs +++ b/tests/ui/coroutine/coroutine-with-nll.rs @@ -1,11 +1,11 @@ -#![feature(generators)] +#![feature(coroutines)] fn main() { || { // The reference in `_a` is a Legal with NLL since it ends before the yield let _a = &mut true; let b = &mut true; - //~^ borrow may still be in use when generator yields + //~^ borrow may still be in use when coroutine yields yield (); println!("{}", b); }; diff --git a/tests/ui/generator/generator-with-nll.stderr b/tests/ui/coroutine/coroutine-with-nll.stderr index 14199aeb930..ed58debe2b4 100644 --- a/tests/ui/generator/generator-with-nll.stderr +++ b/tests/ui/coroutine/coroutine-with-nll.stderr @@ -1,5 +1,5 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/generator-with-nll.rs:7:17 +error[E0626]: borrow may still be in use when coroutine yields + --> $DIR/coroutine-with-nll.rs:7:17 | LL | let b = &mut true; | ^^^^^^^^^ diff --git a/tests/ui/coroutine/coroutine-yielding-or-returning-itself.rs b/tests/ui/coroutine/coroutine-yielding-or-returning-itself.rs new file mode 100644 index 00000000000..3c91b3c9329 --- /dev/null +++ b/tests/ui/coroutine/coroutine-yielding-or-returning-itself.rs @@ -0,0 +1,35 @@ +#![feature(coroutine_trait)] +#![feature(coroutines)] + +// Test that we cannot create a coroutine that returns a value of its +// own type. + +use std::ops::Coroutine; + +pub fn want_cyclic_coroutine_return<T>(_: T) + where T: Coroutine<Yield = (), Return = T> +{ +} + +fn supply_cyclic_coroutine_return() { + want_cyclic_coroutine_return(|| { + //~^ ERROR type mismatch + if false { yield None.unwrap(); } + None.unwrap() + }) +} + +pub fn want_cyclic_coroutine_yield<T>(_: T) + where T: Coroutine<Yield = T, Return = ()> +{ +} + +fn supply_cyclic_coroutine_yield() { + want_cyclic_coroutine_yield(|| { + //~^ ERROR type mismatch + if false { yield None.unwrap(); } + None.unwrap() + }) +} + +fn main() { } diff --git a/tests/ui/generator/generator-yielding-or-returning-itself.stderr b/tests/ui/coroutine/coroutine-yielding-or-returning-itself.stderr index 7841a0854ca..325030524ba 100644 --- a/tests/ui/generator/generator-yielding-or-returning-itself.stderr +++ b/tests/ui/coroutine/coroutine-yielding-or-returning-itself.stderr @@ -1,7 +1,7 @@ -error[E0271]: type mismatch resolving `<{generator@$DIR/generator-yielding-or-returning-itself.rs:15:34: 15:36} as Generator>::Return == {generator@$DIR/generator-yielding-or-returning-itself.rs:15:34: 15:36}` - --> $DIR/generator-yielding-or-returning-itself.rs:15:34 +error[E0271]: type mismatch resolving `<{coroutine@$DIR/coroutine-yielding-or-returning-itself.rs:15:34: 15:36} as Coroutine>::Return == {coroutine@$DIR/coroutine-yielding-or-returning-itself.rs:15:34: 15:36}` + --> $DIR/coroutine-yielding-or-returning-itself.rs:15:34 | -LL | want_cyclic_generator_return(|| { +LL | want_cyclic_coroutine_return(|| { | _____----------------------------_^ | | | | | required by a bound introduced by this call @@ -15,18 +15,18 @@ LL | | }) this error may be the result of a recent compiler bug-fix, see issue #46062 <https://github.com/rust-lang/rust/issues/46062> for more information -note: required by a bound in `want_cyclic_generator_return` - --> $DIR/generator-yielding-or-returning-itself.rs:10:36 +note: required by a bound in `want_cyclic_coroutine_return` + --> $DIR/coroutine-yielding-or-returning-itself.rs:10:36 | -LL | pub fn want_cyclic_generator_return<T>(_: T) +LL | pub fn want_cyclic_coroutine_return<T>(_: T) | ---------------------------- required by a bound in this function -LL | where T: Generator<Yield = (), Return = T> - | ^^^^^^^^^^ required by this bound in `want_cyclic_generator_return` +LL | where T: Coroutine<Yield = (), Return = T> + | ^^^^^^^^^^ required by this bound in `want_cyclic_coroutine_return` -error[E0271]: type mismatch resolving `<{generator@$DIR/generator-yielding-or-returning-itself.rs:28:33: 28:35} as Generator>::Yield == {generator@$DIR/generator-yielding-or-returning-itself.rs:28:33: 28:35}` - --> $DIR/generator-yielding-or-returning-itself.rs:28:33 +error[E0271]: type mismatch resolving `<{coroutine@$DIR/coroutine-yielding-or-returning-itself.rs:28:33: 28:35} as Coroutine>::Yield == {coroutine@$DIR/coroutine-yielding-or-returning-itself.rs:28:33: 28:35}` + --> $DIR/coroutine-yielding-or-returning-itself.rs:28:33 | -LL | want_cyclic_generator_yield(|| { +LL | want_cyclic_coroutine_yield(|| { | _____---------------------------_^ | | | | | required by a bound introduced by this call @@ -40,13 +40,13 @@ LL | | }) this error may be the result of a recent compiler bug-fix, see issue #46062 <https://github.com/rust-lang/rust/issues/46062> for more information -note: required by a bound in `want_cyclic_generator_yield` - --> $DIR/generator-yielding-or-returning-itself.rs:23:24 +note: required by a bound in `want_cyclic_coroutine_yield` + --> $DIR/coroutine-yielding-or-returning-itself.rs:23:24 | -LL | pub fn want_cyclic_generator_yield<T>(_: T) +LL | pub fn want_cyclic_coroutine_yield<T>(_: T) | --------------------------- required by a bound in this function -LL | where T: Generator<Yield = T, Return = ()> - | ^^^^^^^^^ required by this bound in `want_cyclic_generator_yield` +LL | where T: Coroutine<Yield = T, Return = ()> + | ^^^^^^^^^ required by this bound in `want_cyclic_coroutine_yield` error: aborting due to 2 previous errors diff --git a/tests/ui/generator/derived-drop-parent-expr.rs b/tests/ui/coroutine/derived-drop-parent-expr.rs index e381924517d..59a3e847838 100644 --- a/tests/ui/generator/derived-drop-parent-expr.rs +++ b/tests/ui/coroutine/derived-drop-parent-expr.rs @@ -1,7 +1,7 @@ // build-pass //! Like drop-tracking-parent-expression, but also tests that this doesn't ICE when building MIR -#![feature(generators)] +#![feature(coroutines)] fn assert_send<T: Send>(_thing: T) {} diff --git a/tests/ui/generator/discriminant.rs b/tests/ui/coroutine/discriminant.rs index 195e7702299..73bdd9c8671 100644 --- a/tests/ui/generator/discriminant.rs +++ b/tests/ui/coroutine/discriminant.rs @@ -1,12 +1,12 @@ -//! Tests that generator discriminant sizes and ranges are chosen optimally and that they are +//! Tests that coroutine discriminant sizes and ranges are chosen optimally and that they are //! reflected in the output of `mem::discriminant`. // run-pass -#![feature(generators, generator_trait, core_intrinsics, discriminant_kind)] +#![feature(coroutines, coroutine_trait, core_intrinsics, discriminant_kind)] use std::intrinsics::discriminant_value; -use std::marker::{Unpin, DiscriminantKind}; +use std::marker::{DiscriminantKind, Unpin}; use std::mem::size_of_val; use std::{cmp, ops::*}; @@ -66,16 +66,16 @@ macro_rules! yield250 { } fn cycle( - gen: impl Generator<()> + Unpin + DiscriminantKind<Discriminant = u32>, - expected_max_discr: u32 + gen: impl Coroutine<()> + Unpin + DiscriminantKind<Discriminant = u32>, + expected_max_discr: u32, ) { let mut gen = Box::pin(gen); let mut max_discr = 0; loop { max_discr = cmp::max(max_discr, discriminant_value(gen.as_mut().get_mut())); match gen.as_mut().resume(()) { - GeneratorState::Yielded(_) => {} - GeneratorState::Complete(_) => { + CoroutineState::Yielded(_) => {} + CoroutineState::Complete(_) => { assert_eq!(max_discr, expected_max_discr); return; } diff --git a/tests/ui/generator/drop-and-replace.rs b/tests/ui/coroutine/drop-and-replace.rs index a9a50a122a1..38b757fac29 100644 --- a/tests/ui/generator/drop-and-replace.rs +++ b/tests/ui/coroutine/drop-and-replace.rs @@ -1,19 +1,19 @@ // run-pass // Regression test for incorrect DropAndReplace behavior introduced in #60840 // and fixed in #61373. When combined with the optimization implemented in -// #60187, this produced incorrect code for generators when a saved local was +// #60187, this produced incorrect code for coroutines when a saved local was // re-assigned. -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; #[derive(Debug, PartialEq)] struct Foo(i32); impl Drop for Foo { - fn drop(&mut self) { } + fn drop(&mut self) {} } fn main() { @@ -38,7 +38,7 @@ fn main() { loop { match Pin::new(&mut a).resume(()) { - GeneratorState::Complete(()) => break, + CoroutineState::Complete(()) => break, _ => (), } } diff --git a/tests/ui/generator/drop-control-flow.rs b/tests/ui/coroutine/drop-control-flow.rs index 1c25c06ba4c..55d08b8d5b5 100644 --- a/tests/ui/generator/drop-control-flow.rs +++ b/tests/ui/coroutine/drop-control-flow.rs @@ -1,10 +1,10 @@ // build-pass -// A test to ensure generators capture values that were conditionally dropped, +// A test to ensure coroutines capture values that were conditionally dropped, // and also that values that are dropped along all paths to a yield do not get -// included in the generator type. +// included in the coroutine type. -#![feature(generators, negative_impls)] +#![feature(coroutines, negative_impls)] #![allow(unused_assignments, dead_code)] struct Ptr; diff --git a/tests/ui/generator/drop-env.rs b/tests/ui/coroutine/drop-env.rs index 137a407931a..404c043431d 100644 --- a/tests/ui/generator/drop-env.rs +++ b/tests/ui/coroutine/drop-env.rs @@ -3,10 +3,10 @@ // revisions: default nomiropt //[nomiropt]compile-flags: -Z mir-opt-level=0 -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] #![allow(dropping_copy_types)] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; use std::sync::atomic::{AtomicUsize, Ordering}; diff --git a/tests/ui/generator/drop-track-addassign-yield.rs b/tests/ui/coroutine/drop-track-addassign-yield.rs index 1e64f1d2ec7..6c5897458ec 100644 --- a/tests/ui/generator/drop-track-addassign-yield.rs +++ b/tests/ui/coroutine/drop-track-addassign-yield.rs @@ -3,7 +3,7 @@ // Based on addassign-yield.rs, but with drop tracking enabled. Originally we did not implement // the fake_read callback on ExprUseVisitor which caused this case to break. -#![feature(generators)] +#![feature(coroutines)] fn foo() { let _y = static || { diff --git a/tests/ui/generator/drop-tracking-parent-expression.rs b/tests/ui/coroutine/drop-tracking-parent-expression.rs index 198b14528aa..4d40192c07a 100644 --- a/tests/ui/generator/drop-tracking-parent-expression.rs +++ b/tests/ui/coroutine/drop-tracking-parent-expression.rs @@ -1,4 +1,4 @@ -#![feature(generators, negative_impls, rustc_attrs)] +#![feature(coroutines, negative_impls, rustc_attrs)] macro_rules! type_combinations { ( diff --git a/tests/ui/generator/drop-tracking-parent-expression.stderr b/tests/ui/coroutine/drop-tracking-parent-expression.stderr index e85bb1347a7..6cd4ec83377 100644 --- a/tests/ui/generator/drop-tracking-parent-expression.stderr +++ b/tests/ui/coroutine/drop-tracking-parent-expression.stderr @@ -1,8 +1,8 @@ -error: generator cannot be sent between threads safely +error: coroutine cannot be sent between threads safely --> $DIR/drop-tracking-parent-expression.rs:23:13 | LL | assert_send(g); - | ^^^^^^^^^^^ generator is not `Send` + | ^^^^^^^^^^^ coroutine is not `Send` ... LL | / type_combinations!( LL | | // OK @@ -13,8 +13,8 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:17:21: 17:28}`, the trait `Send` is not implemented for `derived_drop::Client` -note: generator is not `Send` as this value is used across a yield + = help: within `{coroutine@$DIR/drop-tracking-parent-expression.rs:17:21: 17:28}`, the trait `Send` is not implemented for `derived_drop::Client` +note: coroutine is not `Send` as this value is used across a yield --> $DIR/drop-tracking-parent-expression.rs:21:22 | LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { @@ -38,11 +38,11 @@ LL | fn assert_send<T: Send>(_thing: T) {} | ^^^^ required by this bound in `assert_send` = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) -error: generator cannot be sent between threads safely +error: coroutine cannot be sent between threads safely --> $DIR/drop-tracking-parent-expression.rs:23:13 | LL | assert_send(g); - | ^^^^^^^^^^^ generator is not `Send` + | ^^^^^^^^^^^ coroutine is not `Send` ... LL | / type_combinations!( LL | | // OK @@ -53,8 +53,8 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:17:21: 17:28}`, the trait `Send` is not implemented for `significant_drop::Client` -note: generator is not `Send` as this value is used across a yield + = help: within `{coroutine@$DIR/drop-tracking-parent-expression.rs:17:21: 17:28}`, the trait `Send` is not implemented for `significant_drop::Client` +note: coroutine is not `Send` as this value is used across a yield --> $DIR/drop-tracking-parent-expression.rs:21:22 | LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { @@ -78,11 +78,11 @@ LL | fn assert_send<T: Send>(_thing: T) {} | ^^^^ required by this bound in `assert_send` = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) -error: generator cannot be sent between threads safely +error: coroutine cannot be sent between threads safely --> $DIR/drop-tracking-parent-expression.rs:23:13 | LL | assert_send(g); - | ^^^^^^^^^^^ generator is not `Send` + | ^^^^^^^^^^^ coroutine is not `Send` ... LL | / type_combinations!( LL | | // OK @@ -93,8 +93,8 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:17:21: 17:28}`, the trait `Send` is not implemented for `insignificant_dtor::Client` -note: generator is not `Send` as this value is used across a yield + = help: within `{coroutine@$DIR/drop-tracking-parent-expression.rs:17:21: 17:28}`, the trait `Send` is not implemented for `insignificant_dtor::Client` +note: coroutine is not `Send` as this value is used across a yield --> $DIR/drop-tracking-parent-expression.rs:21:22 | LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { diff --git a/tests/ui/generator/drop-tracking-yielding-in-match-guards.rs b/tests/ui/coroutine/drop-tracking-yielding-in-match-guards.rs index 92e0136d51b..622765d82aa 100644 --- a/tests/ui/generator/drop-tracking-yielding-in-match-guards.rs +++ b/tests/ui/coroutine/drop-tracking-yielding-in-match-guards.rs @@ -1,7 +1,7 @@ // build-pass // edition:2018 -#![feature(generators)] +#![feature(coroutines)] fn main() { let _ = static |x: u8| match x { diff --git a/tests/ui/generator/drop-yield-twice.rs b/tests/ui/coroutine/drop-yield-twice.rs index f484cbb8d67..015343a2776 100644 --- a/tests/ui/generator/drop-yield-twice.rs +++ b/tests/ui/coroutine/drop-yield-twice.rs @@ -1,10 +1,10 @@ -#![feature(negative_impls, generators)] +#![feature(negative_impls, coroutines)] struct Foo(i32); impl !Send for Foo {} fn main() { - assert_send(|| { //~ ERROR generator cannot be sent between threads safely + assert_send(|| { //~ ERROR coroutine cannot be sent between threads safely let guard = Foo(42); yield; drop(guard); diff --git a/tests/ui/generator/drop-yield-twice.stderr b/tests/ui/coroutine/drop-yield-twice.stderr index 39a906f0bf4..fbbedac5775 100644 --- a/tests/ui/generator/drop-yield-twice.stderr +++ b/tests/ui/coroutine/drop-yield-twice.stderr @@ -1,11 +1,11 @@ -error: generator cannot be sent between threads safely +error: coroutine cannot be sent between threads safely --> $DIR/drop-yield-twice.rs:7:5 | LL | assert_send(|| { - | ^^^^^^^^^^^ generator is not `Send` + | ^^^^^^^^^^^ coroutine is not `Send` | - = help: within `{generator@$DIR/drop-yield-twice.rs:7:17: 7:19}`, the trait `Send` is not implemented for `Foo` -note: generator is not `Send` as this value is used across a yield + = help: within `{coroutine@$DIR/drop-yield-twice.rs:7:17: 7:19}`, the trait `Send` is not implemented for `Foo` +note: coroutine is not `Send` as this value is used across a yield --> $DIR/drop-yield-twice.rs:9:9 | LL | let guard = Foo(42); diff --git a/tests/ui/generator/dropck-resume.rs b/tests/ui/coroutine/dropck-resume.rs index 4c18077f335..07ca4d37aba 100644 --- a/tests/ui/generator/dropck-resume.rs +++ b/tests/ui/coroutine/dropck-resume.rs @@ -1,6 +1,6 @@ -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; struct SetToNone<'a: 'b, 'b>(&'b mut Option<&'a i32>); @@ -11,7 +11,7 @@ impl<'a, 'b> Drop for SetToNone<'a, 'b> { } } -fn drop_using_generator() -> i32 { +fn drop_using_coroutine() -> i32 { let mut y = Some(&0); let z = &mut y; let r; @@ -29,5 +29,5 @@ fn drop_using_generator() -> i32 { } fn main() { - println!("{}", drop_using_generator()); + println!("{}", drop_using_coroutine()); } diff --git a/tests/ui/generator/dropck-resume.stderr b/tests/ui/coroutine/dropck-resume.stderr index ecf92e7e3ae..028523978f9 100644 --- a/tests/ui/generator/dropck-resume.stderr +++ b/tests/ui/coroutine/dropck-resume.stderr @@ -8,7 +8,7 @@ LL | r = y.as_ref().unwrap(); | ^ immutable borrow occurs here LL | LL | } - | - mutable borrow might be used here, when `g` is dropped and runs the destructor for generator + | - mutable borrow might be used here, when `g` is dropped and runs the destructor for coroutine error: aborting due to previous error diff --git a/tests/ui/generator/dropck.rs b/tests/ui/coroutine/dropck.rs index f82111a76b1..450361c8dd0 100644 --- a/tests/ui/generator/dropck.rs +++ b/tests/ui/coroutine/dropck.rs @@ -1,7 +1,7 @@ -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] use std::cell::RefCell; -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; fn main() { @@ -11,7 +11,7 @@ fn main() { //~^ ERROR `*cell` does not live long enough [E0597] // the upvar is the non-dropck `&mut Option<Ref<'a, i32>>`. gen = || { - // but the generator can use it to drop a `Ref<'a, i32>`. + // but the coroutine can use it to drop a `Ref<'a, i32>`. let _d = ref_.take(); //~ ERROR `ref_` does not live long enough yield; }; diff --git a/tests/ui/generator/dropck.stderr b/tests/ui/coroutine/dropck.stderr index 246ac99f83f..241d6dfe0a1 100644 --- a/tests/ui/generator/dropck.stderr +++ b/tests/ui/coroutine/dropck.stderr @@ -11,7 +11,7 @@ LL | } | - | | | `*cell` dropped here while still borrowed - | borrow might be used here, when `gen` is dropped and runs the destructor for generator + | borrow might be used here, when `gen` is dropped and runs the destructor for coroutine | = note: values in a scope are dropped in the opposite order they are defined @@ -19,8 +19,8 @@ error[E0597]: `ref_` does not live long enough --> $DIR/dropck.rs:15:18 | LL | gen = || { - | -- value captured here by generator -LL | // but the generator can use it to drop a `Ref<'a, i32>`. + | -- value captured here by coroutine +LL | // but the coroutine can use it to drop a `Ref<'a, i32>`. LL | let _d = ref_.take(); | ^^^^ borrowed value does not live long enough ... @@ -28,7 +28,7 @@ LL | } | - | | | `ref_` dropped here while still borrowed - | borrow might be used here, when `gen` is dropped and runs the destructor for generator + | borrow might be used here, when `gen` is dropped and runs the destructor for coroutine | = note: values in a scope are dropped in the opposite order they are defined diff --git a/tests/ui/generator/issue-102645.rs b/tests/ui/coroutine/issue-102645.rs index 677cc69d3f2..a0263510e13 100644 --- a/tests/ui/generator/issue-102645.rs +++ b/tests/ui/coroutine/issue-102645.rs @@ -1,6 +1,6 @@ -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; fn main() { diff --git a/tests/ui/generator/issue-102645.stderr b/tests/ui/coroutine/issue-102645.stderr index 5d28dfc45b3..3db090346cd 100644 --- a/tests/ui/generator/issue-102645.stderr +++ b/tests/ui/coroutine/issue-102645.stderr @@ -5,7 +5,7 @@ LL | Pin::new(&mut b).resume(); | ^^^^^^-- an argument of type `()` is missing | note: method defined here - --> $SRC_DIR/core/src/ops/generator.rs:LL:COL + --> $SRC_DIR/core/src/ops/coroutine.rs:LL:COL help: provide the argument | LL | Pin::new(&mut b).resume(()); diff --git a/tests/ui/generator/issue-105084.rs b/tests/ui/coroutine/issue-105084.rs index 50b5da6e6ad..7801f1bcea0 100644 --- a/tests/ui/generator/issue-105084.rs +++ b/tests/ui/coroutine/issue-105084.rs @@ -1,9 +1,9 @@ -#![feature(generators)] -#![feature(generator_clone)] -#![feature(generator_trait)] +#![feature(coroutines)] +#![feature(coroutine_clone)] +#![feature(coroutine_trait)] #![feature(rustc_attrs, stmt_expr_attributes)] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; fn copy<T: Copy>(x: T) -> T { @@ -25,9 +25,9 @@ fn main() { // Allocate the temporary box. Pin::new(&mut g).resume(()); - // The temporary box is in generator locals. + // The temporary box is in coroutine locals. // As it is not taken into account for trait computation, - // the generator is `Copy`. + // the coroutine is `Copy`. let mut h = copy(g); //~^ ERROR the trait bound `Box<(i32, ())>: Copy` is not satisfied in diff --git a/tests/ui/generator/issue-105084.stderr b/tests/ui/coroutine/issue-105084.stderr index 573c31f1134..38f114ff774 100644 --- a/tests/ui/generator/issue-105084.stderr +++ b/tests/ui/coroutine/issue-105084.stderr @@ -2,7 +2,7 @@ error[E0382]: borrow of moved value: `g` --> $DIR/issue-105084.rs:37:14 | LL | let mut g = || { - | ----- move occurs because `g` has type `{generator@$DIR/issue-105084.rs:14:17: 14:19}`, which does not implement the `Copy` trait + | ----- move occurs because `g` has type `{coroutine@$DIR/issue-105084.rs:14:17: 14:19}`, which does not implement the `Copy` trait ... LL | let mut h = copy(g); | - value moved here @@ -22,16 +22,16 @@ help: consider cloning the value if the performance cost is acceptable LL | let mut h = copy(g.clone()); | ++++++++ -error[E0277]: the trait bound `Box<(i32, ())>: Copy` is not satisfied in `{generator@$DIR/issue-105084.rs:14:17: 14:19}` +error[E0277]: the trait bound `Box<(i32, ())>: Copy` is not satisfied in `{coroutine@$DIR/issue-105084.rs:14:17: 14:19}` --> $DIR/issue-105084.rs:31:17 | LL | let mut g = || { - | -- within this `{generator@$DIR/issue-105084.rs:14:17: 14:19}` + | -- within this `{coroutine@$DIR/issue-105084.rs:14:17: 14:19}` ... LL | let mut h = copy(g); - | ^^^^ within `{generator@$DIR/issue-105084.rs:14:17: 14:19}`, the trait `Copy` is not implemented for `Box<(i32, ())>` + | ^^^^ within `{coroutine@$DIR/issue-105084.rs:14:17: 14:19}`, the trait `Copy` is not implemented for `Box<(i32, ())>` | -note: generator does not implement `Copy` as this value is used across a yield +note: coroutine does not implement `Copy` as this value is used across a yield --> $DIR/issue-105084.rs:21:22 | LL | Box::new((5, yield)); diff --git a/tests/ui/generator/issue-110929-generator-conflict-error-ice.rs b/tests/ui/coroutine/issue-110929-coroutine-conflict-error-ice.rs index a45479e5300..feaaa71ea9c 100644 --- a/tests/ui/generator/issue-110929-generator-conflict-error-ice.rs +++ b/tests/ui/coroutine/issue-110929-coroutine-conflict-error-ice.rs @@ -1,5 +1,5 @@ // edition:2021 -#![feature(generators)] +#![feature(coroutines)] fn main() { let x = &mut (); diff --git a/tests/ui/generator/issue-110929-generator-conflict-error-ice.stderr b/tests/ui/coroutine/issue-110929-coroutine-conflict-error-ice.stderr index 66f0e3d94bd..77da6c4cdc9 100644 --- a/tests/ui/generator/issue-110929-generator-conflict-error-ice.stderr +++ b/tests/ui/coroutine/issue-110929-coroutine-conflict-error-ice.stderr @@ -1,8 +1,8 @@ error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/issue-110929-generator-conflict-error-ice.rs:8:9 + --> $DIR/issue-110929-coroutine-conflict-error-ice.rs:8:9 | LL | let _c = || yield *&mut *x; - | -- -- first borrow occurs due to use of `*x` in generator + | -- -- first borrow occurs due to use of `*x` in coroutine | | | first mutable borrow occurs here LL | || _ = &mut *x; @@ -11,7 +11,7 @@ LL | || _ = &mut *x; | second mutable borrow occurs here LL | LL | }; - | - first borrow might be used here, when `_c` is dropped and runs the destructor for generator + | - first borrow might be used here, when `_c` is dropped and runs the destructor for coroutine error: aborting due to previous error diff --git a/tests/ui/generator/issue-113279.rs b/tests/ui/coroutine/issue-113279.rs index f69f804b716..f251c924c13 100644 --- a/tests/ui/generator/issue-113279.rs +++ b/tests/ui/coroutine/issue-113279.rs @@ -1,10 +1,10 @@ -#![feature(generators)] +#![feature(coroutines)] // `foo` attempts to dereference `""`, which results in an error being reported. Later, the -// generator transform for `foo` then produces a union which contains a `str` type - unions should +// coroutine transform for `foo` then produces a union which contains a `str` type - unions should // not contain unsized types, but this is okay because an error has been reported already. // When const propagation happens later in compilation, it attempts to compute the layout of the -// generator (as part of checking whether something can be const propagated) and in turn attempts +// coroutine (as part of checking whether something can be const propagated) and in turn attempts // to compute the layout of `str` in the context of a union - where this caused an ICE. This test // makes sure that doesn't happen again. diff --git a/tests/ui/generator/issue-113279.stderr b/tests/ui/coroutine/issue-113279.stderr index cc9b64ef9ac..cc9b64ef9ac 100644 --- a/tests/ui/generator/issue-113279.stderr +++ b/tests/ui/coroutine/issue-113279.stderr diff --git a/tests/ui/generator/issue-44197.rs b/tests/ui/coroutine/issue-44197.rs index 389b9d13969..c0326bdae4e 100644 --- a/tests/ui/generator/issue-44197.rs +++ b/tests/ui/coroutine/issue-44197.rs @@ -1,15 +1,15 @@ // run-pass -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; fn foo(_: &str) -> String { String::new() } -fn bar(baz: String) -> impl Generator<(), Yield = String, Return = ()> { +fn bar(baz: String) -> impl Coroutine<(), Yield = String, Return = ()> { move || { yield foo(&baz); } @@ -19,7 +19,7 @@ fn foo2(_: &str) -> Result<String, ()> { Err(()) } -fn bar2(baz: String) -> impl Generator<(), Yield = String, Return = ()> { +fn bar2(baz: String) -> impl Coroutine<(), Yield = String, Return = ()> { move || { if let Ok(quux) = foo2(&baz) { yield quux; @@ -30,7 +30,7 @@ fn bar2(baz: String) -> impl Generator<(), Yield = String, Return = ()> { fn main() { assert_eq!( Pin::new(&mut bar(String::new())).resume(()), - GeneratorState::Yielded(String::new()) + CoroutineState::Yielded(String::new()) ); - assert_eq!(Pin::new(&mut bar2(String::new())).resume(()), GeneratorState::Complete(())); + assert_eq!(Pin::new(&mut bar2(String::new())).resume(()), CoroutineState::Complete(())); } diff --git a/tests/ui/generator/issue-45729-unsafe-in-generator.mir.stderr b/tests/ui/coroutine/issue-45729-unsafe-in-coroutine.mir.stderr index 3afbea07931..a9a0d629606 100644 --- a/tests/ui/generator/issue-45729-unsafe-in-generator.mir.stderr +++ b/tests/ui/coroutine/issue-45729-unsafe-in-coroutine.mir.stderr @@ -1,5 +1,5 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block - --> $DIR/issue-45729-unsafe-in-generator.rs:8:9 + --> $DIR/issue-45729-unsafe-in-coroutine.rs:8:9 | LL | *(1 as *mut u32) = 42; | ^^^^^^^^^^^^^^^^^^^^^ dereference of raw pointer diff --git a/tests/ui/generator/issue-45729-unsafe-in-generator.rs b/tests/ui/coroutine/issue-45729-unsafe-in-coroutine.rs index 379c36d2ca3..7961b58597c 100644 --- a/tests/ui/generator/issue-45729-unsafe-in-generator.rs +++ b/tests/ui/coroutine/issue-45729-unsafe-in-coroutine.rs @@ -1,7 +1,7 @@ // revisions: mir thir // [thir]compile-flags: -Z thir-unsafeck -#![feature(generators)] +#![feature(coroutines)] fn main() { let _ = || { diff --git a/tests/ui/generator/issue-45729-unsafe-in-generator.thir.stderr b/tests/ui/coroutine/issue-45729-unsafe-in-coroutine.thir.stderr index 10d768f19fc..22c83e9a3d5 100644 --- a/tests/ui/generator/issue-45729-unsafe-in-generator.thir.stderr +++ b/tests/ui/coroutine/issue-45729-unsafe-in-coroutine.thir.stderr @@ -1,5 +1,5 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block - --> $DIR/issue-45729-unsafe-in-generator.rs:8:9 + --> $DIR/issue-45729-unsafe-in-coroutine.rs:8:9 | LL | *(1 as *mut u32) = 42; | ^^^^^^^^^^^^^^^^ dereference of raw pointer diff --git a/tests/ui/generator/issue-48048.rs b/tests/ui/coroutine/issue-48048.rs index 992bbc97a9f..b61b7c77072 100644 --- a/tests/ui/generator/issue-48048.rs +++ b/tests/ui/coroutine/issue-48048.rs @@ -1,4 +1,4 @@ -#![feature(generators)] +#![feature(coroutines)] fn main() { let x = (|_| {},); @@ -6,7 +6,7 @@ fn main() { || { let x = x; - x.0({ //~ ERROR borrow may still be in use when generator yields + x.0({ //~ ERROR borrow may still be in use when coroutine yields yield; }); }; diff --git a/tests/ui/generator/issue-48048.stderr b/tests/ui/coroutine/issue-48048.stderr index 23423583916..bb9f189fa7c 100644 --- a/tests/ui/generator/issue-48048.stderr +++ b/tests/ui/coroutine/issue-48048.stderr @@ -1,4 +1,4 @@ -error[E0626]: borrow may still be in use when generator yields +error[E0626]: borrow may still be in use when coroutine yields --> $DIR/issue-48048.rs:9:9 | LL | x.0({ diff --git a/tests/ui/coroutine/issue-52304.rs b/tests/ui/coroutine/issue-52304.rs new file mode 100644 index 00000000000..fed3a5f19b3 --- /dev/null +++ b/tests/ui/coroutine/issue-52304.rs @@ -0,0 +1,11 @@ +// check-pass + +#![feature(coroutines, coroutine_trait)] + +use std::ops::Coroutine; + +pub fn example() -> impl Coroutine { + || yield &1 +} + +fn main() {} diff --git a/tests/ui/generator/issue-52398.rs b/tests/ui/coroutine/issue-52398.rs index ada380d116c..8d651d0e2ce 100644 --- a/tests/ui/generator/issue-52398.rs +++ b/tests/ui/coroutine/issue-52398.rs @@ -1,7 +1,7 @@ // run-pass #![allow(unused_variables)] -#![feature(generators)] +#![feature(coroutines)] use std::cell::RefCell; @@ -14,14 +14,14 @@ impl A { fn main() { // Test that the MIR local with type &A created for the auto-borrow adjustment // is caught by typeck - move || { //~ WARN unused generator that must be used + move || { //~ WARN unused coroutine that must be used A.test(yield); }; // Test that the std::cell::Ref temporary returned from the `borrow` call // is caught by typeck let y = RefCell::new(true); - static move || { //~ WARN unused generator that must be used + static move || { //~ WARN unused coroutine that must be used yield *y.borrow(); return "Done"; }; diff --git a/tests/ui/generator/issue-52398.stderr b/tests/ui/coroutine/issue-52398.stderr index 539343275df..18d816da4c6 100644 --- a/tests/ui/generator/issue-52398.stderr +++ b/tests/ui/coroutine/issue-52398.stderr @@ -1,4 +1,4 @@ -warning: unused generator that must be used +warning: unused coroutine that must be used --> $DIR/issue-52398.rs:17:5 | LL | / move || { @@ -6,10 +6,10 @@ LL | | A.test(yield); LL | | }; | |_____^ | - = note: generators are lazy and do nothing unless resumed + = note: coroutines are lazy and do nothing unless resumed = note: `#[warn(unused_must_use)]` on by default -warning: unused generator that must be used +warning: unused coroutine that must be used --> $DIR/issue-52398.rs:24:5 | LL | / static move || { @@ -18,7 +18,7 @@ LL | | return "Done"; LL | | }; | |_____^ | - = note: generators are lazy and do nothing unless resumed + = note: coroutines are lazy and do nothing unless resumed warning: 2 warnings emitted diff --git a/tests/ui/generator/issue-53548-1.rs b/tests/ui/coroutine/issue-53548-1.rs index 173ae3c6fb6..4be8e95f3e7 100644 --- a/tests/ui/generator/issue-53548-1.rs +++ b/tests/ui/coroutine/issue-53548-1.rs @@ -1,4 +1,4 @@ -// A variant of #53548 that does not actually require generators, +// A variant of #53548 that does not actually require coroutines, // but which encountered the same ICE/error. See `issue-53548.rs` // for details. // diff --git a/tests/ui/generator/issue-53548.rs b/tests/ui/coroutine/issue-53548.rs index 3ebabb91462..bb267f74ae2 100644 --- a/tests/ui/generator/issue-53548.rs +++ b/tests/ui/coroutine/issue-53548.rs @@ -1,5 +1,5 @@ // Regression test for #53548. The `Box<dyn Trait>` type below is -// expanded to `Box<dyn Trait + 'static>`, but the generator "witness" +// expanded to `Box<dyn Trait + 'static>`, but the coroutine "witness" // that results is `for<'r> { Box<dyn Trait + 'r> }`. The WF code was // encountering an ICE (when debug-assertions were enabled) and an // unexpected compilation error (without debug-asserions) when trying @@ -17,7 +17,7 @@ // // check-pass -#![feature(generators)] +#![feature(coroutines)] use std::cell::RefCell; use std::rc::Rc; diff --git a/tests/ui/generator/issue-57017.rs b/tests/ui/coroutine/issue-57017.rs index bb2d6679b67..4f63abbdb10 100644 --- a/tests/ui/generator/issue-57017.rs +++ b/tests/ui/coroutine/issue-57017.rs @@ -1,5 +1,5 @@ // build-pass -#![feature(generators, negative_impls)] +#![feature(coroutines, negative_impls)] #![allow(dropping_references, dropping_copy_types)] macro_rules! type_combinations { diff --git a/tests/ui/generator/issue-57084.rs b/tests/ui/coroutine/issue-57084.rs index fbed78ff280..95bed5b151e 100644 --- a/tests/ui/generator/issue-57084.rs +++ b/tests/ui/coroutine/issue-57084.rs @@ -2,10 +2,10 @@ // "cannot relate bound region: ReLateBound(DebruijnIndex(1), BrAnon(1)) <= '?1" // run-pass // edition:2018 -#![feature(generators,generator_trait)] -use std::ops::Generator; +#![feature(coroutines,coroutine_trait)] +use std::ops::Coroutine; -fn with<F>(f: F) -> impl Generator<Yield=(), Return=()> +fn with<F>(f: F) -> impl Coroutine<Yield=(), Return=()> where F: Fn() -> () { move || { @@ -19,7 +19,7 @@ where F: Fn() -> () fn main() { let data = &vec![1]; - || { //~ WARN unused generator that must be used + || { //~ WARN unused coroutine that must be used let _to_pin = with(move || println!("{:p}", data)); loop { yield diff --git a/tests/ui/generator/issue-57084.stderr b/tests/ui/coroutine/issue-57084.stderr index 8f1fc5e8031..9f5b79a6ae8 100644 --- a/tests/ui/generator/issue-57084.stderr +++ b/tests/ui/coroutine/issue-57084.stderr @@ -1,4 +1,4 @@ -warning: unused generator that must be used +warning: unused coroutine that must be used --> $DIR/issue-57084.rs:22:5 | LL | / || { @@ -9,7 +9,7 @@ LL | | } LL | | }; | |_____^ | - = note: generators are lazy and do nothing unless resumed + = note: coroutines are lazy and do nothing unless resumed = note: `#[warn(unused_must_use)]` on by default warning: 1 warning emitted diff --git a/tests/ui/generator/issue-57478.rs b/tests/ui/coroutine/issue-57478.rs index 39710febdb9..716e4c67b87 100644 --- a/tests/ui/generator/issue-57478.rs +++ b/tests/ui/coroutine/issue-57478.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(negative_impls, generators)] +#![feature(negative_impls, coroutines)] struct Foo; impl !Send for Foo {} diff --git a/tests/ui/generator/issue-58888.rs b/tests/ui/coroutine/issue-58888.rs index d42d09d401e..af8e60ce460 100644 --- a/tests/ui/generator/issue-58888.rs +++ b/tests/ui/coroutine/issue-58888.rs @@ -2,9 +2,9 @@ // compile-flags: -g // ignore-asmjs wasm2js does not support source maps yet -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::Generator; +use std::ops::Coroutine; struct Database; @@ -13,7 +13,7 @@ impl Database { Some(()).into_iter() } - fn check_connection(&self) -> impl Generator<Yield = (), Return = ()> + '_ { + fn check_connection(&self) -> impl Coroutine<Yield = (), Return = ()> + '_ { move || { let iter = self.get_connection(); for i in iter { diff --git a/tests/ui/generator/issue-61442-stmt-expr-with-drop.rs b/tests/ui/coroutine/issue-61442-stmt-expr-with-drop.rs index 187c374021d..cff6c24a83f 100644 --- a/tests/ui/generator/issue-61442-stmt-expr-with-drop.rs +++ b/tests/ui/coroutine/issue-61442-stmt-expr-with-drop.rs @@ -4,9 +4,9 @@ // check-pass // edition:2018 -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::Generator; +use std::ops::Coroutine; async fn drop_and_await() { async {}; diff --git a/tests/ui/generator/issue-62506-two_awaits.rs b/tests/ui/coroutine/issue-62506-two_awaits.rs index 672e16b780d..b50e2a45c58 100644 --- a/tests/ui/generator/issue-62506-two_awaits.rs +++ b/tests/ui/coroutine/issue-62506-two_awaits.rs @@ -1,5 +1,5 @@ // Output = String caused an ICE whereas Output = &'static str compiled successfully. -// Broken MIR: generator contains type std::string::String in MIR, +// Broken MIR: coroutine contains type std::string::String in MIR, // but typeck only knows about {<S as T>::Future, ()} // check-pass // edition:2018 diff --git a/tests/ui/coroutine/issue-64620-yield-array-element.rs b/tests/ui/coroutine/issue-64620-yield-array-element.rs new file mode 100644 index 00000000000..a9307d306a6 --- /dev/null +++ b/tests/ui/coroutine/issue-64620-yield-array-element.rs @@ -0,0 +1,9 @@ +// Regression test for #64620 + +#![feature(coroutines)] + +pub fn crash(arr: [usize; 1]) { + yield arr[0]; //~ ERROR: yield expression outside of coroutine literal +} + +fn main() {} diff --git a/tests/ui/generator/issue-64620-yield-array-element.stderr b/tests/ui/coroutine/issue-64620-yield-array-element.stderr index 48383c2ed08..47632d083ea 100644 --- a/tests/ui/generator/issue-64620-yield-array-element.stderr +++ b/tests/ui/coroutine/issue-64620-yield-array-element.stderr @@ -1,4 +1,4 @@ -error[E0627]: yield expression outside of generator literal +error[E0627]: yield expression outside of coroutine literal --> $DIR/issue-64620-yield-array-element.rs:6:5 | LL | yield arr[0]; diff --git a/tests/ui/generator/issue-68112.rs b/tests/ui/coroutine/issue-68112.rs index 9dd68726f92..e2be704dab7 100644 --- a/tests/ui/generator/issue-68112.rs +++ b/tests/ui/coroutine/issue-68112.rs @@ -1,18 +1,18 @@ -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] use std::{ cell::RefCell, sync::Arc, pin::Pin, - ops::{Generator, GeneratorState}, + ops::{Coroutine, CoroutineState}, }; pub struct Ready<T>(Option<T>); -impl<T: Unpin> Generator<()> for Ready<T> { +impl<T: Unpin> Coroutine<()> for Ready<T> { type Return = T; type Yield = (); - fn resume(mut self: Pin<&mut Self>, _args: ()) -> GeneratorState<(), T> { - GeneratorState::Complete(self.0.take().unwrap()) + fn resume(mut self: Pin<&mut Self>, _args: ()) -> CoroutineState<(), T> { + CoroutineState::Complete(self.0.take().unwrap()) } } pub fn make_gen1<T>(t: T) -> Ready<T> { @@ -25,40 +25,40 @@ fn require_send(_: impl Send) {} //~| NOTE required by this bound //~| NOTE required by this bound -fn make_non_send_generator() -> impl Generator<Return = Arc<RefCell<i32>>> { +fn make_non_send_coroutine() -> impl Coroutine<Return = Arc<RefCell<i32>>> { make_gen1(Arc::new(RefCell::new(0))) } fn test1() { let send_gen = || { - let _non_send_gen = make_non_send_generator(); + let _non_send_gen = make_non_send_coroutine(); //~^ NOTE not `Send` yield; //~^ NOTE yield occurs here //~| NOTE value is used across a yield }; require_send(send_gen); - //~^ ERROR generator cannot be sent between threads + //~^ ERROR coroutine cannot be sent between threads //~| NOTE not `Send` //~| NOTE use `std::sync::RwLock` instead } -pub fn make_gen2<T>(t: T) -> impl Generator<Return = T> { +pub fn make_gen2<T>(t: T) -> impl Coroutine<Return = T> { //~^ NOTE appears within the type //~| NOTE expansion of desugaring - || { //~ NOTE used within this generator + || { //~ NOTE used within this coroutine yield; t } } -fn make_non_send_generator2() -> impl Generator<Return = Arc<RefCell<i32>>> { //~ NOTE appears within the type +fn make_non_send_coroutine2() -> impl Coroutine<Return = Arc<RefCell<i32>>> { //~ NOTE appears within the type //~^ NOTE expansion of desugaring make_gen2(Arc::new(RefCell::new(0))) } fn test2() { - let send_gen = || { //~ NOTE used within this generator - let _non_send_gen = make_non_send_generator2(); + let send_gen = || { //~ NOTE used within this coroutine + let _non_send_gen = make_non_send_coroutine2(); yield; }; require_send(send_gen); diff --git a/tests/ui/generator/issue-68112.stderr b/tests/ui/coroutine/issue-68112.stderr index 8080048222f..5efa72ad5fe 100644 --- a/tests/ui/generator/issue-68112.stderr +++ b/tests/ui/coroutine/issue-68112.stderr @@ -1,16 +1,16 @@ -error: generator cannot be sent between threads safely +error: coroutine cannot be sent between threads safely --> $DIR/issue-68112.rs:40:5 | LL | require_send(send_gen); - | ^^^^^^^^^^^^ generator is not `Send` + | ^^^^^^^^^^^^ coroutine is not `Send` | = help: the trait `Sync` is not implemented for `RefCell<i32>` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead -note: generator is not `Send` as this value is used across a yield +note: coroutine is not `Send` as this value is used across a yield --> $DIR/issue-68112.rs:36:9 | -LL | let _non_send_gen = make_non_send_generator(); - | ------------- has type `impl Generator<Return = Arc<RefCell<i32>>>` which is not `Send` +LL | let _non_send_gen = make_non_send_coroutine(); + | ------------- has type `impl Coroutine<Return = Arc<RefCell<i32>>>` which is not `Send` LL | LL | yield; | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later @@ -29,23 +29,23 @@ LL | require_send(send_gen); = help: the trait `Sync` is not implemented for `RefCell<i32>` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead = note: required for `Arc<RefCell<i32>>` to implement `Send` -note: required because it's used within this generator +note: required because it's used within this coroutine --> $DIR/issue-68112.rs:49:5 | LL | || { | ^^ -note: required because it appears within the type `impl Generator<Return = Arc<RefCell<i32>>>` +note: required because it appears within the type `impl Coroutine<Return = Arc<RefCell<i32>>>` --> $DIR/issue-68112.rs:46:30 | -LL | pub fn make_gen2<T>(t: T) -> impl Generator<Return = T> { +LL | pub fn make_gen2<T>(t: T) -> impl Coroutine<Return = T> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required because it appears within the type `impl Generator<Return = Arc<RefCell<i32>>>` +note: required because it appears within the type `impl Coroutine<Return = Arc<RefCell<i32>>>` --> $DIR/issue-68112.rs:54:34 | -LL | fn make_non_send_generator2() -> impl Generator<Return = Arc<RefCell<i32>>> { +LL | fn make_non_send_coroutine2() -> impl Coroutine<Return = Arc<RefCell<i32>>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `impl Generator<Return = Arc<RefCell<i32>>>` -note: required because it's used within this generator + = note: required because it captures the following types: `impl Coroutine<Return = Arc<RefCell<i32>>>` +note: required because it's used within this coroutine --> $DIR/issue-68112.rs:60:20 | LL | let send_gen = || { diff --git a/tests/ui/generator/issue-69017.rs b/tests/ui/coroutine/issue-69017.rs index 511deb60e45..7aaa1ee03c4 100644 --- a/tests/ui/generator/issue-69017.rs +++ b/tests/ui/coroutine/issue-69017.rs @@ -4,12 +4,12 @@ // // check-pass -#![feature(generator_trait)] -#![feature(generators)] +#![feature(coroutine_trait)] +#![feature(coroutines)] -use std::ops::Generator; +use std::ops::Coroutine; -fn gen() -> impl Generator<usize> { +fn gen() -> impl Coroutine<usize> { |_: usize| { println!("-> {}", yield); } diff --git a/tests/ui/generator/issue-69039.rs b/tests/ui/coroutine/issue-69039.rs index ccc141860aa..041985e15a3 100644 --- a/tests/ui/generator/issue-69039.rs +++ b/tests/ui/coroutine/issue-69039.rs @@ -1,14 +1,14 @@ // run-pass -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; fn mkstr(my_name: String, my_mood: String) -> String { format!("{} is {}", my_name.trim(), my_mood.trim()) } -fn my_scenario() -> impl Generator<String, Yield = &'static str, Return = String> { +fn my_scenario() -> impl Coroutine<String, Yield = &'static str, Return = String> { |_arg: String| { let my_name = yield "What is your name?"; let my_mood = yield "How are you feeling?"; @@ -21,14 +21,14 @@ fn main() { assert_eq!( my_session.as_mut().resume("_arg".to_string()), - GeneratorState::Yielded("What is your name?") + CoroutineState::Yielded("What is your name?") ); assert_eq!( my_session.as_mut().resume("Your Name".to_string()), - GeneratorState::Yielded("How are you feeling?") + CoroutineState::Yielded("How are you feeling?") ); assert_eq!( my_session.as_mut().resume("Sensory Organs".to_string()), - GeneratorState::Complete("Your Name is Sensory Organs".to_string()) + CoroutineState::Complete("Your Name is Sensory Organs".to_string()) ); } diff --git a/tests/ui/coroutine/issue-87142.rs b/tests/ui/coroutine/issue-87142.rs new file mode 100644 index 00000000000..b5708c4b385 --- /dev/null +++ b/tests/ui/coroutine/issue-87142.rs @@ -0,0 +1,32 @@ +// compile-flags: -Cdebuginfo=2 +// build-pass + +// Regression test for #87142 +// This test needs the above flags and the "lib" crate type. + +#![feature(impl_trait_in_assoc_type, coroutine_trait, coroutines)] +#![crate_type = "lib"] + +use std::ops::Coroutine; + +pub trait CoroutineProviderAlt: Sized { + type Coro: Coroutine<(), Return = (), Yield = ()>; + + fn start(ctx: Context<Self>) -> Self::Coro; +} + +pub struct Context<G: 'static + CoroutineProviderAlt> { + pub link: Box<G::Coro>, +} + +impl CoroutineProviderAlt for () { + type Coro = impl Coroutine<(), Return = (), Yield = ()>; + fn start(ctx: Context<Self>) -> Self::Coro { + move || { + match ctx { + _ => (), + } + yield (); + } + } +} diff --git a/tests/ui/generator/issue-88653.rs b/tests/ui/coroutine/issue-88653.rs index 1d9377bcef4..ec4c2054758 100644 --- a/tests/ui/generator/issue-88653.rs +++ b/tests/ui/coroutine/issue-88653.rs @@ -1,14 +1,14 @@ // Regression test for #88653, where a confusing warning about a -// type mismatch in generator arguments was issued. +// type mismatch in coroutine arguments was issued. -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::Generator; +use std::ops::Coroutine; -fn foo(bar: bool) -> impl Generator<(bool,)> { - //~^ ERROR: type mismatch in generator arguments [E0631] +fn foo(bar: bool) -> impl Coroutine<(bool,)> { + //~^ ERROR: type mismatch in coroutine arguments [E0631] //~| NOTE: expected due to this - //~| NOTE: expected generator signature `fn((bool,)) -> _` + //~| NOTE: expected coroutine signature `fn((bool,)) -> _` //~| NOTE: in this expansion of desugaring of `impl Trait` //~| NOTE: in this expansion of desugaring of `impl Trait` |bar| { diff --git a/tests/ui/generator/issue-88653.stderr b/tests/ui/coroutine/issue-88653.stderr index b742c6e2f1c..3ae50b5aff2 100644 --- a/tests/ui/generator/issue-88653.stderr +++ b/tests/ui/coroutine/issue-88653.stderr @@ -1,14 +1,14 @@ -error[E0631]: type mismatch in generator arguments +error[E0631]: type mismatch in coroutine arguments --> $DIR/issue-88653.rs:8:22 | -LL | fn foo(bar: bool) -> impl Generator<(bool,)> { +LL | fn foo(bar: bool) -> impl Coroutine<(bool,)> { | ^^^^^^^^^^^^^^^^^^^^^^^ expected due to this ... LL | |bar| { | ----- found signature defined here | - = note: expected generator signature `fn((bool,)) -> _` - found generator signature `fn(bool) -> _` + = note: expected coroutine signature `fn((bool,)) -> _` + found coroutine signature `fn(bool) -> _` error: aborting due to previous error diff --git a/tests/ui/generator/issue-91477.rs b/tests/ui/coroutine/issue-91477.rs index 6c027feb422..c98546f7971 100644 --- a/tests/ui/generator/issue-91477.rs +++ b/tests/ui/coroutine/issue-91477.rs @@ -1,4 +1,4 @@ -#![feature(generators)] +#![feature(coroutines)] fn foo() -> impl Sized { yield 1; //~ ERROR E0627 diff --git a/tests/ui/generator/issue-91477.stderr b/tests/ui/coroutine/issue-91477.stderr index 4597dc1bcdf..0ab3c1fbabc 100644 --- a/tests/ui/generator/issue-91477.stderr +++ b/tests/ui/coroutine/issue-91477.stderr @@ -1,4 +1,4 @@ -error[E0627]: yield expression outside of generator literal +error[E0627]: yield expression outside of coroutine literal --> $DIR/issue-91477.rs:4:5 | LL | yield 1; diff --git a/tests/ui/generator/issue-93161.rs b/tests/ui/coroutine/issue-93161.rs index ae8603b7c09..ae8603b7c09 100644 --- a/tests/ui/generator/issue-93161.rs +++ b/tests/ui/coroutine/issue-93161.rs diff --git a/tests/ui/generator/iterator-count.rs b/tests/ui/coroutine/iterator-count.rs index 90eefe02f66..322e56f8a8b 100644 --- a/tests/ui/generator/iterator-count.rs +++ b/tests/ui/coroutine/iterator-count.rs @@ -1,27 +1,27 @@ // run-pass -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] use std::marker::Unpin; -use std::ops::{GeneratorState, Generator}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; struct W<T>(T); -// This impl isn't safe in general, but the generator used in this test is movable +// This impl isn't safe in general, but the coroutine used in this test is movable // so it won't cause problems. -impl<T: Generator<(), Return = ()> + Unpin> Iterator for W<T> { +impl<T: Coroutine<(), Return = ()> + Unpin> Iterator for W<T> { type Item = T::Yield; fn next(&mut self) -> Option<Self::Item> { match Pin::new(&mut self.0).resume(()) { - GeneratorState::Complete(..) => None, - GeneratorState::Yielded(v) => Some(v), + CoroutineState::Complete(..) => None, + CoroutineState::Yielded(v) => Some(v), } } } -fn test() -> impl Generator<(), Return=(), Yield=u8> + Unpin { +fn test() -> impl Coroutine<(), Return = (), Yield = u8> + Unpin { || { for i in 1..6 { yield i diff --git a/tests/ui/generator/layout-error.rs b/tests/ui/coroutine/layout-error.rs index 7c3d187409a..87da60700a4 100644 --- a/tests/ui/generator/layout-error.rs +++ b/tests/ui/coroutine/layout-error.rs @@ -1,4 +1,4 @@ -// Verifies that computing a layout of a generator tainted by type errors +// Verifies that computing a layout of a coroutine tainted by type errors // doesn't ICE. Regression test for #80998. // // edition:2018 diff --git a/tests/ui/generator/layout-error.stderr b/tests/ui/coroutine/layout-error.stderr index b1a258f4f2c..b1a258f4f2c 100644 --- a/tests/ui/generator/layout-error.stderr +++ b/tests/ui/coroutine/layout-error.stderr diff --git a/tests/ui/generator/live-upvar-across-yield.rs b/tests/ui/coroutine/live-upvar-across-yield.rs index 6a2e42a5573..740a446e737 100644 --- a/tests/ui/generator/live-upvar-across-yield.rs +++ b/tests/ui/coroutine/live-upvar-across-yield.rs @@ -1,8 +1,8 @@ // run-pass -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; fn main() { diff --git a/tests/ui/generator/match-bindings.rs b/tests/ui/coroutine/match-bindings.rs index 865904a57d4..1a5b3cdb026 100644 --- a/tests/ui/generator/match-bindings.rs +++ b/tests/ui/coroutine/match-bindings.rs @@ -1,7 +1,7 @@ // run-pass #![allow(dead_code)] -#![feature(generators)] +#![feature(coroutines)] enum Enum { A(String), @@ -9,7 +9,7 @@ enum Enum { } fn main() { - || { //~ WARN unused generator that must be used + || { //~ WARN unused coroutine that must be used loop { if let true = true { match Enum::A(String::new()) { diff --git a/tests/ui/generator/match-bindings.stderr b/tests/ui/coroutine/match-bindings.stderr index 3dd2d595445..a7aa6eadb95 100644 --- a/tests/ui/generator/match-bindings.stderr +++ b/tests/ui/coroutine/match-bindings.stderr @@ -1,4 +1,4 @@ -warning: unused generator that must be used +warning: unused coroutine that must be used --> $DIR/match-bindings.rs:12:5 | LL | / || { @@ -10,7 +10,7 @@ LL | | } LL | | }; | |_____^ | - = note: generators are lazy and do nothing unless resumed + = note: coroutines are lazy and do nothing unless resumed = note: `#[warn(unused_must_use)]` on by default warning: 1 warning emitted diff --git a/tests/ui/generator/metadata-sufficient-for-layout.rs b/tests/ui/coroutine/metadata-sufficient-for-layout.rs index d0e648ee775..434a2801597 100644 --- a/tests/ui/generator/metadata-sufficient-for-layout.rs +++ b/tests/ui/coroutine/metadata-sufficient-for-layout.rs @@ -1,4 +1,4 @@ -// Check that the layout of a generator is available when auxiliary crate +// Check that the layout of a coroutine is available when auxiliary crate // is compiled with --emit metadata. // // Regression test for #80998. @@ -6,15 +6,15 @@ // aux-build:metadata-sufficient-for-layout.rs #![feature(type_alias_impl_trait, rustc_attrs)] -#![feature(generator_trait)] +#![feature(coroutine_trait)] extern crate metadata_sufficient_for_layout; -use std::ops::Generator; +use std::ops::Coroutine; -type F = impl Generator<(), Yield = (), Return = ()>; +type F = impl Coroutine<(), Yield = (), Return = ()>; -// Static queries the layout of the generator. +// Static queries the layout of the coroutine. static A: Option<F> = None; fn f() -> F { diff --git a/tests/ui/generator/metadata-sufficient-for-layout.stderr b/tests/ui/coroutine/metadata-sufficient-for-layout.stderr index 3488b04f226..3488b04f226 100644 --- a/tests/ui/generator/metadata-sufficient-for-layout.stderr +++ b/tests/ui/coroutine/metadata-sufficient-for-layout.stderr diff --git a/tests/ui/coroutine/nested_coroutine.rs b/tests/ui/coroutine/nested_coroutine.rs new file mode 100644 index 00000000000..04f4aa77153 --- /dev/null +++ b/tests/ui/coroutine/nested_coroutine.rs @@ -0,0 +1,21 @@ +// run-pass + +#![feature(coroutines, coroutine_trait)] + +use std::ops::{Coroutine, CoroutineState}; +use std::pin::Pin; + +fn main() { + let _coroutine = || { + let mut sub_coroutine = || { + yield 2; + }; + + match Pin::new(&mut sub_coroutine).resume(()) { + CoroutineState::Yielded(x) => { + yield x; + } + _ => panic!(), + }; + }; +} diff --git a/tests/ui/generator/niche-in-generator.rs b/tests/ui/coroutine/niche-in-coroutine.rs index 42bee81f524..7ad4c6bc98a 100644 --- a/tests/ui/generator/niche-in-generator.rs +++ b/tests/ui/coroutine/niche-in-coroutine.rs @@ -1,8 +1,8 @@ -// Test that niche finding works with captured generator upvars. +// Test that niche finding works with captured coroutine upvars. // run-pass -#![feature(generators)] +#![feature(coroutines)] use std::mem::size_of_val; diff --git a/tests/ui/generator/non-static-is-unpin.rs b/tests/ui/coroutine/non-static-is-unpin.rs index a5dde3912cc..d6ded53ae5a 100644 --- a/tests/ui/generator/non-static-is-unpin.rs +++ b/tests/ui/coroutine/non-static-is-unpin.rs @@ -2,7 +2,7 @@ //[next] compile-flags: -Ztrait-solver=next // run-pass -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] #![allow(dropping_copy_types)] use std::marker::{PhantomPinned, Unpin}; @@ -11,7 +11,7 @@ fn assert_unpin<G: Unpin>(_: G) { } fn main() { - // Even though this generator holds a `PhantomPinned` in its environment, it + // Even though this coroutine holds a `PhantomPinned` in its environment, it // remains `Unpin`. assert_unpin(|| { let pinned = PhantomPinned; diff --git a/tests/ui/generator/not-send-sync.rs b/tests/ui/coroutine/not-send-sync.rs index 16c8cd47629..dd6182c10de 100644 --- a/tests/ui/generator/not-send-sync.rs +++ b/tests/ui/coroutine/not-send-sync.rs @@ -1,4 +1,4 @@ -#![feature(generators)] +#![feature(coroutines)] #![feature(negative_impls)] struct NotSend; @@ -12,14 +12,14 @@ fn main() { fn assert_send<T: Send>(_: T) {} assert_sync(|| { - //~^ ERROR: generator cannot be shared between threads safely + //~^ ERROR: coroutine cannot be shared between threads safely let a = NotSync; yield; drop(a); }); assert_send(|| { - //~^ ERROR: generator cannot be sent between threads safely + //~^ ERROR: coroutine cannot be sent between threads safely let a = NotSend; yield; drop(a); diff --git a/tests/ui/generator/not-send-sync.stderr b/tests/ui/coroutine/not-send-sync.stderr index 13ce687e0bb..b33a1e63aaf 100644 --- a/tests/ui/generator/not-send-sync.stderr +++ b/tests/ui/coroutine/not-send-sync.stderr @@ -1,11 +1,11 @@ -error: generator cannot be shared between threads safely +error: coroutine cannot be shared between threads safely --> $DIR/not-send-sync.rs:14:5 | LL | assert_sync(|| { - | ^^^^^^^^^^^ generator is not `Sync` + | ^^^^^^^^^^^ coroutine is not `Sync` | - = help: within `{generator@$DIR/not-send-sync.rs:14:17: 14:19}`, the trait `Sync` is not implemented for `NotSync` -note: generator is not `Sync` as this value is used across a yield + = help: within `{coroutine@$DIR/not-send-sync.rs:14:17: 14:19}`, the trait `Sync` is not implemented for `NotSync` +note: coroutine is not `Sync` as this value is used across a yield --> $DIR/not-send-sync.rs:17:9 | LL | let a = NotSync; @@ -18,14 +18,14 @@ note: required by a bound in `assert_sync` LL | fn assert_sync<T: Sync>(_: T) {} | ^^^^ required by this bound in `assert_sync` -error: generator cannot be sent between threads safely +error: coroutine cannot be sent between threads safely --> $DIR/not-send-sync.rs:21:5 | LL | assert_send(|| { - | ^^^^^^^^^^^ generator is not `Send` + | ^^^^^^^^^^^ coroutine is not `Send` | - = help: within `{generator@$DIR/not-send-sync.rs:21:17: 21:19}`, the trait `Send` is not implemented for `NotSend` -note: generator is not `Send` as this value is used across a yield + = help: within `{coroutine@$DIR/not-send-sync.rs:21:17: 21:19}`, the trait `Send` is not implemented for `NotSend` +note: coroutine is not `Send` as this value is used across a yield --> $DIR/not-send-sync.rs:24:9 | LL | let a = NotSend; diff --git a/tests/ui/generator/overlap-locals.rs b/tests/ui/coroutine/overlap-locals.rs index 101c8714fa8..7c151270bb5 100644 --- a/tests/ui/generator/overlap-locals.rs +++ b/tests/ui/coroutine/overlap-locals.rs @@ -1,6 +1,6 @@ // run-pass -#![feature(generators)] +#![feature(coroutines)] fn main() { let a = || { diff --git a/tests/ui/generator/panic-drops-resume.rs b/tests/ui/coroutine/panic-drops-resume.rs index 4c3caeb14d6..e866f216a24 100644 --- a/tests/ui/generator/panic-drops-resume.rs +++ b/tests/ui/coroutine/panic-drops-resume.rs @@ -1,11 +1,11 @@ -//! Tests that panics inside a generator will correctly drop the initial resume argument. +//! Tests that panics inside a coroutine will correctly drop the initial resume argument. // run-pass // needs-unwind -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::Generator; +use std::ops::Coroutine; use std::panic::{catch_unwind, AssertUnwindSafe}; use std::pin::Pin; use std::sync::atomic::{AtomicUsize, Ordering}; diff --git a/tests/ui/generator/panic-drops.rs b/tests/ui/coroutine/panic-drops.rs index 65001fd879b..7e37279b9eb 100644 --- a/tests/ui/generator/panic-drops.rs +++ b/tests/ui/coroutine/panic-drops.rs @@ -2,9 +2,9 @@ // needs-unwind -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::Generator; +use std::ops::Coroutine; use std::panic; use std::pin::Pin; use std::sync::atomic::{AtomicUsize, Ordering}; diff --git a/tests/ui/generator/panic-safe.rs b/tests/ui/coroutine/panic-safe.rs index 3db80bb5821..9aa42756544 100644 --- a/tests/ui/generator/panic-safe.rs +++ b/tests/ui/coroutine/panic-safe.rs @@ -2,9 +2,9 @@ // needs-unwind -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; use std::panic; diff --git a/tests/ui/generator/parent-expression.rs b/tests/ui/coroutine/parent-expression.rs index 198b14528aa..4d40192c07a 100644 --- a/tests/ui/generator/parent-expression.rs +++ b/tests/ui/coroutine/parent-expression.rs @@ -1,4 +1,4 @@ -#![feature(generators, negative_impls, rustc_attrs)] +#![feature(coroutines, negative_impls, rustc_attrs)] macro_rules! type_combinations { ( diff --git a/tests/ui/generator/parent-expression.stderr b/tests/ui/coroutine/parent-expression.stderr index 25a3b051b1f..6b611bc3f10 100644 --- a/tests/ui/generator/parent-expression.stderr +++ b/tests/ui/coroutine/parent-expression.stderr @@ -1,8 +1,8 @@ -error: generator cannot be sent between threads safely +error: coroutine cannot be sent between threads safely --> $DIR/parent-expression.rs:23:13 | LL | assert_send(g); - | ^^^^^^^^^^^ generator is not `Send` + | ^^^^^^^^^^^ coroutine is not `Send` ... LL | / type_combinations!( LL | | // OK @@ -13,8 +13,8 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{generator@$DIR/parent-expression.rs:17:21: 17:28}`, the trait `Send` is not implemented for `derived_drop::Client` -note: generator is not `Send` as this value is used across a yield + = help: within `{coroutine@$DIR/parent-expression.rs:17:21: 17:28}`, the trait `Send` is not implemented for `derived_drop::Client` +note: coroutine is not `Send` as this value is used across a yield --> $DIR/parent-expression.rs:21:22 | LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { @@ -38,11 +38,11 @@ LL | fn assert_send<T: Send>(_thing: T) {} | ^^^^ required by this bound in `assert_send` = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) -error: generator cannot be sent between threads safely +error: coroutine cannot be sent between threads safely --> $DIR/parent-expression.rs:23:13 | LL | assert_send(g); - | ^^^^^^^^^^^ generator is not `Send` + | ^^^^^^^^^^^ coroutine is not `Send` ... LL | / type_combinations!( LL | | // OK @@ -53,8 +53,8 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{generator@$DIR/parent-expression.rs:17:21: 17:28}`, the trait `Send` is not implemented for `significant_drop::Client` -note: generator is not `Send` as this value is used across a yield + = help: within `{coroutine@$DIR/parent-expression.rs:17:21: 17:28}`, the trait `Send` is not implemented for `significant_drop::Client` +note: coroutine is not `Send` as this value is used across a yield --> $DIR/parent-expression.rs:21:22 | LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { @@ -78,11 +78,11 @@ LL | fn assert_send<T: Send>(_thing: T) {} | ^^^^ required by this bound in `assert_send` = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) -error: generator cannot be sent between threads safely +error: coroutine cannot be sent between threads safely --> $DIR/parent-expression.rs:23:13 | LL | assert_send(g); - | ^^^^^^^^^^^ generator is not `Send` + | ^^^^^^^^^^^ coroutine is not `Send` ... LL | / type_combinations!( LL | | // OK @@ -93,8 +93,8 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{generator@$DIR/parent-expression.rs:17:21: 17:28}`, the trait `Send` is not implemented for `insignificant_dtor::Client` -note: generator is not `Send` as this value is used across a yield + = help: within `{coroutine@$DIR/parent-expression.rs:17:21: 17:28}`, the trait `Send` is not implemented for `insignificant_dtor::Client` +note: coroutine is not `Send` as this value is used across a yield --> $DIR/parent-expression.rs:21:22 | LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { diff --git a/tests/ui/generator/partial-drop.rs b/tests/ui/coroutine/partial-drop.rs index 868f36adce2..a4347f52a70 100644 --- a/tests/ui/generator/partial-drop.rs +++ b/tests/ui/coroutine/partial-drop.rs @@ -1,5 +1,5 @@ // check-pass -#![feature(negative_impls, generators)] +#![feature(negative_impls, coroutines)] struct Foo; impl !Send for Foo {} diff --git a/tests/ui/generator/partial-initialization-across-yield.rs b/tests/ui/coroutine/partial-initialization-across-yield.rs index 65d9e6d39ca..75ad5a22804 100644 --- a/tests/ui/generator/partial-initialization-across-yield.rs +++ b/tests/ui/coroutine/partial-initialization-across-yield.rs @@ -1,7 +1,7 @@ -// Test that we don't allow yielding from a generator while a local is partially +// Test that we don't allow yielding from a coroutine while a local is partially // initialized. -#![feature(generators)] +#![feature(coroutines)] struct S { x: i32, y: i32 } struct T(i32, i32); diff --git a/tests/ui/generator/partial-initialization-across-yield.stderr b/tests/ui/coroutine/partial-initialization-across-yield.stderr index 3f9f1c046ba..3f9f1c046ba 100644 --- a/tests/ui/generator/partial-initialization-across-yield.stderr +++ b/tests/ui/coroutine/partial-initialization-across-yield.stderr diff --git a/tests/ui/generator/pattern-borrow.rs b/tests/ui/coroutine/pattern-borrow.rs index d1936370819..76084433d47 100644 --- a/tests/ui/generator/pattern-borrow.rs +++ b/tests/ui/coroutine/pattern-borrow.rs @@ -1,4 +1,4 @@ -#![feature(generators)] +#![feature(coroutines)] enum Test { A(i32), B, } @@ -6,7 +6,7 @@ fn main() { } fn fun(test: Test) { move || { - if let Test::A(ref _a) = test { //~ ERROR borrow may still be in use when generator yields + if let Test::A(ref _a) = test { //~ ERROR borrow may still be in use when coroutine yields yield (); _a.use_ref(); } diff --git a/tests/ui/generator/pattern-borrow.stderr b/tests/ui/coroutine/pattern-borrow.stderr index d78da510491..ddb3bf66214 100644 --- a/tests/ui/generator/pattern-borrow.stderr +++ b/tests/ui/coroutine/pattern-borrow.stderr @@ -1,4 +1,4 @@ -error[E0626]: borrow may still be in use when generator yields +error[E0626]: borrow may still be in use when coroutine yields --> $DIR/pattern-borrow.rs:9:24 | LL | if let Test::A(ref _a) = test { diff --git a/tests/ui/coroutine/pin-box-coroutine.rs b/tests/ui/coroutine/pin-box-coroutine.rs new file mode 100644 index 00000000000..e348551a642 --- /dev/null +++ b/tests/ui/coroutine/pin-box-coroutine.rs @@ -0,0 +1,13 @@ +// run-pass + +#![feature(coroutines, coroutine_trait)] + +use std::ops::Coroutine; + +fn assert_coroutine<G: Coroutine>(_: G) { +} + +fn main() { + assert_coroutine(static || yield); + assert_coroutine(Box::pin(static || yield)); +} diff --git a/tests/ui/generator/print/generator-print-verbose-1.rs b/tests/ui/coroutine/print/coroutine-print-verbose-1.rs index e52234c08a3..c47d7572ca7 100644 --- a/tests/ui/generator/print/generator-print-verbose-1.rs +++ b/tests/ui/coroutine/print/coroutine-print-verbose-1.rs @@ -1,22 +1,22 @@ // compile-flags: -Zverbose -// Same as: tests/ui/generator/issue-68112.stderr +// Same as: tests/ui/coroutine/issue-68112.stderr -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] use std::{ cell::RefCell, sync::Arc, pin::Pin, - ops::{Generator, GeneratorState}, + ops::{Coroutine, CoroutineState}, }; pub struct Ready<T>(Option<T>); -impl<T: Unpin> Generator<()> for Ready<T> { +impl<T: Unpin> Coroutine<()> for Ready<T> { type Return = T; type Yield = (); - fn resume(mut self: Pin<&mut Self>, _args: ()) -> GeneratorState<(), T> { - GeneratorState::Complete(self.0.take().unwrap()) + fn resume(mut self: Pin<&mut Self>, _args: ()) -> CoroutineState<(), T> { + CoroutineState::Complete(self.0.take().unwrap()) } } pub fn make_gen1<T>(t: T) -> Ready<T> { @@ -25,32 +25,32 @@ pub fn make_gen1<T>(t: T) -> Ready<T> { fn require_send(_: impl Send) {} -fn make_non_send_generator() -> impl Generator<Return = Arc<RefCell<i32>>> { +fn make_non_send_coroutine() -> impl Coroutine<Return = Arc<RefCell<i32>>> { make_gen1(Arc::new(RefCell::new(0))) } fn test1() { let send_gen = || { - let _non_send_gen = make_non_send_generator(); + let _non_send_gen = make_non_send_coroutine(); yield; }; require_send(send_gen); - //~^ ERROR generator cannot be sent between threads + //~^ ERROR coroutine cannot be sent between threads } -pub fn make_gen2<T>(t: T) -> impl Generator<Return = T> { +pub fn make_gen2<T>(t: T) -> impl Coroutine<Return = T> { || { yield; t } } -fn make_non_send_generator2() -> impl Generator<Return = Arc<RefCell<i32>>> { +fn make_non_send_coroutine2() -> impl Coroutine<Return = Arc<RefCell<i32>>> { make_gen2(Arc::new(RefCell::new(0))) } fn test2() { let send_gen = || { - let _non_send_gen = make_non_send_generator2(); + let _non_send_gen = make_non_send_coroutine2(); yield; }; require_send(send_gen); diff --git a/tests/ui/generator/print/generator-print-verbose-1.stderr b/tests/ui/coroutine/print/coroutine-print-verbose-1.stderr index d949543de41..bcdcbc154cf 100644 --- a/tests/ui/generator/print/generator-print-verbose-1.stderr +++ b/tests/ui/coroutine/print/coroutine-print-verbose-1.stderr @@ -1,26 +1,26 @@ -error: generator cannot be sent between threads safely - --> $DIR/generator-print-verbose-1.rs:37:5 +error: coroutine cannot be sent between threads safely + --> $DIR/coroutine-print-verbose-1.rs:37:5 | LL | require_send(send_gen); - | ^^^^^^^^^^^^ generator is not `Send` + | ^^^^^^^^^^^^ coroutine is not `Send` | = help: the trait `Sync` is not implemented for `RefCell<i32>` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead -note: generator is not `Send` as this value is used across a yield - --> $DIR/generator-print-verbose-1.rs:35:9 +note: coroutine is not `Send` as this value is used across a yield + --> $DIR/coroutine-print-verbose-1.rs:35:9 | -LL | let _non_send_gen = make_non_send_generator(); - | ------------- has type `Opaque(DefId(0:34 ~ generator_print_verbose_1[7d1d]::make_non_send_generator::{opaque#0}), [])` which is not `Send` +LL | let _non_send_gen = make_non_send_coroutine(); + | ------------- has type `Opaque(DefId(0:34 ~ coroutine_print_verbose_1[75fb]::make_non_send_coroutine::{opaque#0}), [])` which is not `Send` LL | yield; | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later note: required by a bound in `require_send` - --> $DIR/generator-print-verbose-1.rs:26:25 + --> $DIR/coroutine-print-verbose-1.rs:26:25 | LL | fn require_send(_: impl Send) {} | ^^^^ required by this bound in `require_send` error[E0277]: `RefCell<i32>` cannot be shared between threads safely - --> $DIR/generator-print-verbose-1.rs:56:5 + --> $DIR/coroutine-print-verbose-1.rs:56:5 | LL | require_send(send_gen); | ^^^^^^^^^^^^ `RefCell<i32>` cannot be shared between threads safely @@ -28,29 +28,29 @@ LL | require_send(send_gen); = help: the trait `Sync` is not implemented for `RefCell<i32>` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead = note: required for `Arc<RefCell<i32>>` to implement `Send` -note: required because it's used within this generator - --> $DIR/generator-print-verbose-1.rs:42:5 +note: required because it's used within this coroutine + --> $DIR/coroutine-print-verbose-1.rs:42:5 | LL | || { | ^^ -note: required because it appears within the type `Opaque(DefId(0:35 ~ generator_print_verbose_1[7d1d]::make_gen2::{opaque#0}), [Arc<RefCell<i32>>])` - --> $DIR/generator-print-verbose-1.rs:41:30 +note: required because it appears within the type `Opaque(DefId(0:35 ~ coroutine_print_verbose_1[75fb]::make_gen2::{opaque#0}), [Arc<RefCell<i32>>])` + --> $DIR/coroutine-print-verbose-1.rs:41:30 | -LL | pub fn make_gen2<T>(t: T) -> impl Generator<Return = T> { +LL | pub fn make_gen2<T>(t: T) -> impl Coroutine<Return = T> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required because it appears within the type `Opaque(DefId(0:36 ~ generator_print_verbose_1[7d1d]::make_non_send_generator2::{opaque#0}), [])` - --> $DIR/generator-print-verbose-1.rs:47:34 +note: required because it appears within the type `Opaque(DefId(0:36 ~ coroutine_print_verbose_1[75fb]::make_non_send_coroutine2::{opaque#0}), [])` + --> $DIR/coroutine-print-verbose-1.rs:47:34 | -LL | fn make_non_send_generator2() -> impl Generator<Return = Arc<RefCell<i32>>> { +LL | fn make_non_send_coroutine2() -> impl Coroutine<Return = Arc<RefCell<i32>>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `Opaque(DefId(0:36 ~ generator_print_verbose_1[7d1d]::make_non_send_generator2::{opaque#0}), [])` -note: required because it's used within this generator - --> $DIR/generator-print-verbose-1.rs:52:20 + = note: required because it captures the following types: `Opaque(DefId(0:36 ~ coroutine_print_verbose_1[75fb]::make_non_send_coroutine2::{opaque#0}), [])` +note: required because it's used within this coroutine + --> $DIR/coroutine-print-verbose-1.rs:52:20 | LL | let send_gen = || { | ^^ note: required by a bound in `require_send` - --> $DIR/generator-print-verbose-1.rs:26:25 + --> $DIR/coroutine-print-verbose-1.rs:26:25 | LL | fn require_send(_: impl Send) {} | ^^^^ required by this bound in `require_send` diff --git a/tests/ui/generator/print/generator-print-verbose-2.rs b/tests/ui/coroutine/print/coroutine-print-verbose-2.rs index e53a7ef8cc1..c65c33cb4ba 100644 --- a/tests/ui/generator/print/generator-print-verbose-2.rs +++ b/tests/ui/coroutine/print/coroutine-print-verbose-2.rs @@ -1,7 +1,7 @@ // compile-flags: -Zverbose -// Same as test/ui/generator/not-send-sync.rs -#![feature(generators)] +// Same as test/ui/coroutine/not-send-sync.rs +#![feature(coroutines)] #![feature(negative_impls)] struct NotSend; @@ -15,14 +15,14 @@ fn main() { fn assert_send<T: Send>(_: T) {} assert_sync(|| { - //~^ ERROR: generator cannot be shared between threads safely + //~^ ERROR: coroutine cannot be shared between threads safely let a = NotSync; yield; drop(a); }); assert_send(|| { - //~^ ERROR: generator cannot be sent between threads safely + //~^ ERROR: coroutine cannot be sent between threads safely let a = NotSend; yield; drop(a); diff --git a/tests/ui/generator/print/generator-print-verbose-2.stderr b/tests/ui/coroutine/print/coroutine-print-verbose-2.stderr index 8ff7557619f..e9c7a8ffcaa 100644 --- a/tests/ui/generator/print/generator-print-verbose-2.stderr +++ b/tests/ui/coroutine/print/coroutine-print-verbose-2.stderr @@ -1,39 +1,39 @@ -error: generator cannot be shared between threads safely - --> $DIR/generator-print-verbose-2.rs:17:5 +error: coroutine cannot be shared between threads safely + --> $DIR/coroutine-print-verbose-2.rs:17:5 | LL | assert_sync(|| { - | ^^^^^^^^^^^ generator is not `Sync` + | ^^^^^^^^^^^ coroutine is not `Sync` | = help: within `{main::{closure#0} upvar_tys=() {main::{closure#0}}}`, the trait `Sync` is not implemented for `NotSync` -note: generator is not `Sync` as this value is used across a yield - --> $DIR/generator-print-verbose-2.rs:20:9 +note: coroutine is not `Sync` as this value is used across a yield + --> $DIR/coroutine-print-verbose-2.rs:20:9 | LL | let a = NotSync; | - has type `NotSync` which is not `Sync` LL | yield; | ^^^^^ yield occurs here, with `a` maybe used later note: required by a bound in `assert_sync` - --> $DIR/generator-print-verbose-2.rs:14:23 + --> $DIR/coroutine-print-verbose-2.rs:14:23 | LL | fn assert_sync<T: Sync>(_: T) {} | ^^^^ required by this bound in `assert_sync` -error: generator cannot be sent between threads safely - --> $DIR/generator-print-verbose-2.rs:24:5 +error: coroutine cannot be sent between threads safely + --> $DIR/coroutine-print-verbose-2.rs:24:5 | LL | assert_send(|| { - | ^^^^^^^^^^^ generator is not `Send` + | ^^^^^^^^^^^ coroutine is not `Send` | = help: within `{main::{closure#1} upvar_tys=() {main::{closure#1}}}`, the trait `Send` is not implemented for `NotSend` -note: generator is not `Send` as this value is used across a yield - --> $DIR/generator-print-verbose-2.rs:27:9 +note: coroutine is not `Send` as this value is used across a yield + --> $DIR/coroutine-print-verbose-2.rs:27:9 | LL | let a = NotSend; | - has type `NotSend` which is not `Send` LL | yield; | ^^^^^ yield occurs here, with `a` maybe used later note: required by a bound in `assert_send` - --> $DIR/generator-print-verbose-2.rs:15:23 + --> $DIR/coroutine-print-verbose-2.rs:15:23 | LL | fn assert_send<T: Send>(_: T) {} | ^^^^ required by this bound in `assert_send` diff --git a/tests/ui/generator/print/generator-print-verbose-3.rs b/tests/ui/coroutine/print/coroutine-print-verbose-3.rs index 8689539ec8e..3e4bb628176 100644 --- a/tests/ui/generator/print/generator-print-verbose-3.rs +++ b/tests/ui/coroutine/print/coroutine-print-verbose-3.rs @@ -1,10 +1,10 @@ // compile-flags: -Zverbose -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] fn main() { let x = "Type mismatch test"; - let generator :() = || { + let coroutine :() = || { //~^ ERROR mismatched types yield 1i32; return x diff --git a/tests/ui/generator/print/generator-print-verbose-3.stderr b/tests/ui/coroutine/print/coroutine-print-verbose-3.stderr index 69358ed0a91..fb80f29d10d 100644 --- a/tests/ui/generator/print/generator-print-verbose-3.stderr +++ b/tests/ui/coroutine/print/coroutine-print-verbose-3.stderr @@ -1,7 +1,7 @@ error[E0308]: mismatched types - --> $DIR/generator-print-verbose-3.rs:7:25 + --> $DIR/coroutine-print-verbose-3.rs:7:25 | -LL | let generator :() = || { +LL | let coroutine :() = || { | ____________________--___^ | | | | | expected due to this @@ -9,10 +9,10 @@ LL | | LL | | yield 1i32; LL | | return x LL | | }; - | |_____^ expected `()`, found generator + | |_____^ expected `()`, found coroutine | = note: expected unit type `()` - found generator `{main::{closure#0} upvar_tys=(unavailable)}` + found coroutine `{main::{closure#0} upvar_tys=(unavailable)}` error: aborting due to previous error diff --git a/tests/ui/generator/reborrow-mut-upvar.rs b/tests/ui/coroutine/reborrow-mut-upvar.rs index dbd9e24e205..e4f717be8b5 100644 --- a/tests/ui/generator/reborrow-mut-upvar.rs +++ b/tests/ui/coroutine/reborrow-mut-upvar.rs @@ -1,9 +1,9 @@ // run-pass -#![feature(generators)] +#![feature(coroutines)] fn _run(bar: &mut i32) { - || { //~ WARN unused generator that must be used + || { //~ WARN unused coroutine that must be used { let _baz = &*bar; yield; diff --git a/tests/ui/generator/reborrow-mut-upvar.stderr b/tests/ui/coroutine/reborrow-mut-upvar.stderr index 2e1fec35eaf..5b614ac4be8 100644 --- a/tests/ui/generator/reborrow-mut-upvar.stderr +++ b/tests/ui/coroutine/reborrow-mut-upvar.stderr @@ -1,4 +1,4 @@ -warning: unused generator that must be used +warning: unused coroutine that must be used --> $DIR/reborrow-mut-upvar.rs:6:5 | LL | / || { @@ -10,7 +10,7 @@ LL | | *bar = 2; LL | | }; | |_____^ | - = note: generators are lazy and do nothing unless resumed + = note: coroutines are lazy and do nothing unless resumed = note: `#[warn(unused_must_use)]` on by default warning: 1 warning emitted diff --git a/tests/ui/generator/ref-escapes-but-not-over-yield.rs b/tests/ui/coroutine/ref-escapes-but-not-over-yield.rs index 3856d8233bc..a9c13188ff3 100644 --- a/tests/ui/generator/ref-escapes-but-not-over-yield.rs +++ b/tests/ui/coroutine/ref-escapes-but-not-over-yield.rs @@ -1,7 +1,7 @@ -#![feature(generators)] +#![feature(coroutines)] fn foo(x: &i32) { - // In this case, a reference to `b` escapes the generator, but not + // In this case, a reference to `b` escapes the coroutine, but not // because of a yield. We see that there is no yield in the scope of // `b` and give the more generic error message. let mut a = &3; @@ -9,7 +9,7 @@ fn foo(x: &i32) { yield(); let b = 5; a = &b; - //~^ ERROR borrowed data escapes outside of generator + //~^ ERROR borrowed data escapes outside of coroutine }; } diff --git a/tests/ui/generator/ref-escapes-but-not-over-yield.stderr b/tests/ui/coroutine/ref-escapes-but-not-over-yield.stderr index 5fc81004098..4c8694e6786 100644 --- a/tests/ui/generator/ref-escapes-but-not-over-yield.stderr +++ b/tests/ui/coroutine/ref-escapes-but-not-over-yield.stderr @@ -1,14 +1,14 @@ -error[E0521]: borrowed data escapes outside of generator +error[E0521]: borrowed data escapes outside of coroutine --> $DIR/ref-escapes-but-not-over-yield.rs:11:9 | LL | let mut a = &3; - | ----- `a` declared here, outside of the generator body + | ----- `a` declared here, outside of the coroutine body ... LL | a = &b; | ^^^^-- | | | - | | borrow is only valid in the generator body - | reference to `b` escapes the generator body here + | | borrow is only valid in the coroutine body + | reference to `b` escapes the coroutine body here error: aborting due to previous error diff --git a/tests/ui/generator/ref-upvar-not-send.rs b/tests/ui/coroutine/ref-upvar-not-send.rs index eb9ef63ecfc..487fdeea2da 100644 --- a/tests/ui/generator/ref-upvar-not-send.rs +++ b/tests/ui/coroutine/ref-upvar-not-send.rs @@ -1,7 +1,7 @@ -// For `Send` generators, suggest a `T: Sync` requirement for `&T` upvars, +// For `Send` coroutines, suggest a `T: Sync` requirement for `&T` upvars, // and suggest a `T: Send` requirement for `&mut T` upvars. -#![feature(generators)] +#![feature(coroutines)] fn assert_send<T: Send>(_: T) {} //~^ NOTE required by a bound in `assert_send` @@ -13,16 +13,16 @@ fn main() { let x: &*mut () = &std::ptr::null_mut(); let y: &mut *mut () = &mut std::ptr::null_mut(); assert_send(move || { - //~^ ERROR generator cannot be sent between threads safely - //~| NOTE generator is not `Send` + //~^ ERROR coroutine cannot be sent between threads safely + //~| NOTE coroutine is not `Send` yield; let _x = x; }); //~^^ NOTE captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync` //~| NOTE has type `&*mut ()` which is not `Send`, because `*mut ()` is not `Sync` assert_send(move || { - //~^ ERROR generator cannot be sent between threads safely - //~| NOTE generator is not `Send` + //~^ ERROR coroutine cannot be sent between threads safely + //~| NOTE coroutine is not `Send` yield; let _y = y; }); diff --git a/tests/ui/generator/ref-upvar-not-send.stderr b/tests/ui/coroutine/ref-upvar-not-send.stderr index d6a2be977e4..7f18c6fba77 100644 --- a/tests/ui/generator/ref-upvar-not-send.stderr +++ b/tests/ui/coroutine/ref-upvar-not-send.stderr @@ -1,4 +1,4 @@ -error: generator cannot be sent between threads safely +error: coroutine cannot be sent between threads safely --> $DIR/ref-upvar-not-send.rs:15:17 | LL | assert_send(move || { @@ -8,7 +8,7 @@ LL | | LL | | yield; LL | | let _x = x; LL | | }); - | |_____^ generator is not `Send` + | |_____^ coroutine is not `Send` | = help: the trait `Sync` is not implemented for `*mut ()` note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync` @@ -22,7 +22,7 @@ note: required by a bound in `assert_send` LL | fn assert_send<T: Send>(_: T) {} | ^^^^ required by this bound in `assert_send` -error: generator cannot be sent between threads safely +error: coroutine cannot be sent between threads safely --> $DIR/ref-upvar-not-send.rs:23:17 | LL | assert_send(move || { @@ -32,9 +32,9 @@ LL | | LL | | yield; LL | | let _y = y; LL | | }); - | |_____^ generator is not `Send` + | |_____^ coroutine is not `Send` | - = help: within `{generator@$DIR/ref-upvar-not-send.rs:23:17: 23:24}`, the trait `Send` is not implemented for `*mut ()` + = help: within `{coroutine@$DIR/ref-upvar-not-send.rs:23:17: 23:24}`, the trait `Send` is not implemented for `*mut ()` note: captured value is not `Send` because `&mut` references cannot be sent unless their referent is `Send` --> $DIR/ref-upvar-not-send.rs:27:18 | diff --git a/tests/ui/generator/reinit-in-match-guard.rs b/tests/ui/coroutine/reinit-in-match-guard.rs index 260b341a525..1895de1f12b 100644 --- a/tests/ui/generator/reinit-in-match-guard.rs +++ b/tests/ui/coroutine/reinit-in-match-guard.rs @@ -1,6 +1,6 @@ // build-pass -#![feature(generators)] +#![feature(coroutines)] #![allow(unused_assignments, dead_code)] diff --git a/tests/ui/generator/resume-after-return.rs b/tests/ui/coroutine/resume-after-return.rs index 01a059a161c..acbd8740a35 100644 --- a/tests/ui/generator/resume-after-return.rs +++ b/tests/ui/coroutine/resume-after-return.rs @@ -2,9 +2,9 @@ // needs-unwind -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::{GeneratorState, Generator}; +use std::ops::{CoroutineState, Coroutine}; use std::pin::Pin; use std::panic; @@ -17,12 +17,12 @@ fn main() { }; match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} + CoroutineState::Complete(()) => {} s => panic!("bad state: {:?}", s), } match panic::catch_unwind(move || Pin::new(&mut foo).resume(())) { - Ok(_) => panic!("generator successfully resumed"), + Ok(_) => panic!("coroutine successfully resumed"), Err(_) => {} } } diff --git a/tests/ui/generator/resume-arg-late-bound.rs b/tests/ui/coroutine/resume-arg-late-bound.rs index 1c35ba80d2b..dd6d318afbc 100644 --- a/tests/ui/generator/resume-arg-late-bound.rs +++ b/tests/ui/coroutine/resume-arg-late-bound.rs @@ -1,11 +1,11 @@ -//! Tests that we cannot produce a generator that accepts a resume argument +//! Tests that we cannot produce a coroutine that accepts a resume argument //! with any lifetime and then stores it across a `yield`. -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::Generator; +use std::ops::Coroutine; -fn test(a: impl for<'a> Generator<&'a mut bool>) {} +fn test(a: impl for<'a> Coroutine<&'a mut bool>) {} fn main() { let gen = |arg: &mut bool| { diff --git a/tests/ui/generator/resume-arg-late-bound.stderr b/tests/ui/coroutine/resume-arg-late-bound.stderr index 34ee4036cc5..f1a8a8ed711 100644 --- a/tests/ui/generator/resume-arg-late-bound.stderr +++ b/tests/ui/coroutine/resume-arg-late-bound.stderr @@ -4,12 +4,12 @@ error[E0308]: mismatched types LL | test(gen); | ^^^^^^^^^ one type is more general than the other | - = note: expected trait `for<'a> Generator<&'a mut bool>` - found trait `Generator<&mut bool>` + = note: expected trait `for<'a> Coroutine<&'a mut bool>` + found trait `Coroutine<&mut bool>` note: the lifetime requirement is introduced here --> $DIR/resume-arg-late-bound.rs:8:17 | -LL | fn test(a: impl for<'a> Generator<&'a mut bool>) {} +LL | fn test(a: impl for<'a> Coroutine<&'a mut bool>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/generator/resume-arg-size.rs b/tests/ui/coroutine/resume-arg-size.rs index 195166f975b..22bb469f941 100644 --- a/tests/ui/generator/resume-arg-size.rs +++ b/tests/ui/coroutine/resume-arg-size.rs @@ -1,4 +1,4 @@ -#![feature(generators)] +#![feature(coroutines)] #![allow(dropping_copy_types)] // run-pass @@ -6,7 +6,7 @@ use std::mem::size_of_val; fn main() { - // Generator taking a `Copy`able resume arg. + // Coroutine taking a `Copy`able resume arg. let gen_copy = |mut x: usize| { loop { drop(x); @@ -14,7 +14,7 @@ fn main() { } }; - // Generator taking a non-`Copy` resume arg. + // Coroutine taking a non-`Copy` resume arg. let gen_move = |mut x: Box<usize>| { loop { drop(x); @@ -22,7 +22,7 @@ fn main() { } }; - // Neither of these generators have the resume arg live across the `yield`, so they should be + // Neither of these coroutines have the resume arg live across the `yield`, so they should be // 1 Byte in size (only storing the discriminant) assert_eq!(size_of_val(&gen_copy), 1); assert_eq!(size_of_val(&gen_move), 1); diff --git a/tests/ui/generator/resume-live-across-yield.rs b/tests/ui/coroutine/resume-live-across-yield.rs index 4c4cf117a55..935e7d326be 100644 --- a/tests/ui/generator/resume-live-across-yield.rs +++ b/tests/ui/coroutine/resume-live-across-yield.rs @@ -1,8 +1,8 @@ // run-pass -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; use std::sync::atomic::{AtomicUsize, Ordering}; @@ -27,11 +27,11 @@ fn main() { assert_eq!( g.as_mut().resume(Dropper(String::from("Hello world!"))), - GeneratorState::Yielded(()) + CoroutineState::Yielded(()) ); assert_eq!(DROP.load(Ordering::Acquire), 0); match g.as_mut().resume(Dropper(String::from("Number Two"))) { - GeneratorState::Complete(dropper) => { + CoroutineState::Complete(dropper) => { assert_eq!(DROP.load(Ordering::Acquire), 1); assert_eq!(dropper.0, "Number Two"); drop(dropper); diff --git a/tests/ui/generator/retain-resume-ref.rs b/tests/ui/coroutine/retain-resume-ref.rs index 0606ea71cdf..c9f995ab0cf 100644 --- a/tests/ui/generator/retain-resume-ref.rs +++ b/tests/ui/coroutine/retain-resume-ref.rs @@ -1,11 +1,11 @@ //! This test ensures that a mutable reference cannot be passed as a resume argument twice. -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] use std::marker::Unpin; use std::ops::{ - Generator, - GeneratorState::{self, *}, + Coroutine, + CoroutineState::{self, *}, }; use std::pin::Pin; diff --git a/tests/ui/generator/retain-resume-ref.stderr b/tests/ui/coroutine/retain-resume-ref.stderr index bc715c7030e..983443bbfeb 100644 --- a/tests/ui/generator/retain-resume-ref.stderr +++ b/tests/ui/coroutine/retain-resume-ref.stderr @@ -7,7 +7,7 @@ LL | gen.as_mut().resume(&mut thing); | ^^^^^^^^^^ second mutable borrow occurs here LL | LL | } - | - first borrow might be used here, when `gen` is dropped and runs the destructor for generator + | - first borrow might be used here, when `gen` is dropped and runs the destructor for coroutine error: aborting due to previous error diff --git a/tests/ui/generator/size-moved-locals.rs b/tests/ui/coroutine/size-moved-locals.rs index 601a3141828..cfbbb9c1b31 100644 --- a/tests/ui/generator/size-moved-locals.rs +++ b/tests/ui/coroutine/size-moved-locals.rs @@ -4,7 +4,7 @@ // `complex` below.) // // The exact sizes here can change (we'd like to know when they do). What we -// don't want to see is the `complex` generator size being upwards of 2048 bytes +// don't want to see is the `complex` coroutine size being upwards of 2048 bytes // (which would indicate it is reserving space for two copies of Foo.) // // See issue #59123 for a full explanation. @@ -14,9 +14,9 @@ // ignore-asmjs issue #62807 // needs-unwind Size of Closures change on panic=abort -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::Generator; +use std::ops::Coroutine; const FOO_SIZE: usize = 1024; struct Foo(#[allow(unused_tuple_struct_fields)] [u8; FOO_SIZE]); @@ -25,7 +25,7 @@ impl Drop for Foo { fn drop(&mut self) {} } -fn move_before_yield() -> impl Generator<Yield = (), Return = ()> { +fn move_before_yield() -> impl Coroutine<Yield = (), Return = ()> { static || { let first = Foo([0; FOO_SIZE]); let _second = first; @@ -36,7 +36,7 @@ fn move_before_yield() -> impl Generator<Yield = (), Return = ()> { fn noop() {} -fn move_before_yield_with_noop() -> impl Generator<Yield = (), Return = ()> { +fn move_before_yield_with_noop() -> impl Coroutine<Yield = (), Return = ()> { static || { let first = Foo([0; FOO_SIZE]); noop(); @@ -48,7 +48,7 @@ fn move_before_yield_with_noop() -> impl Generator<Yield = (), Return = ()> { // Today we don't have NRVO (we allocate space for both `first` and `second`,) // but we can overlap `first` with `_third`. -fn overlap_move_points() -> impl Generator<Yield = (), Return = ()> { +fn overlap_move_points() -> impl Coroutine<Yield = (), Return = ()> { static || { let first = Foo([0; FOO_SIZE]); yield; @@ -59,7 +59,7 @@ fn overlap_move_points() -> impl Generator<Yield = (), Return = ()> { } } -fn overlap_x_and_y() -> impl Generator<Yield = (), Return = ()> { +fn overlap_x_and_y() -> impl Coroutine<Yield = (), Return = ()> { static || { let x = Foo([0; FOO_SIZE]); yield; diff --git a/tests/ui/coroutine/sized-yield.rs b/tests/ui/coroutine/sized-yield.rs new file mode 100644 index 00000000000..1368c88b522 --- /dev/null +++ b/tests/ui/coroutine/sized-yield.rs @@ -0,0 +1,14 @@ +#![feature(coroutines, coroutine_trait)] + +use std::ops::Coroutine; +use std::pin::Pin; + +fn main() { + let s = String::from("foo"); + let mut gen = move || { + //~^ ERROR the size for values of type + yield s[..]; + }; + Pin::new(&mut gen).resume(()); + //~^ ERROR the size for values of type +} diff --git a/tests/ui/coroutine/sized-yield.stderr b/tests/ui/coroutine/sized-yield.stderr new file mode 100644 index 00000000000..40663ac12de --- /dev/null +++ b/tests/ui/coroutine/sized-yield.stderr @@ -0,0 +1,26 @@ +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/sized-yield.rs:8:27 + | +LL | let mut gen = move || { + | ___________________________^ +LL | | +LL | | yield s[..]; +LL | | }; + | |_____^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = note: the yield type of a coroutine must have a statically known size + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/sized-yield.rs:12:24 + | +LL | Pin::new(&mut gen).resume(()); + | ^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` +note: required by a bound in `CoroutineState` + --> $SRC_DIR/core/src/ops/coroutine.rs:LL:COL + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/smoke-resume-args.rs b/tests/ui/coroutine/smoke-resume-args.rs index fa9271c538f..a801989859e 100644 --- a/tests/ui/generator/smoke-resume-args.rs +++ b/tests/ui/coroutine/smoke-resume-args.rs @@ -3,20 +3,20 @@ // revisions: default nomiropt //[nomiropt]compile-flags: -Z mir-opt-level=0 -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] use std::fmt::Debug; use std::marker::Unpin; use std::ops::{ - Generator, - GeneratorState::{self, *}, + Coroutine, + CoroutineState::{self, *}, }; use std::pin::Pin; use std::sync::atomic::{AtomicUsize, Ordering}; -fn drain<G: Generator<R, Yield = Y> + Unpin, R, Y>( +fn drain<G: Coroutine<R, Yield = Y> + Unpin, R, Y>( gen: &mut G, - inout: Vec<(R, GeneratorState<Y, G::Return>)>, + inout: Vec<(R, CoroutineState<Y, G::Return>)>, ) where Y: Debug + PartialEq, G::Return: Debug + PartialEq, diff --git a/tests/ui/generator/smoke.rs b/tests/ui/coroutine/smoke.rs index 7a917a05dd9..b74ed26865f 100644 --- a/tests/ui/generator/smoke.rs +++ b/tests/ui/coroutine/smoke.rs @@ -6,9 +6,9 @@ // ignore-emscripten no threads support // compile-flags: --test -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::{GeneratorState, Generator}; +use std::ops::{CoroutineState, Coroutine}; use std::pin::Pin; use std::thread; @@ -21,7 +21,7 @@ fn simple() { }; match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} + CoroutineState::Complete(()) => {} s => panic!("bad state: {:?}", s), } } @@ -37,7 +37,7 @@ fn return_capture() { }; match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(ref s) if *s == "foo" => {} + CoroutineState::Complete(ref s) if *s == "foo" => {} s => panic!("bad state: {:?}", s), } } @@ -49,11 +49,11 @@ fn simple_yield() { }; match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(()) => {} + CoroutineState::Yielded(()) => {} s => panic!("bad state: {:?}", s), } match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} + CoroutineState::Complete(()) => {} s => panic!("bad state: {:?}", s), } } @@ -66,11 +66,11 @@ fn yield_capture() { }; match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(ref s) if *s == "foo" => {} + CoroutineState::Yielded(ref s) if *s == "foo" => {} s => panic!("bad state: {:?}", s), } match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} + CoroutineState::Complete(()) => {} s => panic!("bad state: {:?}", s), } } @@ -83,11 +83,11 @@ fn simple_yield_value() { }; match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(ref s) if *s == "bar" => {} + CoroutineState::Yielded(ref s) if *s == "bar" => {} s => panic!("bad state: {:?}", s), } match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(ref s) if *s == "foo" => {} + CoroutineState::Complete(ref s) if *s == "foo" => {} s => panic!("bad state: {:?}", s), } } @@ -101,11 +101,11 @@ fn return_after_yield() { }; match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(()) => {} + CoroutineState::Yielded(()) => {} s => panic!("bad state: {:?}", s), } match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(ref s) if *s == "foo" => {} + CoroutineState::Complete(ref s) if *s == "foo" => {} s => panic!("bad state: {:?}", s), } } @@ -153,11 +153,11 @@ fn send_over_threads() { let mut foo = || { yield }; thread::spawn(move || { match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(()) => {} + CoroutineState::Yielded(()) => {} s => panic!("bad state: {:?}", s), } match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} + CoroutineState::Complete(()) => {} s => panic!("bad state: {:?}", s), } }).join().unwrap(); @@ -166,11 +166,11 @@ fn send_over_threads() { let mut foo = || { yield a }; thread::spawn(move || { match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(ref s) if *s == "a" => {} + CoroutineState::Yielded(ref s) if *s == "a" => {} s => panic!("bad state: {:?}", s), } match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} + CoroutineState::Complete(()) => {} s => panic!("bad state: {:?}", s), } }).join().unwrap(); diff --git a/tests/ui/coroutine/static-coroutine.rs b/tests/ui/coroutine/static-coroutine.rs new file mode 100644 index 00000000000..f9fd65b9793 --- /dev/null +++ b/tests/ui/coroutine/static-coroutine.rs @@ -0,0 +1,20 @@ +// run-pass + +#![feature(coroutines, coroutine_trait)] + +use std::pin::Pin; +use std::ops::{Coroutine, CoroutineState}; + +fn main() { + let mut coroutine = static || { + let a = true; + let b = &a; + yield; + assert_eq!(b as *const _, &a as *const _); + }; + // SAFETY: We shadow the original coroutine variable so have no safe API to + // move it after this point. + let mut coroutine = unsafe { Pin::new_unchecked(&mut coroutine) }; + assert_eq!(coroutine.as_mut().resume(()), CoroutineState::Yielded(())); + assert_eq!(coroutine.as_mut().resume(()), CoroutineState::Complete(())); +} diff --git a/tests/ui/generator/static-mut-reference-across-yield.rs b/tests/ui/coroutine/static-mut-reference-across-yield.rs index 0fa6d9cdc77..07f810856a7 100644 --- a/tests/ui/generator/static-mut-reference-across-yield.rs +++ b/tests/ui/coroutine/static-mut-reference-across-yield.rs @@ -2,7 +2,7 @@ // revisions: mir thir // [thir]compile-flags: -Zthir-unsafeck -#![feature(generators)] +#![feature(coroutines)] static mut A: [i32; 5] = [1, 2, 3, 4, 5]; diff --git a/tests/ui/generator/static-not-unpin.current.stderr b/tests/ui/coroutine/static-not-unpin.current.stderr index 242489841e8..cd607904f5a 100644 --- a/tests/ui/generator/static-not-unpin.current.stderr +++ b/tests/ui/coroutine/static-not-unpin.current.stderr @@ -1,8 +1,8 @@ -error[E0277]: `{static generator@$DIR/static-not-unpin.rs:14:25: 14:34}` cannot be unpinned +error[E0277]: `{static coroutine@$DIR/static-not-unpin.rs:14:25: 14:34}` cannot be unpinned --> $DIR/static-not-unpin.rs:17:18 | -LL | assert_unpin(generator); - | ------------ ^^^^^^^^^ the trait `Unpin` is not implemented for `{static generator@$DIR/static-not-unpin.rs:14:25: 14:34}` +LL | assert_unpin(coroutine); + | ------------ ^^^^^^^^^ the trait `Unpin` is not implemented for `{static coroutine@$DIR/static-not-unpin.rs:14:25: 14:34}` | | | required by a bound introduced by this call | diff --git a/tests/ui/generator/static-not-unpin.next.stderr b/tests/ui/coroutine/static-not-unpin.next.stderr index 242489841e8..cd607904f5a 100644 --- a/tests/ui/generator/static-not-unpin.next.stderr +++ b/tests/ui/coroutine/static-not-unpin.next.stderr @@ -1,8 +1,8 @@ -error[E0277]: `{static generator@$DIR/static-not-unpin.rs:14:25: 14:34}` cannot be unpinned +error[E0277]: `{static coroutine@$DIR/static-not-unpin.rs:14:25: 14:34}` cannot be unpinned --> $DIR/static-not-unpin.rs:17:18 | -LL | assert_unpin(generator); - | ------------ ^^^^^^^^^ the trait `Unpin` is not implemented for `{static generator@$DIR/static-not-unpin.rs:14:25: 14:34}` +LL | assert_unpin(coroutine); + | ------------ ^^^^^^^^^ the trait `Unpin` is not implemented for `{static coroutine@$DIR/static-not-unpin.rs:14:25: 14:34}` | | | required by a bound introduced by this call | diff --git a/tests/ui/generator/static-not-unpin.rs b/tests/ui/coroutine/static-not-unpin.rs index 30d3f291870..6ce78046dcc 100644 --- a/tests/ui/generator/static-not-unpin.rs +++ b/tests/ui/coroutine/static-not-unpin.rs @@ -1,7 +1,7 @@ // revisions: current next //[next] compile-flags: -Ztrait-solver=next -#![feature(generators)] +#![feature(coroutines)] // normalize-stderr-test "std::pin::Unpin" -> "std::marker::Unpin" @@ -11,8 +11,8 @@ fn assert_unpin<T: Unpin>(_: T) { } fn main() { - let mut generator = static || { + let mut coroutine = static || { yield; }; - assert_unpin(generator); //~ ERROR E0277 + assert_unpin(coroutine); //~ ERROR E0277 } diff --git a/tests/ui/generator/static-reference-across-yield.rs b/tests/ui/coroutine/static-reference-across-yield.rs index 23b11593bb5..6496d8b86cc 100644 --- a/tests/ui/generator/static-reference-across-yield.rs +++ b/tests/ui/coroutine/static-reference-across-yield.rs @@ -1,5 +1,5 @@ // build-pass -#![feature(generators)] +#![feature(coroutines)] static A: [i32; 5] = [1, 2, 3, 4, 5]; diff --git a/tests/ui/generator/too-live-local-in-immovable-gen.rs b/tests/ui/coroutine/too-live-local-in-immovable-gen.rs index e0b856db7a5..7eaa1552227 100644 --- a/tests/ui/generator/too-live-local-in-immovable-gen.rs +++ b/tests/ui/coroutine/too-live-local-in-immovable-gen.rs @@ -1,15 +1,15 @@ // run-pass #![allow(unused_unsafe)] -#![feature(generators)] +#![feature(coroutines)] fn main() { unsafe { - static move || { //~ WARN unused generator that must be used - // Tests that the generator transformation finds out that `a` is not live + static move || { //~ WARN unused coroutine that must be used + // Tests that the coroutine transformation finds out that `a` is not live // during the yield expression. Type checking will also compute liveness // and it should also find out that `a` is not live. - // The compiler will panic if the generator transformation finds that + // The compiler will panic if the coroutine transformation finds that // `a` is live and type checking finds it dead. let a = { yield (); diff --git a/tests/ui/generator/too-live-local-in-immovable-gen.stderr b/tests/ui/coroutine/too-live-local-in-immovable-gen.stderr index e262f213f63..4a67dbe71e1 100644 --- a/tests/ui/generator/too-live-local-in-immovable-gen.stderr +++ b/tests/ui/coroutine/too-live-local-in-immovable-gen.stderr @@ -1,8 +1,8 @@ -warning: unused generator that must be used +warning: unused coroutine that must be used --> $DIR/too-live-local-in-immovable-gen.rs:8:9 | LL | / static move || { -LL | | // Tests that the generator transformation finds out that `a` is not live +LL | | // Tests that the coroutine transformation finds out that `a` is not live LL | | // during the yield expression. Type checking will also compute liveness LL | | // and it should also find out that `a` is not live. ... | @@ -10,7 +10,7 @@ LL | | let _ = &a; LL | | }; | |_________^ | - = note: generators are lazy and do nothing unless resumed + = note: coroutines are lazy and do nothing unless resumed = note: `#[warn(unused_must_use)]` on by default warning: 1 warning emitted diff --git a/tests/ui/coroutine/too-many-parameters.rs b/tests/ui/coroutine/too-many-parameters.rs new file mode 100644 index 00000000000..377d80c7b22 --- /dev/null +++ b/tests/ui/coroutine/too-many-parameters.rs @@ -0,0 +1,8 @@ +#![feature(coroutines)] + +fn main() { + |(), ()| { + //~^ error: too many parameters for a coroutine + yield; + }; +} diff --git a/tests/ui/generator/too-many-parameters.stderr b/tests/ui/coroutine/too-many-parameters.stderr index 22d40db3f26..54cf42e78d3 100644 --- a/tests/ui/generator/too-many-parameters.stderr +++ b/tests/ui/coroutine/too-many-parameters.stderr @@ -1,4 +1,4 @@ -error[E0628]: too many parameters for a generator (expected 0 or 1 parameters) +error[E0628]: too many parameters for a coroutine (expected 0 or 1 parameters) --> $DIR/too-many-parameters.rs:4:5 | LL | |(), ()| { diff --git a/tests/ui/generator/type-mismatch-error.rs b/tests/ui/coroutine/type-mismatch-error.rs index d39c788a84b..0d04c21484c 100644 --- a/tests/ui/generator/type-mismatch-error.rs +++ b/tests/ui/coroutine/type-mismatch-error.rs @@ -1,11 +1,11 @@ //! Test that we get the expected type mismatch error instead of "closure is expected to take 0 //! arguments" (which got introduced after implementing resume arguments). -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::Generator; +use std::ops::Coroutine; -fn f<G: Generator>(_: G, _: G::Return) {} +fn f<G: Coroutine>(_: G, _: G::Return) {} fn main() { f( diff --git a/tests/ui/generator/type-mismatch-error.stderr b/tests/ui/coroutine/type-mismatch-error.stderr index 8f5949533e2..8f5949533e2 100644 --- a/tests/ui/generator/type-mismatch-error.stderr +++ b/tests/ui/coroutine/type-mismatch-error.stderr diff --git a/tests/ui/generator/type-mismatch-signature-deduction.rs b/tests/ui/coroutine/type-mismatch-signature-deduction.rs index 8d1ce6c7a43..d4ca622e80f 100644 --- a/tests/ui/generator/type-mismatch-signature-deduction.rs +++ b/tests/ui/coroutine/type-mismatch-signature-deduction.rs @@ -1,8 +1,8 @@ -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::Generator; +use std::ops::Coroutine; -fn foo() -> impl Generator<Return = i32> { +fn foo() -> impl Coroutine<Return = i32> { //~^ ERROR type mismatch || { if false { diff --git a/tests/ui/generator/type-mismatch-signature-deduction.stderr b/tests/ui/coroutine/type-mismatch-signature-deduction.stderr index fe1bade5577..f26e30a8e74 100644 --- a/tests/ui/generator/type-mismatch-signature-deduction.stderr +++ b/tests/ui/coroutine/type-mismatch-signature-deduction.stderr @@ -18,10 +18,10 @@ LL | Ok(5) LL | Err(5) | ++++ + -error[E0271]: type mismatch resolving `<{generator@$DIR/type-mismatch-signature-deduction.rs:7:5: 7:7} as Generator>::Return == i32` +error[E0271]: type mismatch resolving `<{coroutine@$DIR/type-mismatch-signature-deduction.rs:7:5: 7:7} as Coroutine>::Return == i32` --> $DIR/type-mismatch-signature-deduction.rs:5:13 | -LL | fn foo() -> impl Generator<Return = i32> { +LL | fn foo() -> impl Coroutine<Return = i32> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<{integer}, _>`, found `i32` | = note: expected enum `Result<{integer}, _>` diff --git a/tests/ui/generator/unresolved-ct-var.rs b/tests/ui/coroutine/unresolved-ct-var.rs index 0316385fba9..0316385fba9 100644 --- a/tests/ui/generator/unresolved-ct-var.rs +++ b/tests/ui/coroutine/unresolved-ct-var.rs diff --git a/tests/ui/generator/unresolved-ct-var.stderr b/tests/ui/coroutine/unresolved-ct-var.stderr index 9badc1dc291..9badc1dc291 100644 --- a/tests/ui/generator/unresolved-ct-var.stderr +++ b/tests/ui/coroutine/unresolved-ct-var.stderr diff --git a/tests/ui/generator/unsized-capture-across-yield.rs b/tests/ui/coroutine/unsized-capture-across-yield.rs index 7bcb0800ccf..ef9cbc1d677 100644 --- a/tests/ui/generator/unsized-capture-across-yield.rs +++ b/tests/ui/coroutine/unsized-capture-across-yield.rs @@ -1,11 +1,11 @@ -#![feature(generator_trait)] -#![feature(generators)] +#![feature(coroutine_trait)] +#![feature(coroutines)] #![feature(unsized_locals)] //~^ WARN the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes -use std::ops::Generator; +use std::ops::Coroutine; -fn capture() -> impl Generator { +fn capture() -> impl Coroutine { let b: [u8] = *(Box::new([]) as Box<[u8]>); move || { println!("{:?}", &b); diff --git a/tests/ui/generator/unsized-capture-across-yield.stderr b/tests/ui/coroutine/unsized-capture-across-yield.stderr index 8a5b968a561..8a5b968a561 100644 --- a/tests/ui/generator/unsized-capture-across-yield.stderr +++ b/tests/ui/coroutine/unsized-capture-across-yield.stderr diff --git a/tests/ui/generator/unsized-local-across-yield.rs b/tests/ui/coroutine/unsized-local-across-yield.rs index f761f45c2af..7a8ed60e46a 100644 --- a/tests/ui/generator/unsized-local-across-yield.rs +++ b/tests/ui/coroutine/unsized-local-across-yield.rs @@ -1,11 +1,11 @@ -#![feature(generator_trait)] -#![feature(generators)] +#![feature(coroutine_trait)] +#![feature(coroutines)] #![feature(unsized_locals)] //~^ WARN the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes -use std::ops::Generator; +use std::ops::Coroutine; -fn across() -> impl Generator { +fn across() -> impl Coroutine { move || { let b: [u8] = *(Box::new([]) as Box<[u8]>); //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time diff --git a/tests/ui/generator/unsized-local-across-yield.stderr b/tests/ui/coroutine/unsized-local-across-yield.stderr index 1942f266e6c..1942f266e6c 100644 --- a/tests/ui/generator/unsized-local-across-yield.stderr +++ b/tests/ui/coroutine/unsized-local-across-yield.stderr diff --git a/tests/ui/generator/xcrate-reachable.rs b/tests/ui/coroutine/xcrate-reachable.rs index 1b1cff3387d..c6328448868 100644 --- a/tests/ui/generator/xcrate-reachable.rs +++ b/tests/ui/coroutine/xcrate-reachable.rs @@ -2,11 +2,11 @@ // aux-build:xcrate-reachable.rs -#![feature(generator_trait)] +#![feature(coroutine_trait)] extern crate xcrate_reachable as foo; -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; fn main() { diff --git a/tests/ui/generator/xcrate.rs b/tests/ui/coroutine/xcrate.rs index 40986bbeb65..4572d1cfd54 100644 --- a/tests/ui/generator/xcrate.rs +++ b/tests/ui/coroutine/xcrate.rs @@ -2,29 +2,29 @@ // aux-build:xcrate.rs -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] extern crate xcrate; -use std::ops::{GeneratorState, Generator}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; fn main() { let mut foo = xcrate::foo(); match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} + CoroutineState::Complete(()) => {} s => panic!("bad state: {:?}", s), } let mut foo = xcrate::bar(3); match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(3) => {} + CoroutineState::Yielded(3) => {} s => panic!("bad state: {:?}", s), } match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} + CoroutineState::Complete(()) => {} s => panic!("bad state: {:?}", s), } } diff --git a/tests/ui/generator/yield-in-args-rev.rs b/tests/ui/coroutine/yield-in-args-rev.rs index 4c99bb3ef5e..b22c32ccd92 100644 --- a/tests/ui/generator/yield-in-args-rev.rs +++ b/tests/ui/coroutine/yield-in-args-rev.rs @@ -5,12 +5,12 @@ // argument list is not treated as live across the yield by // type-checking. -#![feature(generators)] +#![feature(coroutines)] fn foo(_a: (), _b: &bool) {} fn bar() { - || { //~ WARN unused generator that must be used + || { //~ WARN unused coroutine that must be used let b = true; foo(yield, &b); }; diff --git a/tests/ui/generator/yield-in-args-rev.stderr b/tests/ui/coroutine/yield-in-args-rev.stderr index a87248f6621..dbf46739e8b 100644 --- a/tests/ui/generator/yield-in-args-rev.stderr +++ b/tests/ui/coroutine/yield-in-args-rev.stderr @@ -1,4 +1,4 @@ -warning: unused generator that must be used +warning: unused coroutine that must be used --> $DIR/yield-in-args-rev.rs:13:5 | LL | / || { @@ -7,7 +7,7 @@ LL | | foo(yield, &b); LL | | }; | |_____^ | - = note: generators are lazy and do nothing unless resumed + = note: coroutines are lazy and do nothing unless resumed = note: `#[warn(unused_must_use)]` on by default warning: 1 warning emitted diff --git a/tests/ui/generator/yield-in-args.rs b/tests/ui/coroutine/yield-in-args.rs index 80110af55ab..b2827148d77 100644 --- a/tests/ui/generator/yield-in-args.rs +++ b/tests/ui/coroutine/yield-in-args.rs @@ -1,4 +1,4 @@ -#![feature(generators)] +#![feature(coroutines)] fn foo(_b: &bool, _a: ()) {} diff --git a/tests/ui/generator/yield-in-args.stderr b/tests/ui/coroutine/yield-in-args.stderr index ee6d22c27cd..4ff97281d7b 100644 --- a/tests/ui/generator/yield-in-args.stderr +++ b/tests/ui/coroutine/yield-in-args.stderr @@ -1,4 +1,4 @@ -error[E0626]: borrow may still be in use when generator yields +error[E0626]: borrow may still be in use when coroutine yields --> $DIR/yield-in-args.rs:8:13 | LL | foo(&b, yield); diff --git a/tests/ui/generator/yield-in-const.rs b/tests/ui/coroutine/yield-in-const.rs index fe5ca822cec..22651f32cf8 100644 --- a/tests/ui/generator/yield-in-const.rs +++ b/tests/ui/coroutine/yield-in-const.rs @@ -1,4 +1,4 @@ -#![feature(generators)] +#![feature(coroutines)] const A: u8 = { yield 3u8; 3u8}; //~^ ERROR yield expression outside diff --git a/tests/ui/generator/yield-in-const.stderr b/tests/ui/coroutine/yield-in-const.stderr index dcf4fe63e64..7afcd83403e 100644 --- a/tests/ui/generator/yield-in-const.stderr +++ b/tests/ui/coroutine/yield-in-const.stderr @@ -1,4 +1,4 @@ -error[E0627]: yield expression outside of generator literal +error[E0627]: yield expression outside of coroutine literal --> $DIR/yield-in-const.rs:3:17 | LL | const A: u8 = { yield 3u8; 3u8}; diff --git a/tests/ui/generator/yield-in-function.rs b/tests/ui/coroutine/yield-in-function.rs index 29b811621de..a99312043bd 100644 --- a/tests/ui/generator/yield-in-function.rs +++ b/tests/ui/coroutine/yield-in-function.rs @@ -1,4 +1,4 @@ -#![feature(generators)] +#![feature(coroutines)] fn main() { yield; } //~^ ERROR yield expression outside diff --git a/tests/ui/generator/yield-in-function.stderr b/tests/ui/coroutine/yield-in-function.stderr index 51cce198ca3..b2f839a65db 100644 --- a/tests/ui/generator/yield-in-function.stderr +++ b/tests/ui/coroutine/yield-in-function.stderr @@ -1,4 +1,4 @@ -error[E0627]: yield expression outside of generator literal +error[E0627]: yield expression outside of coroutine literal --> $DIR/yield-in-function.rs:3:13 | LL | fn main() { yield; } diff --git a/tests/ui/generator/yield-in-initializer.rs b/tests/ui/coroutine/yield-in-initializer.rs index 0cab36e5f28..5a7b3a4feaf 100644 --- a/tests/ui/generator/yield-in-initializer.rs +++ b/tests/ui/coroutine/yield-in-initializer.rs @@ -1,9 +1,9 @@ // run-pass -#![feature(generators)] +#![feature(coroutines)] fn main() { - static || { //~ WARN unused generator that must be used + static || { //~ WARN unused coroutine that must be used loop { // Test that `opt` is not live across the yield, even when borrowed in a loop // See https://github.com/rust-lang/rust/issues/52792 diff --git a/tests/ui/generator/yield-in-initializer.stderr b/tests/ui/coroutine/yield-in-initializer.stderr index ed14a2e3273..614df43f2f5 100644 --- a/tests/ui/generator/yield-in-initializer.stderr +++ b/tests/ui/coroutine/yield-in-initializer.stderr @@ -1,4 +1,4 @@ -warning: unused generator that must be used +warning: unused coroutine that must be used --> $DIR/yield-in-initializer.rs:6:5 | LL | / static || { @@ -10,7 +10,7 @@ LL | | } LL | | }; | |_____^ | - = note: generators are lazy and do nothing unless resumed + = note: coroutines are lazy and do nothing unless resumed = note: `#[warn(unused_must_use)]` on by default warning: 1 warning emitted diff --git a/tests/ui/generator/yield-in-static.rs b/tests/ui/coroutine/yield-in-static.rs index d27fbb33ba1..45e0380d46d 100644 --- a/tests/ui/generator/yield-in-static.rs +++ b/tests/ui/coroutine/yield-in-static.rs @@ -1,4 +1,4 @@ -#![feature(generators)] +#![feature(coroutines)] static B: u8 = { yield 3u8; 3u8}; //~^ ERROR yield expression outside diff --git a/tests/ui/generator/yield-in-static.stderr b/tests/ui/coroutine/yield-in-static.stderr index d867f3ad345..17d58325e98 100644 --- a/tests/ui/generator/yield-in-static.stderr +++ b/tests/ui/coroutine/yield-in-static.stderr @@ -1,4 +1,4 @@ -error[E0627]: yield expression outside of generator literal +error[E0627]: yield expression outside of coroutine literal --> $DIR/yield-in-static.rs:3:18 | LL | static B: u8 = { yield 3u8; 3u8}; diff --git a/tests/ui/generator/yield-outside-generator-issue-78653.rs b/tests/ui/coroutine/yield-outside-coroutine-issue-78653.rs index 4e8050c81b0..31025c33b1a 100644 --- a/tests/ui/generator/yield-outside-generator-issue-78653.rs +++ b/tests/ui/coroutine/yield-outside-coroutine-issue-78653.rs @@ -1,7 +1,7 @@ -#![feature(generators)] +#![feature(coroutines)] fn main() { yield || for i in 0 { } - //~^ ERROR yield expression outside of generator literal + //~^ ERROR yield expression outside of coroutine literal //~| ERROR `{integer}` is not an iterator } diff --git a/tests/ui/generator/yield-outside-generator-issue-78653.stderr b/tests/ui/coroutine/yield-outside-coroutine-issue-78653.stderr index dcfb211744c..f28f8913508 100644 --- a/tests/ui/generator/yield-outside-generator-issue-78653.stderr +++ b/tests/ui/coroutine/yield-outside-coroutine-issue-78653.stderr @@ -1,11 +1,11 @@ -error[E0627]: yield expression outside of generator literal - --> $DIR/yield-outside-generator-issue-78653.rs:4:5 +error[E0627]: yield expression outside of coroutine literal + --> $DIR/yield-outside-coroutine-issue-78653.rs:4:5 | LL | yield || for i in 0 { } | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: `{integer}` is not an iterator - --> $DIR/yield-outside-generator-issue-78653.rs:4:23 + --> $DIR/yield-outside-coroutine-issue-78653.rs:4:23 | LL | yield || for i in 0 { } | ^ `{integer}` is not an iterator diff --git a/tests/ui/generator/yield-subtype.rs b/tests/ui/coroutine/yield-subtype.rs index cb3fc909145..3595d449823 100644 --- a/tests/ui/generator/yield-subtype.rs +++ b/tests/ui/coroutine/yield-subtype.rs @@ -2,13 +2,13 @@ #![allow(dead_code)] #![allow(dead_code)] -#![feature(generators)] +#![feature(coroutines)] fn bar<'a>() { let a: &'static str = "hi"; let b: &'a str = a; - || { //~ WARN unused generator that must be used + || { //~ WARN unused coroutine that must be used yield a; yield b; }; diff --git a/tests/ui/generator/yield-subtype.stderr b/tests/ui/coroutine/yield-subtype.stderr index 97862e91cd4..5e7ae9f581e 100644 --- a/tests/ui/generator/yield-subtype.stderr +++ b/tests/ui/coroutine/yield-subtype.stderr @@ -1,4 +1,4 @@ -warning: unused generator that must be used +warning: unused coroutine that must be used --> $DIR/yield-subtype.rs:11:5 | LL | / || { @@ -7,7 +7,7 @@ LL | | yield b; LL | | }; | |_____^ | - = note: generators are lazy and do nothing unless resumed + = note: coroutines are lazy and do nothing unless resumed = note: `#[warn(unused_must_use)]` on by default warning: 1 warning emitted diff --git a/tests/ui/generator/yield-while-iterating.rs b/tests/ui/coroutine/yield-while-iterating.rs index 985e5d8bdc8..66ac6d3922a 100644 --- a/tests/ui/generator/yield-while-iterating.rs +++ b/tests/ui/coroutine/yield-while-iterating.rs @@ -1,11 +1,11 @@ -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::{GeneratorState, Generator}; +use std::ops::{CoroutineState, Coroutine}; use std::cell::Cell; use std::pin::Pin; fn yield_during_iter_owned_data(x: Vec<i32>) { - // The generator owns `x`, so we error out when yielding with a + // The coroutine owns `x`, so we error out when yielding with a // reference to it. This winds up becoming a rather confusing // regionck error -- in particular, we would freeze with the // reference in scope, and it doesn't live long enough. diff --git a/tests/ui/generator/yield-while-iterating.stderr b/tests/ui/coroutine/yield-while-iterating.stderr index b6563475235..5330121f372 100644 --- a/tests/ui/generator/yield-while-iterating.stderr +++ b/tests/ui/coroutine/yield-while-iterating.stderr @@ -1,4 +1,4 @@ -error[E0626]: borrow may still be in use when generator yields +error[E0626]: borrow may still be in use when coroutine yields --> $DIR/yield-while-iterating.rs:13:18 | LL | for p in &x { @@ -12,7 +12,7 @@ error[E0502]: cannot borrow `x` as immutable because it is also borrowed as muta LL | let mut b = || { | -- mutable borrow occurs here LL | for p in &mut x { - | - first borrow occurs due to use of `x` in generator + | - first borrow occurs due to use of `x` in coroutine ... LL | println!("{}", x[0]); | ^ immutable borrow occurs here diff --git a/tests/ui/generator/yield-while-local-borrowed.rs b/tests/ui/coroutine/yield-while-local-borrowed.rs index 061a64dbc36..7f8d1d4543d 100644 --- a/tests/ui/generator/yield-while-local-borrowed.rs +++ b/tests/ui/coroutine/yield-while-local-borrowed.rs @@ -1,7 +1,7 @@ -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::{GeneratorState, Generator}; use std::cell::Cell; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; fn borrow_local_inline() { @@ -11,8 +11,8 @@ fn borrow_local_inline() { // `b` and gets extended by region inference.) let mut b = move || { let a = &mut 3; - //~^ ERROR borrow may still be in use when generator yields - yield(); + //~^ ERROR borrow may still be in use when coroutine yields + yield (); println!("{}", a); }; Pin::new(&mut b).resume(()); @@ -24,7 +24,7 @@ fn borrow_local_inline_done() { { let a = &mut 3; } - yield(); + yield (); }; Pin::new(&mut b).resume(()); } @@ -38,12 +38,12 @@ fn borrow_local() { let a = 3; { let b = &a; - //~^ ERROR borrow may still be in use when generator yields - yield(); + //~^ ERROR borrow may still be in use when coroutine yields + yield (); println!("{}", b); } }; Pin::new(&mut b).resume(()); } -fn main() { } +fn main() {} diff --git a/tests/ui/generator/yield-while-local-borrowed.stderr b/tests/ui/coroutine/yield-while-local-borrowed.stderr index c1513ef9b71..8fe981de929 100644 --- a/tests/ui/generator/yield-while-local-borrowed.stderr +++ b/tests/ui/coroutine/yield-while-local-borrowed.stderr @@ -1,20 +1,20 @@ -error[E0626]: borrow may still be in use when generator yields +error[E0626]: borrow may still be in use when coroutine yields --> $DIR/yield-while-local-borrowed.rs:13:17 | LL | let a = &mut 3; | ^^^^^^ LL | -LL | yield(); - | ------- possible yield occurs here +LL | yield (); + | -------- possible yield occurs here -error[E0626]: borrow may still be in use when generator yields +error[E0626]: borrow may still be in use when coroutine yields --> $DIR/yield-while-local-borrowed.rs:40:21 | LL | let b = &a; | ^^ LL | -LL | yield(); - | ------- possible yield occurs here +LL | yield (); + | -------- possible yield occurs here error: aborting due to 2 previous errors diff --git a/tests/ui/generator/yield-while-ref-reborrowed.rs b/tests/ui/coroutine/yield-while-ref-reborrowed.rs index a03ef945dd2..07c59175858 100644 --- a/tests/ui/generator/yield-while-ref-reborrowed.rs +++ b/tests/ui/coroutine/yield-while-ref-reborrowed.rs @@ -1,12 +1,12 @@ -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::{GeneratorState, Generator}; +use std::ops::{CoroutineState, Coroutine}; use std::cell::Cell; use std::pin::Pin; fn reborrow_shared_ref(x: &i32) { // This is OK -- we have a borrow live over the yield, but it's of - // data that outlives the generator. + // data that outlives the coroutine. let mut b = move || { let a = &*x; yield(); @@ -17,7 +17,7 @@ fn reborrow_shared_ref(x: &i32) { fn reborrow_mutable_ref(x: &mut i32) { // This is OK -- we have a borrow live over the yield, but it's of - // data that outlives the generator. + // data that outlives the coroutine. let mut b = move || { let a = &mut *x; yield(); diff --git a/tests/ui/generator/yield-while-ref-reborrowed.stderr b/tests/ui/coroutine/yield-while-ref-reborrowed.stderr index 47147f9c05d..e60a9531622 100644 --- a/tests/ui/generator/yield-while-ref-reborrowed.stderr +++ b/tests/ui/coroutine/yield-while-ref-reborrowed.stderr @@ -2,9 +2,9 @@ error[E0501]: cannot borrow `x` as immutable because previous closure requires u --> $DIR/yield-while-ref-reborrowed.rs:36:20 | LL | let mut b = || { - | -- generator construction occurs here + | -- coroutine construction occurs here LL | let a = &mut *x; - | -- first borrow occurs due to use of `x` in generator + | -- first borrow occurs due to use of `x` in coroutine ... LL | println!("{}", x); | ^ second borrow occurs here diff --git a/tests/ui/generator/yielding-in-match-guards.rs b/tests/ui/coroutine/yielding-in-match-guards.rs index 4e89fc975d0..a9575a9e77e 100644 --- a/tests/ui/generator/yielding-in-match-guards.rs +++ b/tests/ui/coroutine/yielding-in-match-guards.rs @@ -8,7 +8,7 @@ // indeed a temporary borrow `y` from `x` is live // while `f().await` is being evaluated. // Thus, `&'_ u8` should be included in type signature -// of the underlying generator. +// of the underlying coroutine. #![feature(if_let_guard)] 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/drop/dynamic-drop.rs b/tests/ui/drop/dynamic-drop.rs index caef6358ea7..5bf2cc30e7f 100644 --- a/tests/ui/drop/dynamic-drop.rs +++ b/tests/ui/drop/dynamic-drop.rs @@ -1,7 +1,7 @@ // run-pass // needs-unwind -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] #![feature(if_let_guard)] #![allow(unused_assignments)] @@ -9,7 +9,7 @@ use std::cell::{Cell, RefCell}; use std::mem::ManuallyDrop; -use std::ops::Generator; +use std::ops::Coroutine; use std::panic; use std::pin::Pin; @@ -173,7 +173,7 @@ fn vec_simple(a: &Allocator) { let _x = vec![a.alloc(), a.alloc(), a.alloc(), a.alloc()]; } -fn generator(a: &Allocator, run_count: usize) { +fn coroutine(a: &Allocator, run_count: usize) { assert!(run_count < 4); let mut gen = || { @@ -471,10 +471,10 @@ fn main() { run_test(|a| field_assignment(a, false)); run_test(|a| field_assignment(a, true)); - run_test(|a| generator(a, 0)); - run_test(|a| generator(a, 1)); - run_test(|a| generator(a, 2)); - run_test(|a| generator(a, 3)); + run_test(|a| coroutine(a, 0)); + run_test(|a| coroutine(a, 1)); + run_test(|a| coroutine(a, 2)); + run_test(|a| coroutine(a, 3)); run_test(|a| mixed_drop_and_nondrop(a)); 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/E0283.rs b/tests/ui/error-codes/E0283.rs index 0643af4b7e8..5134660e3f4 100644 --- a/tests/ui/error-codes/E0283.rs +++ b/tests/ui/error-codes/E0283.rs @@ -1,10 +1,10 @@ -trait Generator { +trait Coroutine { fn create() -> u32; } struct Impl; -impl Generator for Impl { +impl Coroutine for Impl { fn create() -> u32 { 1 } } @@ -22,12 +22,12 @@ fn foo(bar: u32) {} struct AnotherImpl; -impl Generator for AnotherImpl { +impl Coroutine for AnotherImpl { fn create() -> u32 { 2 } } fn main() { - let cont: u32 = Generator::create(); //~ ERROR E0790 + let cont: u32 = Coroutine::create(); //~ ERROR E0790 } fn buzz() { diff --git a/tests/ui/error-codes/E0283.stderr b/tests/ui/error-codes/E0283.stderr index fa8d4b6e015..6008809f050 100644 --- a/tests/ui/error-codes/E0283.stderr +++ b/tests/ui/error-codes/E0283.stderr @@ -2,14 +2,14 @@ error[E0790]: cannot call associated function on trait without specifying the co --> $DIR/E0283.rs:30:21 | LL | fn create() -> u32; - | ------------------- `Generator::create` defined here + | ------------------- `Coroutine::create` defined here ... -LL | let cont: u32 = Generator::create(); +LL | let cont: u32 = Coroutine::create(); | ^^^^^^^^^^^^^^^^^ cannot call associated function of trait | help: use a fully-qualified path to a specific available implementation | -LL | let cont: u32 = </* self type */ as Generator>::create(); +LL | let cont: u32 = </* self type */ as Coroutine>::create(); | +++++++++++++++++++ + error[E0283]: type annotations needed 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/errors/remap-path-prefix-macro.normal.run.stdout b/tests/ui/errors/remap-path-prefix-macro.normal.run.stdout new file mode 100644 index 00000000000..3bbdcbb8655 --- /dev/null +++ b/tests/ui/errors/remap-path-prefix-macro.normal.run.stdout @@ -0,0 +1 @@ +remapped/errors/remap-path-prefix-macro.rs diff --git a/tests/ui/errors/remap-path-prefix-macro.rs b/tests/ui/errors/remap-path-prefix-macro.rs new file mode 100644 index 00000000000..0ba706b0a8f --- /dev/null +++ b/tests/ui/errors/remap-path-prefix-macro.rs @@ -0,0 +1,12 @@ +// run-pass +// check-run-results + +// revisions: normal with-macro-scope without-macro-scope +// compile-flags: --remap-path-prefix={{src-base}}=remapped +// [with-macro-scope]compile-flags: -Zremap-path-scope=macro,diagnostics +// [without-macro-scope]compile-flags: -Zremap-path-scope=diagnostics +// no-remap-src-base: Manually remap, so the remapped path remains in .stderr file. + +fn main() { + println!("{}", file!()); +} diff --git a/tests/ui/errors/remap-path-prefix-macro.with-macro-scope.run.stdout b/tests/ui/errors/remap-path-prefix-macro.with-macro-scope.run.stdout new file mode 100644 index 00000000000..3bbdcbb8655 --- /dev/null +++ b/tests/ui/errors/remap-path-prefix-macro.with-macro-scope.run.stdout @@ -0,0 +1 @@ +remapped/errors/remap-path-prefix-macro.rs diff --git a/tests/ui/errors/remap-path-prefix-macro.without-macro-scope.run.stdout b/tests/ui/errors/remap-path-prefix-macro.without-macro-scope.run.stdout new file mode 100644 index 00000000000..642823fec86 --- /dev/null +++ b/tests/ui/errors/remap-path-prefix-macro.without-macro-scope.run.stdout @@ -0,0 +1 @@ +$DIR/remap-path-prefix-macro.rs diff --git a/tests/ui/errors/remap-path-prefix.stderr b/tests/ui/errors/remap-path-prefix.normal.stderr index 62dbd4b8881..004f10b4e43 100644 --- a/tests/ui/errors/remap-path-prefix.stderr +++ b/tests/ui/errors/remap-path-prefix.normal.stderr @@ -1,5 +1,5 @@ error[E0425]: cannot find value `ferris` in this scope - --> remapped/errors/remap-path-prefix.rs:16:5 + --> remapped/errors/remap-path-prefix.rs:19:5 | LL | ferris | ^^^^^^ not found in this scope diff --git a/tests/ui/errors/remap-path-prefix.rs b/tests/ui/errors/remap-path-prefix.rs index 393b8e22f1c..e3338c10fd7 100644 --- a/tests/ui/errors/remap-path-prefix.rs +++ b/tests/ui/errors/remap-path-prefix.rs @@ -1,4 +1,7 @@ +// revisions: normal with-diagnostic-scope without-diagnostic-scope // compile-flags: --remap-path-prefix={{src-base}}=remapped +// [with-diagnostic-scope]compile-flags: -Zremap-path-scope=diagnostics +// [without-diagnostic-scope]compile-flags: -Zremap-path-scope=object // no-remap-src-base: Manually remap, so the remapped path remains in .stderr file. // The remapped paths are not normalized by compiletest. diff --git a/tests/ui/errors/remap-path-prefix.with-diagnostic-scope.stderr b/tests/ui/errors/remap-path-prefix.with-diagnostic-scope.stderr new file mode 100644 index 00000000000..004f10b4e43 --- /dev/null +++ b/tests/ui/errors/remap-path-prefix.with-diagnostic-scope.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find value `ferris` in this scope + --> remapped/errors/remap-path-prefix.rs:19:5 + | +LL | ferris + | ^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/errors/remap-path-prefix.without-diagnostic-scope.stderr b/tests/ui/errors/remap-path-prefix.without-diagnostic-scope.stderr new file mode 100644 index 00000000000..98fe328193c --- /dev/null +++ b/tests/ui/errors/remap-path-prefix.without-diagnostic-scope.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find value `ferris` in this scope + --> $DIR/remap-path-prefix.rs:19:5 + | +LL | ferris + | ^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. 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-closure_track_caller.rs b/tests/ui/feature-gates/feature-gate-closure_track_caller.rs index a4c91f3bc18..58a9c84be5a 100644 --- a/tests/ui/feature-gates/feature-gate-closure_track_caller.rs +++ b/tests/ui/feature-gates/feature-gate-closure_track_caller.rs @@ -1,9 +1,9 @@ // edition:2021 #![feature(stmt_expr_attributes)] -#![feature(generators)] +#![feature(coroutines)] fn main() { let _closure = #[track_caller] || {}; //~ `#[track_caller]` on closures - let _generator = #[track_caller] || { yield; }; //~ `#[track_caller]` on closures + let _coroutine = #[track_caller] || { yield; }; //~ `#[track_caller]` on closures let _future = #[track_caller] async {}; //~ `#[track_caller]` on closures } diff --git a/tests/ui/feature-gates/feature-gate-closure_track_caller.stderr b/tests/ui/feature-gates/feature-gate-closure_track_caller.stderr index cf2ea5fe1ca..d5ef5d09ed4 100644 --- a/tests/ui/feature-gates/feature-gate-closure_track_caller.stderr +++ b/tests/ui/feature-gates/feature-gate-closure_track_caller.stderr @@ -10,7 +10,7 @@ LL | let _closure = #[track_caller] || {}; error[E0658]: `#[track_caller]` on closures is currently unstable --> $DIR/feature-gate-closure_track_caller.rs:7:22 | -LL | let _generator = #[track_caller] || { yield; }; +LL | let _coroutine = #[track_caller] || { yield; }; | ^^^^^^^^^^^^^^^ | = note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information diff --git a/tests/ui/feature-gates/feature-gate-generators.rs b/tests/ui/feature-gates/feature-gate-coroutines.rs index 931fee13471..c3c5aec8824 100644 --- a/tests/ui/feature-gates/feature-gate-generators.rs +++ b/tests/ui/feature-gates/feature-gate-coroutines.rs @@ -1,6 +1,6 @@ fn main() { yield true; //~ ERROR yield syntax is experimental - //~^ ERROR yield expression outside of generator literal + //~^ ERROR yield expression outside of coroutine literal } #[cfg(FALSE)] diff --git a/tests/ui/feature-gates/feature-gate-generators.stderr b/tests/ui/feature-gates/feature-gate-coroutines.stderr index dfea178a637..dd561643901 100644 --- a/tests/ui/feature-gates/feature-gate-generators.stderr +++ b/tests/ui/feature-gates/feature-gate-coroutines.stderr @@ -1,32 +1,32 @@ error[E0658]: yield syntax is experimental - --> $DIR/feature-gate-generators.rs:2:5 + --> $DIR/feature-gate-coroutines.rs:2:5 | LL | yield true; | ^^^^^^^^^^ | = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information - = help: add `#![feature(generators)]` to the crate attributes to enable + = help: add `#![feature(coroutines)]` to the crate attributes to enable error[E0658]: yield syntax is experimental - --> $DIR/feature-gate-generators.rs:8:5 + --> $DIR/feature-gate-coroutines.rs:8:5 | LL | yield; | ^^^^^ | = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information - = help: add `#![feature(generators)]` to the crate attributes to enable + = help: add `#![feature(coroutines)]` to the crate attributes to enable error[E0658]: yield syntax is experimental - --> $DIR/feature-gate-generators.rs:9:5 + --> $DIR/feature-gate-coroutines.rs:9:5 | LL | yield 0; | ^^^^^^^ | = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information - = help: add `#![feature(generators)]` to the crate attributes to enable + = help: add `#![feature(coroutines)]` to the crate attributes to enable -error[E0627]: yield expression outside of generator literal - --> $DIR/feature-gate-generators.rs:2:5 +error[E0627]: yield expression outside of coroutine literal + --> $DIR/feature-gate-coroutines.rs:2:5 | LL | yield true; | ^^^^^^^^^^ 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/generator/async-generator-issue-67158.rs b/tests/ui/generator/async-generator-issue-67158.rs deleted file mode 100644 index 8125a7a9bb6..00000000000 --- a/tests/ui/generator/async-generator-issue-67158.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![feature(generators)] -// edition:2018 -// Regression test for #67158. -fn main() { - async { yield print!(":C") }; //~ ERROR `async` generators are not yet supported -} diff --git a/tests/ui/generator/auxiliary/metadata-sufficient-for-layout.rs b/tests/ui/generator/auxiliary/metadata-sufficient-for-layout.rs deleted file mode 100644 index 207c2735f88..00000000000 --- a/tests/ui/generator/auxiliary/metadata-sufficient-for-layout.rs +++ /dev/null @@ -1,11 +0,0 @@ -// compile-flags: --emit metadata -#![feature(generators, generator_trait)] - -use std::marker::Unpin; -use std::ops::Generator; - -pub fn g() -> impl Generator<(), Yield = (), Return = ()> { - || { - yield; - } -} diff --git a/tests/ui/generator/auxiliary/xcrate-reachable.rs b/tests/ui/generator/auxiliary/xcrate-reachable.rs deleted file mode 100644 index 2dd5ea67523..00000000000 --- a/tests/ui/generator/auxiliary/xcrate-reachable.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -fn msg() -> u32 { - 0 -} - -pub fn foo() -> impl Generator<(), Yield=(), Return=u32> { - || { - yield; - return msg(); - } -} diff --git a/tests/ui/generator/auxiliary/xcrate.rs b/tests/ui/generator/auxiliary/xcrate.rs deleted file mode 100644 index d07abd0918c..00000000000 --- a/tests/ui/generator/auxiliary/xcrate.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![feature(generators, generator_trait)] - -use std::marker::Unpin; -use std::ops::Generator; - -pub fn foo() -> impl Generator<(), Yield = (), Return = ()> { - || { - if false { - yield; - } - } -} - -pub fn bar<T: 'static>(t: T) -> Box<Generator<(), Yield = T, Return = ()> + Unpin> { - Box::new(|| { - yield t; - }) -} diff --git a/tests/ui/generator/generator-yielding-or-returning-itself.rs b/tests/ui/generator/generator-yielding-or-returning-itself.rs deleted file mode 100644 index 30788e3c186..00000000000 --- a/tests/ui/generator/generator-yielding-or-returning-itself.rs +++ /dev/null @@ -1,35 +0,0 @@ -#![feature(generator_trait)] -#![feature(generators)] - -// Test that we cannot create a generator that returns a value of its -// own type. - -use std::ops::Generator; - -pub fn want_cyclic_generator_return<T>(_: T) - where T: Generator<Yield = (), Return = T> -{ -} - -fn supply_cyclic_generator_return() { - want_cyclic_generator_return(|| { - //~^ ERROR type mismatch - if false { yield None.unwrap(); } - None.unwrap() - }) -} - -pub fn want_cyclic_generator_yield<T>(_: T) - where T: Generator<Yield = T, Return = ()> -{ -} - -fn supply_cyclic_generator_yield() { - want_cyclic_generator_yield(|| { - //~^ ERROR type mismatch - if false { yield None.unwrap(); } - None.unwrap() - }) -} - -fn main() { } diff --git a/tests/ui/generator/issue-52304.rs b/tests/ui/generator/issue-52304.rs deleted file mode 100644 index 3e9de765b12..00000000000 --- a/tests/ui/generator/issue-52304.rs +++ /dev/null @@ -1,11 +0,0 @@ -// check-pass - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -pub fn example() -> impl Generator { - || yield &1 -} - -fn main() {} diff --git a/tests/ui/generator/issue-64620-yield-array-element.rs b/tests/ui/generator/issue-64620-yield-array-element.rs deleted file mode 100644 index 2cbe8f51614..00000000000 --- a/tests/ui/generator/issue-64620-yield-array-element.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Regression test for #64620 - -#![feature(generators)] - -pub fn crash(arr: [usize; 1]) { - yield arr[0]; //~ ERROR: yield expression outside of generator literal -} - -fn main() {} diff --git a/tests/ui/generator/issue-87142.rs b/tests/ui/generator/issue-87142.rs deleted file mode 100644 index 7f670919ed6..00000000000 --- a/tests/ui/generator/issue-87142.rs +++ /dev/null @@ -1,32 +0,0 @@ -// compile-flags: -Cdebuginfo=2 -// build-pass - -// Regression test for #87142 -// This test needs the above flags and the "lib" crate type. - -#![feature(impl_trait_in_assoc_type, generator_trait, generators)] -#![crate_type = "lib"] - -use std::ops::Generator; - -pub trait GeneratorProviderAlt: Sized { - type Gen: Generator<(), Return = (), Yield = ()>; - - fn start(ctx: Context<Self>) -> Self::Gen; -} - -pub struct Context<G: 'static + GeneratorProviderAlt> { - pub link: Box<G::Gen>, -} - -impl GeneratorProviderAlt for () { - type Gen = impl Generator<(), Return = (), Yield = ()>; - fn start(ctx: Context<Self>) -> Self::Gen { - move || { - match ctx { - _ => (), - } - yield (); - } - } -} diff --git a/tests/ui/generator/nested_generators.rs b/tests/ui/generator/nested_generators.rs deleted file mode 100644 index 45519150eec..00000000000 --- a/tests/ui/generator/nested_generators.rs +++ /dev/null @@ -1,21 +0,0 @@ -// run-pass - -#![feature(generators, generator_trait)] - -use std::ops::{Generator, GeneratorState}; -use std::pin::Pin; - -fn main() { - let _generator = || { - let mut sub_generator = || { - yield 2; - }; - - match Pin::new(&mut sub_generator).resume(()) { - GeneratorState::Yielded(x) => { - yield x; - } - _ => panic!(), - }; - }; -} diff --git a/tests/ui/generator/pin-box-generator.rs b/tests/ui/generator/pin-box-generator.rs deleted file mode 100644 index c3136f5c0ec..00000000000 --- a/tests/ui/generator/pin-box-generator.rs +++ /dev/null @@ -1,13 +0,0 @@ -// run-pass - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -fn assert_generator<G: Generator>(_: G) { -} - -fn main() { - assert_generator(static || yield); - assert_generator(Box::pin(static || yield)); -} diff --git a/tests/ui/generator/sized-yield.rs b/tests/ui/generator/sized-yield.rs deleted file mode 100644 index c6dd738d6ac..00000000000 --- a/tests/ui/generator/sized-yield.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::pin::Pin; - -fn main() { - let s = String::from("foo"); - let mut gen = move || { - //~^ ERROR the size for values of type - yield s[..]; - }; - Pin::new(&mut gen).resume(()); - //~^ ERROR the size for values of type -} diff --git a/tests/ui/generator/sized-yield.stderr b/tests/ui/generator/sized-yield.stderr deleted file mode 100644 index fb34540d969..00000000000 --- a/tests/ui/generator/sized-yield.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/sized-yield.rs:8:26 - | -LL | let mut gen = move || { - | __________________________^ -LL | | -LL | | yield s[..]; -LL | | }; - | |____^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `str` - = note: the yield type of a generator must have a statically known size - -error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/sized-yield.rs:12:23 - | -LL | Pin::new(&mut gen).resume(()); - | ^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `str` -note: required by a bound in `GeneratorState` - --> $SRC_DIR/core/src/ops/generator.rs:LL:COL - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/static-generators.rs b/tests/ui/generator/static-generators.rs deleted file mode 100644 index d098bf1e688..00000000000 --- a/tests/ui/generator/static-generators.rs +++ /dev/null @@ -1,20 +0,0 @@ -// run-pass - -#![feature(generators, generator_trait)] - -use std::pin::Pin; -use std::ops::{Generator, GeneratorState}; - -fn main() { - let mut generator = static || { - let a = true; - let b = &a; - yield; - assert_eq!(b as *const _, &a as *const _); - }; - // SAFETY: We shadow the original generator variable so have no safe API to - // move it after this point. - let mut generator = unsafe { Pin::new_unchecked(&mut generator) }; - assert_eq!(generator.as_mut().resume(()), GeneratorState::Yielded(())); - assert_eq!(generator.as_mut().resume(()), GeneratorState::Complete(())); -} diff --git a/tests/ui/generator/too-many-parameters.rs b/tests/ui/generator/too-many-parameters.rs deleted file mode 100644 index 7a353ea298b..00000000000 --- a/tests/ui/generator/too-many-parameters.rs +++ /dev/null @@ -1,8 +0,0 @@ -#![feature(generators)] - -fn main() { - |(), ()| { - //~^ error: too many parameters for a generator - yield; - }; -} diff --git a/tests/ui/generic-associated-types/bugs/issue-100013.rs b/tests/ui/generic-associated-types/bugs/issue-100013.rs index 973c548d785..b13b730d5d8 100644 --- a/tests/ui/generic-associated-types/bugs/issue-100013.rs +++ b/tests/ui/generic-associated-types/bugs/issue-100013.rs @@ -3,7 +3,7 @@ // edition: 2021 // We really should accept this, but we need implied bounds between the regions -// in a generator interior. +// in a coroutine interior. pub trait FutureIterator { type Future<'s, 'cx>: Send @@ -12,21 +12,21 @@ pub trait FutureIterator { } fn call<I: FutureIterator>() -> impl Send { - async { // a generator checked for autotrait impl `Send` + async { // a coroutine checked for autotrait impl `Send` let x = None::<I::Future<'_, '_>>; // a type referencing GAT async {}.await; // a yield point } } fn call2<'a, 'b, I: FutureIterator>() -> impl Send { - async { // a generator checked for autotrait impl `Send` + async { // a coroutine checked for autotrait impl `Send` let x = None::<I::Future<'a, 'b>>; // a type referencing GAT async {}.await; // a yield point } } fn call3<'a: 'b, 'b, I: FutureIterator>() -> impl Send { - async { // a generator checked for autotrait impl `Send` + async { // a coroutine checked for autotrait impl `Send` let x = None::<I::Future<'a, 'b>>; // a type referencing GAT async {}.await; // a yield point } diff --git a/tests/ui/generic-associated-types/bugs/issue-100013.stderr b/tests/ui/generic-associated-types/bugs/issue-100013.stderr index 93c69422f00..ff82aebfef9 100644 --- a/tests/ui/generic-associated-types/bugs/issue-100013.stderr +++ b/tests/ui/generic-associated-types/bugs/issue-100013.stderr @@ -1,7 +1,7 @@ error: lifetime bound not satisfied --> $DIR/issue-100013.rs:15:5 | -LL | / async { // a generator checked for autotrait impl `Send` +LL | / async { // a coroutine checked for autotrait impl `Send` LL | | let x = None::<I::Future<'_, '_>>; // a type referencing GAT LL | | async {}.await; // a yield point LL | | } @@ -12,7 +12,7 @@ LL | | } error: lifetime bound not satisfied --> $DIR/issue-100013.rs:22:5 | -LL | / async { // a generator checked for autotrait impl `Send` +LL | / async { // a coroutine checked for autotrait impl `Send` LL | | let x = None::<I::Future<'a, 'b>>; // a type referencing GAT LL | | async {}.await; // a yield point LL | | } @@ -27,7 +27,7 @@ LL | fn call2<'a, 'b, I: FutureIterator>() -> impl Send { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here -LL | async { // a generator checked for autotrait impl `Send` +LL | async { // a coroutine checked for autotrait impl `Send` LL | let x = None::<I::Future<'a, 'b>>; // a type referencing GAT | ^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'b` | @@ -36,7 +36,7 @@ LL | let x = None::<I::Future<'a, 'b>>; // a type referencing GAT error: lifetime bound not satisfied --> $DIR/issue-100013.rs:29:5 | -LL | / async { // a generator checked for autotrait impl `Send` +LL | / async { // a coroutine checked for autotrait impl `Send` LL | | let x = None::<I::Future<'a, 'b>>; // a type referencing GAT LL | | async {}.await; // a yield point LL | | } 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/bounds_regression.rs b/tests/ui/impl-trait/bounds_regression.rs index 31fc46203d3..f32d83c0c40 100644 --- a/tests/ui/impl-trait/bounds_regression.rs +++ b/tests/ui/impl-trait/bounds_regression.rs @@ -1,6 +1,6 @@ // run-pass -pub trait FakeGenerator { +pub trait FakeCoroutine { type Yield; type Return; } @@ -9,15 +9,15 @@ pub trait FakeFuture { type Output; } -pub fn future_from_generator< - T: FakeGenerator<Yield = ()> +pub fn future_from_coroutine< + T: FakeCoroutine<Yield = ()> >(x: T) -> impl FakeFuture<Output = T::Return> { GenFuture(x) } -struct GenFuture<T: FakeGenerator<Yield = ()>>(#[allow(unused_tuple_struct_fields)] T); +struct GenFuture<T: FakeCoroutine<Yield = ()>>(#[allow(unused_tuple_struct_fields)] T); -impl<T: FakeGenerator<Yield = ()>> FakeFuture for GenFuture<T> { +impl<T: FakeCoroutine<Yield = ()>> FakeFuture for GenFuture<T> { type Output = T::Return; } 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/issues/issue-58504.rs b/tests/ui/impl-trait/issues/issue-58504.rs index f1d7b94ef2d..03b51ae92d1 100644 --- a/tests/ui/impl-trait/issues/issue-58504.rs +++ b/tests/ui/impl-trait/issues/issue-58504.rs @@ -1,12 +1,12 @@ -#![feature(generators, generator_trait, never_type)] +#![feature(coroutines, coroutine_trait, never_type)] -use std::ops::Generator; +use std::ops::Coroutine; -fn mk_gen() -> impl Generator<Return=!, Yield=()> { +fn mk_gen() -> impl Coroutine<Return=!, Yield=()> { || { loop { yield; } } } fn main() { - let gens: [impl Generator<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ]; + let gens: [impl Coroutine<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ]; //~^ `impl Trait` only allowed in function and inherent method argument and return types } diff --git a/tests/ui/impl-trait/issues/issue-58504.stderr b/tests/ui/impl-trait/issues/issue-58504.stderr index 1be676ee075..49376f559cf 100644 --- a/tests/ui/impl-trait/issues/issue-58504.stderr +++ b/tests/ui/impl-trait/issues/issue-58504.stderr @@ -1,7 +1,7 @@ error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings --> $DIR/issue-58504.rs:10:16 | -LL | let gens: [impl Generator<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ]; +LL | let gens: [impl Coroutine<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/impl-trait/lifetimes.rs b/tests/ui/impl-trait/lifetimes.rs index 9a9843375e4..f853117a9c6 100644 --- a/tests/ui/impl-trait/lifetimes.rs +++ b/tests/ui/impl-trait/lifetimes.rs @@ -1,7 +1,7 @@ // run-pass #![allow(warnings)] -#![feature(generators)] +#![feature(coroutines)] use std::fmt::Debug; @@ -114,7 +114,7 @@ impl<'unnecessary_lifetime> MyVec { self.0.iter().flat_map(|inner_vec| inner_vec.iter()) } - fn generator_doesnt_capture_unnecessary_lifetime<'s: 's>() -> impl Sized { + fn coroutine_doesnt_capture_unnecessary_lifetime<'s: 's>() -> impl Sized { || yield } } 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/recursive-generator.rs b/tests/ui/impl-trait/recursive-coroutine.rs index 000af70c454..6351cef95a6 100644 --- a/tests/ui/impl-trait/recursive-generator.rs +++ b/tests/ui/impl-trait/recursive-coroutine.rs @@ -1,16 +1,16 @@ -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; -fn foo() -> impl Generator<Yield = (), Return = ()> { +fn foo() -> impl Coroutine<Yield = (), Return = ()> { //~^ ERROR cannot resolve opaque type //~| NOTE recursive opaque type //~| NOTE in this expansion of desugaring of || { let mut gen = Box::pin(foo()); - //~^ NOTE generator captures itself here + //~^ NOTE coroutine captures itself here let mut r = gen.as_mut().resume(()); - while let GeneratorState::Yielded(v) = r { + while let CoroutineState::Yielded(v) = r { yield v; r = gen.as_mut().resume(()); } diff --git a/tests/ui/impl-trait/recursive-generator.stderr b/tests/ui/impl-trait/recursive-coroutine.stderr index 86e193d9599..d36a58a8643 100644 --- a/tests/ui/impl-trait/recursive-generator.stderr +++ b/tests/ui/impl-trait/recursive-coroutine.stderr @@ -1,11 +1,11 @@ error[E0720]: cannot resolve opaque type - --> $DIR/recursive-generator.rs:5:13 + --> $DIR/recursive-coroutine.rs:5:13 | -LL | fn foo() -> impl Generator<Yield = (), Return = ()> { +LL | fn foo() -> impl Coroutine<Yield = (), Return = ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ recursive opaque type ... LL | let mut gen = Box::pin(foo()); - | ------- generator captures itself here + | ------- coroutine captures itself here error: aborting due to previous error diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs index ffc0cd9d10c..8331eec906e 100644 --- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs +++ b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs @@ -1,7 +1,7 @@ // Test that impl trait does not allow creating recursive types that are // otherwise forbidden. -#![feature(generators)] +#![feature(coroutines)] #![allow(unconditional_recursion)] fn option(i: i32) -> impl Sized { @@ -50,14 +50,14 @@ fn closure_sig() -> impl Sized { || closure_sig() } -fn generator_sig() -> impl Sized { +fn coroutine_sig() -> impl Sized { //~^ ERROR - || generator_sig() + || coroutine_sig() } -fn generator_capture() -> impl Sized { +fn coroutine_capture() -> impl Sized { //~^ ERROR - let x = generator_capture(); + let x = coroutine_capture(); move || { yield; x; @@ -69,10 +69,10 @@ fn substs_change<T: 'static>() -> impl Sized { (substs_change::<&T>(),) } -fn generator_hold() -> impl Sized { +fn coroutine_hold() -> impl Sized { //~^ ERROR move || { - let x = generator_hold(); + let x = coroutine_hold(); yield; x; } diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr index 1d919fb5240..8e9aa8ad0a6 100644 --- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr +++ b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr @@ -81,24 +81,24 @@ LL | || closure_sig() error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:53:23 | -LL | fn generator_sig() -> impl Sized { +LL | fn coroutine_sig() -> impl Sized { | ^^^^^^^^^^ recursive opaque type LL | -LL | || generator_sig() +LL | || coroutine_sig() | ------------------ returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:55:5: 55:7}` error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:58:27 | -LL | fn generator_capture() -> impl Sized { +LL | fn coroutine_capture() -> impl Sized { | ^^^^^^^^^^ recursive opaque type ... LL | / move || { LL | | yield; LL | | x; - | | - generator captures itself here + | | - coroutine captures itself here LL | | } - | |_____- returning here with type `{generator@$DIR/recursive-impl-trait-type-indirect.rs:61:5: 61:12}` + | |_____- returning here with type `{coroutine@$DIR/recursive-impl-trait-type-indirect.rs:61:5: 61:12}` error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:67:35 @@ -112,11 +112,11 @@ LL | (substs_change::<&T>(),) error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:72:24 | -LL | fn generator_hold() -> impl Sized { +LL | fn coroutine_hold() -> impl Sized { | ^^^^^^^^^^ recursive opaque type ... -LL | let x = generator_hold(); - | - generator captures itself here +LL | let x = coroutine_hold(); + | - coroutine captures itself here error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:86:26 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/lazy-type-alias-impl-trait/freeze_cycle.rs b/tests/ui/lazy-type-alias-impl-trait/freeze_cycle.rs index f02a93ed41b..80aba0ba04d 100644 --- a/tests/ui/lazy-type-alias-impl-trait/freeze_cycle.rs +++ b/tests/ui/lazy-type-alias-impl-trait/freeze_cycle.rs @@ -1,8 +1,8 @@ // check-pass -#![feature(generator_trait, negative_impls)] +#![feature(coroutine_trait, negative_impls)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::task::{Poll, Context}; use std::future::{Future}; use std::ptr::NonNull; @@ -17,27 +17,27 @@ unsafe impl Send for ResumeTy {} unsafe impl Sync for ResumeTy {} -pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return> +pub const fn from_coroutine<T>(gen: T) -> impl Future<Output = T::Return> where - T: Generator<ResumeTy, Yield = ()>, + T: Coroutine<ResumeTy, Yield = ()>, { - struct GenFuture<T: Generator<ResumeTy, Yield = ()>>(T); + struct GenFuture<T: Coroutine<ResumeTy, Yield = ()>>(T); // We rely on the fact that async/await futures are immovable in order to create - // self-referential borrows in the underlying generator. - impl<T: Generator<ResumeTy, Yield = ()>> !Unpin for GenFuture<T> {} + // self-referential borrows in the underlying coroutine. + impl<T: Coroutine<ResumeTy, Yield = ()>> !Unpin for GenFuture<T> {} - impl<T: Generator<ResumeTy, Yield = ()>> Future for GenFuture<T> { + impl<T: Coroutine<ResumeTy, Yield = ()>> Future for GenFuture<T> { type Output = T::Return; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { // SAFETY: Safe because we're !Unpin + !Drop, and this is just a field projection. let gen = unsafe { Pin::map_unchecked_mut(self, |s| &mut s.0) }; - // Resume the generator, turning the `&mut Context` into a `NonNull` raw pointer. The + // Resume the coroutine, turning the `&mut Context` into a `NonNull` raw pointer. The // `.await` lowering will safely cast that back to a `&mut Context`. match gen.resume(ResumeTy(NonNull::from(cx).cast::<Context<'static>>())) { - GeneratorState::Yielded(()) => Poll::Pending, - GeneratorState::Complete(x) => Poll::Ready(x), + CoroutineState::Yielded(()) => Poll::Pending, + CoroutineState::Complete(x) => Poll::Ready(x), } } } diff --git a/tests/ui/lifetimes/borrowck-let-suggestion.stderr b/tests/ui/lifetimes/borrowck-let-suggestion.stderr index da0078698ae..62119664764 100644 --- a/tests/ui/lifetimes/borrowck-let-suggestion.stderr +++ b/tests/ui/lifetimes/borrowck-let-suggestion.stderr @@ -10,6 +10,10 @@ LL | x.use_mut(); | - borrow later used here | = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider consuming the `Vec<i32>` when turning it into an `Iterator` + | +LL | let mut x = vec![1].into_iter(); + | ~~~~~~~~~ help: consider using a `let` binding to create a longer lived value | LL ~ let binding = vec![1]; diff --git a/tests/ui/lifetimes/issue-77175.rs b/tests/ui/lifetimes/issue-77175.rs index 2282752b6c1..8072691ae3c 100644 --- a/tests/ui/lifetimes/issue-77175.rs +++ b/tests/ui/lifetimes/issue-77175.rs @@ -5,7 +5,7 @@ // Prior to the fix, the compiler complained that the 'a lifetime was only used // once. This was obviously wrong since the lifetime is used twice: For the s3 // parameter and the return type. The issue was caused by the compiler -// desugaring the async function into a generator that uses only a single +// desugaring the async function into a coroutine that uses only a single // lifetime, which then the validator complained about becauase of the // single_use_lifetimes constraints. async fn bar<'a>(s1: String, s2: &'_ str, s3: &'a str) -> &'a str { 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/lint/must_not_suspend/tuple-mismatch.rs b/tests/ui/lint/must_not_suspend/tuple-mismatch.rs index c7e14e42561..2f3c5d9ea29 100644 --- a/tests/ui/lint/must_not_suspend/tuple-mismatch.rs +++ b/tests/ui/lint/must_not_suspend/tuple-mismatch.rs @@ -1,7 +1,7 @@ -#![feature(generators)] +#![feature(coroutines)] fn main() { - let _generator = || { + let _coroutine = || { yield ((), ((), ())); yield ((), ()); //~^ ERROR mismatched types diff --git a/tests/ui/lint/unused/issue-74883-unused-paren-baren-yield.rs b/tests/ui/lint/unused/issue-74883-unused-paren-baren-yield.rs index 8064c3a88d1..c5dd281cb4e 100644 --- a/tests/ui/lint/unused/issue-74883-unused-paren-baren-yield.rs +++ b/tests/ui/lint/unused/issue-74883-unused-paren-baren-yield.rs @@ -1,8 +1,8 @@ -#![feature(generator_trait)] -#![feature(generators)] +#![feature(coroutine_trait)] +#![feature(coroutines)] #![deny(unused_braces, unused_parens)] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; fn main() { diff --git a/tests/ui/lint/unused/unused-closure.rs b/tests/ui/lint/unused/unused-closure.rs index c96c907318c..12ee8b3a9bb 100644 --- a/tests/ui/lint/unused/unused-closure.rs +++ b/tests/ui/lint/unused/unused-closure.rs @@ -1,8 +1,8 @@ -// Test that closures and generators are "must use" types. +// Test that closures and coroutines are "must use" types. // edition:2018 #![feature(async_closure)] -#![feature(generators)] +#![feature(coroutines)] #![deny(unused_must_use)] fn unused() { diff --git a/tests/ui/liveness/liveness-upvars.rs b/tests/ui/liveness/liveness-upvars.rs index d446d57d396..17158dfbc6c 100644 --- a/tests/ui/liveness/liveness-upvars.rs +++ b/tests/ui/liveness/liveness-upvars.rs @@ -1,6 +1,6 @@ // edition:2018 // check-pass -#![feature(generators)] +#![feature(coroutines)] #![warn(unused)] #![allow(unreachable_code)] @@ -60,7 +60,7 @@ pub fn f() { }; let _ = async move { println!("{}", c); - // Never read because this is a generator. + // Never read because this is a coroutine. c += 1; //~ WARN value assigned to `c` is never read }; } @@ -110,7 +110,7 @@ async fn yield_now() { todo!(); } -pub fn async_generator() { +pub fn async_coroutine() { let mut state: u32 = 0; let _ = async { @@ -129,7 +129,7 @@ pub fn async_generator() { }; } -pub fn generator() { +pub fn coroutine() { let mut s: u32 = 0; let _ = |_| { s = 0; diff --git a/tests/ui/macros/stringify.rs b/tests/ui/macros/stringify.rs index 8b4e6250a30..1e9e7a89dde 100644 --- a/tests/ui/macros/stringify.rs +++ b/tests/ui/macros/stringify.rs @@ -7,7 +7,7 @@ #![feature(box_patterns)] #![feature(const_trait_impl)] #![feature(decl_macro)] -#![feature(generators)] +#![feature(coroutines)] #![feature(more_qualified_paths)] #![feature(raw_ref_op)] #![feature(trait_alias)] 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/mir/issue-71793-inline-args-storage.rs b/tests/ui/mir/issue-71793-inline-args-storage.rs index 18f2e38d14c..3749d5ebf81 100644 --- a/tests/ui/mir/issue-71793-inline-args-storage.rs +++ b/tests/ui/mir/issue-71793-inline-args-storage.rs @@ -1,5 +1,5 @@ // Verifies that inliner emits StorageLive & StorageDead when introducing -// temporaries for arguments, so that they don't become part of the generator. +// temporaries for arguments, so that they don't become part of the coroutine. // Regression test for #71793. // // check-pass diff --git a/tests/ui/mir/remove-zsts-query-cycle.rs b/tests/ui/mir/remove-zsts-query-cycle.rs index be4d68f2de7..bcaf8468857 100644 --- a/tests/ui/mir/remove-zsts-query-cycle.rs +++ b/tests/ui/mir/remove-zsts-query-cycle.rs @@ -1,5 +1,5 @@ // Regression test for #88972. Used to cause a query cycle: -// optimized mir -> remove zsts -> layout of a generator -> optimized mir. +// optimized mir -> remove zsts -> layout of a coroutine -> optimized mir. // // edition:2018 // compile-flags: --crate-type=lib -Zinline-mir=yes 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/nll/generator-distinct-lifetime.rs b/tests/ui/nll/coroutine-distinct-lifetime.rs index 90fe6b56960..0483b8858ba 100644 --- a/tests/ui/nll/generator-distinct-lifetime.rs +++ b/tests/ui/nll/coroutine-distinct-lifetime.rs @@ -1,7 +1,7 @@ -#![feature(generators)] +#![feature(coroutines)] // Test for issue #47189. Here, both `s` and `t` are live for the -// generator's lifetime, but within the generator they have distinct +// coroutine's lifetime, but within the coroutine they have distinct // lifetimes. We accept this code -- even though the borrow extends // over a yield -- because the data that is borrowed (`*x`) is not // stored on the stack. diff --git a/tests/ui/nll/generator-upvar-mutability.rs b/tests/ui/nll/coroutine-upvar-mutability.rs index c49ea15b824..12853b16b9b 100644 --- a/tests/ui/nll/generator-upvar-mutability.rs +++ b/tests/ui/nll/coroutine-upvar-mutability.rs @@ -1,6 +1,6 @@ -// Check that generators respect the muatability of their upvars. +// Check that coroutines respect the muatability of their upvars. -#![feature(generators)] +#![feature(coroutines)] fn mutate_upvar() { let x = 0; diff --git a/tests/ui/nll/generator-upvar-mutability.stderr b/tests/ui/nll/coroutine-upvar-mutability.stderr index 31b061b61d1..464bbc76931 100644 --- a/tests/ui/nll/generator-upvar-mutability.stderr +++ b/tests/ui/nll/coroutine-upvar-mutability.stderr @@ -1,5 +1,5 @@ error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/generator-upvar-mutability.rs:8:9 + --> $DIR/coroutine-upvar-mutability.rs:8:9 | LL | let x = 0; | - help: consider changing this to be mutable: `mut x` diff --git a/tests/ui/nll/extra-unused-mut.rs b/tests/ui/nll/extra-unused-mut.rs index 340f2952acc..b04e3954249 100644 --- a/tests/ui/nll/extra-unused-mut.rs +++ b/tests/ui/nll/extra-unused-mut.rs @@ -2,7 +2,7 @@ // check-pass -#![feature(generators)] +#![feature(coroutines)] #![deny(unused_mut)] fn ref_argument(ref _y: i32) {} @@ -16,7 +16,7 @@ fn mutable_upvar() { } // #50897 -fn generator_mutable_upvar() { +fn coroutine_mutable_upvar() { let mut x = 0; move || { x = 1; diff --git a/tests/ui/nll/issue-48623-generator.rs b/tests/ui/nll/issue-48623-coroutine.rs index 08d2584ee5e..bd11aaf1429 100644 --- a/tests/ui/nll/issue-48623-generator.rs +++ b/tests/ui/nll/issue-48623-coroutine.rs @@ -2,7 +2,7 @@ #![allow(path_statements)] #![allow(dead_code)] -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] struct WithDrop; @@ -10,9 +10,9 @@ impl Drop for WithDrop { fn drop(&mut self) {} } -fn reborrow_from_generator(r: &mut ()) { +fn reborrow_from_coroutine(r: &mut ()) { let d = WithDrop; - move || { d; yield; &mut *r }; //~ WARN unused generator that must be used + move || { d; yield; &mut *r }; //~ WARN unused coroutine that must be used } fn main() {} diff --git a/tests/ui/nll/issue-48623-generator.stderr b/tests/ui/nll/issue-48623-coroutine.stderr index bfdfca21004..1b7b1735aac 100644 --- a/tests/ui/nll/issue-48623-generator.stderr +++ b/tests/ui/nll/issue-48623-coroutine.stderr @@ -1,10 +1,10 @@ -warning: unused generator that must be used - --> $DIR/issue-48623-generator.rs:15:5 +warning: unused coroutine that must be used + --> $DIR/issue-48623-coroutine.rs:15:5 | LL | move || { d; yield; &mut *r }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: generators are lazy and do nothing unless resumed + = note: coroutines are lazy and do nothing unless resumed = note: `#[warn(unused_must_use)]` on by default warning: 1 warning emitted diff --git a/tests/ui/nll/issue-55850.rs b/tests/ui/nll/issue-55850.rs index e6279bd028e..fc873af9463 100644 --- a/tests/ui/nll/issue-55850.rs +++ b/tests/ui/nll/issue-55850.rs @@ -1,16 +1,16 @@ #![allow(unused_mut)] -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] use std::marker::Unpin; -use std::ops::Generator; -use std::ops::GeneratorState::Yielded; +use std::ops::Coroutine; +use std::ops::CoroutineState::Yielded; use std::pin::Pin; pub struct GenIter<G>(G); impl <G> Iterator for GenIter<G> where - G: Generator + Unpin, + G: Coroutine + Unpin, { type Item = G::Yield; @@ -26,7 +26,7 @@ fn bug<'a>() -> impl Iterator<Item = &'a str> { GenIter(move || { let mut s = String::new(); yield &s[..] //~ ERROR cannot yield value referencing local variable `s` [E0515] - //~| ERROR borrow may still be in use when generator yields + //~| ERROR borrow may still be in use when coroutine yields }) } diff --git a/tests/ui/nll/issue-55850.stderr b/tests/ui/nll/issue-55850.stderr index 86a8cdc42ff..3d43817f4d8 100644 --- a/tests/ui/nll/issue-55850.stderr +++ b/tests/ui/nll/issue-55850.stderr @@ -7,7 +7,7 @@ LL | yield &s[..] | | `s` is borrowed here | yields a value referencing data owned by the current function -error[E0626]: borrow may still be in use when generator yields +error[E0626]: borrow may still be in use when coroutine yields --> $DIR/issue-55850.rs:28:16 | LL | yield &s[..] diff --git a/tests/ui/object-safety/assoc_type_bounds_implicit_sized.fixed b/tests/ui/object-safety/assoc_type_bounds_implicit_sized.fixed new file mode 100644 index 00000000000..45c7e07a264 --- /dev/null +++ b/tests/ui/object-safety/assoc_type_bounds_implicit_sized.fixed @@ -0,0 +1,10 @@ +// run-rustfix +trait TraitWithAType { + type Item: ?Sized; +} +trait Trait {} +struct A {} +impl TraitWithAType for A { + type Item = dyn Trait; //~ ERROR E0277 +} +fn main() {} diff --git a/tests/ui/object-safety/assoc_type_bounds_implicit_sized.rs b/tests/ui/object-safety/assoc_type_bounds_implicit_sized.rs new file mode 100644 index 00000000000..c3e958f4983 --- /dev/null +++ b/tests/ui/object-safety/assoc_type_bounds_implicit_sized.rs @@ -0,0 +1,10 @@ +// run-rustfix +trait TraitWithAType { + type Item; +} +trait Trait {} +struct A {} +impl TraitWithAType for A { + type Item = dyn Trait; //~ ERROR E0277 +} +fn main() {} diff --git a/tests/ui/object-safety/assoc_type_bounds_implicit_sized.stderr b/tests/ui/object-safety/assoc_type_bounds_implicit_sized.stderr new file mode 100644 index 00000000000..110e7150733 --- /dev/null +++ b/tests/ui/object-safety/assoc_type_bounds_implicit_sized.stderr @@ -0,0 +1,20 @@ +error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time + --> $DIR/assoc_type_bounds_implicit_sized.rs:8:17 + | +LL | type Item = dyn Trait; + | ^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Trait + 'static)` +note: required by a bound in `TraitWithAType::Item` + --> $DIR/assoc_type_bounds_implicit_sized.rs:3:5 + | +LL | type Item; + | ^^^^^^^^^^ required by this bound in `TraitWithAType::Item` +help: consider relaxing the implicit `Sized` restriction + | +LL | type Item: ?Sized; + | ++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr b/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr index 224d33fb2da..b67a1244ece 100644 --- a/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr +++ b/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr @@ -33,6 +33,10 @@ help: consider removing the `?Sized` bound to make the type parameter `Sized` LL - fn bop<T: Bop + ?Sized>() { LL + fn bop<T: Bop>() { | +help: consider relaxing the implicit `Sized` restriction + | +LL | type Bar: Default + ?Sized + | ++++++++ error: aborting due to 2 previous errors 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/packed/packed-struct-drop-aligned.rs b/tests/ui/packed/packed-struct-drop-aligned.rs index 9f9f41e2515..4fec72763a4 100644 --- a/tests/ui/packed/packed-struct-drop-aligned.rs +++ b/tests/ui/packed/packed-struct-drop-aligned.rs @@ -1,9 +1,9 @@ // run-pass -#![feature(generators)] -#![feature(generator_trait)] +#![feature(coroutines)] +#![feature(coroutine_trait)] use std::cell::Cell; use std::mem; -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; struct Aligned<'a> { @@ -44,7 +44,7 @@ fn main() { let _ = &p; p.1 = Aligned { drop_count }; assert_eq!(drop_count.get(), 1); - // Test that a generator drop function moves a value from a packed + // Test that a coroutine drop function moves a value from a packed // struct to a separate local before dropping it. We move out the // first field to generate and open drop for the second field. drop(p.0); diff --git a/tests/ui/parser/doc-comment-in-stmt.fixed b/tests/ui/parser/doc-comment-in-stmt.fixed new file mode 100644 index 00000000000..4b3ecccf66c --- /dev/null +++ b/tests/ui/parser/doc-comment-in-stmt.fixed @@ -0,0 +1,27 @@ +// run-rustfix +#![allow(unused)] +fn foo() -> bool { + false + // !self.allow_ty_infer() + //~^ ERROR found doc comment +} + +fn bar() -> bool { + false + /* ! bar */ //~ ERROR found doc comment +} + +fn baz() -> i32 { + 1 /* * baz */ //~ ERROR found doc comment +} + +fn quux() -> i32 { + 2 // / quux + //~^ ERROR found doc comment +} + +fn main() { + let x = 0; + let y = x.max(1) // !foo //~ ERROR found doc comment + .min(2); +} diff --git a/tests/ui/parser/doc-comment-in-stmt.rs b/tests/ui/parser/doc-comment-in-stmt.rs index b02df13213f..73d08f51c66 100644 --- a/tests/ui/parser/doc-comment-in-stmt.rs +++ b/tests/ui/parser/doc-comment-in-stmt.rs @@ -1,3 +1,5 @@ +// run-rustfix +#![allow(unused)] fn foo() -> bool { false //!self.allow_ty_infer() @@ -14,7 +16,12 @@ fn baz() -> i32 { } fn quux() -> i32 { - 2 /*! quux */ //~ ERROR found doc comment + 2 /// quux + //~^ ERROR found doc comment } -fn main() {} +fn main() { + let x = 0; + let y = x.max(1) //!foo //~ ERROR found doc comment + .min(2); +} diff --git a/tests/ui/parser/doc-comment-in-stmt.stderr b/tests/ui/parser/doc-comment-in-stmt.stderr index febfb600cc7..7aefd5c9952 100644 --- a/tests/ui/parser/doc-comment-in-stmt.stderr +++ b/tests/ui/parser/doc-comment-in-stmt.stderr @@ -1,50 +1,61 @@ error: expected one of `.`, `;`, `?`, `}`, or an operator, found doc comment `//!self.allow_ty_infer()` - --> $DIR/doc-comment-in-stmt.rs:3:5 + --> $DIR/doc-comment-in-stmt.rs:5:5 | LL | false | - expected one of `.`, `;`, `?`, `}`, or an operator LL | //!self.allow_ty_infer() | ^^^^^^^^^^^^^^^^^^^^^^^^ unexpected token | -help: add a space before `!` to use a regular comment +help: add a space before `!` to write a regular comment | LL | // !self.allow_ty_infer() - | ~~~~ + | + error: expected one of `.`, `;`, `?`, `}`, or an operator, found doc comment `/*! bar */` - --> $DIR/doc-comment-in-stmt.rs:9:5 + --> $DIR/doc-comment-in-stmt.rs:11:5 | LL | false | - expected one of `.`, `;`, `?`, `}`, or an operator LL | /*! bar */ | ^^^^^^^^^^ unexpected token | -help: add a space before `!` to use a regular comment +help: add a space before `!` to write a regular comment | LL | /* ! bar */ - | ~~~~ + | + error: expected one of `.`, `;`, `?`, `}`, or an operator, found doc comment `/** baz */` - --> $DIR/doc-comment-in-stmt.rs:13:7 + --> $DIR/doc-comment-in-stmt.rs:15:7 | LL | 1 /** baz */ | ^^^^^^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator | -help: add a space before `*` to use a regular comment +help: add a space before the last `*` to write a regular comment | LL | 1 /* * baz */ - | ~~~~ + | + -error: expected one of `.`, `;`, `?`, `}`, or an operator, found doc comment `/*! quux */` - --> $DIR/doc-comment-in-stmt.rs:17:7 +error: expected one of `.`, `;`, `?`, `}`, or an operator, found doc comment `/// quux` + --> $DIR/doc-comment-in-stmt.rs:19:7 | -LL | 2 /*! quux */ - | ^^^^^^^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator +LL | 2 /// quux + | ^^^^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator | -help: add a space before `!` to use a regular comment +help: add a space before the last `/` to write a regular comment | -LL | 2 /* ! quux */ - | ~~~~ +LL | 2 // / quux + | + -error: aborting due to 4 previous errors +error: expected one of `.`, `;`, `?`, `else`, or an operator, found doc comment `//!foo + --> $DIR/doc-comment-in-stmt.rs:25:22 + | +LL | let y = x.max(1) //!foo + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected one of `.`, `;`, `?`, `else`, or an operator + | +help: add a space before `!` to write a regular comment + | +LL | let y = x.max(1) // !foo + | + + +error: aborting due to 5 previous errors 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/polymorphization/generators.rs b/tests/ui/polymorphization/coroutine.rs index 779bac0ace2..3f28e89e36c 100644 --- a/tests/ui/polymorphization/generators.rs +++ b/tests/ui/polymorphization/coroutine.rs @@ -1,10 +1,10 @@ // build-fail // compile-flags:-Zpolymorphize=on -Zinline-mir=off -#![feature(generic_const_exprs, generators, generator_trait, rustc_attrs)] +#![feature(generic_const_exprs, coroutines, coroutine_trait, rustc_attrs)] //~^ WARN the feature `generic_const_exprs` is incomplete use std::marker::Unpin; -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; enum YieldOrReturn<Y, R> { @@ -14,13 +14,13 @@ enum YieldOrReturn<Y, R> { fn finish<T, Y, R>(mut t: T) -> Vec<YieldOrReturn<Y, R>> where - T: Generator<(), Yield = Y, Return = R> + Unpin, + T: Coroutine<(), Yield = Y, Return = R> + Unpin, { let mut results = Vec::new(); loop { match Pin::new(&mut t).resume(()) { - GeneratorState::Yielded(yielded) => results.push(YieldOrReturn::Yield(yielded)), - GeneratorState::Complete(returned) => { + CoroutineState::Yielded(yielded) => results.push(YieldOrReturn::Yield(yielded)), + CoroutineState::Complete(returned) => { results.push(YieldOrReturn::Return(returned)); return results; } @@ -28,10 +28,10 @@ where } } -// This test checks that the polymorphization analysis functions on generators. +// This test checks that the polymorphization analysis functions on coroutines. #[rustc_polymorphize_error] -pub fn unused_type<T>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin { +pub fn unused_type<T>() -> impl Coroutine<(), Yield = u32, Return = u32> + Unpin { || { //~^ ERROR item has unused generic parameters yield 1; @@ -40,7 +40,7 @@ pub fn unused_type<T>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin } #[rustc_polymorphize_error] -pub fn used_type_in_yield<Y: Default>() -> impl Generator<(), Yield = Y, Return = u32> + Unpin { +pub fn used_type_in_yield<Y: Default>() -> impl Coroutine<(), Yield = Y, Return = u32> + Unpin { || { yield Y::default(); 2 @@ -48,7 +48,7 @@ pub fn used_type_in_yield<Y: Default>() -> impl Generator<(), Yield = Y, Return } #[rustc_polymorphize_error] -pub fn used_type_in_return<R: Default>() -> impl Generator<(), Yield = u32, Return = R> + Unpin { +pub fn used_type_in_return<R: Default>() -> impl Coroutine<(), Yield = u32, Return = R> + Unpin { || { yield 3; R::default() @@ -56,7 +56,7 @@ pub fn used_type_in_return<R: Default>() -> impl Generator<(), Yield = u32, Retu } #[rustc_polymorphize_error] -pub fn unused_const<const T: u32>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin { +pub fn unused_const<const T: u32>() -> impl Coroutine<(), Yield = u32, Return = u32> + Unpin { || { //~^ ERROR item has unused generic parameters yield 1; @@ -65,7 +65,7 @@ pub fn unused_const<const T: u32>() -> impl Generator<(), Yield = u32, Return = } #[rustc_polymorphize_error] -pub fn used_const_in_yield<const Y: u32>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin +pub fn used_const_in_yield<const Y: u32>() -> impl Coroutine<(), Yield = u32, Return = u32> + Unpin { || { yield Y; @@ -74,7 +74,7 @@ pub fn used_const_in_yield<const Y: u32>() -> impl Generator<(), Yield = u32, Re } #[rustc_polymorphize_error] -pub fn used_const_in_return<const R: u32>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin +pub fn used_const_in_return<const R: u32>() -> impl Coroutine<(), Yield = u32, Return = u32> + Unpin { || { yield 4; diff --git a/tests/ui/polymorphization/generators.stderr b/tests/ui/polymorphization/coroutine.stderr index 32d49d25f02..67b55a59883 100644 --- a/tests/ui/polymorphization/generators.stderr +++ b/tests/ui/polymorphization/coroutine.stderr @@ -1,24 +1,24 @@ warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/generators.rs:3:12 + --> $DIR/coroutine.rs:3:12 | -LL | #![feature(generic_const_exprs, generators, generator_trait, rustc_attrs)] +LL | #![feature(generic_const_exprs, coroutines, coroutine_trait, rustc_attrs)] | ^^^^^^^^^^^^^^^^^^^ | = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information = note: `#[warn(incomplete_features)]` on by default error: item has unused generic parameters - --> $DIR/generators.rs:35:5 + --> $DIR/coroutine.rs:35:5 | -LL | pub fn unused_type<T>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin { +LL | pub fn unused_type<T>() -> impl Coroutine<(), Yield = u32, Return = u32> + Unpin { | - generic parameter `T` is unused LL | || { | ^^ error: item has unused generic parameters - --> $DIR/generators.rs:60:5 + --> $DIR/coroutine.rs:60:5 | -LL | pub fn unused_const<const T: u32>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin { +LL | pub fn unused_const<const T: u32>() -> impl Coroutine<(), Yield = u32, Return = u32> + Unpin { | ------------ generic parameter `T` is unused LL | || { | ^^ diff --git a/tests/ui/print_type_sizes/generator.rs b/tests/ui/print_type_sizes/coroutine.rs index d1cd36274ef..aae72e0f37e 100644 --- a/tests/ui/print_type_sizes/generator.rs +++ b/tests/ui/print_type_sizes/coroutine.rs @@ -2,11 +2,11 @@ // build-pass // ignore-pass -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] -use std::ops::Generator; +use std::ops::Coroutine; -fn generator<const C: usize>(array: [u8; C]) -> impl Generator<Yield = (), Return = ()> { +fn coroutine<const C: usize>(array: [u8; C]) -> impl Coroutine<Yield = (), Return = ()> { move |()| { yield (); let _ = array; @@ -14,5 +14,5 @@ fn generator<const C: usize>(array: [u8; C]) -> impl Generator<Yield = (), Retur } pub fn foo() { - let _ = generator([0; 8192]); + let _ = coroutine([0; 8192]); } diff --git a/tests/ui/print_type_sizes/generator.stdout b/tests/ui/print_type_sizes/coroutine.stdout index f8c52a595cc..5d51339558c 100644 --- a/tests/ui/print_type_sizes/generator.stdout +++ b/tests/ui/print_type_sizes/coroutine.stdout @@ -1,4 +1,4 @@ -print-type-size type: `{generator@$DIR/generator.rs:10:5: 10:14}`: 8193 bytes, alignment: 1 bytes +print-type-size type: `{coroutine@$DIR/coroutine.rs:10:5: 10:14}`: 8193 bytes, alignment: 1 bytes print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 8192 bytes print-type-size upvar `.array`: 8192 bytes diff --git a/tests/ui/print_type_sizes/generator_discr_placement.rs b/tests/ui/print_type_sizes/coroutine_discr_placement.rs index 6adc14f9b99..78fe75cdeb9 100644 --- a/tests/ui/print_type_sizes/generator_discr_placement.rs +++ b/tests/ui/print_type_sizes/coroutine_discr_placement.rs @@ -2,10 +2,10 @@ // build-pass // ignore-pass -// Tests a generator that has its discriminant as the *final* field. +// Tests a coroutine that has its discriminant as the *final* field. // Avoid emitting panic handlers, like the rest of these tests... -#![feature(generators)] +#![feature(coroutines)] #![allow(dropping_copy_types)] pub fn foo() { diff --git a/tests/ui/print_type_sizes/generator_discr_placement.stdout b/tests/ui/print_type_sizes/coroutine_discr_placement.stdout index f7bdee1112b..f34a8e9a706 100644 --- a/tests/ui/print_type_sizes/generator_discr_placement.stdout +++ b/tests/ui/print_type_sizes/coroutine_discr_placement.stdout @@ -1,4 +1,4 @@ -print-type-size type: `{generator@$DIR/generator_discr_placement.rs:12:13: 12:15}`: 8 bytes, alignment: 4 bytes +print-type-size type: `{coroutine@$DIR/coroutine_discr_placement.rs:12:13: 12:15}`: 8 bytes, alignment: 4 bytes print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 0 bytes print-type-size variant `Suspend0`: 7 bytes diff --git a/tests/ui/regions/closure-in-projection-issue-97405.rs b/tests/ui/regions/closure-in-projection-issue-97405.rs index e567d5c2723..5489533972e 100644 --- a/tests/ui/regions/closure-in-projection-issue-97405.rs +++ b/tests/ui/regions/closure-in-projection-issue-97405.rs @@ -1,5 +1,5 @@ // Regression test for #97405. -// In `good_generic_fn` the param `T` ends up in the substs of closures/generators, +// In `good_generic_fn` the param `T` ends up in the substs of closures/coroutines, // but we should be able to prove `<Gen<T> as Iterator>::Item: 'static` without // requiring `T: 'static` 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-2091-track-caller/tracked-closure.rs b/tests/ui/rfcs/rfc-2091-track-caller/tracked-closure.rs index 670c423a7e0..86bcf1f6f8d 100644 --- a/tests/ui/rfcs/rfc-2091-track-caller/tracked-closure.rs +++ b/tests/ui/rfcs/rfc-2091-track-caller/tracked-closure.rs @@ -2,10 +2,10 @@ #![feature(stmt_expr_attributes)] #![feature(closure_track_caller)] -#![feature(generator_trait)] -#![feature(generators)] +#![feature(coroutine_trait)] +#![feature(coroutines)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; use std::panic::Location; @@ -93,53 +93,53 @@ fn test_closure() { #[track_caller] -fn mono_generator<F: Generator<String, Yield = (&'static str, String, Loc), Return = ()>>( +fn mono_coroutine<F: Coroutine<String, Yield = (&'static str, String, Loc), Return = ()>>( val: Pin<&mut F> ) -> (&'static str, String, Loc) { match val.resume("Mono".to_string()) { - GeneratorState::Yielded(val) => val, + CoroutineState::Yielded(val) => val, _ => unreachable!() } } #[track_caller] -fn dyn_generator( - val: Pin<&mut dyn Generator<String, Yield = (&'static str, String, Loc), Return = ()>> +fn dyn_coroutine( + val: Pin<&mut dyn Coroutine<String, Yield = (&'static str, String, Loc), Return = ()>> ) -> (&'static str, String, Loc) { match val.resume("Dyn".to_string()) { - GeneratorState::Yielded(val) => val, + CoroutineState::Yielded(val) => val, _ => unreachable!() } } -fn test_generator() { - let generator = #[track_caller] |arg: String| { +fn test_coroutine() { + let coroutine = #[track_caller] |arg: String| { yield ("first", arg.clone(), Location::caller()); yield ("second", arg.clone(), Location::caller()); }; - let mut pinned = Box::pin(generator); - let (dyn_ret, dyn_arg, dyn_loc) = dyn_generator(pinned.as_mut()); + let mut pinned = Box::pin(coroutine); + let (dyn_ret, dyn_arg, dyn_loc) = dyn_coroutine(pinned.as_mut()); assert_eq!(dyn_ret, "first"); assert_eq!(dyn_arg, "Dyn".to_string()); - // The `Generator` trait does not have `#[track_caller]` on `resume`, so + // The `Coroutine` trait does not have `#[track_caller]` on `resume`, so // this will not match. assert_ne!(dyn_loc.file(), file!()); - let (mono_ret, mono_arg, mono_loc) = mono_generator(pinned.as_mut()); + let (mono_ret, mono_arg, mono_loc) = mono_coroutine(pinned.as_mut()); let mono_line = line!() - 1; assert_eq!(mono_ret, "second"); - // The generator ignores the argument to the second `resume` call + // The coroutine ignores the argument to the second `resume` call assert_eq!(mono_arg, "Dyn".to_string()); assert_eq!(mono_loc.file(), file!()); assert_eq!(mono_loc.line(), mono_line); assert_eq!(mono_loc.column(), 42); - let non_tracked_generator = || { yield Location::caller(); }; - let non_tracked_line = line!() - 1; // This is the line of the generator, not its caller - let non_tracked_loc = match Box::pin(non_tracked_generator).as_mut().resume(()) { - GeneratorState::Yielded(val) => val, + let non_tracked_coroutine = || { yield Location::caller(); }; + let non_tracked_line = line!() - 1; // This is the line of the coroutine, not its caller + let non_tracked_loc = match Box::pin(non_tracked_coroutine).as_mut().resume(()) { + CoroutineState::Yielded(val) => val, _ => unreachable!() }; assert_eq!(non_tracked_loc.file(), file!()); @@ -150,5 +150,5 @@ fn test_generator() { fn main() { test_closure(); - test_generator(); + test_coroutine(); } 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/rust-2018/edition-lint-infer-outlives-multispan.stderr b/tests/ui/rust-2018/edition-lint-infer-outlives-multispan.stderr index f5ec287d291..1f4190665b9 100644 --- a/tests/ui/rust-2018/edition-lint-infer-outlives-multispan.stderr +++ b/tests/ui/rust-2018/edition-lint-infer-outlives-multispan.stderr @@ -861,12 +861,7 @@ LL | $($name: 'a, $name: 'a, )+; | ^^^^^^^^^ ^^^^^^^^^ ... LL | m!(T0 T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 T11 T12 T13 T14 T15); - | --------------------------------------------------------- - | | - | in this macro invocation - | in this macro invocation - | in this macro invocation - | in this macro invocation + | --------------------------------------------------------- in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) help: remove these bounds diff --git a/tests/ui/sanitize/issue-111184-generator-witness.rs b/tests/ui/sanitize/issue-111184-coroutine-witness.rs index d36d8bce561..dffb739f203 100644 --- a/tests/ui/sanitize/issue-111184-generator-witness.rs +++ b/tests/ui/sanitize/issue-111184-coroutine-witness.rs @@ -1,4 +1,4 @@ -// Regression test for issue 111184, where ty::GeneratorWitness were not expected to occur in +// Regression test for issue 111184, where ty::CoroutineWitness were not expected to occur in // encode_ty and caused the compiler to ICE. // // needs-sanitizer-cfi 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/issue-84973-blacklist.rs b/tests/ui/suggestions/issue-84973-blacklist.rs index 6813b07a2ee..6a35d779c1c 100644 --- a/tests/ui/suggestions/issue-84973-blacklist.rs +++ b/tests/ui/suggestions/issue-84973-blacklist.rs @@ -1,7 +1,7 @@ // Checks that certain traits for which we don't want to suggest borrowing // are blacklisted and don't cause the suggestion to be issued. -#![feature(generators)] +#![feature(coroutines)] fn f_copy<T: Copy>(t: T) {} fn f_clone<T: Clone>(t: T) {} diff --git a/tests/ui/suggestions/issue-84973-blacklist.stderr b/tests/ui/suggestions/issue-84973-blacklist.stderr index c8ce146cebf..e0bdb6949a9 100644 --- a/tests/ui/suggestions/issue-84973-blacklist.stderr +++ b/tests/ui/suggestions/issue-84973-blacklist.stderr @@ -31,11 +31,11 @@ LL + #[derive(Clone)] LL | struct S; | -error[E0277]: `{static generator@$DIR/issue-84973-blacklist.rs:17:13: 17:22}` cannot be unpinned +error[E0277]: `{static coroutine@$DIR/issue-84973-blacklist.rs:17:13: 17:22}` cannot be unpinned --> $DIR/issue-84973-blacklist.rs:17:13 | LL | f_unpin(static || { yield; }); - | ------- ^^^^^^^^^^^^^^^^^^^^ the trait `Unpin` is not implemented for `{static generator@$DIR/issue-84973-blacklist.rs:17:13: 17:22}` + | ------- ^^^^^^^^^^^^^^^^^^^^ the trait `Unpin` is not implemented for `{static coroutine@$DIR/issue-84973-blacklist.rs:17:13: 17:22}` | | | required by a bound introduced by this call | 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/silenced-binding-typo.fixed b/tests/ui/suggestions/silenced-binding-typo.fixed new file mode 100644 index 00000000000..e0f9e31bef3 --- /dev/null +++ b/tests/ui/suggestions/silenced-binding-typo.fixed @@ -0,0 +1,5 @@ +// run-rustfix +fn main() { + let x = 42; //~ HELP + let _y = x; //~ ERROR +} diff --git a/tests/ui/suggestions/silenced-binding-typo.rs b/tests/ui/suggestions/silenced-binding-typo.rs new file mode 100644 index 00000000000..6cadd5a93a7 --- /dev/null +++ b/tests/ui/suggestions/silenced-binding-typo.rs @@ -0,0 +1,5 @@ +// run-rustfix +fn main() { + let _x = 42; //~ HELP + let _y = x; //~ ERROR +} diff --git a/tests/ui/suggestions/silenced-binding-typo.stderr b/tests/ui/suggestions/silenced-binding-typo.stderr new file mode 100644 index 00000000000..9c0e6e26569 --- /dev/null +++ b/tests/ui/suggestions/silenced-binding-typo.stderr @@ -0,0 +1,14 @@ +error[E0425]: cannot find value `x` in this scope + --> $DIR/silenced-binding-typo.rs:4:14 + | +LL | let _y = x; + | ^ + | +help: a local variable with a similar name exists, consider changing it + | +LL | let x = 42; + | ~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. 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/suggestions/unnamable-types.rs b/tests/ui/suggestions/unnamable-types.rs index f2485041d9b..a4e32d7c806 100644 --- a/tests/ui/suggestions/unnamable-types.rs +++ b/tests/ui/suggestions/unnamable-types.rs @@ -1,7 +1,7 @@ // Test that we do not suggest to add type annotations for unnamable types. #![crate_type="lib"] -#![feature(generators)] +#![feature(coroutines)] const A = 5; //~^ ERROR: missing type for `const` item diff --git a/tests/ui/suggestions/unnamable-types.stderr b/tests/ui/suggestions/unnamable-types.stderr index 19e9af14535..d003b91691c 100644 --- a/tests/ui/suggestions/unnamable-types.stderr +++ b/tests/ui/suggestions/unnamable-types.stderr @@ -55,7 +55,7 @@ error: missing type for `const` item LL | const G = || -> i32 { yield 0; return 1; }; | ^ | -note: however, the inferred type `{generator@$DIR/unnamable-types.rs:37:11: 37:20}` cannot be named +note: however, the inferred type `{coroutine@$DIR/unnamable-types.rs:37:11: 37:20}` cannot be named --> $DIR/unnamable-types.rs:37:11 | LL | const G = || -> i32 { yield 0; return 1; }; diff --git a/tests/ui/threads-sendsync/sync-send-iterators-in-libcollections.rs b/tests/ui/threads-sendsync/sync-send-iterators-in-libcollections.rs index fd53bb607f7..61f54ac4e0b 100644 --- a/tests/ui/threads-sendsync/sync-send-iterators-in-libcollections.rs +++ b/tests/ui/threads-sendsync/sync-send-iterators-in-libcollections.rs @@ -37,7 +37,7 @@ macro_rules! is_sync_send { } fn main() { - // The iterator "generator" list should exhaust what corresponding + // The iterator "coroutine" list should exhaust what corresponding // implementations have where `Sync` and `Send` semantics apply. all_sync_send!(BinaryHeap::<usize>::new(), iter, drain, into_iter); 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/coroutine.fail.stderr b/tests/ui/traits/new-solver/coroutine.fail.stderr new file mode 100644 index 00000000000..14e67727d0b --- /dev/null +++ b/tests/ui/traits/new-solver/coroutine.fail.stderr @@ -0,0 +1,64 @@ +error[E0277]: the trait bound `{coroutine@$DIR/coroutine.rs:18:21: 18:23}: Coroutine<A>` is not satisfied + --> $DIR/coroutine.rs:18:21 + | +LL | needs_coroutine(|| { + | _____---------------_^ + | | | + | | required by a bound introduced by this call +LL | | +LL | | +LL | | +LL | | yield (); +LL | | }); + | |_____^ the trait `Coroutine<A>` is not implemented for `{coroutine@$DIR/coroutine.rs:18:21: 18:23}` + | +note: required by a bound in `needs_coroutine` + --> $DIR/coroutine.rs:14:28 + | +LL | fn needs_coroutine(_: impl Coroutine<A, Yield = B, Return = C>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `needs_coroutine` + +error[E0271]: type mismatch resolving `<{coroutine@$DIR/coroutine.rs:18:21: 18:23} as Coroutine<A>>::Yield == B` + --> $DIR/coroutine.rs:18:21 + | +LL | needs_coroutine(|| { + | _____---------------_^ + | | | + | | required by a bound introduced by this call +LL | | +LL | | +LL | | +LL | | yield (); +LL | | }); + | |_____^ types differ + | +note: required by a bound in `needs_coroutine` + --> $DIR/coroutine.rs:14:41 + | +LL | fn needs_coroutine(_: impl Coroutine<A, Yield = B, Return = C>) {} + | ^^^^^^^^^ required by this bound in `needs_coroutine` + +error[E0271]: type mismatch resolving `<{coroutine@$DIR/coroutine.rs:18:21: 18:23} as Coroutine<A>>::Return == C` + --> $DIR/coroutine.rs:18:21 + | +LL | needs_coroutine(|| { + | _____---------------_^ + | | | + | | required by a bound introduced by this call +LL | | +LL | | +LL | | +LL | | yield (); +LL | | }); + | |_____^ types differ + | +note: required by a bound in `needs_coroutine` + --> $DIR/coroutine.rs:14:52 + | +LL | fn needs_coroutine(_: impl Coroutine<A, Yield = B, Return = C>) {} + | ^^^^^^^^^^ required by this bound in `needs_coroutine` + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0271, E0277. +For more information about an error, try `rustc --explain E0271`. diff --git a/tests/ui/traits/new-solver/coroutine.rs b/tests/ui/traits/new-solver/coroutine.rs new file mode 100644 index 00000000000..af16f70fb56 --- /dev/null +++ b/tests/ui/traits/new-solver/coroutine.rs @@ -0,0 +1,32 @@ +// compile-flags: -Ztrait-solver=next +// edition: 2021 +// revisions: pass fail +//[pass] check-pass + +#![feature(coroutine_trait, coroutines)] + +use std::ops::Coroutine; + +struct A; +struct B; +struct C; + +fn needs_coroutine(_: impl Coroutine<A, Yield = B, Return = C>) {} + +#[cfg(fail)] +fn main() { + needs_coroutine(|| { + //[fail]~^ ERROR Coroutine<A>` is not satisfied + //[fail]~| ERROR as Coroutine<A>>::Yield == B` + //[fail]~| ERROR as Coroutine<A>>::Return == C` + yield (); + }); +} + +#[cfg(pass)] +fn main() { + needs_coroutine(|_: A| { + let _: A = yield B; + C + }) +} 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/generator.fail.stderr b/tests/ui/traits/new-solver/generator.fail.stderr deleted file mode 100644 index e3fe4bf5a6a..00000000000 --- a/tests/ui/traits/new-solver/generator.fail.stderr +++ /dev/null @@ -1,64 +0,0 @@ -error[E0277]: the trait bound `{generator@$DIR/generator.rs:18:21: 18:23}: Generator<A>` is not satisfied - --> $DIR/generator.rs:18:21 - | -LL | needs_generator(|| { - | _____---------------_^ - | | | - | | required by a bound introduced by this call -LL | | -LL | | -LL | | -LL | | yield (); -LL | | }); - | |_____^ the trait `Generator<A>` is not implemented for `{generator@$DIR/generator.rs:18:21: 18:23}` - | -note: required by a bound in `needs_generator` - --> $DIR/generator.rs:14:28 - | -LL | fn needs_generator(_: impl Generator<A, Yield = B, Return = C>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `needs_generator` - -error[E0271]: type mismatch resolving `<{generator@$DIR/generator.rs:18:21: 18:23} as Generator<A>>::Yield == B` - --> $DIR/generator.rs:18:21 - | -LL | needs_generator(|| { - | _____---------------_^ - | | | - | | required by a bound introduced by this call -LL | | -LL | | -LL | | -LL | | yield (); -LL | | }); - | |_____^ types differ - | -note: required by a bound in `needs_generator` - --> $DIR/generator.rs:14:41 - | -LL | fn needs_generator(_: impl Generator<A, Yield = B, Return = C>) {} - | ^^^^^^^^^ required by this bound in `needs_generator` - -error[E0271]: type mismatch resolving `<{generator@$DIR/generator.rs:18:21: 18:23} as Generator<A>>::Return == C` - --> $DIR/generator.rs:18:21 - | -LL | needs_generator(|| { - | _____---------------_^ - | | | - | | required by a bound introduced by this call -LL | | -LL | | -LL | | -LL | | yield (); -LL | | }); - | |_____^ types differ - | -note: required by a bound in `needs_generator` - --> $DIR/generator.rs:14:52 - | -LL | fn needs_generator(_: impl Generator<A, Yield = B, Return = C>) {} - | ^^^^^^^^^^ required by this bound in `needs_generator` - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0271, E0277. -For more information about an error, try `rustc --explain E0271`. diff --git a/tests/ui/traits/new-solver/generator.rs b/tests/ui/traits/new-solver/generator.rs deleted file mode 100644 index 364373ca8be..00000000000 --- a/tests/ui/traits/new-solver/generator.rs +++ /dev/null @@ -1,32 +0,0 @@ -// compile-flags: -Ztrait-solver=next -// edition: 2021 -// revisions: pass fail -//[pass] check-pass - -#![feature(generator_trait, generators)] - -use std::ops::Generator; - -struct A; -struct B; -struct C; - -fn needs_generator(_: impl Generator<A, Yield = B, Return = C>) {} - -#[cfg(fail)] -fn main() { - needs_generator(|| { - //[fail]~^ ERROR Generator<A>` is not satisfied - //[fail]~| ERROR as Generator<A>>::Yield == B` - //[fail]~| ERROR as Generator<A>>::Return == C` - yield (); - }); -} - -#[cfg(pass)] -fn main() { - needs_generator(|_: A| { - let _: A = yield B; - C - }) -} 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/closure_parent_substs.rs b/tests/ui/type-alias-impl-trait/closure_parent_substs.rs index 3ff20d99ad8..7d8193b26cc 100644 --- a/tests/ui/type-alias-impl-trait/closure_parent_substs.rs +++ b/tests/ui/type-alias-impl-trait/closure_parent_substs.rs @@ -1,5 +1,5 @@ // When WF checking the hidden type in the ParamEnv of the opaque type, -// one complication arises when the hidden type is a closure/generator: +// one complication arises when the hidden type is a closure/coroutine: // the "parent_substs" of the type may reference lifetime parameters // not present in the opaque type. // These region parameters are not really useful in this check. diff --git a/tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs b/tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs new file mode 100644 index 00000000000..ad1ede9c3e4 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs @@ -0,0 +1,22 @@ +#![feature(coroutines, coroutine_trait, rustc_attrs)] +#![feature(type_alias_impl_trait)] + +// check-pass + +mod gen { + use std::ops::Coroutine; + + pub type CoroOnce<Y, R> = impl Coroutine<Yield = Y, Return = R>; + + pub const fn const_coroutine<Y, R>(yielding: Y, returning: R) -> CoroOnce<Y, R> { + move || { + yield yielding; + + return returning; + } + } +} + +const FOO: gen::CoroOnce<usize, usize> = gen::const_coroutine(10, 100); + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs b/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs deleted file mode 100644 index a213dbba4ea..00000000000 --- a/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs +++ /dev/null @@ -1,22 +0,0 @@ -#![feature(generators, generator_trait, rustc_attrs)] -#![feature(type_alias_impl_trait)] - -// check-pass - -mod gen { - use std::ops::Generator; - - pub type GenOnce<Y, R> = impl Generator<Yield = Y, Return = R>; - - pub const fn const_generator<Y, R>(yielding: Y, returning: R) -> GenOnce<Y, R> { - move || { - yield yielding; - - return returning; - } - } -} - -const FOO: gen::GenOnce<usize, usize> = gen::const_generator(10, 100); - -fn main() {} diff --git a/tests/ui/type-alias-impl-trait/issue-58662-coroutine-with-lifetime.rs b/tests/ui/type-alias-impl-trait/issue-58662-coroutine-with-lifetime.rs new file mode 100644 index 00000000000..bc6a3439212 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/issue-58662-coroutine-with-lifetime.rs @@ -0,0 +1,39 @@ +// check-pass + +#![feature(coroutines, coroutine_trait)] +#![feature(type_alias_impl_trait)] + +use std::ops::{Coroutine, CoroutineState}; +use std::pin::Pin; + +type RandCoroutine<'a> = impl Coroutine<Return = (), Yield = u64> + 'a; +fn rand_coroutine<'a>(rng: &'a ()) -> RandCoroutine<'a> { + move || { + let _rng = rng; + loop { + yield 0; + } + } +} + +pub type RandCoroutineWithIndirection<'c> = impl Coroutine<Return = (), Yield = u64> + 'c; +pub fn rand_coroutine_with_indirection<'a>(rng: &'a ()) -> RandCoroutineWithIndirection<'a> { + fn helper<'b>(rng: &'b ()) -> impl 'b + Coroutine<Return = (), Yield = u64> { + move || { + let _rng = rng; + loop { + yield 0; + } + } + } + + helper(rng) +} + +fn main() { + let mut gen = rand_coroutine(&()); + match unsafe { Pin::new_unchecked(&mut gen) }.resume(()) { + CoroutineState::Yielded(_) => {} + CoroutineState::Complete(_) => {} + }; +} diff --git a/tests/ui/type-alias-impl-trait/issue-58662-generator-with-lifetime.rs b/tests/ui/type-alias-impl-trait/issue-58662-generator-with-lifetime.rs deleted file mode 100644 index 477b61390ed..00000000000 --- a/tests/ui/type-alias-impl-trait/issue-58662-generator-with-lifetime.rs +++ /dev/null @@ -1,39 +0,0 @@ -// check-pass - -#![feature(generators, generator_trait)] -#![feature(type_alias_impl_trait)] - -use std::ops::{Generator, GeneratorState}; -use std::pin::Pin; - -type RandGenerator<'a> = impl Generator<Return = (), Yield = u64> + 'a; -fn rand_generator<'a>(rng: &'a ()) -> RandGenerator<'a> { - move || { - let _rng = rng; - loop { - yield 0; - } - } -} - -pub type RandGeneratorWithIndirection<'c> = impl Generator<Return = (), Yield = u64> + 'c; -pub fn rand_generator_with_indirection<'a>(rng: &'a ()) -> RandGeneratorWithIndirection<'a> { - fn helper<'b>(rng: &'b ()) -> impl 'b + Generator<Return = (), Yield = u64> { - move || { - let _rng = rng; - loop { - yield 0; - } - } - } - - helper(rng) -} - -fn main() { - let mut gen = rand_generator(&()); - match unsafe { Pin::new_unchecked(&mut gen) }.resume(()) { - GeneratorState::Yielded(_) => {} - GeneratorState::Complete(_) => {} - }; -} diff --git a/tests/ui/type-alias-impl-trait/issue-58662-simplified.rs b/tests/ui/type-alias-impl-trait/issue-58662-simplified.rs index 27ca7d0fdc9..a1cf23dab7b 100644 --- a/tests/ui/type-alias-impl-trait/issue-58662-simplified.rs +++ b/tests/ui/type-alias-impl-trait/issue-58662-simplified.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] #![feature(type_alias_impl_trait)] trait Trait {} diff --git a/tests/ui/type-alias-impl-trait/issue-94429.rs b/tests/ui/type-alias-impl-trait/issue-94429.rs index d764545f906..306e73003fa 100644 --- a/tests/ui/type-alias-impl-trait/issue-94429.rs +++ b/tests/ui/type-alias-impl-trait/issue-94429.rs @@ -1,18 +1,18 @@ -#![feature(impl_trait_in_assoc_type, generator_trait, generators)] -use std::ops::Generator; +#![feature(impl_trait_in_assoc_type, coroutine_trait, coroutines)] +use std::ops::Coroutine; trait Runnable { - type Gen: Generator<Yield = (), Return = ()>; + type Coro: Coroutine<Yield = (), Return = ()>; - fn run(&mut self) -> Self::Gen; + fn run(&mut self) -> Self::Coro; } struct Implementor {} impl Runnable for Implementor { - type Gen = impl Generator<Yield = (), Return = ()>; + type Coro = impl Coroutine<Yield = (), Return = ()>; - fn run(&mut self) -> Self::Gen { + fn run(&mut self) -> Self::Coro { //~^ ERROR: type mismatch resolving move || { yield 1; diff --git a/tests/ui/type-alias-impl-trait/issue-94429.stderr b/tests/ui/type-alias-impl-trait/issue-94429.stderr index 26605cdd2c2..360ecfa61bf 100644 --- a/tests/ui/type-alias-impl-trait/issue-94429.stderr +++ b/tests/ui/type-alias-impl-trait/issue-94429.stderr @@ -1,8 +1,8 @@ -error[E0271]: type mismatch resolving `<{generator@$DIR/issue-94429.rs:17:9: 17:16} as Generator>::Yield == ()` +error[E0271]: type mismatch resolving `<{coroutine@$DIR/issue-94429.rs:17:9: 17:16} as Coroutine>::Yield == ()` --> $DIR/issue-94429.rs:15:26 | -LL | fn run(&mut self) -> Self::Gen { - | ^^^^^^^^^ expected integer, found `()` +LL | fn run(&mut self) -> Self::Coro { + | ^^^^^^^^^^ expected integer, found `()` error: aborting due to previous error 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-116473-ice-wrong-span-variant-args.stderr b/tests/ui/typeck/issue-116473-ice-wrong-span-variant-args.stderr index 437800f1181..b17936ee3d3 100644 --- a/tests/ui/typeck/issue-116473-ice-wrong-span-variant-args.stderr +++ b/tests/ui/typeck/issue-116473-ice-wrong-span-variant-args.stderr @@ -7,10 +7,7 @@ LL | ($variant:tt) => (if let EnumUnit::$variant::<i32, u32> {} = 5 { true } | not allowed on this type ... LL | recursive_tt!(); - | --------------- - | | - | in this macro invocation - | in this macro invocation + | --------------- in this macro invocation | = note: enum variants can't have type parameters = note: this error originates in the macro `recursive_tt` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -44,10 +41,7 @@ LL | ($variant:ident) => (if let EnumUnit::$variant::<i32, u32> {} = 5 { tru | ^^^ ^^^ type argument not allowed ... LL | recursive_ident!(); - | ------------------ - | | - | in this macro invocation - | in this macro invocation + | ------------------ in this macro invocation | = note: enum variants can't have type parameters = note: this error originates in the macro `recursive_ident` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -81,10 +75,7 @@ LL | ($variant:tt) => (if let EnumUnit::$variant::<i32, u32> {} = 5 { true } | not allowed on this type ... LL | nested1_tt!(); - | ------------- - | | - | in this macro invocation - | in this macro invocation + | ------------- in this macro invocation | = note: enum variants can't have type parameters = note: this error originates in the macro `nested2_tt` which comes from the expansion of the macro `nested1_tt` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -119,10 +110,7 @@ LL | ($variant:ident) => (if let EnumUnit::$variant::<i32, u32> {} = 5 { tru | ^^^ ^^^ type argument not allowed ... LL | nested1_ident!(); - | ---------------- - | | - | in this macro invocation - | in this macro invocation + | ---------------- in this macro invocation | = note: enum variants can't have type parameters = note: this error originates in the macro `nested2_ident` which comes from the expansion of the macro `nested1_ident` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -156,10 +144,7 @@ LL | ($arg1:tt, $arg2:tt) => (if let EnumUnit::VariantB::<$arg1, $arg2> {} | not allowed on this type ... LL | nested1_tt_args_in_first_macro!(); - | --------------------------------- - | | - | in this macro invocation - | in this macro invocation + | --------------------------------- in this macro invocation | = note: enum variants can't have type parameters = note: this error originates in the macro `nested1_tt_args_in_first_macro` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -194,10 +179,7 @@ LL | ($arg1:ident, $arg2:ident) => (if let EnumUnit::VariantB::<$arg1, $arg2 | not allowed on this type ... LL | nested1_ident_args_in_first_macro!(); - | ------------------------------------ - | | - | in this macro invocation - | in this macro invocation + | ------------------------------------ in this macro invocation | = note: enum variants can't have type parameters = note: this error originates in the macro `nested2_ident_args_in_first_macro` which comes from the expansion of the macro `nested1_ident_args_in_first_macro` (in Nightly builds, run with -Z macro-backtrace for more info) 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/typeck/issue-36708.stderr b/tests/ui/typeck/issue-36708.stderr index 140f19f1ff7..f1e0f471928 100644 --- a/tests/ui/typeck/issue-36708.stderr +++ b/tests/ui/typeck/issue-36708.stderr @@ -2,7 +2,12 @@ error[E0049]: method `foo` has 1 type parameter but its trait declaration has 0 --> $DIR/issue-36708.rs:8:12 | LL | fn foo<T>() {} - | ^ found 1 type parameter, expected 0 + | ^ found 1 type parameter + | + ::: $DIR/auxiliary/issue-36708.rs:4:5 + | +LL | fn foo(); + | --------- expected 0 type parameters error: aborting due to previous error diff --git a/tests/ui/typeck/issue-91334.rs b/tests/ui/typeck/issue-91334.rs index 29204276bb3..1ffc56e6612 100644 --- a/tests/ui/typeck/issue-91334.rs +++ b/tests/ui/typeck/issue-91334.rs @@ -2,6 +2,6 @@ // error-pattern: this file contains an unclosed delimiter -#![feature(generators)] +#![feature(coroutines)] fn f(){||yield(((){), diff --git a/tests/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.rs b/tests/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.rs index 9d0aa413207..057bdf0f618 100644 --- a/tests/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.rs +++ b/tests/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.rs @@ -5,5 +5,5 @@ fn g<F>(_: F) where F: FnOnce(Option<F>) {} fn main() { - g(|_| { }); //~ ERROR closure/generator type that references itself + g(|_| { }); //~ ERROR closure/coroutine type that references itself } diff --git a/tests/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.stderr b/tests/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.stderr index 6d5dbca0558..9d3c1902cf3 100644 --- a/tests/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.stderr +++ b/tests/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.stderr @@ -1,4 +1,4 @@ -error[E0644]: closure/generator type that references itself +error[E0644]: closure/coroutine type that references itself --> $DIR/unboxed-closure-no-cyclic-sig.rs:8:7 | LL | g(|_| { }); 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`. diff --git a/tests/ui/weird-exprs.rs b/tests/ui/weird-exprs.rs index 892b281357f..6d40d6377c5 100644 --- a/tests/ui/weird-exprs.rs +++ b/tests/ui/weird-exprs.rs @@ -1,6 +1,6 @@ // run-pass -#![feature(generators)] +#![feature(coroutines)] #![allow(non_camel_case_types)] #![allow(dead_code)] |
