diff options
Diffstat (limited to 'tests')
711 files changed, 4145 insertions, 2076 deletions
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/async-fn-debug-awaitee-field.rs b/tests/codegen/async-fn-debug-awaitee-field.rs index 29defe68f8b..03cc46cdcde 100644 --- a/tests/codegen/async-fn-debug-awaitee-field.rs +++ b/tests/codegen/async-fn-debug-awaitee-field.rs @@ -1,4 +1,4 @@ -// 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. 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/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/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/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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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/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.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.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.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/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.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 e442f8a7522..592b4d9b723 100644 --- a/tests/mir-opt/inline/issue_106141.rs +++ b/tests/mir-opt/inline/issue_106141.rs @@ -1,5 +1,9 @@ +// 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() } @@ -10,6 +14,8 @@ fn index() -> usize { #[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.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 13ff1e284d9..1ef6b69ef5b 100644 --- a/tests/mir-opt/instrument_coverage.bar.InstrumentCoverage.diff +++ b/tests/mir-opt/instrument_coverage.bar.InstrumentCoverage.diff @@ -4,7 +4,7 @@ fn bar() -> bool { let mut _0: bool; -+ coverage Counter(0) => /the/src/instrument_coverage.rs:20:1 - 22:2; ++ coverage Counter(0) => /the/src/instrument_coverage.rs:21:1 - 23:2; + bb0: { + Coverage::CounterIncrement(0); diff --git a/tests/mir-opt/instrument_coverage.main.InstrumentCoverage.diff b/tests/mir-opt/instrument_coverage.main.InstrumentCoverage.diff index f5c59c84693..14b4833a515 100644 --- a/tests/mir-opt/instrument_coverage.main.InstrumentCoverage.diff +++ b/tests/mir-opt/instrument_coverage.main.InstrumentCoverage.diff @@ -9,11 +9,11 @@ + coverage ExpressionId(0) => Expression { lhs: Counter(0), op: Add, rhs: Counter(1) }; + coverage ExpressionId(1) => Expression { lhs: Expression(0), op: Subtract, rhs: Counter(1) }; -+ coverage Counter(0) => /the/src/instrument_coverage.rs:11:1 - 11:11; -+ coverage Expression(0) => /the/src/instrument_coverage.rs:12:5 - 13:17; -+ coverage Expression(1) => /the/src/instrument_coverage.rs:14:13 - 14:18; -+ coverage Expression(1) => /the/src/instrument_coverage.rs:17:1 - 17:2; -+ coverage Counter(1) => /the/src/instrument_coverage.rs:15:10 - 15:11; ++ 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::CounterIncrement(0); 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 f8ac75513ba..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: (); 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 f8ac75513ba..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: (); 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.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 7af69e08ca1..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,18 +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 - scope 1 (inlined inner) { // at $DIR/spans.rs:10:5: 10:14 - debug x => _2; // in scope 1 at $DIR/spans.rs:13:14: 13:15 + 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 } 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 = _1; // scope 1 at $DIR/spans.rs:14:5: 14:7 - StorageDead(_2); // scope 0 at $DIR/spans.rs:10:13: 10:14 - return; // scope 0 at $DIR/spans.rs:11:2: 11:2 + 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 7af69e08ca1..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,18 +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 - scope 1 (inlined inner) { // at $DIR/spans.rs:10:5: 10:14 - debug x => _2; // in scope 1 at $DIR/spans.rs:13:14: 13:15 + 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 } 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 = _1; // scope 1 at $DIR/spans.rs:14:5: 14:7 - StorageDead(_2); // scope 0 at $DIR/spans.rs:10:13: 10:14 - return; // scope 0 at $DIR/spans.rs:11:2: 11:2 + 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/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/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/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/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/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/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-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-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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/in-trait/method-signature-matches.lt.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr index 59139e4d5ae..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 @@ -6,7 +6,7 @@ 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:52:28 diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.stderr b/tests/ui/impl-trait/in-trait/specialization-broken.stderr index 1d169b5d690..25c0adeddbd 100644 --- a/tests/ui/impl-trait/in-trait/specialization-broken.stderr +++ b/tests/ui/impl-trait/in-trait/specialization-broken.stderr @@ -2,7 +2,7 @@ error[E0053]: method `bar` has an incompatible type for trait --> $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 { | ^ 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/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/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/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/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/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/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/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/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/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/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/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-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/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/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/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/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/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/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/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/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-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-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/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)] |
