diff options
Diffstat (limited to 'tests/ui/generator')
195 files changed, 0 insertions, 7674 deletions
diff --git a/tests/ui/generator/addassign-yield.rs b/tests/ui/generator/addassign-yield.rs deleted file mode 100644 index 7211367af..000000000 --- a/tests/ui/generator/addassign-yield.rs +++ /dev/null @@ -1,38 +0,0 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir -// run-pass -// Regression test for broken MIR error (#61442) -// Due to the two possible evaluation orders for -// a '+=' expression (depending on whether or not the 'AddAssign' trait -// is being used), we were failing to account for all types that might -// possibly be live across a yield point. - -#![feature(generators)] - -fn foo() { - let _x = static || { - let mut s = String::new(); - s += { yield; "" }; - }; - - let _y = static || { - let x = &mut 0; - *{ yield; x } += match String::new() { _ => 0 }; - }; - - // Please don't ever actually write something like this - let _z = static || { - let x = &mut 0; - *{ - let inner = &mut 1; - *{ yield (); inner } += match String::new() { _ => 1}; - yield; - x - } += match String::new() { _ => 2 }; - }; -} - -fn main() { - foo() -} 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 8125a7a9b..000000000 --- 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/async-generator-issue-67158.stderr b/tests/ui/generator/async-generator-issue-67158.stderr deleted file mode 100644 index 7270d188e..000000000 --- a/tests/ui/generator/async-generator-issue-67158.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0727]: `async` generators are not yet supported - --> $DIR/async-generator-issue-67158.rs:5:13 - | -LL | async { yield print!(":C") }; - | ^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0727`. diff --git a/tests/ui/generator/auto-trait-regions.drop_tracking.stderr b/tests/ui/generator/auto-trait-regions.drop_tracking.stderr deleted file mode 100644 index b2a5b92ed..000000000 --- a/tests/ui/generator/auto-trait-regions.drop_tracking.stderr +++ /dev/null @@ -1,55 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:48:24 - | -LL | let a = A(&mut true, &mut true, No); - | ^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary value which is freed while still in use -... -LL | assert_foo(a); - | - borrow later used here - | -help: consider using a `let` binding to create a longer lived value - | -LL ~ let binding = true; -LL ~ let a = A(&mut binding, &mut true, No); - | - -error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:48:35 - | -LL | let a = A(&mut true, &mut true, No); - | ^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary value which is freed while still in use -... -LL | assert_foo(a); - | - borrow later used here - | -help: consider using a `let` binding to create a longer lived value - | -LL ~ let binding = true; -LL ~ let a = A(&mut true, &mut binding, No); - | - -error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:34:5 - | -LL | assert_foo(gen); - | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough - | - = note: `&'0 OnlyFooIfStaticRef` must implement `Foo`, for any lifetime `'0`... - = note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef` - -error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:54:5 - | -LL | assert_foo(gen); - | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough - | - = note: `Foo` would have to be implemented for the type `A<'0, '1>`, for any two lifetimes `'0` and `'1`... - = note: ...but `Foo` is actually implemented for the type `A<'_, '2>`, for some specific lifetime `'2` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/tests/ui/generator/auto-trait-regions.drop_tracking_mir.stderr b/tests/ui/generator/auto-trait-regions.drop_tracking_mir.stderr deleted file mode 100644 index b2a5b92ed..000000000 --- a/tests/ui/generator/auto-trait-regions.drop_tracking_mir.stderr +++ /dev/null @@ -1,55 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:48:24 - | -LL | let a = A(&mut true, &mut true, No); - | ^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary value which is freed while still in use -... -LL | assert_foo(a); - | - borrow later used here - | -help: consider using a `let` binding to create a longer lived value - | -LL ~ let binding = true; -LL ~ let a = A(&mut binding, &mut true, No); - | - -error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:48:35 - | -LL | let a = A(&mut true, &mut true, No); - | ^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary value which is freed while still in use -... -LL | assert_foo(a); - | - borrow later used here - | -help: consider using a `let` binding to create a longer lived value - | -LL ~ let binding = true; -LL ~ let a = A(&mut true, &mut binding, No); - | - -error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:34:5 - | -LL | assert_foo(gen); - | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough - | - = note: `&'0 OnlyFooIfStaticRef` must implement `Foo`, for any lifetime `'0`... - = note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef` - -error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:54:5 - | -LL | assert_foo(gen); - | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough - | - = note: `Foo` would have to be implemented for the type `A<'0, '1>`, for any two lifetimes `'0` and `'1`... - = note: ...but `Foo` is actually implemented for the type `A<'_, '2>`, for some specific lifetime `'2` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/tests/ui/generator/auto-trait-regions.no_drop_tracking.stderr b/tests/ui/generator/auto-trait-regions.no_drop_tracking.stderr deleted file mode 100644 index b2a5b92ed..000000000 --- a/tests/ui/generator/auto-trait-regions.no_drop_tracking.stderr +++ /dev/null @@ -1,55 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:48:24 - | -LL | let a = A(&mut true, &mut true, No); - | ^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary value which is freed while still in use -... -LL | assert_foo(a); - | - borrow later used here - | -help: consider using a `let` binding to create a longer lived value - | -LL ~ let binding = true; -LL ~ let a = A(&mut binding, &mut true, No); - | - -error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:48:35 - | -LL | let a = A(&mut true, &mut true, No); - | ^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary value which is freed while still in use -... -LL | assert_foo(a); - | - borrow later used here - | -help: consider using a `let` binding to create a longer lived value - | -LL ~ let binding = true; -LL ~ let a = A(&mut true, &mut binding, No); - | - -error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:34:5 - | -LL | assert_foo(gen); - | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough - | - = note: `&'0 OnlyFooIfStaticRef` must implement `Foo`, for any lifetime `'0`... - = note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef` - -error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:54:5 - | -LL | assert_foo(gen); - | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough - | - = note: `Foo` would have to be implemented for the type `A<'0, '1>`, for any two lifetimes `'0` and `'1`... - = note: ...but `Foo` is actually implemented for the type `A<'_, '2>`, for some specific lifetime `'2` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/tests/ui/generator/auto-trait-regions.rs b/tests/ui/generator/auto-trait-regions.rs deleted file mode 100644 index fd13e4131..000000000 --- a/tests/ui/generator/auto-trait-regions.rs +++ /dev/null @@ -1,56 +0,0 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir -#![feature(generators)] -#![feature(auto_traits)] -#![feature(negative_impls)] - -auto trait Foo {} - -struct No; - -impl !Foo for No {} - -struct A<'a, 'b>(&'a mut bool, &'b mut bool, No); - -impl<'a, 'b: 'a> Foo for A<'a, 'b> {} - -struct OnlyFooIfStaticRef(No); -impl Foo for &'static OnlyFooIfStaticRef {} - -struct OnlyFooIfRef(No); -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 - let x: &'static _ = &OnlyFooIfStaticRef(No); - let gen = || { - let x = x; - yield; - assert_foo(x); - }; - assert_foo(gen); - //~^ ERROR implementation of `Foo` is not general enough - - // Allow impls which matches any lifetime - let x = &OnlyFooIfRef(No); - let gen = || { - let x = x; - yield; - assert_foo(x); - }; - assert_foo(gen); // ok - - // Disallow impls which relates lifetimes in the generator interior - let gen = || { - let a = A(&mut true, &mut true, No); - //~^ temporary value dropped while borrowed - //~| temporary value dropped while borrowed - yield; - assert_foo(a); - }; - assert_foo(gen); - //~^ ERROR not general enough -} 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 207c2735f..000000000 --- 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 2dd5ea675..000000000 --- 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 d07abd091..000000000 --- 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/borrow-in-tail-expr.rs b/tests/ui/generator/borrow-in-tail-expr.rs deleted file mode 100644 index 540f5e3e1..000000000 --- a/tests/ui/generator/borrow-in-tail-expr.rs +++ /dev/null @@ -1,11 +0,0 @@ -// run-pass - -#![feature(generators)] - -fn main() { - let _a = || { - yield; - let a = String::new(); - a.len() - }; -} diff --git a/tests/ui/generator/borrowing.drop_tracking.stderr b/tests/ui/generator/borrowing.drop_tracking.stderr deleted file mode 100644 index 96e3c327f..000000000 --- a/tests/ui/generator/borrowing.drop_tracking.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:13:33 - | -LL | let _b = { - | -- borrow later stored here -LL | let a = 3; -LL | Pin::new(&mut || yield &a).resume(()) - | -- ^ borrowed value does not live long enough - | | - | value captured here by generator -LL | -LL | }; - | - `a` dropped here while still borrowed - -error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:20:20 - | -LL | let _b = { - | -- borrow later stored here -LL | let a = 3; -LL | || { - | -- value captured here by generator -LL | yield &a - | ^ borrowed value does not live long enough -... -LL | }; - | - `a` dropped here while still borrowed - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui/generator/borrowing.drop_tracking_mir.stderr b/tests/ui/generator/borrowing.drop_tracking_mir.stderr deleted file mode 100644 index 8fbad276d..000000000 --- a/tests/ui/generator/borrowing.drop_tracking_mir.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:13:33 - | -LL | Pin::new(&mut || yield &a).resume(()) - | ----------^ - | | | - | | borrowed value does not live long enough - | value captured here by generator - | 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 - | | - | `a` dropped here while still borrowed - | - = note: the temporary is part of an expression at the end of a block; - consider forcing this temporary to be dropped sooner, before the block's local variables are dropped -help: for example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block - | -LL | let x = Pin::new(&mut || yield &a).resume(()); x - | +++++++ +++ - -error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:20:20 - | -LL | let _b = { - | -- borrow later stored here -LL | let a = 3; -LL | || { - | -- value captured here by generator -LL | yield &a - | ^ borrowed value does not live long enough -... -LL | }; - | - `a` dropped here while still borrowed - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui/generator/borrowing.no_drop_tracking.stderr b/tests/ui/generator/borrowing.no_drop_tracking.stderr deleted file mode 100644 index 96e3c327f..000000000 --- a/tests/ui/generator/borrowing.no_drop_tracking.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:13:33 - | -LL | let _b = { - | -- borrow later stored here -LL | let a = 3; -LL | Pin::new(&mut || yield &a).resume(()) - | -- ^ borrowed value does not live long enough - | | - | value captured here by generator -LL | -LL | }; - | - `a` dropped here while still borrowed - -error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:20:20 - | -LL | let _b = { - | -- borrow later stored here -LL | let a = 3; -LL | || { - | -- value captured here by generator -LL | yield &a - | ^ borrowed value does not live long enough -... -LL | }; - | - `a` dropped here while still borrowed - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui/generator/borrowing.rs b/tests/ui/generator/borrowing.rs deleted file mode 100644 index 29f39437f..000000000 --- a/tests/ui/generator/borrowing.rs +++ /dev/null @@ -1,24 +0,0 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::pin::Pin; - -fn main() { - let _b = { - let a = 3; - Pin::new(&mut || yield &a).resume(()) - //~^ ERROR: `a` does not live long enough - }; - - let _b = { - let a = 3; - || { - yield &a - //~^ ERROR: `a` does not live long enough - } - }; -} diff --git a/tests/ui/generator/clone-impl-async.rs b/tests/ui/generator/clone-impl-async.rs deleted file mode 100644 index 9e9b59d36..000000000 --- a/tests/ui/generator/clone-impl-async.rs +++ /dev/null @@ -1,70 +0,0 @@ -// edition:2021 -// gate-test-generator_clone -// Verifies that feature(generator_clone) doesn't allow async blocks to be cloned/copied. - -#![feature(generators, generator_clone)] - -use std::future::ready; - -struct NonClone; - -fn main() { - let inner_non_clone = async { - let non_clone = NonClone; - let () = ready(()).await; - drop(non_clone); - }; - check_copy(&inner_non_clone); - //~^ ERROR : Copy` is not satisfied - check_clone(&inner_non_clone); - //~^ ERROR : Clone` is not satisfied - - let non_clone = NonClone; - let outer_non_clone = async move { - drop(non_clone); - }; - check_copy(&outer_non_clone); - //~^ ERROR : Copy` is not satisfied - check_clone(&outer_non_clone); - //~^ ERROR : Clone` is not satisfied - - let maybe_copy_clone = async move {}; - check_copy(&maybe_copy_clone); - //~^ ERROR : Copy` is not satisfied - check_clone(&maybe_copy_clone); - //~^ ERROR : Clone` is not satisfied - - let inner_non_clone_fn = the_inner_non_clone_fn(); - check_copy(&inner_non_clone_fn); - //~^ ERROR : Copy` is not satisfied - check_clone(&inner_non_clone_fn); - //~^ ERROR : Clone` is not satisfied - - let outer_non_clone_fn = the_outer_non_clone_fn(NonClone); - check_copy(&outer_non_clone_fn); - //~^ ERROR : Copy` is not satisfied - check_clone(&outer_non_clone_fn); - //~^ ERROR : Clone` is not satisfied - - let maybe_copy_clone_fn = the_maybe_copy_clone_fn(); - check_copy(&maybe_copy_clone_fn); - //~^ ERROR : Copy` is not satisfied - check_clone(&maybe_copy_clone_fn); - //~^ ERROR : Clone` is not satisfied -} - -async fn the_inner_non_clone_fn() { - let non_clone = NonClone; - let () = ready(()).await; - drop(non_clone); -} - -async fn the_outer_non_clone_fn(non_clone: NonClone) { - let () = ready(()).await; - drop(non_clone); -} - -async fn the_maybe_copy_clone_fn() {} - -fn check_copy<T: Copy>(_x: &T) {} -fn check_clone<T: Clone>(_x: &T) {} diff --git a/tests/ui/generator/clone-impl-async.stderr b/tests/ui/generator/clone-impl-async.stderr deleted file mode 100644 index 985472887..000000000 --- a/tests/ui/generator/clone-impl-async.stderr +++ /dev/null @@ -1,171 +0,0 @@ -error[E0277]: the trait bound `[async block@$DIR/clone-impl-async.rs:12:27: 16:6]: Copy` is not satisfied - --> $DIR/clone-impl-async.rs:17:16 - | -LL | check_copy(&inner_non_clone); - | ---------- ^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `[async block@$DIR/clone-impl-async.rs:12:27: 16:6]` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_copy` - --> $DIR/clone-impl-async.rs:69:18 - | -LL | fn check_copy<T: Copy>(_x: &T) {} - | ^^^^ required by this bound in `check_copy` - -error[E0277]: the trait bound `[async block@$DIR/clone-impl-async.rs:12:27: 16:6]: Clone` is not satisfied - --> $DIR/clone-impl-async.rs:19:17 - | -LL | check_clone(&inner_non_clone); - | ----------- ^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `[async block@$DIR/clone-impl-async.rs:12:27: 16:6]` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_clone` - --> $DIR/clone-impl-async.rs:70:19 - | -LL | fn check_clone<T: Clone>(_x: &T) {} - | ^^^^^ required by this bound in `check_clone` - -error[E0277]: the trait bound `[async block@$DIR/clone-impl-async.rs:23:27: 25:6]: Copy` is not satisfied - --> $DIR/clone-impl-async.rs:26:16 - | -LL | check_copy(&outer_non_clone); - | ---------- ^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `[async block@$DIR/clone-impl-async.rs:23:27: 25:6]` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_copy` - --> $DIR/clone-impl-async.rs:69:18 - | -LL | fn check_copy<T: Copy>(_x: &T) {} - | ^^^^ required by this bound in `check_copy` - -error[E0277]: the trait bound `[async block@$DIR/clone-impl-async.rs:23:27: 25:6]: Clone` is not satisfied - --> $DIR/clone-impl-async.rs:28:17 - | -LL | check_clone(&outer_non_clone); - | ----------- ^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `[async block@$DIR/clone-impl-async.rs:23:27: 25:6]` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_clone` - --> $DIR/clone-impl-async.rs:70:19 - | -LL | fn check_clone<T: Clone>(_x: &T) {} - | ^^^^^ required by this bound in `check_clone` - -error[E0277]: the trait bound `[async block@$DIR/clone-impl-async.rs:31:28: 31:41]: Copy` is not satisfied - --> $DIR/clone-impl-async.rs:32:16 - | -LL | check_copy(&maybe_copy_clone); - | ---------- ^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `[async block@$DIR/clone-impl-async.rs:31:28: 31:41]` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_copy` - --> $DIR/clone-impl-async.rs:69:18 - | -LL | fn check_copy<T: Copy>(_x: &T) {} - | ^^^^ required by this bound in `check_copy` - -error[E0277]: the trait bound `[async block@$DIR/clone-impl-async.rs:31:28: 31:41]: Clone` is not satisfied - --> $DIR/clone-impl-async.rs:34:17 - | -LL | check_clone(&maybe_copy_clone); - | ----------- ^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `[async block@$DIR/clone-impl-async.rs:31:28: 31:41]` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_clone` - --> $DIR/clone-impl-async.rs:70:19 - | -LL | fn check_clone<T: Clone>(_x: &T) {} - | ^^^^^ required by this bound in `check_clone` - -error[E0277]: the trait bound `impl Future<Output = ()>: Copy` is not satisfied - --> $DIR/clone-impl-async.rs:38:16 - | -LL | check_copy(&inner_non_clone_fn); - | ---------- ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `impl Future<Output = ()>` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_copy` - --> $DIR/clone-impl-async.rs:69:18 - | -LL | fn check_copy<T: Copy>(_x: &T) {} - | ^^^^ required by this bound in `check_copy` - -error[E0277]: the trait bound `impl Future<Output = ()>: Clone` is not satisfied - --> $DIR/clone-impl-async.rs:40:17 - | -LL | check_clone(&inner_non_clone_fn); - | ----------- ^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `impl Future<Output = ()>` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_clone` - --> $DIR/clone-impl-async.rs:70:19 - | -LL | fn check_clone<T: Clone>(_x: &T) {} - | ^^^^^ required by this bound in `check_clone` - -error[E0277]: the trait bound `impl Future<Output = ()>: Copy` is not satisfied - --> $DIR/clone-impl-async.rs:44:16 - | -LL | check_copy(&outer_non_clone_fn); - | ---------- ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `impl Future<Output = ()>` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_copy` - --> $DIR/clone-impl-async.rs:69:18 - | -LL | fn check_copy<T: Copy>(_x: &T) {} - | ^^^^ required by this bound in `check_copy` - -error[E0277]: the trait bound `impl Future<Output = ()>: Clone` is not satisfied - --> $DIR/clone-impl-async.rs:46:17 - | -LL | check_clone(&outer_non_clone_fn); - | ----------- ^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `impl Future<Output = ()>` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_clone` - --> $DIR/clone-impl-async.rs:70:19 - | -LL | fn check_clone<T: Clone>(_x: &T) {} - | ^^^^^ required by this bound in `check_clone` - -error[E0277]: the trait bound `impl Future<Output = ()>: Copy` is not satisfied - --> $DIR/clone-impl-async.rs:50:16 - | -LL | check_copy(&maybe_copy_clone_fn); - | ---------- ^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `impl Future<Output = ()>` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_copy` - --> $DIR/clone-impl-async.rs:69:18 - | -LL | fn check_copy<T: Copy>(_x: &T) {} - | ^^^^ required by this bound in `check_copy` - -error[E0277]: the trait bound `impl Future<Output = ()>: Clone` is not satisfied - --> $DIR/clone-impl-async.rs:52:17 - | -LL | check_clone(&maybe_copy_clone_fn); - | ----------- ^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `impl Future<Output = ()>` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_clone` - --> $DIR/clone-impl-async.rs:70:19 - | -LL | fn check_clone<T: Clone>(_x: &T) {} - | ^^^^^ required by this bound in `check_clone` - -error: aborting due to 12 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/clone-impl-static.rs b/tests/ui/generator/clone-impl-static.rs deleted file mode 100644 index 55ed0f281..000000000 --- a/tests/ui/generator/clone-impl-static.rs +++ /dev/null @@ -1,17 +0,0 @@ -// gate-test-generator_clone -// Verifies that static generators cannot be cloned/copied. - -#![feature(generators, generator_clone)] - -fn main() { - let gen = static move || { - yield; - }; - check_copy(&gen); - //~^ ERROR Copy` is not satisfied - check_clone(&gen); - //~^ ERROR Clone` is not satisfied -} - -fn check_copy<T: Copy>(_x: &T) {} -fn check_clone<T: Clone>(_x: &T) {} diff --git a/tests/ui/generator/clone-impl-static.stderr b/tests/ui/generator/clone-impl-static.stderr deleted file mode 100644 index cbadf6f15..000000000 --- a/tests/ui/generator/clone-impl-static.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0277]: the trait bound `[static generator@$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]` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_copy` - --> $DIR/clone-impl-static.rs:16:18 - | -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 - --> $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]` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_clone` - --> $DIR/clone-impl-static.rs:17:19 - | -LL | fn check_clone<T: Clone>(_x: &T) {} - | ^^^^^ required by this bound in `check_clone` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/clone-impl.rs b/tests/ui/generator/clone-impl.rs deleted file mode 100644 index cbfd65a53..000000000 --- a/tests/ui/generator/clone-impl.rs +++ /dev/null @@ -1,73 +0,0 @@ -// gate-test-generator_clone -// Verifies that non-static generators can be cloned/copied if all their upvars and locals held -// across awaits can be cloned/copied. - -#![feature(generators, generator_clone)] - -struct NonClone; - -fn main() { - let copyable: u32 = 123; - let clonable_0: Vec<u32> = Vec::new(); - let clonable_1: Vec<u32> = Vec::new(); - let non_clonable: NonClone = NonClone; - - let gen_copy_0 = move || { - yield; - drop(copyable); - }; - check_copy(&gen_copy_0); - check_clone(&gen_copy_0); - let gen_copy_1 = move || { - /* - let v = vec!['a']; - let n = NonClone; - drop(v); - drop(n); - */ - yield; - let v = vec!['a']; - let n = NonClone; - drop(n); - drop(copyable); - }; - check_copy(&gen_copy_1); - check_clone(&gen_copy_1); - let gen_clone_0 = move || { - let v = vec!['a']; - yield; - drop(v); - drop(clonable_0); - }; - check_copy(&gen_clone_0); - //~^ ERROR the trait bound `Vec<u32>: Copy` is not satisfied - //~| ERROR the trait bound `Vec<char>: Copy` is not satisfied - check_clone(&gen_clone_0); - let gen_clone_1 = move || { - let v = vec!['a']; - /* - let n = NonClone; - drop(n); - */ - yield; - let n = NonClone; - drop(n); - drop(v); - drop(clonable_1); - }; - check_copy(&gen_clone_1); - //~^ ERROR the trait bound `Vec<u32>: Copy` is not satisfied - //~| ERROR the trait bound `Vec<char>: Copy` is not satisfied - check_clone(&gen_clone_1); - let gen_non_clone = move || { - yield; - drop(non_clonable); - }; - check_copy(&gen_non_clone); - //~^ ERROR the trait bound `NonClone: Copy` is not satisfied - check_clone(&gen_non_clone); - //~^ ERROR the trait bound `NonClone: Clone` is not satisfied -} - -fn check_copy<T: Copy>(_x: &T) {} -fn check_clone<T: Clone>(_x: &T) {} diff --git a/tests/ui/generator/clone-impl.stderr b/tests/ui/generator/clone-impl.stderr deleted file mode 100644 index 64eb47c1a..000000000 --- a/tests/ui/generator/clone-impl.stderr +++ /dev/null @@ -1,144 +0,0 @@ -error[E0277]: the trait bound `Vec<u32>: Copy` is not satisfied in `[generator@$DIR/clone-impl.rs:36:23: 36:30]` - --> $DIR/clone-impl.rs:42:16 - | -LL | let gen_clone_0 = move || { - | ------- within this `[generator@$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>` - | -note: captured value does not implement `Copy` - --> $DIR/clone-impl.rs:40:14 - | -LL | drop(clonable_0); - | ^^^^^^^^^^ has type `Vec<u32>` which does not implement `Copy` -note: required by a bound in `check_copy` - --> $DIR/clone-impl.rs:72:18 - | -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]` - --> $DIR/clone-impl.rs:42:16 - | -LL | let gen_clone_0 = move || { - | ------- within this `[generator@$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>` - | -note: generator does not implement `Copy` as this value is used across a yield - --> $DIR/clone-impl.rs:38:9 - | -LL | let v = vec!['a']; - | - has type `Vec<char>` which does not implement `Copy` -LL | yield; - | ^^^^^ yield occurs here, with `v` maybe used later -... -LL | }; - | - `v` is later dropped here -note: required by a bound in `check_copy` - --> $DIR/clone-impl.rs:72:18 - | -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]` - --> $DIR/clone-impl.rs:58:16 - | -LL | let gen_clone_1 = move || { - | ------- within this `[generator@$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>` - | -note: captured value does not implement `Copy` - --> $DIR/clone-impl.rs:56:14 - | -LL | drop(clonable_1); - | ^^^^^^^^^^ has type `Vec<u32>` which does not implement `Copy` -note: required by a bound in `check_copy` - --> $DIR/clone-impl.rs:72:18 - | -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]` - --> $DIR/clone-impl.rs:58:16 - | -LL | let gen_clone_1 = move || { - | ------- within this `[generator@$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>` - | -note: generator does not implement `Copy` as this value is used across a yield - --> $DIR/clone-impl.rs:52:9 - | -LL | let v = vec!['a']; - | - has type `Vec<char>` which does not implement `Copy` -... -LL | yield; - | ^^^^^ yield occurs here, with `v` maybe used later -... -LL | }; - | - `v` is later dropped here -note: required by a bound in `check_copy` - --> $DIR/clone-impl.rs:72:18 - | -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]` - --> $DIR/clone-impl.rs:66:16 - | -LL | let gen_non_clone = move || { - | ------- within this `[generator@$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` - | -note: captured value does not implement `Copy` - --> $DIR/clone-impl.rs:64:14 - | -LL | drop(non_clonable); - | ^^^^^^^^^^^^ has type `NonClone` which does not implement `Copy` -note: required by a bound in `check_copy` - --> $DIR/clone-impl.rs:72:18 - | -LL | fn check_copy<T: Copy>(_x: &T) {} - | ^^^^ required by this bound in `check_copy` -help: consider annotating `NonClone` with `#[derive(Copy)]` - | -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]` - --> $DIR/clone-impl.rs:68:17 - | -LL | let gen_non_clone = move || { - | ------- within this `[generator@$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` - | -note: captured value does not implement `Clone` - --> $DIR/clone-impl.rs:64:14 - | -LL | drop(non_clonable); - | ^^^^^^^^^^^^ has type `NonClone` which does not implement `Clone` -note: required by a bound in `check_clone` - --> $DIR/clone-impl.rs:73:19 - | -LL | fn check_clone<T: Clone>(_x: &T) {} - | ^^^^^ required by this bound in `check_clone` -help: consider annotating `NonClone` with `#[derive(Clone)]` - | -LL + #[derive(Clone)] -LL | struct NonClone; - | - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/conditional-drop.rs b/tests/ui/generator/conditional-drop.rs deleted file mode 100644 index 0927df869..000000000 --- a/tests/ui/generator/conditional-drop.rs +++ /dev/null @@ -1,61 +0,0 @@ -// run-pass - -// revisions: default nomiropt -//[nomiropt]compile-flags: -Z mir-opt-level=0 - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::pin::Pin; -use std::sync::atomic::{AtomicUsize, Ordering}; - -static A: AtomicUsize = AtomicUsize::new(0); - -struct B; - -impl Drop for B { - fn drop(&mut self) { - A.fetch_add(1, Ordering::SeqCst); - } -} - - -fn test() -> bool { true } -fn test2() -> bool { false } - -fn main() { - t1(); - t2(); -} - -fn t1() { - let mut a = || { - let b = B; - if test() { - drop(b); - } - yield; - }; - - let n = A.load(Ordering::SeqCst); - Pin::new(&mut a).resume(()); - assert_eq!(A.load(Ordering::SeqCst), n + 1); - Pin::new(&mut a).resume(()); - assert_eq!(A.load(Ordering::SeqCst), n + 1); -} - -fn t2() { - let mut a = || { - let b = B; - if test2() { - drop(b); - } - yield; - }; - - let n = A.load(Ordering::SeqCst); - Pin::new(&mut a).resume(()); - assert_eq!(A.load(Ordering::SeqCst), n); - Pin::new(&mut a).resume(()); - assert_eq!(A.load(Ordering::SeqCst), n + 1); -} diff --git a/tests/ui/generator/control-flow.rs b/tests/ui/generator/control-flow.rs deleted file mode 100644 index 4f69c7855..000000000 --- a/tests/ui/generator/control-flow.rs +++ /dev/null @@ -1,53 +0,0 @@ -// run-pass - -// revisions: default nomiropt -//[nomiropt]compile-flags: -Z mir-opt-level=0 - -#![feature(generators, generator_trait)] - -use std::marker::Unpin; -use std::ops::{GeneratorState, Generator}; -use std::pin::Pin; - -fn finish<T>(mut amt: usize, mut t: T) -> T::Return - where T: Generator<(), Yield = ()> + Unpin, -{ - loop { - match Pin::new(&mut t).resume(()) { - GeneratorState::Yielded(()) => amt = amt.checked_sub(1).unwrap(), - GeneratorState::Complete(ret) => { - assert_eq!(amt, 0); - return ret - } - } - } - -} - -fn main() { - finish(1, || yield); - finish(8, || { - for _ in 0..8 { - yield; - } - }); - finish(1, || { - if true { - yield; - } else { - } - }); - finish(1, || { - if false { - } else { - yield; - } - }); - finish(2, || { - if { yield; false } { - yield; - panic!() - } - yield - }); -} diff --git a/tests/ui/generator/derived-drop-parent-expr.rs b/tests/ui/generator/derived-drop-parent-expr.rs deleted file mode 100644 index 4bd34346a..000000000 --- a/tests/ui/generator/derived-drop-parent-expr.rs +++ /dev/null @@ -1,17 +0,0 @@ -// build-pass -// compile-flags:-Zdrop-tracking - -//! Like drop-tracking-parent-expression, but also tests that this doesn't ICE when building MIR -#![feature(generators)] - -fn assert_send<T: Send>(_thing: T) {} - -#[derive(Default)] -pub struct Client { pub nickname: String } - -fn main() { - let g = move || match drop(Client { ..Client::default() }) { - _status => yield, - }; - assert_send(g); -} diff --git a/tests/ui/generator/discriminant.rs b/tests/ui/generator/discriminant.rs deleted file mode 100644 index 195e77022..000000000 --- a/tests/ui/generator/discriminant.rs +++ /dev/null @@ -1,137 +0,0 @@ -//! Tests that generator 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)] - -use std::intrinsics::discriminant_value; -use std::marker::{Unpin, DiscriminantKind}; -use std::mem::size_of_val; -use std::{cmp, ops::*}; - -macro_rules! yield25 { - ($e:expr) => { - yield $e; - yield $e; - yield $e; - yield $e; - yield $e; - - yield $e; - yield $e; - yield $e; - yield $e; - yield $e; - - yield $e; - yield $e; - yield $e; - yield $e; - yield $e; - - yield $e; - yield $e; - yield $e; - yield $e; - yield $e; - - yield $e; - yield $e; - yield $e; - yield $e; - yield $e; - }; -} - -/// Yields 250 times. -macro_rules! yield250 { - () => { - yield250!(()) - }; - - ($e:expr) => { - yield25!($e); - yield25!($e); - yield25!($e); - yield25!($e); - yield25!($e); - - yield25!($e); - yield25!($e); - yield25!($e); - yield25!($e); - yield25!($e); - }; -} - -fn cycle( - gen: impl Generator<()> + 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(_) => { - assert_eq!(max_discr, expected_max_discr); - return; - } - } - } -} - -fn main() { - // Has only one invalid discr. value. - let gen_u8_tiny_niche = || { - || { - // 3 reserved variants - - yield250!(); // 253 variants - - yield; // 254 - yield; // 255 - } - }; - - // Uses all values in the u8 discriminant. - let gen_u8_full = || { - || { - // 3 reserved variants - - yield250!(); // 253 variants - - yield; // 254 - yield; // 255 - yield; // 256 - } - }; - - // Barely needs a u16 discriminant. - let gen_u16 = || { - || { - // 3 reserved variants - - yield250!(); // 253 variants - - yield; // 254 - yield; // 255 - yield; // 256 - yield; // 257 - } - }; - - assert_eq!(size_of_val(&gen_u8_tiny_niche()), 1); - assert_eq!(size_of_val(&Some(gen_u8_tiny_niche())), 1); // uses niche - assert_eq!(size_of_val(&Some(Some(gen_u8_tiny_niche()))), 2); // cannot use niche anymore - assert_eq!(size_of_val(&gen_u8_full()), 1); - assert_eq!(size_of_val(&Some(gen_u8_full())), 2); // cannot use niche - assert_eq!(size_of_val(&gen_u16()), 2); - assert_eq!(size_of_val(&Some(gen_u16())), 2); // uses niche - - cycle(gen_u8_tiny_niche(), 254); - cycle(gen_u8_full(), 255); - cycle(gen_u16(), 256); -} diff --git a/tests/ui/generator/drop-and-replace.rs b/tests/ui/generator/drop-and-replace.rs deleted file mode 100644 index a9a50a122..000000000 --- a/tests/ui/generator/drop-and-replace.rs +++ /dev/null @@ -1,45 +0,0 @@ -// 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 -// re-assigned. - -#![feature(generators, generator_trait)] - -use std::ops::{Generator, GeneratorState}; -use std::pin::Pin; - -#[derive(Debug, PartialEq)] -struct Foo(i32); - -impl Drop for Foo { - fn drop(&mut self) { } -} - -fn main() { - let mut a = || { - let mut x = Foo(4); - yield; - assert_eq!(x.0, 4); - - // At one point this tricked our dataflow analysis into thinking `x` was - // StorageDead after the assignment. - x = Foo(5); - assert_eq!(x.0, 5); - - { - let y = Foo(6); - yield; - assert_eq!(y.0, 6); - } - - assert_eq!(x.0, 5); - }; - - loop { - match Pin::new(&mut a).resume(()) { - GeneratorState::Complete(()) => break, - _ => (), - } - } -} diff --git a/tests/ui/generator/drop-control-flow.rs b/tests/ui/generator/drop-control-flow.rs deleted file mode 100644 index c6efda954..000000000 --- a/tests/ui/generator/drop-control-flow.rs +++ /dev/null @@ -1,139 +0,0 @@ -// build-pass -// compile-flags: -Zdrop-tracking - -// A test to ensure generators 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. - -#![feature(generators, negative_impls)] -#![allow(unused_assignments, dead_code)] - -struct Ptr; -impl<'a> Drop for Ptr { - fn drop(&mut self) {} -} - -struct NonSend; -impl !Send for NonSend {} - -fn assert_send<T: Send>(_: T) {} - -// This test case is reduced from tests/ui/drop/dynamic-drop-async.rs -fn one_armed_if(arg: bool) { - let _ = || { - let arr = [Ptr]; - if arg { - drop(arr); - } - yield; - }; -} - -fn two_armed_if(arg: bool) { - assert_send(|| { - let arr = [Ptr]; - if arg { - drop(arr); - } else { - drop(arr); - } - yield; - }) -} - -fn if_let(arg: Option<i32>) { - let _ = || { - let arr = [Ptr]; - if let Some(_) = arg { - drop(arr); - } - yield; - }; -} - -fn init_in_if(arg: bool) { - assert_send(|| { - let mut x = NonSend; - drop(x); - if arg { - x = NonSend; - } else { - yield; - } - }) -} - -fn init_in_match_arm(arg: Option<i32>) { - assert_send(|| { - let mut x = NonSend; - drop(x); - match arg { - Some(_) => x = NonSend, - None => yield, - } - }) -} - -fn reinit() { - let _ = || { - let mut arr = [Ptr]; - drop(arr); - arr = [Ptr]; - yield; - }; -} - -fn loop_uninit() { - let _ = || { - let mut arr = [Ptr]; - let mut count = 0; - drop(arr); - while count < 3 { - yield; - arr = [Ptr]; - count += 1; - } - }; -} - -fn nested_loop() { - let _ = || { - let mut arr = [Ptr]; - let mut count = 0; - drop(arr); - while count < 3 { - for _ in 0..3 { - yield; - } - arr = [Ptr]; - count += 1; - } - }; -} - -fn loop_continue(b: bool) { - let _ = || { - let mut arr = [Ptr]; - let mut count = 0; - drop(arr); - while count < 3 { - count += 1; - yield; - if b { - arr = [Ptr]; - continue; - } - } - }; -} - -fn main() { - one_armed_if(true); - if_let(Some(41)); - init_in_if(true); - init_in_match_arm(Some(41)); - reinit(); - loop_uninit(); - nested_loop(); - loop_continue(true); -} diff --git a/tests/ui/generator/drop-env.rs b/tests/ui/generator/drop-env.rs deleted file mode 100644 index 137a40793..000000000 --- a/tests/ui/generator/drop-env.rs +++ /dev/null @@ -1,67 +0,0 @@ -// run-pass - -// revisions: default nomiropt -//[nomiropt]compile-flags: -Z mir-opt-level=0 - -#![feature(generators, generator_trait)] -#![allow(dropping_copy_types)] - -use std::ops::Generator; -use std::pin::Pin; -use std::sync::atomic::{AtomicUsize, Ordering}; - -static A: AtomicUsize = AtomicUsize::new(0); - -struct B; - -impl Drop for B { - fn drop(&mut self) { - A.fetch_add(1, Ordering::SeqCst); - } -} - -fn main() { - t1(); - t2(); - t3(); -} - -fn t1() { - let b = B; - let mut foo = || { - yield; - drop(b); - }; - - let n = A.load(Ordering::SeqCst); - drop(Pin::new(&mut foo).resume(())); - assert_eq!(A.load(Ordering::SeqCst), n); - drop(foo); - assert_eq!(A.load(Ordering::SeqCst), n + 1); -} - -fn t2() { - let b = B; - let mut foo = || { - yield b; - }; - - let n = A.load(Ordering::SeqCst); - drop(Pin::new(&mut foo).resume(())); - assert_eq!(A.load(Ordering::SeqCst), n + 1); - drop(foo); - assert_eq!(A.load(Ordering::SeqCst), n + 1); -} - -fn t3() { - let b = B; - let foo = || { - yield; - drop(b); - }; - - let n = A.load(Ordering::SeqCst); - assert_eq!(A.load(Ordering::SeqCst), n); - drop(foo); - assert_eq!(A.load(Ordering::SeqCst), n + 1); -} diff --git a/tests/ui/generator/drop-track-addassign-yield.rs b/tests/ui/generator/drop-track-addassign-yield.rs deleted file mode 100644 index 71cfb170b..000000000 --- a/tests/ui/generator/drop-track-addassign-yield.rs +++ /dev/null @@ -1,41 +0,0 @@ -// run-pass -// compile-flags: -Zdrop-tracking - -// 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)] - -fn foo() { - let _y = static || { - let x = &mut 0; - *{ - yield; - x - } += match String::new() { - _ => 0, - }; - }; - - // Please don't ever actually write something like this - let _z = static || { - let x = &mut 0; - *{ - let inner = &mut 1; - *{ - yield (); - inner - } += match String::new() { - _ => 1, - }; - yield; - x - } += match String::new() { - _ => 2, - }; - }; -} - -fn main() { - foo() -} diff --git a/tests/ui/generator/drop-tracking-error-body.rs b/tests/ui/generator/drop-tracking-error-body.rs deleted file mode 100644 index f99d9ab6b..000000000 --- a/tests/ui/generator/drop-tracking-error-body.rs +++ /dev/null @@ -1,18 +0,0 @@ -// compile-flags: -Zdrop-tracking-mir --edition=2021 - -#![feature(generators)] - -pub async fn async_bad_body() { - match true {} //~ ERROR non-exhaustive patterns: type `bool` is non-empty -} - -pub fn generator_bad_body() { - || { - // 'non-exhaustive pattern' only seems to be reported once, so this annotation doesn't work - // keep the function around so we can make sure it doesn't ICE - match true {}; // ERROR non-exhaustive patterns: type `bool` is non-empty - yield (); - }; -} - -fn main() {} diff --git a/tests/ui/generator/drop-tracking-error-body.stderr b/tests/ui/generator/drop-tracking-error-body.stderr deleted file mode 100644 index 28a689233..000000000 --- a/tests/ui/generator/drop-tracking-error-body.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0004]: non-exhaustive patterns: type `bool` is non-empty - --> $DIR/drop-tracking-error-body.rs:6:11 - | -LL | match true {} - | ^^^^ - | - = note: the matched value is of type `bool` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match true { -LL + _ => todo!(), -LL ~ } - | - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/generator/drop-tracking-parent-expression.drop_tracking.stderr b/tests/ui/generator/drop-tracking-parent-expression.drop_tracking.stderr deleted file mode 100644 index c07906ec3..000000000 --- a/tests/ui/generator/drop-tracking-parent-expression.drop_tracking.stderr +++ /dev/null @@ -1,128 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/drop-tracking-parent-expression.rs:21:21: 21:28]`, the trait `Send` is not implemented for `derived_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `derived_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -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 - --> $DIR/drop-tracking-parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/drop-tracking-parent-expression.rs:21:21: 21:28]`, the trait `Send` is not implemented for `significant_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `significant_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -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 - --> $DIR/drop-tracking-parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/drop-tracking-parent-expression.rs:21:21: 21:28]`, the trait `Send` is not implemented for `insignificant_dtor::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `insignificant_dtor::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -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: aborting due to 3 previous errors - diff --git a/tests/ui/generator/drop-tracking-parent-expression.drop_tracking_mir.stderr b/tests/ui/generator/drop-tracking-parent-expression.drop_tracking_mir.stderr deleted file mode 100644 index 35698a98d..000000000 --- a/tests/ui/generator/drop-tracking-parent-expression.drop_tracking_mir.stderr +++ /dev/null @@ -1,122 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:27:13 - | -LL | assert_send(g); - | ^^^^^^^^^^^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/drop-tracking-parent-expression.rs:21:21: 21:28]`, the trait `Send` is not implemented for `derived_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `derived_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -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 - --> $DIR/drop-tracking-parent-expression.rs:27:13 - | -LL | assert_send(g); - | ^^^^^^^^^^^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/drop-tracking-parent-expression.rs:21:21: 21:28]`, the trait `Send` is not implemented for `significant_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `significant_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -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 - --> $DIR/drop-tracking-parent-expression.rs:27:13 - | -LL | assert_send(g); - | ^^^^^^^^^^^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/drop-tracking-parent-expression.rs:21:21: 21:28]`, the trait `Send` is not implemented for `insignificant_dtor::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `insignificant_dtor::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -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: aborting due to 3 previous errors - diff --git a/tests/ui/generator/drop-tracking-parent-expression.no_drop_tracking.stderr b/tests/ui/generator/drop-tracking-parent-expression.no_drop_tracking.stderr deleted file mode 100644 index 1a05bfe4f..000000000 --- a/tests/ui/generator/drop-tracking-parent-expression.no_drop_tracking.stderr +++ /dev/null @@ -1,334 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/drop-tracking-parent-expression.rs:21:21: 21:28]`, the trait `Send` is not implemented for `copy::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `copy::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -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 - --> $DIR/drop-tracking-parent-expression.rs:40:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/drop-tracking-parent-expression.rs:37:21: 37:28]`, the trait `Send` is not implemented for `copy::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:38:22 - | -LL | let g = move || match drop($name::Client::default()) { - | ------------------------ has type `copy::Client` which is not `Send` -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -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 - --> $DIR/drop-tracking-parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/drop-tracking-parent-expression.rs:21:21: 21:28]`, the trait `Send` is not implemented for `derived_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `derived_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -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 - --> $DIR/drop-tracking-parent-expression.rs:40:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/drop-tracking-parent-expression.rs:37:21: 37:28]`, the trait `Send` is not implemented for `derived_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:38:22 - | -LL | let g = move || match drop($name::Client::default()) { - | ------------------------ has type `derived_drop::Client` which is not `Send` -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -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 - --> $DIR/drop-tracking-parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/drop-tracking-parent-expression.rs:21:21: 21:28]`, the trait `Send` is not implemented for `significant_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `significant_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -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 - --> $DIR/drop-tracking-parent-expression.rs:40:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/drop-tracking-parent-expression.rs:37:21: 37:28]`, the trait `Send` is not implemented for `significant_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:38:22 - | -LL | let g = move || match drop($name::Client::default()) { - | ------------------------ has type `significant_drop::Client` which is not `Send` -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -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 - --> $DIR/drop-tracking-parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/drop-tracking-parent-expression.rs:21:21: 21:28]`, the trait `Send` is not implemented for `insignificant_dtor::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `insignificant_dtor::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -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 - --> $DIR/drop-tracking-parent-expression.rs:40:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/drop-tracking-parent-expression.rs:37:21: 37:28]`, the trait `Send` is not implemented for `insignificant_dtor::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:38:22 - | -LL | let g = move || match drop($name::Client::default()) { - | ------------------------ has type `insignificant_dtor::Client` which is not `Send` -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -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: aborting due to 8 previous errors - diff --git a/tests/ui/generator/drop-tracking-parent-expression.rs b/tests/ui/generator/drop-tracking-parent-expression.rs deleted file mode 100644 index ed9ac6d11..000000000 --- a/tests/ui/generator/drop-tracking-parent-expression.rs +++ /dev/null @@ -1,77 +0,0 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir - -#![feature(generators, negative_impls, rustc_attrs)] - -macro_rules! type_combinations { - ( - $( $name:ident => { $( $tt:tt )* } );* $(;)? - ) => { $( - mod $name { - $( $tt )* - - impl !Sync for Client {} - impl !Send for Client {} - } - - // Struct update syntax. This fails because the Client used in the update is considered - // dropped *after* the yield. - { - let g = move || match drop($name::Client { ..$name::Client::default() }) { - //~^ `significant_drop::Client` which is not `Send` - //~| `insignificant_dtor::Client` which is not `Send` - //[no_drop_tracking,drop_tracking]~| `derived_drop::Client` which is not `Send` - _ => yield, - }; - assert_send(g); - //~^ ERROR cannot be sent between threads - //~| ERROR cannot be sent between threads - //~| ERROR cannot be sent between threads - //[no_drop_tracking]~| ERROR cannot be sent between threads - } - - // Simple owned value. This works because the Client is considered moved into `drop`, - // even though the temporary expression doesn't end until after the yield. - { - let g = move || match drop($name::Client::default()) { - _ => yield, - }; - assert_send(g); - //[no_drop_tracking]~^ ERROR cannot be sent between threads - //[no_drop_tracking]~| ERROR cannot be sent between threads - //[no_drop_tracking]~| ERROR cannot be sent between threads - //[no_drop_tracking]~| ERROR cannot be sent between threads - } - )* } -} - -fn assert_send<T: Send>(_thing: T) {} - -fn main() { - type_combinations!( - // OK - copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; - // NOT OK: MIR borrowck thinks that this is used after the yield, even though - // this has no `Drop` impl and only the drops of the fields are observable. - // FIXME: this should compile. - derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; - // NOT OK - significant_drop => { - #[derive(Default)] - pub struct Client; - impl Drop for Client { - fn drop(&mut self) {} - } - }; - // NOT OK (we need to agree with MIR borrowck) - insignificant_dtor => { - #[derive(Default)] - #[rustc_insignificant_dtor] - pub struct Client; - impl Drop for Client { - fn drop(&mut self) {} - } - }; - ); -} diff --git a/tests/ui/generator/drop-tracking-yielding-in-match-guards.rs b/tests/ui/generator/drop-tracking-yielding-in-match-guards.rs deleted file mode 100644 index cbc291701..000000000 --- a/tests/ui/generator/drop-tracking-yielding-in-match-guards.rs +++ /dev/null @@ -1,14 +0,0 @@ -// build-pass -// edition:2018 -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir - -#![feature(generators)] - -fn main() { - let _ = static |x: u8| match x { - y if { yield } == y + 1 => (), - _ => (), - }; -} diff --git a/tests/ui/generator/drop-yield-twice.rs b/tests/ui/generator/drop-yield-twice.rs deleted file mode 100644 index f484cbb8d..000000000 --- a/tests/ui/generator/drop-yield-twice.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![feature(negative_impls, generators)] - -struct Foo(i32); -impl !Send for Foo {} - -fn main() { - assert_send(|| { //~ ERROR generator cannot be sent between threads safely - let guard = Foo(42); - yield; - drop(guard); - yield; - }) -} - -fn assert_send<T: Send>(_: T) {} diff --git a/tests/ui/generator/drop-yield-twice.stderr b/tests/ui/generator/drop-yield-twice.stderr deleted file mode 100644 index 0808a2c85..000000000 --- a/tests/ui/generator/drop-yield-twice.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/drop-yield-twice.rs:7:17 - | -LL | assert_send(|| { - | _________________^ -LL | | let guard = Foo(42); -LL | | yield; -LL | | drop(guard); -LL | | yield; -LL | | }) - | |_____^ generator 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 - --> $DIR/drop-yield-twice.rs:9:9 - | -LL | let guard = Foo(42); - | ----- has type `Foo` which is not `Send` -LL | yield; - | ^^^^^ yield occurs here, with `guard` maybe used later -... -LL | }) - | - `guard` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/drop-yield-twice.rs:15:19 - | -LL | fn assert_send<T: Send>(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to previous error - diff --git a/tests/ui/generator/dropck-resume.rs b/tests/ui/generator/dropck-resume.rs deleted file mode 100644 index 4c18077f3..000000000 --- a/tests/ui/generator/dropck-resume.rs +++ /dev/null @@ -1,33 +0,0 @@ -#![feature(generators, generator_trait)] - -use std::ops::{Generator, GeneratorState}; -use std::pin::Pin; - -struct SetToNone<'a: 'b, 'b>(&'b mut Option<&'a i32>); - -impl<'a, 'b> Drop for SetToNone<'a, 'b> { - fn drop(&mut self) { - *self.0 = None; - } -} - -fn drop_using_generator() -> i32 { - let mut y = Some(&0); - let z = &mut y; - let r; - { - let mut g = move |r| { - let _s = SetToNone(r); - yield; - }; - let mut g = Pin::new(&mut g); - g.as_mut().resume(z); - r = y.as_ref().unwrap(); - //~^ ERROR cannot borrow `y` as immutable because it is also borrowed as mutable - } - **r -} - -fn main() { - println!("{}", drop_using_generator()); -} diff --git a/tests/ui/generator/dropck-resume.stderr b/tests/ui/generator/dropck-resume.stderr deleted file mode 100644 index b0756eb55..000000000 --- a/tests/ui/generator/dropck-resume.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0502]: cannot borrow `y` as immutable because it is also borrowed as mutable - --> $DIR/dropck-resume.rs:25:13 - | -LL | let z = &mut y; - | ------ mutable borrow occurs here -... -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 - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/tests/ui/generator/dropck.rs b/tests/ui/generator/dropck.rs deleted file mode 100644 index f82111a76..000000000 --- a/tests/ui/generator/dropck.rs +++ /dev/null @@ -1,20 +0,0 @@ -#![feature(generators, generator_trait)] - -use std::cell::RefCell; -use std::ops::Generator; -use std::pin::Pin; - -fn main() { - let (mut gen, cell); - cell = Box::new(RefCell::new(0)); - let ref_ = Box::leak(Box::new(Some(cell.borrow_mut()))); - //~^ 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>`. - let _d = ref_.take(); //~ ERROR `ref_` does not live long enough - yield; - }; - Pin::new(&mut gen).resume(()); - // drops the RefCell and then the Ref, leading to use-after-free -} diff --git a/tests/ui/generator/dropck.stderr b/tests/ui/generator/dropck.stderr deleted file mode 100644 index b9a3a124a..000000000 --- a/tests/ui/generator/dropck.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error[E0597]: `*cell` does not live long enough - --> $DIR/dropck.rs:10:40 - | -LL | let (mut gen, cell); - | ---- binding `cell` declared here -LL | cell = Box::new(RefCell::new(0)); -LL | let ref_ = Box::leak(Box::new(Some(cell.borrow_mut()))); - | ^^^^^^^^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `*cell` dropped here while still borrowed - | borrow might be used here, when `gen` is dropped and runs the destructor for generator - | - = note: values in a scope are dropped in the opposite order they are defined - -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>`. -LL | let _d = ref_.take(); - | ^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `ref_` dropped here while still borrowed - | borrow might be used here, when `gen` is dropped and runs the destructor for generator - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui/generator/generator-region-requirements.migrate.stderr b/tests/ui/generator/generator-region-requirements.migrate.stderr deleted file mode 100644 index 8a96d187f..000000000 --- a/tests/ui/generator/generator-region-requirements.migrate.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0621]: explicit lifetime required in the type of `x` - --> $DIR/generator-region-requirements.rs:16:51 - | -LL | fn dangle(x: &mut i32) -> &'static mut i32 { - | -------- help: add explicit lifetime `'static` to the type of `x`: `&'static mut i32` -... -LL | GeneratorState::Complete(c) => return c, - | ^ lifetime `'static` required - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0621`. diff --git a/tests/ui/generator/generator-region-requirements.rs b/tests/ui/generator/generator-region-requirements.rs deleted file mode 100644 index 7269a79ca..000000000 --- a/tests/ui/generator/generator-region-requirements.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![feature(generators, generator_trait)] -use std::ops::{Generator, GeneratorState}; -use std::pin::Pin; - -fn dangle(x: &mut i32) -> &'static mut i32 { - let mut g = || { - yield; - x - }; - loop { - match Pin::new(&mut g).resume(()) { - GeneratorState::Complete(c) => return c, - //~^ ERROR lifetime may not live long enough - GeneratorState::Yielded(_) => (), - } - } -} - -fn main() {} diff --git a/tests/ui/generator/generator-region-requirements.stderr b/tests/ui/generator/generator-region-requirements.stderr deleted file mode 100644 index 87f604672..000000000 --- a/tests/ui/generator/generator-region-requirements.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: lifetime may not live long enough - --> $DIR/generator-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, - | ^ 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/generator/generator-resume-after-panic.rs deleted file mode 100644 index f2e67f1f7..000000000 --- a/tests/ui/generator/generator-resume-after-panic.rs +++ /dev/null @@ -1,25 +0,0 @@ -// run-fail -// needs-unwind -// error-pattern:generator resumed after panicking -// ignore-emscripten no processes - -// Test that we get the correct message for resuming a panicked generator. - -#![feature(generators, generator_trait)] - -use std::{ - ops::Generator, - pin::Pin, - panic, -}; - -fn main() { - let mut g = || { - panic!(); - yield; - }; - panic::catch_unwind(panic::AssertUnwindSafe(|| { - let x = Pin::new(&mut g).resume(()); - })); - Pin::new(&mut g).resume(()); -} diff --git a/tests/ui/generator/generator-with-nll.rs b/tests/ui/generator/generator-with-nll.rs deleted file mode 100644 index cee3e6d22..000000000 --- a/tests/ui/generator/generator-with-nll.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(generators)] - -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 - yield (); - println!("{}", b); - }; -} diff --git a/tests/ui/generator/generator-with-nll.stderr b/tests/ui/generator/generator-with-nll.stderr deleted file mode 100644 index 14199aeb9..000000000 --- a/tests/ui/generator/generator-with-nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/generator-with-nll.rs:7:17 - | -LL | let b = &mut true; - | ^^^^^^^^^ -LL | -LL | yield (); - | -------- possible yield occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0626`. 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 30788e3c1..000000000 --- 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/generator-yielding-or-returning-itself.stderr b/tests/ui/generator/generator-yielding-or-returning-itself.stderr deleted file mode 100644 index a26dbf3f2..000000000 --- a/tests/ui/generator/generator-yielding-or-returning-itself.stderr +++ /dev/null @@ -1,53 +0,0 @@ -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 - | -LL | want_cyclic_generator_return(|| { - | _____----------------------------_^ - | | | - | | required by a bound introduced by this call -LL | | -LL | | if false { yield None.unwrap(); } -LL | | None.unwrap() -LL | | }) - | |_____^ cyclic type of infinite size - | - = note: closures cannot capture themselves or take themselves as argument; - 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 - | -LL | pub fn want_cyclic_generator_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` - -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 - | -LL | want_cyclic_generator_yield(|| { - | _____---------------------------_^ - | | | - | | required by a bound introduced by this call -LL | | -LL | | if false { yield None.unwrap(); } -LL | | None.unwrap() -LL | | }) - | |_____^ cyclic type of infinite size - | - = note: closures cannot capture themselves or take themselves as argument; - 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 - | -LL | pub fn want_cyclic_generator_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` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/generator/issue-102645.rs b/tests/ui/generator/issue-102645.rs deleted file mode 100644 index 35acd5cd7..000000000 --- a/tests/ui/generator/issue-102645.rs +++ /dev/null @@ -1,23 +0,0 @@ -// compile-flags: -Zdrop-tracking - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::pin::Pin; - -fn main() { - let mut a = 5; - let mut b = || { - let d = 6; - yield; - _zzz(); // #break - a = d; - }; - Pin::new(&mut b).resume(); - //~^ ERROR this method takes 1 argument but 0 arguments were supplied - // This type error is required to reproduce the ICE... -} - -fn _zzz() { - () -} diff --git a/tests/ui/generator/issue-102645.stderr b/tests/ui/generator/issue-102645.stderr deleted file mode 100644 index 3f9a4c2f3..000000000 --- a/tests/ui/generator/issue-102645.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0061]: this method takes 1 argument but 0 arguments were supplied - --> $DIR/issue-102645.rs:16:22 - | -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 -help: provide the argument - | -LL | Pin::new(&mut b).resume(()); - | ~~~~ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0061`. diff --git a/tests/ui/generator/issue-105084.drop_tracking_mir.stderr b/tests/ui/generator/issue-105084.drop_tracking_mir.stderr deleted file mode 100644 index 1cd4c4e4d..000000000 --- a/tests/ui/generator/issue-105084.drop_tracking_mir.stderr +++ /dev/null @@ -1,51 +0,0 @@ -error[E0382]: borrow of moved value: `g` - --> $DIR/issue-105084.rs:45:14 - | -LL | let mut g = || { - | ----- move occurs because `g` has type `[generator@$DIR/issue-105084.rs:22:17: 22:19]`, which does not implement the `Copy` trait -... -LL | let mut h = copy(g); - | - value moved here -... -LL | Pin::new(&mut g).resume(()); - | ^^^^^^ value borrowed here after move - | -note: consider changing this parameter type in function `copy` to borrow instead if owning the value isn't necessary - --> $DIR/issue-105084.rs:17:21 - | -LL | fn copy<T: Copy>(x: T) -> T { - | ---- ^ this parameter takes ownership of the value - | | - | in this function -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:22:17: 22:19]` - --> $DIR/issue-105084.rs:39:17 - | -LL | let mut g = || { - | -- within this `[generator@$DIR/issue-105084.rs:22:17: 22:19]` -... -LL | let mut h = copy(g); - | ^^^^ within `[generator@$DIR/issue-105084.rs:22:17: 22:19]`, the trait `Copy` is not implemented for `Box<(i32, ())>` - | -note: generator does not implement `Copy` as this value is used across a yield - --> $DIR/issue-105084.rs:29:22 - | -LL | Box::new((5, yield)); - | -------------^^^^^-- - | | | - | | yield occurs here, with `Box::new((5, yield))` maybe used later - | has type `Box<(i32, ())>` which does not implement `Copy` -note: required by a bound in `copy` - --> $DIR/issue-105084.rs:17:12 - | -LL | fn copy<T: Copy>(x: T) -> T { - | ^^^^ required by this bound in `copy` - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0277, E0382. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/issue-105084.rs b/tests/ui/generator/issue-105084.rs deleted file mode 100644 index ff9357b76..000000000 --- a/tests/ui/generator/issue-105084.rs +++ /dev/null @@ -1,50 +0,0 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir -// [no_drop_tracking] known-bug: #105084 -// [no_drop_tracking] check-pass -// [drop_tracking] known-bug: #105084 -// [drop_tracking] check-pass - -#![feature(generators)] -#![feature(generator_clone)] -#![feature(generator_trait)] -#![feature(rustc_attrs, stmt_expr_attributes)] - -use std::ops::Generator; -use std::pin::Pin; - -fn copy<T: Copy>(x: T) -> T { - x -} - -fn main() { - let mut g = || { - // This is desuraged as 4 stages: - // - allocate a `*mut u8` with `exchange_malloc`; - // - create a Box that is ignored for trait computations; - // - compute fields (and yields); - // - assign to `t`. - let t = #[rustc_box] - Box::new((5, yield)); - drop(t); - }; - - // Allocate the temporary box. - Pin::new(&mut g).resume(()); - - // The temporary box is in generator locals. - // As it is not taken into account for trait computation, - // the generator is `Copy`. - let mut h = copy(g); - //[drop_tracking_mir]~^ ERROR the trait bound `Box<(i32, ())>: Copy` is not satisfied in - - // We now have 2 boxes with the same backing allocation: - // one inside `g` and one inside `h`. - // Proceed and drop `t` in `g`. - Pin::new(&mut g).resume(()); - //[drop_tracking_mir]~^ ERROR borrow of moved value: `g` - - // Proceed and drop `t` in `h` -> double free! - Pin::new(&mut h).resume(()); -} diff --git a/tests/ui/generator/issue-110929-generator-conflict-error-ice.rs b/tests/ui/generator/issue-110929-generator-conflict-error-ice.rs deleted file mode 100644 index 9408acc15..000000000 --- a/tests/ui/generator/issue-110929-generator-conflict-error-ice.rs +++ /dev/null @@ -1,12 +0,0 @@ -// edition:2021 -// compile-flags: -Zdrop-tracking-mir=yes -#![feature(generators)] - -fn main() { - let x = &mut (); - || { - let _c = || yield *&mut *x; - || _ = &mut *x; - //~^ cannot borrow `*x` as mutable more than once at a time - }; -} diff --git a/tests/ui/generator/issue-110929-generator-conflict-error-ice.stderr b/tests/ui/generator/issue-110929-generator-conflict-error-ice.stderr deleted file mode 100644 index 4d72ebe79..000000000 --- a/tests/ui/generator/issue-110929-generator-conflict-error-ice.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/issue-110929-generator-conflict-error-ice.rs:9:9 - | -LL | let _c = || yield *&mut *x; - | -- -- first borrow occurs due to use of `*x` in generator - | | - | first mutable borrow occurs here -LL | || _ = &mut *x; - | ^^ -- second borrow occurs due to use of `*x` in closure - | | - | second mutable borrow occurs here -LL | -LL | }; - | - first borrow might be used here, when `_c` is dropped and runs the destructor for generator - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/generator/issue-44197.rs b/tests/ui/generator/issue-44197.rs deleted file mode 100644 index 389b9d139..000000000 --- a/tests/ui/generator/issue-44197.rs +++ /dev/null @@ -1,36 +0,0 @@ -// run-pass - -#![feature(generators, generator_trait)] - -use std::ops::{Generator, GeneratorState}; -use std::pin::Pin; - -fn foo(_: &str) -> String { - String::new() -} - -fn bar(baz: String) -> impl Generator<(), Yield = String, Return = ()> { - move || { - yield foo(&baz); - } -} - -fn foo2(_: &str) -> Result<String, ()> { - Err(()) -} - -fn bar2(baz: String) -> impl Generator<(), Yield = String, Return = ()> { - move || { - if let Ok(quux) = foo2(&baz) { - yield quux; - } - } -} - -fn main() { - assert_eq!( - Pin::new(&mut bar(String::new())).resume(()), - GeneratorState::Yielded(String::new()) - ); - assert_eq!(Pin::new(&mut bar2(String::new())).resume(()), GeneratorState::Complete(())); -} diff --git a/tests/ui/generator/issue-45729-unsafe-in-generator.mir.stderr b/tests/ui/generator/issue-45729-unsafe-in-generator.mir.stderr deleted file mode 100644 index 3afbea079..000000000 --- a/tests/ui/generator/issue-45729-unsafe-in-generator.mir.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block - --> $DIR/issue-45729-unsafe-in-generator.rs:8:9 - | -LL | *(1 as *mut u32) = 42; - | ^^^^^^^^^^^^^^^^^^^^^ dereference of raw pointer - | - = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0133`. diff --git a/tests/ui/generator/issue-45729-unsafe-in-generator.rs b/tests/ui/generator/issue-45729-unsafe-in-generator.rs deleted file mode 100644 index 379c36d2c..000000000 --- a/tests/ui/generator/issue-45729-unsafe-in-generator.rs +++ /dev/null @@ -1,12 +0,0 @@ -// revisions: mir thir -// [thir]compile-flags: -Z thir-unsafeck - -#![feature(generators)] - -fn main() { - let _ = || { - *(1 as *mut u32) = 42; - //~^ ERROR dereference of raw pointer is unsafe - yield; - }; -} diff --git a/tests/ui/generator/issue-45729-unsafe-in-generator.thir.stderr b/tests/ui/generator/issue-45729-unsafe-in-generator.thir.stderr deleted file mode 100644 index 10d768f19..000000000 --- a/tests/ui/generator/issue-45729-unsafe-in-generator.thir.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block - --> $DIR/issue-45729-unsafe-in-generator.rs:8:9 - | -LL | *(1 as *mut u32) = 42; - | ^^^^^^^^^^^^^^^^ dereference of raw pointer - | - = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0133`. diff --git a/tests/ui/generator/issue-48048.rs b/tests/ui/generator/issue-48048.rs deleted file mode 100644 index 992bbc97a..000000000 --- a/tests/ui/generator/issue-48048.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(generators)] - -fn main() { - let x = (|_| {},); - - || { - let x = x; - - x.0({ //~ ERROR borrow may still be in use when generator yields - yield; - }); - }; -} diff --git a/tests/ui/generator/issue-48048.stderr b/tests/ui/generator/issue-48048.stderr deleted file mode 100644 index 234235839..000000000 --- a/tests/ui/generator/issue-48048.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/issue-48048.rs:9:9 - | -LL | x.0({ - | ^^^ -LL | yield; - | ----- possible yield occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0626`. diff --git a/tests/ui/generator/issue-52304.rs b/tests/ui/generator/issue-52304.rs deleted file mode 100644 index 3e9de765b..000000000 --- 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-52398.rs b/tests/ui/generator/issue-52398.rs deleted file mode 100644 index ada380d11..000000000 --- a/tests/ui/generator/issue-52398.rs +++ /dev/null @@ -1,28 +0,0 @@ -// run-pass -#![allow(unused_variables)] - -#![feature(generators)] - -use std::cell::RefCell; - -struct A; - -impl A { - fn test(&self, 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 - 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 - yield *y.borrow(); - return "Done"; - }; -} diff --git a/tests/ui/generator/issue-52398.stderr b/tests/ui/generator/issue-52398.stderr deleted file mode 100644 index 539343275..000000000 --- a/tests/ui/generator/issue-52398.stderr +++ /dev/null @@ -1,24 +0,0 @@ -warning: unused generator that must be used - --> $DIR/issue-52398.rs:17:5 - | -LL | / move || { -LL | | A.test(yield); -LL | | }; - | |_____^ - | - = note: generators are lazy and do nothing unless resumed - = note: `#[warn(unused_must_use)]` on by default - -warning: unused generator that must be used - --> $DIR/issue-52398.rs:24:5 - | -LL | / static move || { -LL | | yield *y.borrow(); -LL | | return "Done"; -LL | | }; - | |_____^ - | - = note: generators are lazy and do nothing unless resumed - -warning: 2 warnings emitted - diff --git a/tests/ui/generator/issue-53548-1.rs b/tests/ui/generator/issue-53548-1.rs deleted file mode 100644 index 173ae3c6f..000000000 --- a/tests/ui/generator/issue-53548-1.rs +++ /dev/null @@ -1,20 +0,0 @@ -// A variant of #53548 that does not actually require generators, -// but which encountered the same ICE/error. See `issue-53548.rs` -// for details. -// -// check-pass - -use std::cell::RefCell; -use std::rc::Rc; - -trait Trait: 'static {} - -struct Store<C> { - inner: Rc<RefCell<Option<C>>>, -} - -fn main() { - let store = Store::<Box<for<'a> fn(&(dyn Trait + 'a))>> { - inner: Default::default(), - }; -} diff --git a/tests/ui/generator/issue-53548.rs b/tests/ui/generator/issue-53548.rs deleted file mode 100644 index 3ebabb914..000000000 --- a/tests/ui/generator/issue-53548.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Regression test for #53548. The `Box<dyn Trait>` type below is -// expanded to `Box<dyn Trait + 'static>`, but the generator "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 -// to process this `'r` region bound. In particular, to be WF, the -// region bound must meet the requirements of the trait, and hence we -// got `for<'r> { 'r: 'static }`. This would ICE because the `Binder` -// constructor we were using was assering that no higher-ranked -// regions were involved (because the WF code is supposed to skip -// those). The error (if debug-asserions were disabled) came because -// we obviously cannot prove that `'r: 'static` for any region `'r`. -// Pursuant with our "lazy WF" strategy for higher-ranked regions, the -// fix is not to require that `for<'r> { 'r: 'static }` holds (this is -// also analogous to what we would do for higher-ranked regions -// appearing within the trait in other positions). -// -// check-pass - -#![feature(generators)] - -use std::cell::RefCell; -use std::rc::Rc; - -trait Trait: 'static {} - -struct Store<C> { - inner: Rc<RefCell<Option<C>>>, -} - -fn main() { - Box::new(static move || { - let store = Store::<Box<dyn Trait>> { - inner: Default::default(), - }; - yield (); - }); -} diff --git a/tests/ui/generator/issue-57017.no_drop_tracking.stderr b/tests/ui/generator/issue-57017.no_drop_tracking.stderr deleted file mode 100644 index f7b8e198c..000000000 --- a/tests/ui/generator/issue-57017.no_drop_tracking.stderr +++ /dev/null @@ -1,248 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/issue-57017.rs:32:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation - | - = help: the trait `Sync` is not implemented for `copy::unsync::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-57017.rs:30:28 - | -LL | let g = move || match drop(&$name::unsync::Client::default()) { - | --------------------------------- has type `©::unsync::Client` which is not `Send` -LL | _status => yield, - | ^^^^^ yield occurs here, with `&$name::unsync::Client::default()` maybe used later -LL | }; - | - `&$name::unsync::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:52:19 - | -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 - --> $DIR/issue-57017.rs:44:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/issue-57017.rs:41:21: 41:28]`, the trait `Send` is not implemented for `copy::unsend::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-57017.rs:42:28 - | -LL | let g = move || match drop($name::unsend::Client::default()) { - | -------------------------------- has type `copy::unsend::Client` which is not `Send` -LL | _status => yield, - | ^^^^^ yield occurs here, with `$name::unsend::Client::default()` maybe used later -LL | }; - | - `$name::unsend::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:52:19 - | -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 - --> $DIR/issue-57017.rs:32:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation - | - = help: the trait `Sync` is not implemented for `derived_drop::unsync::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-57017.rs:30:28 - | -LL | let g = move || match drop(&$name::unsync::Client::default()) { - | --------------------------------- has type `&derived_drop::unsync::Client` which is not `Send` -LL | _status => yield, - | ^^^^^ yield occurs here, with `&$name::unsync::Client::default()` maybe used later -LL | }; - | - `&$name::unsync::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:52:19 - | -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 - --> $DIR/issue-57017.rs:44:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/issue-57017.rs:41:21: 41:28]`, the trait `Send` is not implemented for `derived_drop::unsend::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-57017.rs:42:28 - | -LL | let g = move || match drop($name::unsend::Client::default()) { - | -------------------------------- has type `derived_drop::unsend::Client` which is not `Send` -LL | _status => yield, - | ^^^^^ yield occurs here, with `$name::unsend::Client::default()` maybe used later -LL | }; - | - `$name::unsend::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:52:19 - | -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 - --> $DIR/issue-57017.rs:32:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation - | - = help: the trait `Sync` is not implemented for `significant_drop::unsync::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-57017.rs:30:28 - | -LL | let g = move || match drop(&$name::unsync::Client::default()) { - | --------------------------------- has type `&significant_drop::unsync::Client` which is not `Send` -LL | _status => yield, - | ^^^^^ yield occurs here, with `&$name::unsync::Client::default()` maybe used later -LL | }; - | - `&$name::unsync::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:52:19 - | -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 - --> $DIR/issue-57017.rs:44:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/issue-57017.rs:41:21: 41:28]`, the trait `Send` is not implemented for `significant_drop::unsend::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-57017.rs:42:28 - | -LL | let g = move || match drop($name::unsend::Client::default()) { - | -------------------------------- has type `significant_drop::unsend::Client` which is not `Send` -LL | _status => yield, - | ^^^^^ yield occurs here, with `$name::unsend::Client::default()` maybe used later -LL | }; - | - `$name::unsend::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:52:19 - | -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: aborting due to 6 previous errors - diff --git a/tests/ui/generator/issue-57017.rs b/tests/ui/generator/issue-57017.rs deleted file mode 100644 index 381897c77..000000000 --- a/tests/ui/generator/issue-57017.rs +++ /dev/null @@ -1,66 +0,0 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir -// [drop_tracking] build-pass -// [drop_tracking_mir] build-pass - -#![feature(generators, negative_impls)] -#![allow(dropping_references, dropping_copy_types)] - -macro_rules! type_combinations { - ( - $( $name:ident => { $( $tt:tt )* } );* - ) => { $( - mod $name { - pub mod unsync { - $( $tt )* - - impl !Sync for Client {} - } - pub mod unsend { - $( $tt )* - - impl !Send for Client {} - } - } - - // This is the same bug as issue 57017, but using yield instead of await - { - let g = move || match drop(&$name::unsync::Client::default()) { - _status => yield, - }; - assert_send(g); - //[no_drop_tracking]~^ ERROR generator cannot be sent between threads safely - //[no_drop_tracking]~| ERROR generator cannot be sent between threads safely - //[no_drop_tracking]~| ERROR generator cannot be sent between threads safely - } - - // This tests that `Client` is properly considered to be dropped after moving it into the - // function. - { - let g = move || match drop($name::unsend::Client::default()) { - _status => yield, - }; - assert_send(g); - //[no_drop_tracking]~^ ERROR generator cannot be sent between threads safely - //[no_drop_tracking]~| ERROR generator cannot be sent between threads safely - //[no_drop_tracking]~| ERROR generator cannot be sent between threads safely - } - )* } -} - -fn assert_send<T: Send>(_thing: T) {} - -fn main() { - type_combinations!( - copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; - derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; - significant_drop => { - #[derive(Default)] - pub struct Client; - impl Drop for Client { - fn drop(&mut self) {} - } - } - ); -} diff --git a/tests/ui/generator/issue-57084.rs b/tests/ui/generator/issue-57084.rs deleted file mode 100644 index fbed78ff2..000000000 --- a/tests/ui/generator/issue-57084.rs +++ /dev/null @@ -1,28 +0,0 @@ -// This issue reproduces an ICE on compile (E.g. fails on 2018-12-19 nightly). -// "cannot relate bound region: ReLateBound(DebruijnIndex(1), BrAnon(1)) <= '?1" -// run-pass -// edition:2018 -#![feature(generators,generator_trait)] -use std::ops::Generator; - -fn with<F>(f: F) -> impl Generator<Yield=(), Return=()> -where F: Fn() -> () -{ - move || { - loop { - match f() { - _ => yield, - } - } - } -} - -fn main() { - let data = &vec![1]; - || { //~ WARN unused generator 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/generator/issue-57084.stderr deleted file mode 100644 index 8f1fc5e80..000000000 --- a/tests/ui/generator/issue-57084.stderr +++ /dev/null @@ -1,16 +0,0 @@ -warning: unused generator that must be used - --> $DIR/issue-57084.rs:22:5 - | -LL | / || { -LL | | let _to_pin = with(move || println!("{:p}", data)); -LL | | loop { -LL | | yield -LL | | } -LL | | }; - | |_____^ - | - = note: generators 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.no_drop_tracking.stderr b/tests/ui/generator/issue-57478.no_drop_tracking.stderr deleted file mode 100644 index 612dd9c37..000000000 --- a/tests/ui/generator/issue-57478.no_drop_tracking.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/issue-57478.rs:13:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | let guard = Foo; -LL | | drop(guard); -LL | | yield; -LL | | }) - | |_____^ generator is not `Send` - | - = help: within `[generator@$DIR/issue-57478.rs:13:17: 13:19]`, the trait `Send` is not implemented for `Foo` -note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-57478.rs:17:9 - | -LL | let guard = Foo; - | ----- has type `Foo` which is not `Send` -LL | drop(guard); -LL | yield; - | ^^^^^ yield occurs here, with `guard` maybe used later -LL | }) - | - `guard` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/issue-57478.rs:21:19 - | -LL | fn assert_send<T: Send>(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to previous error - diff --git a/tests/ui/generator/issue-57478.rs b/tests/ui/generator/issue-57478.rs deleted file mode 100644 index 3c23b5992..000000000 --- a/tests/ui/generator/issue-57478.rs +++ /dev/null @@ -1,21 +0,0 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir -// [drop_tracking] check-pass -// [drop_tracking_mir] check-pass - -#![feature(negative_impls, generators)] - -struct Foo; -impl !Send for Foo {} - -fn main() { - assert_send(|| { - //[no_drop_tracking]~^ ERROR generator cannot be sent between threads safely - let guard = Foo; - drop(guard); - yield; - }) -} - -fn assert_send<T: Send>(_: T) {} diff --git a/tests/ui/generator/issue-58888.rs b/tests/ui/generator/issue-58888.rs deleted file mode 100644 index d42d09d40..000000000 --- a/tests/ui/generator/issue-58888.rs +++ /dev/null @@ -1,28 +0,0 @@ -// run-pass -// compile-flags: -g -// ignore-asmjs wasm2js does not support source maps yet - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -struct Database; - -impl Database { - fn get_connection(&self) -> impl Iterator<Item = ()> { - Some(()).into_iter() - } - - fn check_connection(&self) -> impl Generator<Yield = (), Return = ()> + '_ { - move || { - let iter = self.get_connection(); - for i in iter { - yield i - } - } - } -} - -fn main() { - Database.check_connection(); -} diff --git a/tests/ui/generator/issue-61442-stmt-expr-with-drop.rs b/tests/ui/generator/issue-61442-stmt-expr-with-drop.rs deleted file mode 100644 index 187c37402..000000000 --- a/tests/ui/generator/issue-61442-stmt-expr-with-drop.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Test that we don't consider temporaries for statement expressions as live -// across yields - -// check-pass -// edition:2018 - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -async fn drop_and_await() { - async {}; - async {}.await; -} - -fn drop_and_yield() { - let x = || { - String::new(); - yield; - }; - Box::pin(x).as_mut().resume(()); - let y = static || { - String::new(); - yield; - }; - Box::pin(y).as_mut().resume(()); -} - -fn main() { - drop_and_await(); - drop_and_yield(); -} diff --git a/tests/ui/generator/issue-62506-two_awaits.rs b/tests/ui/generator/issue-62506-two_awaits.rs deleted file mode 100644 index 672e16b78..000000000 --- a/tests/ui/generator/issue-62506-two_awaits.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Output = String caused an ICE whereas Output = &'static str compiled successfully. -// Broken MIR: generator contains type std::string::String in MIR, -// but typeck only knows about {<S as T>::Future, ()} -// check-pass -// edition:2018 - -use std::future::Future; - -pub trait T { - type Future: Future<Output = String>; - fn bar() -> Self::Future; -} -pub async fn foo<S>() where S: T { - S::bar().await; - S::bar().await; -} -pub 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 2cbe8f516..000000000 --- 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-64620-yield-array-element.stderr b/tests/ui/generator/issue-64620-yield-array-element.stderr deleted file mode 100644 index 48383c2ed..000000000 --- a/tests/ui/generator/issue-64620-yield-array-element.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0627]: yield expression outside of generator literal - --> $DIR/issue-64620-yield-array-element.rs:6:5 - | -LL | yield arr[0]; - | ^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0627`. diff --git a/tests/ui/generator/issue-68112.drop_tracking.stderr b/tests/ui/generator/issue-68112.drop_tracking.stderr deleted file mode 100644 index 282eac1b6..000000000 --- a/tests/ui/generator/issue-68112.drop_tracking.stderr +++ /dev/null @@ -1,66 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/issue-68112.rs:43:18 - | -LL | require_send(send_gen); - | ^^^^^^^^ generator 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/issue-68112.rs:39:9 - | -LL | let _non_send_gen = make_non_send_generator(); - | ------------- has type `impl Generator<Return = Arc<RefCell<i32>>>` which is not `Send` -LL | -LL | yield; - | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later -... -LL | }; - | - `_non_send_gen` is later dropped here -note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:25: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/issue-68112.rs:67:18 - | -LL | require_send(send_gen); - | ------------ ^^^^^^^^ `RefCell<i32>` cannot be shared between threads safely - | | - | required by a bound introduced by this call - | - = 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/issue-68112.rs:52:5 - | -LL | || { - | ^^ -note: required because it appears within the type `impl Generator<Return = Arc<RefCell<i32>>>` - --> $DIR/issue-68112.rs:49:30 - | -LL | pub fn make_gen2<T>(t: T) -> impl Generator<Return = T> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required because it appears within the type `impl Generator<Return = Arc<RefCell<i32>>>` - --> $DIR/issue-68112.rs:57:34 - | -LL | fn make_non_send_generator2() -> impl Generator<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 - --> $DIR/issue-68112.rs:63:20 - | -LL | let send_gen = || { - | ^^ -note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:25:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/issue-68112.drop_tracking_mir.stderr b/tests/ui/generator/issue-68112.drop_tracking_mir.stderr deleted file mode 100644 index a83522b71..000000000 --- a/tests/ui/generator/issue-68112.drop_tracking_mir.stderr +++ /dev/null @@ -1,61 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/issue-68112.rs:43:5 - | -LL | require_send(send_gen); - | ^^^^^^^^^^^^ generator 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/issue-68112.rs:39:9 - | -LL | let _non_send_gen = make_non_send_generator(); - | ------------- has type `impl Generator<Return = Arc<RefCell<i32>>>` which is not `Send` -LL | -LL | yield; - | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later -note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:25: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/issue-68112.rs:67:5 - | -LL | require_send(send_gen); - | ^^^^^^^^^^^^ `RefCell<i32>` cannot be shared between threads safely - | - = 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/issue-68112.rs:52:5 - | -LL | || { - | ^^ -note: required because it appears within the type `impl Generator<Return = Arc<RefCell<i32>>>` - --> $DIR/issue-68112.rs:49:30 - | -LL | pub fn make_gen2<T>(t: T) -> impl Generator<Return = T> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required because it appears within the type `impl Generator<Return = Arc<RefCell<i32>>>` - --> $DIR/issue-68112.rs:57:34 - | -LL | fn make_non_send_generator2() -> impl Generator<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 - --> $DIR/issue-68112.rs:63:20 - | -LL | let send_gen = || { - | ^^ -note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:25:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/issue-68112.no_drop_tracking.stderr b/tests/ui/generator/issue-68112.no_drop_tracking.stderr deleted file mode 100644 index 282eac1b6..000000000 --- a/tests/ui/generator/issue-68112.no_drop_tracking.stderr +++ /dev/null @@ -1,66 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/issue-68112.rs:43:18 - | -LL | require_send(send_gen); - | ^^^^^^^^ generator 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/issue-68112.rs:39:9 - | -LL | let _non_send_gen = make_non_send_generator(); - | ------------- has type `impl Generator<Return = Arc<RefCell<i32>>>` which is not `Send` -LL | -LL | yield; - | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later -... -LL | }; - | - `_non_send_gen` is later dropped here -note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:25: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/issue-68112.rs:67:18 - | -LL | require_send(send_gen); - | ------------ ^^^^^^^^ `RefCell<i32>` cannot be shared between threads safely - | | - | required by a bound introduced by this call - | - = 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/issue-68112.rs:52:5 - | -LL | || { - | ^^ -note: required because it appears within the type `impl Generator<Return = Arc<RefCell<i32>>>` - --> $DIR/issue-68112.rs:49:30 - | -LL | pub fn make_gen2<T>(t: T) -> impl Generator<Return = T> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required because it appears within the type `impl Generator<Return = Arc<RefCell<i32>>>` - --> $DIR/issue-68112.rs:57:34 - | -LL | fn make_non_send_generator2() -> impl Generator<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 - --> $DIR/issue-68112.rs:63:20 - | -LL | let send_gen = || { - | ^^ -note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:25:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/issue-68112.rs b/tests/ui/generator/issue-68112.rs deleted file mode 100644 index 48b53b769..000000000 --- a/tests/ui/generator/issue-68112.rs +++ /dev/null @@ -1,76 +0,0 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir -#![feature(generators, generator_trait)] - -use std::{ - cell::RefCell, - sync::Arc, - pin::Pin, - ops::{Generator, GeneratorState}, -}; - -pub struct Ready<T>(Option<T>); -impl<T: Unpin> Generator<()> for Ready<T> { - type Return = T; - type Yield = (); - fn resume(mut self: Pin<&mut Self>, _args: ()) -> GeneratorState<(), T> { - GeneratorState::Complete(self.0.take().unwrap()) - } -} -pub fn make_gen1<T>(t: T) -> Ready<T> { - Ready(Some(t)) -} - -fn require_send(_: impl Send) {} -//~^ NOTE required by a bound -//~| NOTE required by a bound -//~| NOTE required by this bound -//~| NOTE required by this bound - -fn make_non_send_generator() -> impl Generator<Return = Arc<RefCell<i32>>> { - make_gen1(Arc::new(RefCell::new(0))) -} - -fn test1() { - let send_gen = || { - let _non_send_gen = make_non_send_generator(); - //~^ NOTE not `Send` - yield; - //~^ NOTE yield occurs here - //~| NOTE value is used across a yield - }; //[no_drop_tracking,drop_tracking]~ NOTE later dropped here - require_send(send_gen); - //~^ ERROR generator 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> { -//~^ NOTE appears within the type -//~| NOTE expansion of desugaring - || { //~ NOTE used within this generator - yield; - t - } -} -fn make_non_send_generator2() -> impl Generator<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(); - yield; - }; - require_send(send_gen); - //~^ ERROR `RefCell<i32>` cannot be shared between threads safely - //~| NOTE `RefCell<i32>` cannot be shared between threads safely - //~| NOTE required for - //[no_drop_tracking,drop_tracking]~| NOTE required by a bound introduced by this call - //~| NOTE captures the following types - //~| NOTE use `std::sync::RwLock` instead -} - -fn main() {} diff --git a/tests/ui/generator/issue-69017.rs b/tests/ui/generator/issue-69017.rs deleted file mode 100644 index 511deb60e..000000000 --- a/tests/ui/generator/issue-69017.rs +++ /dev/null @@ -1,18 +0,0 @@ -// This issue reproduces an ICE on compile -// Fails on 2020-02-08 nightly -// regressed commit: https://github.com/rust-lang/rust/commit/f8fd4624474a68bd26694eff3536b9f3a127b2d3 -// -// check-pass - -#![feature(generator_trait)] -#![feature(generators)] - -use std::ops::Generator; - -fn gen() -> impl Generator<usize> { - |_: usize| { - println!("-> {}", yield); - } -} - -fn main() {} diff --git a/tests/ui/generator/issue-69039.rs b/tests/ui/generator/issue-69039.rs deleted file mode 100644 index ccc141860..000000000 --- a/tests/ui/generator/issue-69039.rs +++ /dev/null @@ -1,34 +0,0 @@ -// run-pass - -#![feature(generators, generator_trait)] - -use std::ops::{Generator, GeneratorState}; - -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> { - |_arg: String| { - let my_name = yield "What is your name?"; - let my_mood = yield "How are you feeling?"; - mkstr(my_name, my_mood) - } -} - -fn main() { - let mut my_session = Box::pin(my_scenario()); - - assert_eq!( - my_session.as_mut().resume("_arg".to_string()), - GeneratorState::Yielded("What is your name?") - ); - assert_eq!( - my_session.as_mut().resume("Your Name".to_string()), - GeneratorState::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()) - ); -} diff --git a/tests/ui/generator/issue-87142.rs b/tests/ui/generator/issue-87142.rs deleted file mode 100644 index 7f670919e..000000000 --- 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/issue-88653.rs b/tests/ui/generator/issue-88653.rs deleted file mode 100644 index 1d9377bce..000000000 --- a/tests/ui/generator/issue-88653.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Regression test for #88653, where a confusing warning about a -// type mismatch in generator arguments was issued. - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -fn foo(bar: bool) -> impl Generator<(bool,)> { - //~^ ERROR: type mismatch in generator arguments [E0631] - //~| NOTE: expected due to this - //~| NOTE: expected generator signature `fn((bool,)) -> _` - //~| NOTE: in this expansion of desugaring of `impl Trait` - //~| NOTE: in this expansion of desugaring of `impl Trait` - |bar| { - //~^ NOTE: found signature defined here - if bar { - yield bar; - } - } -} - -fn main() {} diff --git a/tests/ui/generator/issue-88653.stderr b/tests/ui/generator/issue-88653.stderr deleted file mode 100644 index b742c6e2f..000000000 --- a/tests/ui/generator/issue-88653.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0631]: type mismatch in generator arguments - --> $DIR/issue-88653.rs:8:22 - | -LL | fn foo(bar: bool) -> impl Generator<(bool,)> { - | ^^^^^^^^^^^^^^^^^^^^^^^ expected due to this -... -LL | |bar| { - | ----- found signature defined here - | - = note: expected generator signature `fn((bool,)) -> _` - found generator signature `fn(bool) -> _` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0631`. diff --git a/tests/ui/generator/issue-91477.rs b/tests/ui/generator/issue-91477.rs deleted file mode 100644 index 6c027feb4..000000000 --- a/tests/ui/generator/issue-91477.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![feature(generators)] - -fn foo() -> impl Sized { - yield 1; //~ ERROR E0627 -} - -fn main() {} diff --git a/tests/ui/generator/issue-91477.stderr b/tests/ui/generator/issue-91477.stderr deleted file mode 100644 index 4597dc1bc..000000000 --- a/tests/ui/generator/issue-91477.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0627]: yield expression outside of generator literal - --> $DIR/issue-91477.rs:4:5 - | -LL | yield 1; - | ^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0627`. diff --git a/tests/ui/generator/issue-93161.rs b/tests/ui/generator/issue-93161.rs deleted file mode 100644 index 8d3f7c62f..000000000 --- a/tests/ui/generator/issue-93161.rs +++ /dev/null @@ -1,96 +0,0 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir -// edition:2021 -// run-pass - -#![feature(never_type)] - -use std::future::Future; - -// See if we can run a basic `async fn` -pub async fn foo(x: &u32, y: u32) -> u32 { - let y = &y; - let z = 9; - let z = &z; - let y = async { *y + *z }.await; - let a = 10; - let a = &a; - *x + y + *a -} - -async fn add(x: u32, y: u32) -> u32 { - let a = async { x + y }; - a.await -} - -async fn build_aggregate(a: u32, b: u32, c: u32, d: u32) -> u32 { - let x = (add(a, b).await, add(c, d).await); - x.0 + x.1 -} - -enum Never {} -fn never() -> Never { - panic!() -} - -async fn includes_never(crash: bool, x: u32) -> u32 { - let result = async { x * x }.await; - if !crash { - return result; - } - #[allow(unused)] - let bad = never(); - result *= async { x + x }.await; - drop(bad); - result -} - -async fn partial_init(x: u32) -> u32 { - #[allow(unreachable_code)] - let _x: (String, !) = (String::new(), return async { x + x }.await); -} - -async fn read_exact(_from: &mut &[u8], _to: &mut [u8]) -> Option<()> { - Some(()) -} - -async fn hello_world() { - let data = [0u8; 1]; - let mut reader = &data[..]; - - let mut marker = [0u8; 1]; - read_exact(&mut reader, &mut marker).await.unwrap(); -} - -fn run_fut<T>(fut: impl Future<Output = T>) -> T { - use std::sync::Arc; - use std::task::{Context, Poll, Wake, Waker}; - - struct MyWaker; - impl Wake for MyWaker { - fn wake(self: Arc<Self>) { - unimplemented!() - } - } - - let waker = Waker::from(Arc::new(MyWaker)); - let mut context = Context::from_waker(&waker); - - let mut pinned = Box::pin(fut); - loop { - match pinned.as_mut().poll(&mut context) { - Poll::Pending => continue, - Poll::Ready(v) => return v, - } - } -} - -fn main() { - let x = 5; - assert_eq!(run_fut(foo(&x, 7)), 31); - assert_eq!(run_fut(build_aggregate(1, 2, 3, 4)), 10); - assert_eq!(run_fut(includes_never(false, 4)), 16); - assert_eq!(run_fut(partial_init(4)), 8); - run_fut(hello_world()); -} diff --git a/tests/ui/generator/iterator-count.rs b/tests/ui/generator/iterator-count.rs deleted file mode 100644 index 90eefe02f..000000000 --- a/tests/ui/generator/iterator-count.rs +++ /dev/null @@ -1,44 +0,0 @@ -// run-pass - -#![feature(generators, generator_trait)] - -use std::marker::Unpin; -use std::ops::{GeneratorState, Generator}; -use std::pin::Pin; - -struct W<T>(T); - -// This impl isn't safe in general, but the generator used in this test is movable -// so it won't cause problems. -impl<T: Generator<(), 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), - } - } -} - -fn test() -> impl Generator<(), Return=(), Yield=u8> + Unpin { - || { - for i in 1..6 { - yield i - } - } -} - -fn main() { - let end = 11; - - let closure_test = |start| { - move || { - for i in start..end { - yield i - } - } - }; - - assert!(W(test()).chain(W(closure_test(6))).eq(1..11)); -} diff --git a/tests/ui/generator/layout-error.rs b/tests/ui/generator/layout-error.rs deleted file mode 100644 index 7c3d18740..000000000 --- a/tests/ui/generator/layout-error.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Verifies that computing a layout of a generator tainted by type errors -// doesn't ICE. Regression test for #80998. -// -// edition:2018 - -#![feature(type_alias_impl_trait)] -use std::future::Future; - -pub struct Task<F: Future>(F); -impl<F: Future> Task<F> { - const fn new() -> Self { - todo!() - } - fn spawn(&self, _: impl FnOnce() -> F) { - todo!() - } -} - -fn main() { - async fn cb() { - let a = Foo; //~ ERROR cannot find value `Foo` in this scope - } - - type F = impl Future; - // Check that statics are inhabited computes they layout. - static POOL: Task<F> = Task::new(); - Task::spawn(&POOL, || cb()); -} diff --git a/tests/ui/generator/layout-error.stderr b/tests/ui/generator/layout-error.stderr deleted file mode 100644 index b1a258f4f..000000000 --- a/tests/ui/generator/layout-error.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0425]: cannot find value `Foo` in this scope - --> $DIR/layout-error.rs:21:17 - | -LL | let a = Foo; - | ^^^ 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/generator/live-upvar-across-yield.rs b/tests/ui/generator/live-upvar-across-yield.rs deleted file mode 100644 index 6a2e42a55..000000000 --- a/tests/ui/generator/live-upvar-across-yield.rs +++ /dev/null @@ -1,14 +0,0 @@ -// run-pass - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::pin::Pin; - -fn main() { - let b = |_| 3; - let mut a = || { - b(yield); - }; - Pin::new(&mut a).resume(()); -} diff --git a/tests/ui/generator/match-bindings.rs b/tests/ui/generator/match-bindings.rs deleted file mode 100644 index 865904a57..000000000 --- a/tests/ui/generator/match-bindings.rs +++ /dev/null @@ -1,23 +0,0 @@ -// run-pass -#![allow(dead_code)] - -#![feature(generators)] - -enum Enum { - A(String), - B -} - -fn main() { - || { //~ WARN unused generator that must be used - loop { - if let true = true { - match Enum::A(String::new()) { - Enum::A(_var) => {} - Enum::B => {} - } - } - yield; - } - }; -} diff --git a/tests/ui/generator/match-bindings.stderr b/tests/ui/generator/match-bindings.stderr deleted file mode 100644 index 3dd2d5954..000000000 --- a/tests/ui/generator/match-bindings.stderr +++ /dev/null @@ -1,17 +0,0 @@ -warning: unused generator that must be used - --> $DIR/match-bindings.rs:12:5 - | -LL | / || { -LL | | loop { -LL | | if let true = true { -LL | | match Enum::A(String::new()) { -... | -LL | | } -LL | | }; - | |_____^ - | - = note: generators are lazy and do nothing unless resumed - = note: `#[warn(unused_must_use)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/generator/metadata-sufficient-for-layout.rs b/tests/ui/generator/metadata-sufficient-for-layout.rs deleted file mode 100644 index d0e648ee7..000000000 --- a/tests/ui/generator/metadata-sufficient-for-layout.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Check that the layout of a generator is available when auxiliary crate -// is compiled with --emit metadata. -// -// Regression test for #80998. -// -// aux-build:metadata-sufficient-for-layout.rs - -#![feature(type_alias_impl_trait, rustc_attrs)] -#![feature(generator_trait)] - -extern crate metadata_sufficient_for_layout; - -use std::ops::Generator; - -type F = impl Generator<(), Yield = (), Return = ()>; - -// Static queries the layout of the generator. -static A: Option<F> = None; - -fn f() -> F { - metadata_sufficient_for_layout::g() -} - -#[rustc_error] -fn main() {} //~ ERROR diff --git a/tests/ui/generator/metadata-sufficient-for-layout.stderr b/tests/ui/generator/metadata-sufficient-for-layout.stderr deleted file mode 100644 index 3488b04f2..000000000 --- a/tests/ui/generator/metadata-sufficient-for-layout.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/metadata-sufficient-for-layout.rs:25:1 - | -LL | fn main() {} - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/generator/nested_generators.rs b/tests/ui/generator/nested_generators.rs deleted file mode 100644 index 45519150e..000000000 --- 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/niche-in-generator.rs b/tests/ui/generator/niche-in-generator.rs deleted file mode 100644 index 42bee81f5..000000000 --- a/tests/ui/generator/niche-in-generator.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Test that niche finding works with captured generator upvars. - -// run-pass - -#![feature(generators)] - -use std::mem::size_of_val; - -fn take<T>(_: T) {} - -fn main() { - let x = false; - let gen1 = || { - yield; - take(x); - }; - - assert_eq!(size_of_val(&gen1), size_of_val(&Some(gen1))); -} diff --git a/tests/ui/generator/non-static-is-unpin.rs b/tests/ui/generator/non-static-is-unpin.rs deleted file mode 100644 index a5dde3912..000000000 --- a/tests/ui/generator/non-static-is-unpin.rs +++ /dev/null @@ -1,21 +0,0 @@ -// revisions: current next -//[next] compile-flags: -Ztrait-solver=next -// run-pass - -#![feature(generators, generator_trait)] -#![allow(dropping_copy_types)] - -use std::marker::{PhantomPinned, Unpin}; - -fn assert_unpin<G: Unpin>(_: G) { -} - -fn main() { - // Even though this generator holds a `PhantomPinned` in its environment, it - // remains `Unpin`. - assert_unpin(|| { - let pinned = PhantomPinned; - yield; - drop(pinned); - }); -} diff --git a/tests/ui/generator/not-send-sync.drop_tracking.stderr b/tests/ui/generator/not-send-sync.drop_tracking.stderr deleted file mode 100644 index 718fd4224..000000000 --- a/tests/ui/generator/not-send-sync.drop_tracking.stderr +++ /dev/null @@ -1,60 +0,0 @@ -error: generator cannot be shared between threads safely - --> $DIR/not-send-sync.rs:17:17 - | -LL | assert_sync(|| { - | _________________^ -LL | | -LL | | let a = NotSync; -LL | | yield; -LL | | drop(a); -LL | | }); - | |_____^ generator is not `Sync` - | - = help: within `[generator@$DIR/not-send-sync.rs:17:17: 17:19]`, the trait `Sync` is not implemented for `NotSync` -note: generator is not `Sync` as this value is used across a yield - --> $DIR/not-send-sync.rs:20:9 - | -LL | let a = NotSync; - | - has type `NotSync` which is not `Sync` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -LL | drop(a); -LL | }); - | - `a` is later dropped here -note: required by a bound in `assert_sync` - --> $DIR/not-send-sync.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/not-send-sync.rs:24:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | let a = NotSend; -LL | | yield; -LL | | drop(a); -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `[generator@$DIR/not-send-sync.rs:24:17: 24:19]`, the trait `Send` is not implemented for `NotSend` -note: generator is not `Send` as this value is used across a yield - --> $DIR/not-send-sync.rs:27:9 - | -LL | let a = NotSend; - | - has type `NotSend` which is not `Send` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -LL | drop(a); -LL | }); - | - `a` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/not-send-sync.rs:15:23 - | -LL | fn assert_send<T: Send>(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/generator/not-send-sync.drop_tracking_mir.stderr b/tests/ui/generator/not-send-sync.drop_tracking_mir.stderr deleted file mode 100644 index 66f01ae37..000000000 --- a/tests/ui/generator/not-send-sync.drop_tracking_mir.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error: generator cannot be shared between threads safely - --> $DIR/not-send-sync.rs:17:5 - | -LL | assert_sync(|| { - | ^^^^^^^^^^^ generator is not `Sync` - | - = help: within `[generator@$DIR/not-send-sync.rs:17:17: 17:19]`, the trait `Sync` is not implemented for `NotSync` -note: generator is not `Sync` as this value is used across a yield - --> $DIR/not-send-sync.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/not-send-sync.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/not-send-sync.rs:24:5 - | -LL | assert_send(|| { - | ^^^^^^^^^^^ generator is not `Send` - | - = help: within `[generator@$DIR/not-send-sync.rs:24:17: 24:19]`, the trait `Send` is not implemented for `NotSend` -note: generator is not `Send` as this value is used across a yield - --> $DIR/not-send-sync.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/not-send-sync.rs:15:23 - | -LL | fn assert_send<T: Send>(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/generator/not-send-sync.no_drop_tracking.stderr b/tests/ui/generator/not-send-sync.no_drop_tracking.stderr deleted file mode 100644 index 718fd4224..000000000 --- a/tests/ui/generator/not-send-sync.no_drop_tracking.stderr +++ /dev/null @@ -1,60 +0,0 @@ -error: generator cannot be shared between threads safely - --> $DIR/not-send-sync.rs:17:17 - | -LL | assert_sync(|| { - | _________________^ -LL | | -LL | | let a = NotSync; -LL | | yield; -LL | | drop(a); -LL | | }); - | |_____^ generator is not `Sync` - | - = help: within `[generator@$DIR/not-send-sync.rs:17:17: 17:19]`, the trait `Sync` is not implemented for `NotSync` -note: generator is not `Sync` as this value is used across a yield - --> $DIR/not-send-sync.rs:20:9 - | -LL | let a = NotSync; - | - has type `NotSync` which is not `Sync` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -LL | drop(a); -LL | }); - | - `a` is later dropped here -note: required by a bound in `assert_sync` - --> $DIR/not-send-sync.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/not-send-sync.rs:24:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | let a = NotSend; -LL | | yield; -LL | | drop(a); -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `[generator@$DIR/not-send-sync.rs:24:17: 24:19]`, the trait `Send` is not implemented for `NotSend` -note: generator is not `Send` as this value is used across a yield - --> $DIR/not-send-sync.rs:27:9 - | -LL | let a = NotSend; - | - has type `NotSend` which is not `Send` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -LL | drop(a); -LL | }); - | - `a` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/not-send-sync.rs:15:23 - | -LL | fn assert_send<T: Send>(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/generator/not-send-sync.rs b/tests/ui/generator/not-send-sync.rs deleted file mode 100644 index 8794db452..000000000 --- a/tests/ui/generator/not-send-sync.rs +++ /dev/null @@ -1,30 +0,0 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir -#![feature(generators)] -#![feature(negative_impls)] - -struct NotSend; -struct NotSync; - -impl !Send for NotSend {} -impl !Sync for NotSync {} - -fn main() { - fn assert_sync<T: Sync>(_: T) {} - fn assert_send<T: Send>(_: T) {} - - assert_sync(|| { - //~^ ERROR: generator cannot be shared between threads safely - let a = NotSync; - yield; - drop(a); - }); - - assert_send(|| { - //~^ ERROR: generator cannot be sent between threads safely - let a = NotSend; - yield; - drop(a); - }); -} diff --git a/tests/ui/generator/overlap-locals.rs b/tests/ui/generator/overlap-locals.rs deleted file mode 100644 index 101c8714f..000000000 --- a/tests/ui/generator/overlap-locals.rs +++ /dev/null @@ -1,29 +0,0 @@ -// run-pass - -#![feature(generators)] - -fn main() { - let a = || { - { - let w: i32 = 4; - yield; - println!("{:?}", w); - } - { - let x: i32 = 5; - yield; - println!("{:?}", x); - } - { - let y: i32 = 6; - yield; - println!("{:?}", y); - } - { - let z: i32 = 7; - yield; - println!("{:?}", z); - } - }; - assert_eq!(8, std::mem::size_of_val(&a)); -} diff --git a/tests/ui/generator/panic-drops-resume.rs b/tests/ui/generator/panic-drops-resume.rs deleted file mode 100644 index 4c3caeb14..000000000 --- a/tests/ui/generator/panic-drops-resume.rs +++ /dev/null @@ -1,36 +0,0 @@ -//! Tests that panics inside a generator will correctly drop the initial resume argument. - -// run-pass -// needs-unwind - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::panic::{catch_unwind, AssertUnwindSafe}; -use std::pin::Pin; -use std::sync::atomic::{AtomicUsize, Ordering}; - -static DROP: AtomicUsize = AtomicUsize::new(0); - -struct Dropper {} - -impl Drop for Dropper { - fn drop(&mut self) { - DROP.fetch_add(1, Ordering::SeqCst); - } -} - -fn main() { - let mut gen = |_arg| { - if true { - panic!(); - } - yield (); - }; - let mut gen = Pin::new(&mut gen); - - assert_eq!(DROP.load(Ordering::Acquire), 0); - let res = catch_unwind(AssertUnwindSafe(|| gen.as_mut().resume(Dropper {}))); - assert!(res.is_err()); - assert_eq!(DROP.load(Ordering::Acquire), 1); -} diff --git a/tests/ui/generator/panic-drops.rs b/tests/ui/generator/panic-drops.rs deleted file mode 100644 index 65001fd87..000000000 --- a/tests/ui/generator/panic-drops.rs +++ /dev/null @@ -1,57 +0,0 @@ -// run-pass -// needs-unwind - - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::panic; -use std::pin::Pin; -use std::sync::atomic::{AtomicUsize, Ordering}; - -static A: AtomicUsize = AtomicUsize::new(0); - -struct B; - -impl Drop for B { - fn drop(&mut self) { - A.fetch_add(1, Ordering::SeqCst); - } -} - -fn bool_true() -> bool { - true -} - -fn main() { - let b = B; - let mut foo = || { - if bool_true() { - panic!(); - } - drop(b); - yield; - }; - - assert_eq!(A.load(Ordering::SeqCst), 0); - let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { - Pin::new(&mut foo).resume(()) - })); - assert!(res.is_err()); - assert_eq!(A.load(Ordering::SeqCst), 1); - - let mut foo = || { - if bool_true() { - panic!(); - } - drop(B); - yield; - }; - - assert_eq!(A.load(Ordering::SeqCst), 1); - let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { - Pin::new(&mut foo).resume(()) - })); - assert!(res.is_err()); - assert_eq!(A.load(Ordering::SeqCst), 1); -} diff --git a/tests/ui/generator/panic-safe.rs b/tests/ui/generator/panic-safe.rs deleted file mode 100644 index 3db80bb58..000000000 --- a/tests/ui/generator/panic-safe.rs +++ /dev/null @@ -1,30 +0,0 @@ -// run-pass -// needs-unwind - - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::pin::Pin; -use std::panic; - -fn main() { - let mut foo = || { - if true { - panic!(); - } - yield; - }; - - let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { - Pin::new(&mut foo).resume(()) - })); - assert!(res.is_err()); - - for _ in 0..10 { - let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { - Pin::new(&mut foo).resume(()) - })); - assert!(res.is_err()); - } -} diff --git a/tests/ui/generator/parent-expression.drop_tracking.stderr b/tests/ui/generator/parent-expression.drop_tracking.stderr deleted file mode 100644 index ef489088b..000000000 --- a/tests/ui/generator/parent-expression.drop_tracking.stderr +++ /dev/null @@ -1,128 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/parent-expression.rs:21:21: 21:28]`, the trait `Send` is not implemented for `derived_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `derived_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -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 - --> $DIR/parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/parent-expression.rs:21:21: 21:28]`, the trait `Send` is not implemented for `significant_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `significant_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -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 - --> $DIR/parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/parent-expression.rs:21:21: 21:28]`, the trait `Send` is not implemented for `insignificant_dtor::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `insignificant_dtor::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -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: aborting due to 3 previous errors - diff --git a/tests/ui/generator/parent-expression.drop_tracking_mir.stderr b/tests/ui/generator/parent-expression.drop_tracking_mir.stderr deleted file mode 100644 index bf8144564..000000000 --- a/tests/ui/generator/parent-expression.drop_tracking_mir.stderr +++ /dev/null @@ -1,122 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/parent-expression.rs:27:13 - | -LL | assert_send(g); - | ^^^^^^^^^^^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/parent-expression.rs:21:21: 21:28]`, the trait `Send` is not implemented for `derived_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `derived_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -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 - --> $DIR/parent-expression.rs:27:13 - | -LL | assert_send(g); - | ^^^^^^^^^^^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/parent-expression.rs:21:21: 21:28]`, the trait `Send` is not implemented for `significant_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `significant_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -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 - --> $DIR/parent-expression.rs:27:13 - | -LL | assert_send(g); - | ^^^^^^^^^^^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/parent-expression.rs:21:21: 21:28]`, the trait `Send` is not implemented for `insignificant_dtor::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `insignificant_dtor::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -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: aborting due to 3 previous errors - diff --git a/tests/ui/generator/parent-expression.no_drop_tracking.stderr b/tests/ui/generator/parent-expression.no_drop_tracking.stderr deleted file mode 100644 index 2e1313a80..000000000 --- a/tests/ui/generator/parent-expression.no_drop_tracking.stderr +++ /dev/null @@ -1,334 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/parent-expression.rs:21:21: 21:28]`, the trait `Send` is not implemented for `copy::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `copy::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -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 - --> $DIR/parent-expression.rs:40:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/parent-expression.rs:37:21: 37:28]`, the trait `Send` is not implemented for `copy::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:38:22 - | -LL | let g = move || match drop($name::Client::default()) { - | ------------------------ has type `copy::Client` which is not `Send` -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -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 - --> $DIR/parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/parent-expression.rs:21:21: 21:28]`, the trait `Send` is not implemented for `derived_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `derived_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -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 - --> $DIR/parent-expression.rs:40:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/parent-expression.rs:37:21: 37:28]`, the trait `Send` is not implemented for `derived_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:38:22 - | -LL | let g = move || match drop($name::Client::default()) { - | ------------------------ has type `derived_drop::Client` which is not `Send` -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -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 - --> $DIR/parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/parent-expression.rs:21:21: 21:28]`, the trait `Send` is not implemented for `significant_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `significant_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -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 - --> $DIR/parent-expression.rs:40:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/parent-expression.rs:37:21: 37:28]`, the trait `Send` is not implemented for `significant_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:38:22 - | -LL | let g = move || match drop($name::Client::default()) { - | ------------------------ has type `significant_drop::Client` which is not `Send` -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -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 - --> $DIR/parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/parent-expression.rs:21:21: 21:28]`, the trait `Send` is not implemented for `insignificant_dtor::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `insignificant_dtor::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -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 - --> $DIR/parent-expression.rs:40:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/parent-expression.rs:37:21: 37:28]`, the trait `Send` is not implemented for `insignificant_dtor::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:38:22 - | -LL | let g = move || match drop($name::Client::default()) { - | ------------------------ has type `insignificant_dtor::Client` which is not `Send` -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -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: aborting due to 8 previous errors - diff --git a/tests/ui/generator/parent-expression.rs b/tests/ui/generator/parent-expression.rs deleted file mode 100644 index 239034e3d..000000000 --- a/tests/ui/generator/parent-expression.rs +++ /dev/null @@ -1,77 +0,0 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir - -#![feature(generators, negative_impls, rustc_attrs)] - -macro_rules! type_combinations { - ( - $( $name:ident => { $( $tt:tt )* } );* $(;)? - ) => { $( - mod $name { - $( $tt )* - - impl !Sync for Client {} - impl !Send for Client {} - } - - // Struct update syntax. This fails because the Client used in the update is considered - // dropped *after* the yield. - { - let g = move || match drop($name::Client { ..$name::Client::default() }) { - //~^ `significant_drop::Client` which is not `Send` - //~| `insignificant_dtor::Client` which is not `Send` - //~| `derived_drop::Client` which is not `Send` - _ => yield, - }; - assert_send(g); - //~^ ERROR cannot be sent between threads - //~| ERROR cannot be sent between threads - //~| ERROR cannot be sent between threads - //[no_drop_tracking]~^^^^ ERROR cannot be sent between threads - } - - // Simple owned value. This works because the Client is considered moved into `drop`, - // even though the temporary expression doesn't end until after the yield. - { - let g = move || match drop($name::Client::default()) { - _ => yield, - }; - assert_send(g); - //[no_drop_tracking]~^ ERROR cannot be sent between threads - //[no_drop_tracking]~| ERROR cannot be sent between threads - //[no_drop_tracking]~| ERROR cannot be sent between threads - //[no_drop_tracking]~| ERROR cannot be sent between threads - } - )* } -} - -fn assert_send<T: Send>(_thing: T) {} - -fn main() { - type_combinations!( - // OK - copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; - // NOT OK: MIR borrowck thinks that this is used after the yield, even though - // this has no `Drop` impl and only the drops of the fields are observable. - // FIXME: this should compile. - derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; - // NOT OK - significant_drop => { - #[derive(Default)] - pub struct Client; - impl Drop for Client { - fn drop(&mut self) {} - } - }; - // NOT OK (we need to agree with MIR borrowck) - insignificant_dtor => { - #[derive(Default)] - #[rustc_insignificant_dtor] - pub struct Client; - impl Drop for Client { - fn drop(&mut self) {} - } - }; - ); -} diff --git a/tests/ui/generator/partial-drop.drop_tracking.stderr b/tests/ui/generator/partial-drop.drop_tracking.stderr deleted file mode 100644 index f1b25cb8c..000000000 --- a/tests/ui/generator/partial-drop.drop_tracking.stderr +++ /dev/null @@ -1,61 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/partial-drop.rs:17:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | let guard = Bar { foo: Foo, x: 42 }; -LL | | drop(guard.foo); -LL | | yield; -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `[generator@$DIR/partial-drop.rs:17:17: 17:19]`, the trait `Send` is not implemented for `Foo` -note: generator is not `Send` as this value is used across a yield - --> $DIR/partial-drop.rs:21:9 - | -LL | let guard = Bar { foo: Foo, x: 42 }; - | ----- has type `Bar` which is not `Send` -LL | drop(guard.foo); -LL | yield; - | ^^^^^ yield occurs here, with `guard` maybe used later -LL | }); - | - `guard` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/partial-drop.rs:33:19 - | -LL | fn assert_send<T: Send>(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: generator cannot be sent between threads safely - --> $DIR/partial-drop.rs:24:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | let guard = Bar { foo: Foo, x: 42 }; -LL | | let Bar { foo, x } = guard; -LL | | drop(foo); -LL | | yield; -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `[generator@$DIR/partial-drop.rs:24:17: 24:19]`, the trait `Send` is not implemented for `Foo` -note: generator is not `Send` as this value is used across a yield - --> $DIR/partial-drop.rs:29:9 - | -LL | let guard = Bar { foo: Foo, x: 42 }; - | ----- has type `Bar` which is not `Send` -... -LL | yield; - | ^^^^^ yield occurs here, with `guard` maybe used later -LL | }); - | - `guard` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/partial-drop.rs:33:19 - | -LL | fn assert_send<T: Send>(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/generator/partial-drop.no_drop_tracking.stderr b/tests/ui/generator/partial-drop.no_drop_tracking.stderr deleted file mode 100644 index 91152b5ea..000000000 --- a/tests/ui/generator/partial-drop.no_drop_tracking.stderr +++ /dev/null @@ -1,61 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/partial-drop.rs:17:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | let guard = Bar { foo: Foo, x: 42 }; -LL | | drop(guard.foo); -LL | | yield; -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `[generator@$DIR/partial-drop.rs:17:17: 17:19]`, the trait `Send` is not implemented for `Foo` -note: generator is not `Send` as this value is used across a yield - --> $DIR/partial-drop.rs:21:9 - | -LL | let guard = Bar { foo: Foo, x: 42 }; - | ----- has type `Bar` which is not `Send` -LL | drop(guard.foo); -LL | yield; - | ^^^^^ yield occurs here, with `guard` maybe used later -LL | }); - | - `guard` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/partial-drop.rs:33:19 - | -LL | fn assert_send<T: Send>(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: generator cannot be sent between threads safely - --> $DIR/partial-drop.rs:24:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | let guard = Bar { foo: Foo, x: 42 }; -LL | | let Bar { foo, x } = guard; -LL | | drop(foo); -LL | | yield; -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `[generator@$DIR/partial-drop.rs:24:17: 24:19]`, the trait `Send` is not implemented for `Foo` -note: generator is not `Send` as this value is used across a yield - --> $DIR/partial-drop.rs:29:9 - | -LL | let Bar { foo, x } = guard; - | --- has type `Foo` which is not `Send` -LL | drop(foo); -LL | yield; - | ^^^^^ yield occurs here, with `foo` maybe used later -LL | }); - | - `foo` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/partial-drop.rs:33:19 - | -LL | fn assert_send<T: Send>(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/generator/partial-drop.rs b/tests/ui/generator/partial-drop.rs deleted file mode 100644 index 1d3ae075d..000000000 --- a/tests/ui/generator/partial-drop.rs +++ /dev/null @@ -1,33 +0,0 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir -// [drop_tracking_mir] check-pass - -#![feature(negative_impls, generators)] - -struct Foo; -impl !Send for Foo {} - -struct Bar { - foo: Foo, - x: i32, -} - -fn main() { - assert_send(|| { - //[no_drop_tracking,drop_tracking]~^ ERROR generator cannot be sent between threads safely - let guard = Bar { foo: Foo, x: 42 }; - drop(guard.foo); - yield; - }); - - assert_send(|| { - //[no_drop_tracking,drop_tracking]~^ ERROR generator cannot be sent between threads safely - let guard = Bar { foo: Foo, x: 42 }; - let Bar { foo, x } = guard; - drop(foo); - yield; - }); -} - -fn assert_send<T: Send>(_: T) {} diff --git a/tests/ui/generator/partial-initialization-across-yield.rs b/tests/ui/generator/partial-initialization-across-yield.rs deleted file mode 100644 index 65d9e6d39..000000000 --- a/tests/ui/generator/partial-initialization-across-yield.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Test that we don't allow yielding from a generator while a local is partially -// initialized. - -#![feature(generators)] - -struct S { x: i32, y: i32 } -struct T(i32, i32); - -fn test_tuple() { - let _ = || { - let mut t: (i32, i32); - t.0 = 42; //~ ERROR E0381 - yield; - t.1 = 88; - let _ = t; - }; -} - -fn test_tuple_struct() { - let _ = || { - let mut t: T; - t.0 = 42; //~ ERROR E0381 - yield; - t.1 = 88; - let _ = t; - }; -} - -fn test_struct() { - let _ = || { - let mut t: S; - t.x = 42; //~ ERROR E0381 - yield; - t.y = 88; - let _ = t; - }; -} - -fn main() { - test_tuple(); - test_tuple_struct(); - test_struct(); -} diff --git a/tests/ui/generator/partial-initialization-across-yield.stderr b/tests/ui/generator/partial-initialization-across-yield.stderr deleted file mode 100644 index 3f9f1c046..000000000 --- a/tests/ui/generator/partial-initialization-across-yield.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0381]: partially assigned binding `t` isn't fully initialized - --> $DIR/partial-initialization-across-yield.rs:12:9 - | -LL | let mut t: (i32, i32); - | ----- binding declared here but left uninitialized -LL | t.0 = 42; - | ^^^^^^^^ `t` partially assigned here but it isn't fully initialized - | - = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit` - -error[E0381]: partially assigned binding `t` isn't fully initialized - --> $DIR/partial-initialization-across-yield.rs:22:9 - | -LL | let mut t: T; - | ----- binding declared here but left uninitialized -LL | t.0 = 42; - | ^^^^^^^^ `t` partially assigned here but it isn't fully initialized - | - = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit` - -error[E0381]: partially assigned binding `t` isn't fully initialized - --> $DIR/partial-initialization-across-yield.rs:32:9 - | -LL | let mut t: S; - | ----- binding declared here but left uninitialized -LL | t.x = 42; - | ^^^^^^^^ `t` partially assigned here but it isn't fully initialized - | - = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/tests/ui/generator/pattern-borrow.rs b/tests/ui/generator/pattern-borrow.rs deleted file mode 100644 index d19363708..000000000 --- a/tests/ui/generator/pattern-borrow.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![feature(generators)] - -enum Test { A(i32), B, } - -fn main() { } - -fn fun(test: Test) { - move || { - if let Test::A(ref _a) = test { //~ ERROR borrow may still be in use when generator yields - yield (); - _a.use_ref(); - } - }; -} - -trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } } -impl<T> Fake for T { } diff --git a/tests/ui/generator/pattern-borrow.stderr b/tests/ui/generator/pattern-borrow.stderr deleted file mode 100644 index d78da5104..000000000 --- a/tests/ui/generator/pattern-borrow.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/pattern-borrow.rs:9:24 - | -LL | if let Test::A(ref _a) = test { - | ^^^^^^ -LL | yield (); - | -------- possible yield occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0626`. diff --git a/tests/ui/generator/pin-box-generator.rs b/tests/ui/generator/pin-box-generator.rs deleted file mode 100644 index c3136f5c0..000000000 --- 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/print/generator-print-verbose-1.drop_tracking.stderr b/tests/ui/generator/print/generator-print-verbose-1.drop_tracking.stderr deleted file mode 100644 index 429b202f6..000000000 --- a/tests/ui/generator/print/generator-print-verbose-1.drop_tracking.stderr +++ /dev/null @@ -1,64 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/generator-print-verbose-1.rs:40:18 - | -LL | require_send(send_gen); - | ^^^^^^^^ generator 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:38: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 | yield; - | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later -LL | }; - | - `_non_send_gen` is later dropped here -note: required by a bound in `require_send` - --> $DIR/generator-print-verbose-1.rs:29: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:59:18 - | -LL | require_send(send_gen); - | ------------ ^^^^^^^^ `RefCell<i32>` cannot be shared between threads safely - | | - | required by a bound introduced by this call - | - = 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:45: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:44:30 - | -LL | pub fn make_gen2<T>(t: T) -> impl Generator<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:50:34 - | -LL | fn make_non_send_generator2() -> impl Generator<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:55:20 - | -LL | let send_gen = || { - | ^^ -note: required by a bound in `require_send` - --> $DIR/generator-print-verbose-1.rs:29:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/print/generator-print-verbose-1.drop_tracking_mir.stderr b/tests/ui/generator/print/generator-print-verbose-1.drop_tracking_mir.stderr deleted file mode 100644 index 01a30fd2f..000000000 --- a/tests/ui/generator/print/generator-print-verbose-1.drop_tracking_mir.stderr +++ /dev/null @@ -1,60 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/generator-print-verbose-1.rs:40:5 - | -LL | require_send(send_gen); - | ^^^^^^^^^^^^ generator 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:38: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 | 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:29: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:59:5 - | -LL | require_send(send_gen); - | ^^^^^^^^^^^^ `RefCell<i32>` cannot be shared between threads safely - | - = 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:45: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:44:30 - | -LL | pub fn make_gen2<T>(t: T) -> impl Generator<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:50:34 - | -LL | fn make_non_send_generator2() -> impl Generator<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:55:20 - | -LL | let send_gen = || { - | ^^ -note: required by a bound in `require_send` - --> $DIR/generator-print-verbose-1.rs:29:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/print/generator-print-verbose-1.no_drop_tracking.stderr b/tests/ui/generator/print/generator-print-verbose-1.no_drop_tracking.stderr deleted file mode 100644 index 429b202f6..000000000 --- a/tests/ui/generator/print/generator-print-verbose-1.no_drop_tracking.stderr +++ /dev/null @@ -1,64 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/generator-print-verbose-1.rs:40:18 - | -LL | require_send(send_gen); - | ^^^^^^^^ generator 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:38: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 | yield; - | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later -LL | }; - | - `_non_send_gen` is later dropped here -note: required by a bound in `require_send` - --> $DIR/generator-print-verbose-1.rs:29: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:59:18 - | -LL | require_send(send_gen); - | ------------ ^^^^^^^^ `RefCell<i32>` cannot be shared between threads safely - | | - | required by a bound introduced by this call - | - = 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:45: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:44:30 - | -LL | pub fn make_gen2<T>(t: T) -> impl Generator<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:50:34 - | -LL | fn make_non_send_generator2() -> impl Generator<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:55:20 - | -LL | let send_gen = || { - | ^^ -note: required by a bound in `require_send` - --> $DIR/generator-print-verbose-1.rs:29:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/print/generator-print-verbose-1.rs b/tests/ui/generator/print/generator-print-verbose-1.rs deleted file mode 100644 index c7052c7d1..000000000 --- a/tests/ui/generator/print/generator-print-verbose-1.rs +++ /dev/null @@ -1,63 +0,0 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir -// compile-flags: -Zverbose - -// Same as: tests/ui/generator/issue-68112.stderr - -#![feature(generators, generator_trait)] - -use std::{ - cell::RefCell, - sync::Arc, - pin::Pin, - ops::{Generator, GeneratorState}, -}; - -pub struct Ready<T>(Option<T>); -impl<T: Unpin> Generator<()> for Ready<T> { - type Return = T; - type Yield = (); - fn resume(mut self: Pin<&mut Self>, _args: ()) -> GeneratorState<(), T> { - GeneratorState::Complete(self.0.take().unwrap()) - } -} -pub fn make_gen1<T>(t: T) -> Ready<T> { - Ready(Some(t)) -} - -fn require_send(_: impl Send) {} - -fn make_non_send_generator() -> impl Generator<Return = Arc<RefCell<i32>>> { - make_gen1(Arc::new(RefCell::new(0))) -} - -fn test1() { - let send_gen = || { - let _non_send_gen = make_non_send_generator(); - yield; - }; - require_send(send_gen); - //~^ ERROR generator cannot be sent between threads -} - -pub fn make_gen2<T>(t: T) -> impl Generator<Return = T> { - || { - yield; - t - } -} -fn make_non_send_generator2() -> impl Generator<Return = Arc<RefCell<i32>>> { - make_gen2(Arc::new(RefCell::new(0))) -} - -fn test2() { - let send_gen = || { - let _non_send_gen = make_non_send_generator2(); - yield; - }; - require_send(send_gen); - //~^ ERROR `RefCell<i32>` cannot be shared between threads safely -} - -fn main() {} diff --git a/tests/ui/generator/print/generator-print-verbose-2.drop_tracking.stderr b/tests/ui/generator/print/generator-print-verbose-2.drop_tracking.stderr deleted file mode 100644 index 1f2e530f6..000000000 --- a/tests/ui/generator/print/generator-print-verbose-2.drop_tracking.stderr +++ /dev/null @@ -1,60 +0,0 @@ -error: generator cannot be shared between threads safely - --> $DIR/generator-print-verbose-2.rs:20:17 - | -LL | assert_sync(|| { - | _________________^ -LL | | -LL | | let a = NotSync; -LL | | yield; -LL | | drop(a); -LL | | }); - | |_____^ generator is not `Sync` - | - = help: within `[main::{closure#0} upvar_tys=() {NotSync, ()}]`, 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:23:9 - | -LL | let a = NotSync; - | - has type `NotSync` which is not `Sync` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -LL | drop(a); -LL | }); - | - `a` is later dropped here -note: required by a bound in `assert_sync` - --> $DIR/generator-print-verbose-2.rs:17: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:27:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | let a = NotSend; -LL | | yield; -LL | | drop(a); -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `[main::{closure#1} upvar_tys=() {NotSend, ()}]`, 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:30:9 - | -LL | let a = NotSend; - | - has type `NotSend` which is not `Send` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -LL | drop(a); -LL | }); - | - `a` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/generator-print-verbose-2.rs:18:23 - | -LL | fn assert_send<T: Send>(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/generator/print/generator-print-verbose-2.drop_tracking_mir.stderr b/tests/ui/generator/print/generator-print-verbose-2.drop_tracking_mir.stderr deleted file mode 100644 index 354369f19..000000000 --- a/tests/ui/generator/print/generator-print-verbose-2.drop_tracking_mir.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error: generator cannot be shared between threads safely - --> $DIR/generator-print-verbose-2.rs:20:5 - | -LL | assert_sync(|| { - | ^^^^^^^^^^^ generator 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:23: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:17: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:27:5 - | -LL | assert_send(|| { - | ^^^^^^^^^^^ generator 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:30: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:18:23 - | -LL | fn assert_send<T: Send>(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/generator/print/generator-print-verbose-2.no_drop_tracking.stderr b/tests/ui/generator/print/generator-print-verbose-2.no_drop_tracking.stderr deleted file mode 100644 index 1f2e530f6..000000000 --- a/tests/ui/generator/print/generator-print-verbose-2.no_drop_tracking.stderr +++ /dev/null @@ -1,60 +0,0 @@ -error: generator cannot be shared between threads safely - --> $DIR/generator-print-verbose-2.rs:20:17 - | -LL | assert_sync(|| { - | _________________^ -LL | | -LL | | let a = NotSync; -LL | | yield; -LL | | drop(a); -LL | | }); - | |_____^ generator is not `Sync` - | - = help: within `[main::{closure#0} upvar_tys=() {NotSync, ()}]`, 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:23:9 - | -LL | let a = NotSync; - | - has type `NotSync` which is not `Sync` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -LL | drop(a); -LL | }); - | - `a` is later dropped here -note: required by a bound in `assert_sync` - --> $DIR/generator-print-verbose-2.rs:17: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:27:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | let a = NotSend; -LL | | yield; -LL | | drop(a); -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `[main::{closure#1} upvar_tys=() {NotSend, ()}]`, 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:30:9 - | -LL | let a = NotSend; - | - has type `NotSend` which is not `Send` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -LL | drop(a); -LL | }); - | - `a` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/generator-print-verbose-2.rs:18:23 - | -LL | fn assert_send<T: Send>(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/generator/print/generator-print-verbose-2.rs b/tests/ui/generator/print/generator-print-verbose-2.rs deleted file mode 100644 index ab29db6e0..000000000 --- a/tests/ui/generator/print/generator-print-verbose-2.rs +++ /dev/null @@ -1,33 +0,0 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir -// compile-flags: -Zverbose - -// Same as test/ui/generator/not-send-sync.rs -#![feature(generators)] -#![feature(negative_impls)] - -struct NotSend; -struct NotSync; - -impl !Send for NotSend {} -impl !Sync for NotSync {} - -fn main() { - fn assert_sync<T: Sync>(_: T) {} - fn assert_send<T: Send>(_: T) {} - - assert_sync(|| { - //~^ ERROR: generator cannot be shared between threads safely - let a = NotSync; - yield; - drop(a); - }); - - assert_send(|| { - //~^ ERROR: generator cannot be sent between threads safely - let a = NotSend; - yield; - drop(a); - }); -} diff --git a/tests/ui/generator/print/generator-print-verbose-3.rs b/tests/ui/generator/print/generator-print-verbose-3.rs deleted file mode 100644 index 8689539ec..000000000 --- a/tests/ui/generator/print/generator-print-verbose-3.rs +++ /dev/null @@ -1,12 +0,0 @@ -// compile-flags: -Zverbose - -#![feature(generators, generator_trait)] - -fn main() { - let x = "Type mismatch test"; - let generator :() = || { - //~^ ERROR mismatched types - yield 1i32; - return x - }; -} diff --git a/tests/ui/generator/print/generator-print-verbose-3.stderr b/tests/ui/generator/print/generator-print-verbose-3.stderr deleted file mode 100644 index d15646259..000000000 --- a/tests/ui/generator/print/generator-print-verbose-3.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/generator-print-verbose-3.rs:7:25 - | -LL | let generator :() = || { - | ____________________--___^ - | | | - | | expected due to this -LL | | -LL | | yield 1i32; -LL | | return x -LL | | }; - | |_____^ expected `()`, found generator - | - = note: expected unit type `()` - found generator `[main::{closure#0} upvar_tys=(unavailable)]` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/generator/reborrow-mut-upvar.rs b/tests/ui/generator/reborrow-mut-upvar.rs deleted file mode 100644 index dbd9e24e2..000000000 --- a/tests/ui/generator/reborrow-mut-upvar.rs +++ /dev/null @@ -1,16 +0,0 @@ -// run-pass - -#![feature(generators)] - -fn _run(bar: &mut i32) { - || { //~ WARN unused generator that must be used - { - let _baz = &*bar; - yield; - } - - *bar = 2; - }; -} - -fn main() {} diff --git a/tests/ui/generator/reborrow-mut-upvar.stderr b/tests/ui/generator/reborrow-mut-upvar.stderr deleted file mode 100644 index 2e1fec35e..000000000 --- a/tests/ui/generator/reborrow-mut-upvar.stderr +++ /dev/null @@ -1,17 +0,0 @@ -warning: unused generator that must be used - --> $DIR/reborrow-mut-upvar.rs:6:5 - | -LL | / || { -LL | | { -LL | | let _baz = &*bar; -LL | | yield; -... | -LL | | *bar = 2; -LL | | }; - | |_____^ - | - = note: generators 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/generator/ref-escapes-but-not-over-yield.rs deleted file mode 100644 index 3856d8233..000000000 --- a/tests/ui/generator/ref-escapes-but-not-over-yield.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![feature(generators)] - -fn foo(x: &i32) { - // In this case, a reference to `b` escapes the generator, 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; - let mut b = move || { - yield(); - let b = 5; - a = &b; - //~^ ERROR borrowed data escapes outside of generator - }; -} - -fn main() { } diff --git a/tests/ui/generator/ref-escapes-but-not-over-yield.stderr b/tests/ui/generator/ref-escapes-but-not-over-yield.stderr deleted file mode 100644 index 5fc810040..000000000 --- a/tests/ui/generator/ref-escapes-but-not-over-yield.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0521]: borrowed data escapes outside of generator - --> $DIR/ref-escapes-but-not-over-yield.rs:11:9 - | -LL | let mut a = &3; - | ----- `a` declared here, outside of the generator body -... -LL | a = &b; - | ^^^^-- - | | | - | | borrow is only valid in the generator body - | reference to `b` escapes the generator body here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0521`. diff --git a/tests/ui/generator/ref-upvar-not-send.rs b/tests/ui/generator/ref-upvar-not-send.rs deleted file mode 100644 index eb9ef63ec..000000000 --- a/tests/ui/generator/ref-upvar-not-send.rs +++ /dev/null @@ -1,31 +0,0 @@ -// For `Send` generators, suggest a `T: Sync` requirement for `&T` upvars, -// and suggest a `T: Send` requirement for `&mut T` upvars. - -#![feature(generators)] - -fn assert_send<T: Send>(_: T) {} -//~^ NOTE required by a bound in `assert_send` -//~| NOTE required by this bound in `assert_send` -//~| NOTE required by a bound in `assert_send` -//~| NOTE required by this bound in `assert_send` - -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` - 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` - yield; - let _y = y; - }); - //~^^ NOTE captured value is not `Send` because `&mut` references cannot be sent unless their referent is `Send` - //~| NOTE has type `&mut *mut ()` which is not `Send`, because `*mut ()` is not `Send` -} diff --git a/tests/ui/generator/ref-upvar-not-send.stderr b/tests/ui/generator/ref-upvar-not-send.stderr deleted file mode 100644 index 689ace67e..000000000 --- a/tests/ui/generator/ref-upvar-not-send.stderr +++ /dev/null @@ -1,50 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/ref-upvar-not-send.rs:15:17 - | -LL | assert_send(move || { - | _________________^ -LL | | -LL | | -LL | | yield; -LL | | let _x = x; -LL | | }); - | |_____^ generator 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` - --> $DIR/ref-upvar-not-send.rs:19:18 - | -LL | let _x = x; - | ^ has type `&*mut ()` which is not `Send`, because `*mut ()` is not `Sync` -note: required by a bound in `assert_send` - --> $DIR/ref-upvar-not-send.rs:6:19 - | -LL | fn assert_send<T: Send>(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: generator cannot be sent between threads safely - --> $DIR/ref-upvar-not-send.rs:23:17 - | -LL | assert_send(move || { - | _________________^ -LL | | -LL | | -LL | | yield; -LL | | let _y = y; -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `[generator@$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 - | -LL | let _y = y; - | ^ has type `&mut *mut ()` which is not `Send`, because `*mut ()` is not `Send` -note: required by a bound in `assert_send` - --> $DIR/ref-upvar-not-send.rs:6:19 - | -LL | fn assert_send<T: Send>(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/generator/reinit-in-match-guard.rs b/tests/ui/generator/reinit-in-match-guard.rs deleted file mode 100644 index 260b341a5..000000000 --- a/tests/ui/generator/reinit-in-match-guard.rs +++ /dev/null @@ -1,25 +0,0 @@ -// build-pass - -#![feature(generators)] - -#![allow(unused_assignments, dead_code)] - -fn main() { - let _ = || { - let mut x = vec![22_usize]; - std::mem::drop(x); - match y() { - true if { - x = vec![]; - false - } => {} - _ => { - yield; - } - } - }; -} - -fn y() -> bool { - true -} diff --git a/tests/ui/generator/resume-after-return.rs b/tests/ui/generator/resume-after-return.rs deleted file mode 100644 index 01a059a16..000000000 --- a/tests/ui/generator/resume-after-return.rs +++ /dev/null @@ -1,28 +0,0 @@ -// run-pass -// needs-unwind - - -#![feature(generators, generator_trait)] - -use std::ops::{GeneratorState, Generator}; -use std::pin::Pin; -use std::panic; - -fn main() { - let mut foo = || { - if true { - return - } - yield; - }; - - match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } - - match panic::catch_unwind(move || Pin::new(&mut foo).resume(())) { - Ok(_) => panic!("generator successfully resumed"), - Err(_) => {} - } -} diff --git a/tests/ui/generator/resume-arg-late-bound.rs b/tests/ui/generator/resume-arg-late-bound.rs deleted file mode 100644 index 1c35ba80d..000000000 --- a/tests/ui/generator/resume-arg-late-bound.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! Tests that we cannot produce a generator that accepts a resume argument -//! with any lifetime and then stores it across a `yield`. - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -fn test(a: impl for<'a> Generator<&'a mut bool>) {} - -fn main() { - let gen = |arg: &mut bool| { - yield (); - *arg = true; - }; - test(gen); - //~^ ERROR mismatched types -} diff --git a/tests/ui/generator/resume-arg-late-bound.stderr b/tests/ui/generator/resume-arg-late-bound.stderr deleted file mode 100644 index 34ee4036c..000000000 --- a/tests/ui/generator/resume-arg-late-bound.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/resume-arg-late-bound.rs:15:5 - | -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: 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>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/generator/resume-arg-size.rs b/tests/ui/generator/resume-arg-size.rs deleted file mode 100644 index 195166f97..000000000 --- a/tests/ui/generator/resume-arg-size.rs +++ /dev/null @@ -1,29 +0,0 @@ -#![feature(generators)] -#![allow(dropping_copy_types)] - -// run-pass - -use std::mem::size_of_val; - -fn main() { - // Generator taking a `Copy`able resume arg. - let gen_copy = |mut x: usize| { - loop { - drop(x); - x = yield; - } - }; - - // Generator taking a non-`Copy` resume arg. - let gen_move = |mut x: Box<usize>| { - loop { - drop(x); - x = yield; - } - }; - - // Neither of these generators 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/generator/resume-live-across-yield.rs deleted file mode 100644 index 4c4cf117a..000000000 --- a/tests/ui/generator/resume-live-across-yield.rs +++ /dev/null @@ -1,45 +0,0 @@ -// run-pass - -#![feature(generators, generator_trait)] - -use std::ops::{Generator, GeneratorState}; -use std::pin::Pin; -use std::sync::atomic::{AtomicUsize, Ordering}; - -static DROP: AtomicUsize = AtomicUsize::new(0); - -#[derive(PartialEq, Eq, Debug)] -struct Dropper(String); - -impl Drop for Dropper { - fn drop(&mut self) { - DROP.fetch_add(1, Ordering::SeqCst); - } -} - -fn main() { - let mut g = |mut _d| { - _d = yield; - _d - }; - - let mut g = Pin::new(&mut g); - - assert_eq!( - g.as_mut().resume(Dropper(String::from("Hello world!"))), - GeneratorState::Yielded(()) - ); - assert_eq!(DROP.load(Ordering::Acquire), 0); - match g.as_mut().resume(Dropper(String::from("Number Two"))) { - GeneratorState::Complete(dropper) => { - assert_eq!(DROP.load(Ordering::Acquire), 1); - assert_eq!(dropper.0, "Number Two"); - drop(dropper); - assert_eq!(DROP.load(Ordering::Acquire), 2); - } - _ => unreachable!(), - } - - drop(g); - assert_eq!(DROP.load(Ordering::Acquire), 2); -} diff --git a/tests/ui/generator/retain-resume-ref.drop_tracking.stderr b/tests/ui/generator/retain-resume-ref.drop_tracking.stderr deleted file mode 100644 index 7122a951e..000000000 --- a/tests/ui/generator/retain-resume-ref.drop_tracking.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0499]: cannot borrow `thing` as mutable more than once at a time - --> $DIR/retain-resume-ref.rs:27:25 - | -LL | gen.as_mut().resume(&mut thing); - | ---------- first mutable borrow occurs here -LL | gen.as_mut().resume(&mut thing); - | ------ ^^^^^^^^^^ second mutable borrow occurs here - | | - | first borrow later used by call - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/generator/retain-resume-ref.drop_tracking_mir.stderr b/tests/ui/generator/retain-resume-ref.drop_tracking_mir.stderr deleted file mode 100644 index 736ed1fb6..000000000 --- a/tests/ui/generator/retain-resume-ref.drop_tracking_mir.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0499]: cannot borrow `thing` as mutable more than once at a time - --> $DIR/retain-resume-ref.rs:27:25 - | -LL | gen.as_mut().resume(&mut thing); - | ---------- first mutable borrow occurs here -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 - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/generator/retain-resume-ref.no_drop_tracking.stderr b/tests/ui/generator/retain-resume-ref.no_drop_tracking.stderr deleted file mode 100644 index 7122a951e..000000000 --- a/tests/ui/generator/retain-resume-ref.no_drop_tracking.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0499]: cannot borrow `thing` as mutable more than once at a time - --> $DIR/retain-resume-ref.rs:27:25 - | -LL | gen.as_mut().resume(&mut thing); - | ---------- first mutable borrow occurs here -LL | gen.as_mut().resume(&mut thing); - | ------ ^^^^^^^^^^ second mutable borrow occurs here - | | - | first borrow later used by call - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/generator/retain-resume-ref.rs b/tests/ui/generator/retain-resume-ref.rs deleted file mode 100644 index 0050d98d0..000000000 --- a/tests/ui/generator/retain-resume-ref.rs +++ /dev/null @@ -1,29 +0,0 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir - -//! This test ensures that a mutable reference cannot be passed as a resume argument twice. - -#![feature(generators, generator_trait)] - -use std::marker::Unpin; -use std::ops::{ - Generator, - GeneratorState::{self, *}, -}; -use std::pin::Pin; - -fn main() { - let mut thing = String::from("hello"); - - let mut gen = |r| { - if false { - yield r; - } - }; - - let mut gen = Pin::new(&mut gen); - gen.as_mut().resume(&mut thing); - gen.as_mut().resume(&mut thing); - //~^ cannot borrow `thing` as mutable more than once at a time -} diff --git a/tests/ui/generator/size-moved-locals.rs b/tests/ui/generator/size-moved-locals.rs deleted file mode 100644 index 601a31418..000000000 --- a/tests/ui/generator/size-moved-locals.rs +++ /dev/null @@ -1,78 +0,0 @@ -// run-pass -// Test that we don't duplicate storage for a variable that is moved to another -// binding. This used to happen in the presence of unwind and drop edges (see -// `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 -// (which would indicate it is reserving space for two copies of Foo.) -// -// See issue #59123 for a full explanation. - -// edition:2018 -// ignore-wasm32 issue #62807 -// ignore-asmjs issue #62807 -// needs-unwind Size of Closures change on panic=abort - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -const FOO_SIZE: usize = 1024; -struct Foo(#[allow(unused_tuple_struct_fields)] [u8; FOO_SIZE]); - -impl Drop for Foo { - fn drop(&mut self) {} -} - -fn move_before_yield() -> impl Generator<Yield = (), Return = ()> { - static || { - let first = Foo([0; FOO_SIZE]); - let _second = first; - yield; - // _second dropped here - } -} - -fn noop() {} - -fn move_before_yield_with_noop() -> impl Generator<Yield = (), Return = ()> { - static || { - let first = Foo([0; FOO_SIZE]); - noop(); - let _second = first; - yield; - // _second dropped here - } -} - -// 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 = ()> { - static || { - let first = Foo([0; FOO_SIZE]); - yield; - let second = first; - yield; - let _third = second; - yield; - } -} - -fn overlap_x_and_y() -> impl Generator<Yield = (), Return = ()> { - static || { - let x = Foo([0; FOO_SIZE]); - yield; - drop(x); - let y = Foo([0; FOO_SIZE]); - yield; - drop(y); - } -} - -fn main() { - assert_eq!(1025, std::mem::size_of_val(&move_before_yield())); - assert_eq!(1026, std::mem::size_of_val(&move_before_yield_with_noop())); - assert_eq!(2051, std::mem::size_of_val(&overlap_move_points())); - assert_eq!(1026, std::mem::size_of_val(&overlap_x_and_y())); -} diff --git a/tests/ui/generator/sized-yield.rs b/tests/ui/generator/sized-yield.rs deleted file mode 100644 index c6dd738d6..000000000 --- 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 fb34540d9..000000000 --- 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/smoke-resume-args.rs b/tests/ui/generator/smoke-resume-args.rs deleted file mode 100644 index fa9271c53..000000000 --- a/tests/ui/generator/smoke-resume-args.rs +++ /dev/null @@ -1,100 +0,0 @@ -// run-pass - -// revisions: default nomiropt -//[nomiropt]compile-flags: -Z mir-opt-level=0 - -#![feature(generators, generator_trait)] - -use std::fmt::Debug; -use std::marker::Unpin; -use std::ops::{ - Generator, - GeneratorState::{self, *}, -}; -use std::pin::Pin; -use std::sync::atomic::{AtomicUsize, Ordering}; - -fn drain<G: Generator<R, Yield = Y> + Unpin, R, Y>( - gen: &mut G, - inout: Vec<(R, GeneratorState<Y, G::Return>)>, -) where - Y: Debug + PartialEq, - G::Return: Debug + PartialEq, -{ - let mut gen = Pin::new(gen); - - for (input, out) in inout { - assert_eq!(gen.as_mut().resume(input), out); - } -} - -static DROPS: AtomicUsize = AtomicUsize::new(0); - -#[derive(Debug, PartialEq)] -struct DropMe; - -impl Drop for DropMe { - fn drop(&mut self) { - DROPS.fetch_add(1, Ordering::SeqCst); - } -} - -fn expect_drops<T>(expected_drops: usize, f: impl FnOnce() -> T) -> T { - DROPS.store(0, Ordering::SeqCst); - - let res = f(); - - let actual_drops = DROPS.load(Ordering::SeqCst); - assert_eq!(actual_drops, expected_drops); - res -} - -fn main() { - drain( - &mut |mut b| { - while b != 0 { - b = yield (b + 1); - } - -1 - }, - vec![(1, Yielded(2)), (-45, Yielded(-44)), (500, Yielded(501)), (0, Complete(-1))], - ); - - expect_drops(2, || drain(&mut |a| yield a, vec![(DropMe, Yielded(DropMe))])); - - expect_drops(6, || { - drain( - &mut |a| yield yield a, - vec![(DropMe, Yielded(DropMe)), (DropMe, Yielded(DropMe)), (DropMe, Complete(DropMe))], - ) - }); - - #[allow(unreachable_code)] - expect_drops(2, || drain(&mut |a| yield return a, vec![(DropMe, Complete(DropMe))])); - - expect_drops(2, || { - drain( - &mut |a: DropMe| { - if false { yield () } else { a } - }, - vec![(DropMe, Complete(DropMe))], - ) - }); - - expect_drops(4, || { - drain( - #[allow(unused_assignments, unused_variables)] - &mut |mut a: DropMe| { - a = yield; - a = yield; - a = yield; - }, - vec![ - (DropMe, Yielded(())), - (DropMe, Yielded(())), - (DropMe, Yielded(())), - (DropMe, Complete(())), - ], - ) - }); -} diff --git a/tests/ui/generator/smoke.rs b/tests/ui/generator/smoke.rs deleted file mode 100644 index 7a917a05d..000000000 --- a/tests/ui/generator/smoke.rs +++ /dev/null @@ -1,177 +0,0 @@ -// run-pass - -// revisions: default nomiropt -//[nomiropt]compile-flags: -Z mir-opt-level=0 - -// ignore-emscripten no threads support -// compile-flags: --test - -#![feature(generators, generator_trait)] - -use std::ops::{GeneratorState, Generator}; -use std::pin::Pin; -use std::thread; - -#[test] -fn simple() { - let mut foo = || { - if false { - yield; - } - }; - - match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } -} - -#[test] -fn return_capture() { - let a = String::from("foo"); - let mut foo = || { - if false { - yield; - } - a - }; - - match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(ref s) if *s == "foo" => {} - s => panic!("bad state: {:?}", s), - } -} - -#[test] -fn simple_yield() { - let mut foo = || { - yield; - }; - - match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(()) => {} - s => panic!("bad state: {:?}", s), - } - match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } -} - -#[test] -fn yield_capture() { - let b = String::from("foo"); - let mut foo = || { - yield b; - }; - - match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(ref s) if *s == "foo" => {} - s => panic!("bad state: {:?}", s), - } - match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } -} - -#[test] -fn simple_yield_value() { - let mut foo = || { - yield String::from("bar"); - return String::from("foo") - }; - - match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(ref s) if *s == "bar" => {} - s => panic!("bad state: {:?}", s), - } - match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(ref s) if *s == "foo" => {} - s => panic!("bad state: {:?}", s), - } -} - -#[test] -fn return_after_yield() { - let a = String::from("foo"); - let mut foo = || { - yield; - return a - }; - - match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(()) => {} - s => panic!("bad state: {:?}", s), - } - match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(ref s) if *s == "foo" => {} - s => panic!("bad state: {:?}", s), - } -} - -#[test] -fn send_and_sync() { - assert_send_sync(|| { - yield - }); - assert_send_sync(|| { - yield String::from("foo"); - }); - assert_send_sync(|| { - yield; - return String::from("foo"); - }); - let a = 3; - assert_send_sync(|| { - yield a; - return - }); - let a = 3; - assert_send_sync(move || { - yield a; - return - }); - let a = String::from("a"); - assert_send_sync(|| { - yield ; - drop(a); - return - }); - let a = String::from("a"); - assert_send_sync(move || { - yield ; - drop(a); - return - }); - - fn assert_send_sync<T: Send + Sync>(_: T) {} -} - -#[test] -fn send_over_threads() { - let mut foo = || { yield }; - thread::spawn(move || { - match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(()) => {} - s => panic!("bad state: {:?}", s), - } - match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } - }).join().unwrap(); - - let a = String::from("a"); - let mut foo = || { yield a }; - thread::spawn(move || { - match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(ref s) if *s == "a" => {} - s => panic!("bad state: {:?}", s), - } - match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } - }).join().unwrap(); -} diff --git a/tests/ui/generator/static-generators.rs b/tests/ui/generator/static-generators.rs deleted file mode 100644 index d098bf1e6..000000000 --- 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/static-mut-reference-across-yield.rs b/tests/ui/generator/static-mut-reference-across-yield.rs deleted file mode 100644 index 4784ff49b..000000000 --- a/tests/ui/generator/static-mut-reference-across-yield.rs +++ /dev/null @@ -1,34 +0,0 @@ -// build-pass -// revisions: mir thir drop_tracking drop_tracking_mir -// [thir]compile-flags: -Zthir-unsafeck -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir - -#![feature(generators)] - -static mut A: [i32; 5] = [1, 2, 3, 4, 5]; - -fn is_send_sync<T: Send + Sync>(_: T) {} - -fn main() { - unsafe { - let gen_index = static || { - let u = A[{ - yield; - 1 - }]; - }; - let gen_match = static || match A { - i if { - yield; - true - } => - { - () - } - _ => (), - }; - is_send_sync(gen_index); - is_send_sync(gen_match); - } -} diff --git a/tests/ui/generator/static-not-unpin.current.stderr b/tests/ui/generator/static-not-unpin.current.stderr deleted file mode 100644 index ecd8ca60c..000000000 --- a/tests/ui/generator/static-not-unpin.current.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0277]: `[static generator@$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]` - | | - | required by a bound introduced by this call - | - = note: consider using the `pin!` macro - consider using `Box::pin` if you need to access the pinned value outside of the current scope -note: required by a bound in `assert_unpin` - --> $DIR/static-not-unpin.rs:10:20 - | -LL | fn assert_unpin<T: Unpin>(_: T) { - | ^^^^^ required by this bound in `assert_unpin` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/static-not-unpin.next.stderr b/tests/ui/generator/static-not-unpin.next.stderr deleted file mode 100644 index ecd8ca60c..000000000 --- a/tests/ui/generator/static-not-unpin.next.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0277]: `[static generator@$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]` - | | - | required by a bound introduced by this call - | - = note: consider using the `pin!` macro - consider using `Box::pin` if you need to access the pinned value outside of the current scope -note: required by a bound in `assert_unpin` - --> $DIR/static-not-unpin.rs:10:20 - | -LL | fn assert_unpin<T: Unpin>(_: T) { - | ^^^^^ required by this bound in `assert_unpin` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/static-not-unpin.rs b/tests/ui/generator/static-not-unpin.rs deleted file mode 100644 index 30d3f2918..000000000 --- a/tests/ui/generator/static-not-unpin.rs +++ /dev/null @@ -1,18 +0,0 @@ -// revisions: current next -//[next] compile-flags: -Ztrait-solver=next - -#![feature(generators)] - -// normalize-stderr-test "std::pin::Unpin" -> "std::marker::Unpin" - -use std::marker::Unpin; - -fn assert_unpin<T: Unpin>(_: T) { -} - -fn main() { - let mut generator = static || { - yield; - }; - assert_unpin(generator); //~ ERROR E0277 -} diff --git a/tests/ui/generator/static-reference-across-yield.rs b/tests/ui/generator/static-reference-across-yield.rs deleted file mode 100644 index 23b11593b..000000000 --- a/tests/ui/generator/static-reference-across-yield.rs +++ /dev/null @@ -1,16 +0,0 @@ -// build-pass -#![feature(generators)] - -static A: [i32; 5] = [1, 2, 3, 4, 5]; - -fn main() { - static || { - let u = A[{yield; 1}]; - }; - static || { - match A { - i if { yield; true } => (), - _ => (), - } - }; -} diff --git a/tests/ui/generator/too-live-local-in-immovable-gen.rs b/tests/ui/generator/too-live-local-in-immovable-gen.rs deleted file mode 100644 index e0b856db7..000000000 --- a/tests/ui/generator/too-live-local-in-immovable-gen.rs +++ /dev/null @@ -1,21 +0,0 @@ -// run-pass -#![allow(unused_unsafe)] - -#![feature(generators)] - -fn main() { - unsafe { - static move || { //~ WARN unused generator that must be used - // Tests that the generator 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 - // `a` is live and type checking finds it dead. - let a = { - yield (); - 4i32 - }; - let _ = &a; - }; - } -} diff --git a/tests/ui/generator/too-live-local-in-immovable-gen.stderr b/tests/ui/generator/too-live-local-in-immovable-gen.stderr deleted file mode 100644 index e262f213f..000000000 --- a/tests/ui/generator/too-live-local-in-immovable-gen.stderr +++ /dev/null @@ -1,17 +0,0 @@ -warning: unused generator 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 | | // during the yield expression. Type checking will also compute liveness -LL | | // and it should also find out that `a` is not live. -... | -LL | | let _ = &a; -LL | | }; - | |_________^ - | - = note: generators are lazy and do nothing unless resumed - = note: `#[warn(unused_must_use)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/generator/too-many-parameters.rs b/tests/ui/generator/too-many-parameters.rs deleted file mode 100644 index 7a353ea29..000000000 --- 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/generator/too-many-parameters.stderr b/tests/ui/generator/too-many-parameters.stderr deleted file mode 100644 index 22d40db3f..000000000 --- a/tests/ui/generator/too-many-parameters.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0628]: too many parameters for a generator (expected 0 or 1 parameters) - --> $DIR/too-many-parameters.rs:4:5 - | -LL | |(), ()| { - | ^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0628`. diff --git a/tests/ui/generator/type-mismatch-error.rs b/tests/ui/generator/type-mismatch-error.rs deleted file mode 100644 index d39c788a8..000000000 --- a/tests/ui/generator/type-mismatch-error.rs +++ /dev/null @@ -1,22 +0,0 @@ -//! 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)] - -use std::ops::Generator; - -fn f<G: Generator>(_: G, _: G::Return) {} - -fn main() { - f( - |a: u8| { - if false { - yield (); - } else { - a - //~^ error: `if` and `else` have incompatible types - } - }, - 0u8, - ); -} diff --git a/tests/ui/generator/type-mismatch-error.stderr b/tests/ui/generator/type-mismatch-error.stderr deleted file mode 100644 index 8f5949533..000000000 --- a/tests/ui/generator/type-mismatch-error.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0308]: `if` and `else` have incompatible types - --> $DIR/type-mismatch-error.rs:16:17 - | -LL | / if false { -LL | | yield (); - | | --------- - | | | | - | | | help: consider removing this semicolon - | | expected because of this -LL | | } else { -LL | | a - | | ^ expected `()`, found `u8` -LL | | -LL | | } - | |_____________- `if` and `else` have incompatible types - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/generator/type-mismatch-signature-deduction.rs b/tests/ui/generator/type-mismatch-signature-deduction.rs deleted file mode 100644 index 8d1ce6c7a..000000000 --- a/tests/ui/generator/type-mismatch-signature-deduction.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -fn foo() -> impl Generator<Return = i32> { - //~^ ERROR type mismatch - || { - if false { - return Ok(6); - } - - yield (); - - 5 //~ ERROR mismatched types [E0308] - } -} - -fn main() {} diff --git a/tests/ui/generator/type-mismatch-signature-deduction.stderr b/tests/ui/generator/type-mismatch-signature-deduction.stderr deleted file mode 100644 index ef6d896f8..000000000 --- a/tests/ui/generator/type-mismatch-signature-deduction.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/type-mismatch-signature-deduction.rs:14:9 - | -LL | 5 - | ^ expected `Result<{integer}, _>`, found integer - | - = note: expected enum `Result<{integer}, _>` - found type `{integer}` -note: return type inferred to be `Result<{integer}, _>` here - --> $DIR/type-mismatch-signature-deduction.rs:9:20 - | -LL | return Ok(6); - | ^^^^^ -help: try wrapping the expression in a variant of `Result` - | -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` - --> $DIR/type-mismatch-signature-deduction.rs:5:13 - | -LL | fn foo() -> impl Generator<Return = i32> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<{integer}, _>`, found `i32` - | - = note: expected enum `Result<{integer}, _>` - found type `i32` - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0271, E0308. -For more information about an error, try `rustc --explain E0271`. diff --git a/tests/ui/generator/unresolved-ct-var-drop-tracking.rs b/tests/ui/generator/unresolved-ct-var-drop-tracking.rs deleted file mode 100644 index a6589348d..000000000 --- a/tests/ui/generator/unresolved-ct-var-drop-tracking.rs +++ /dev/null @@ -1,15 +0,0 @@ -// incremental -// edition:2021 -// compile-flags: -Zdrop-tracking - -fn main() { - let _ = async { - let s = std::array::from_fn(|_| ()).await; - //~^ ERROR `[(); _]` is not a future - //~| ERROR type inside `async` block must be known in this context - //~| ERROR type inside `async` block must be known in this context - //~| ERROR type inside `async` block must be known in this context - //~| ERROR type inside `async` block must be known in this context - //~| ERROR type inside `async` block must be known in this context - }; -} diff --git a/tests/ui/generator/unresolved-ct-var-drop-tracking.stderr b/tests/ui/generator/unresolved-ct-var-drop-tracking.stderr deleted file mode 100644 index dec0141ab..000000000 --- a/tests/ui/generator/unresolved-ct-var-drop-tracking.stderr +++ /dev/null @@ -1,78 +0,0 @@ -error[E0277]: `[(); _]` is not a future - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ----------------------------^^^^^ - | | || - | | |`[(); _]` is not a future - | | help: remove the `.await` - | this call returns `[(); _]` - | - = help: the trait `Future` is not implemented for `[(); _]` - = note: [(); _] must be a future or must implement `IntoFuture` to be awaited - = note: required for `[(); _]` to implement `IntoFuture` - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^ - -error: aborting due to 6 previous errors - -Some errors have detailed explanations: E0277, E0698. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/unresolved-ct-var.rs b/tests/ui/generator/unresolved-ct-var.rs deleted file mode 100644 index 0a1570fc2..000000000 --- a/tests/ui/generator/unresolved-ct-var.rs +++ /dev/null @@ -1,14 +0,0 @@ -// incremental -// edition:2021 - -fn main() { - let _ = async { - let s = std::array::from_fn(|_| ()).await; - //~^ ERROR `[(); _]` is not a future - //~| ERROR type inside `async` block must be known in this context - //~| ERROR type inside `async` block must be known in this context - //~| ERROR type inside `async` block must be known in this context - //~| ERROR type inside `async` block must be known in this context - //~| ERROR type inside `async` block must be known in this context - }; -} diff --git a/tests/ui/generator/unresolved-ct-var.stderr b/tests/ui/generator/unresolved-ct-var.stderr deleted file mode 100644 index ace254178..000000000 --- a/tests/ui/generator/unresolved-ct-var.stderr +++ /dev/null @@ -1,78 +0,0 @@ -error[E0277]: `[(); _]` is not a future - --> $DIR/unresolved-ct-var.rs:6:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ----------------------------^^^^^ - | | || - | | |`[(); _]` is not a future - | | help: remove the `.await` - | this call returns `[(); _]` - | - = help: the trait `Future` is not implemented for `[(); _]` - = note: [(); _] must be a future or must implement `IntoFuture` to be awaited - = note: required for `[(); _]` to implement `IntoFuture` - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var.rs:6:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var.rs:6:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var.rs:6:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var.rs:6:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var.rs:6:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^ - -error: aborting due to 6 previous errors - -Some errors have detailed explanations: E0277, E0698. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/xcrate-reachable.rs b/tests/ui/generator/xcrate-reachable.rs deleted file mode 100644 index 1b1cff338..000000000 --- a/tests/ui/generator/xcrate-reachable.rs +++ /dev/null @@ -1,14 +0,0 @@ -// run-pass - -// aux-build:xcrate-reachable.rs - -#![feature(generator_trait)] - -extern crate xcrate_reachable as foo; - -use std::ops::Generator; -use std::pin::Pin; - -fn main() { - Pin::new(&mut foo::foo()).resume(()); -} diff --git a/tests/ui/generator/xcrate.rs b/tests/ui/generator/xcrate.rs deleted file mode 100644 index 40986bbeb..000000000 --- a/tests/ui/generator/xcrate.rs +++ /dev/null @@ -1,30 +0,0 @@ -// run-pass - -// aux-build:xcrate.rs - -#![feature(generators, generator_trait)] - -extern crate xcrate; - -use std::ops::{GeneratorState, Generator}; -use std::pin::Pin; - -fn main() { - let mut foo = xcrate::foo(); - - match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } - - let mut foo = xcrate::bar(3); - - match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(3) => {} - s => panic!("bad state: {:?}", s), - } - match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } -} diff --git a/tests/ui/generator/yield-in-args-rev.rs b/tests/ui/generator/yield-in-args-rev.rs deleted file mode 100644 index 4c99bb3ef..000000000 --- a/tests/ui/generator/yield-in-args-rev.rs +++ /dev/null @@ -1,19 +0,0 @@ -// run-pass -#![allow(dead_code)] - -// Test that a borrow that occurs after a yield in the same -// argument list is not treated as live across the yield by -// type-checking. - -#![feature(generators)] - -fn foo(_a: (), _b: &bool) {} - -fn bar() { - || { //~ WARN unused generator that must be used - let b = true; - foo(yield, &b); - }; -} - -fn main() { } diff --git a/tests/ui/generator/yield-in-args-rev.stderr b/tests/ui/generator/yield-in-args-rev.stderr deleted file mode 100644 index a87248f66..000000000 --- a/tests/ui/generator/yield-in-args-rev.stderr +++ /dev/null @@ -1,14 +0,0 @@ -warning: unused generator that must be used - --> $DIR/yield-in-args-rev.rs:13:5 - | -LL | / || { -LL | | let b = true; -LL | | foo(yield, &b); -LL | | }; - | |_____^ - | - = note: generators are lazy and do nothing unless resumed - = note: `#[warn(unused_must_use)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/generator/yield-in-args.rs b/tests/ui/generator/yield-in-args.rs deleted file mode 100644 index 80110af55..000000000 --- a/tests/ui/generator/yield-in-args.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(generators)] - -fn foo(_b: &bool, _a: ()) {} - -fn main() { - || { - let b = true; - foo(&b, yield); //~ ERROR - }; -} diff --git a/tests/ui/generator/yield-in-args.stderr b/tests/ui/generator/yield-in-args.stderr deleted file mode 100644 index ee6d22c27..000000000 --- a/tests/ui/generator/yield-in-args.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/yield-in-args.rs:8:13 - | -LL | foo(&b, yield); - | ^^ ----- possible yield occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0626`. diff --git a/tests/ui/generator/yield-in-const.rs b/tests/ui/generator/yield-in-const.rs deleted file mode 100644 index fe5ca822c..000000000 --- a/tests/ui/generator/yield-in-const.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![feature(generators)] - -const A: u8 = { yield 3u8; 3u8}; -//~^ ERROR yield expression outside - -fn main() {} diff --git a/tests/ui/generator/yield-in-const.stderr b/tests/ui/generator/yield-in-const.stderr deleted file mode 100644 index dcf4fe63e..000000000 --- a/tests/ui/generator/yield-in-const.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0627]: yield expression outside of generator literal - --> $DIR/yield-in-const.rs:3:17 - | -LL | const A: u8 = { yield 3u8; 3u8}; - | ^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0627`. diff --git a/tests/ui/generator/yield-in-function.rs b/tests/ui/generator/yield-in-function.rs deleted file mode 100644 index 29b811621..000000000 --- a/tests/ui/generator/yield-in-function.rs +++ /dev/null @@ -1,4 +0,0 @@ -#![feature(generators)] - -fn main() { yield; } -//~^ ERROR yield expression outside diff --git a/tests/ui/generator/yield-in-function.stderr b/tests/ui/generator/yield-in-function.stderr deleted file mode 100644 index 51cce198c..000000000 --- a/tests/ui/generator/yield-in-function.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0627]: yield expression outside of generator literal - --> $DIR/yield-in-function.rs:3:13 - | -LL | fn main() { yield; } - | ^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0627`. diff --git a/tests/ui/generator/yield-in-initializer.rs b/tests/ui/generator/yield-in-initializer.rs deleted file mode 100644 index 0cab36e5f..000000000 --- a/tests/ui/generator/yield-in-initializer.rs +++ /dev/null @@ -1,17 +0,0 @@ -// run-pass - -#![feature(generators)] - -fn main() { - static || { //~ WARN unused generator 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 - let opt = { - yield; - true - }; - let _ = &opt; - } - }; -} diff --git a/tests/ui/generator/yield-in-initializer.stderr b/tests/ui/generator/yield-in-initializer.stderr deleted file mode 100644 index ed14a2e32..000000000 --- a/tests/ui/generator/yield-in-initializer.stderr +++ /dev/null @@ -1,17 +0,0 @@ -warning: unused generator that must be used - --> $DIR/yield-in-initializer.rs:6:5 - | -LL | / static || { -LL | | loop { -LL | | // Test that `opt` is not live across the yield, even when borrowed in a loop -LL | | // See https://github.com/rust-lang/rust/issues/52792 -... | -LL | | } -LL | | }; - | |_____^ - | - = note: generators are lazy and do nothing unless resumed - = note: `#[warn(unused_must_use)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/generator/yield-in-static.rs b/tests/ui/generator/yield-in-static.rs deleted file mode 100644 index d27fbb33b..000000000 --- a/tests/ui/generator/yield-in-static.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![feature(generators)] - -static B: u8 = { yield 3u8; 3u8}; -//~^ ERROR yield expression outside - -fn main() {} diff --git a/tests/ui/generator/yield-in-static.stderr b/tests/ui/generator/yield-in-static.stderr deleted file mode 100644 index d867f3ad3..000000000 --- a/tests/ui/generator/yield-in-static.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0627]: yield expression outside of generator literal - --> $DIR/yield-in-static.rs:3:18 - | -LL | static B: u8 = { yield 3u8; 3u8}; - | ^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0627`. diff --git a/tests/ui/generator/yield-outside-generator-issue-78653.rs b/tests/ui/generator/yield-outside-generator-issue-78653.rs deleted file mode 100644 index 4e8050c81..000000000 --- a/tests/ui/generator/yield-outside-generator-issue-78653.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![feature(generators)] - -fn main() { - yield || for i in 0 { } - //~^ ERROR yield expression outside of generator literal - //~| ERROR `{integer}` is not an iterator -} diff --git a/tests/ui/generator/yield-outside-generator-issue-78653.stderr b/tests/ui/generator/yield-outside-generator-issue-78653.stderr deleted file mode 100644 index dcfb21174..000000000 --- a/tests/ui/generator/yield-outside-generator-issue-78653.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0627]: yield expression outside of generator literal - --> $DIR/yield-outside-generator-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 - | -LL | yield || for i in 0 { } - | ^ `{integer}` is not an iterator - | - = help: the trait `Iterator` is not implemented for `{integer}` - = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` - = note: required for `{integer}` to implement `IntoIterator` - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0277, E0627. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/yield-subtype.rs b/tests/ui/generator/yield-subtype.rs deleted file mode 100644 index cb3fc9091..000000000 --- a/tests/ui/generator/yield-subtype.rs +++ /dev/null @@ -1,17 +0,0 @@ -// run-pass -#![allow(dead_code)] -#![allow(dead_code)] - -#![feature(generators)] - -fn bar<'a>() { - let a: &'static str = "hi"; - let b: &'a str = a; - - || { //~ WARN unused generator that must be used - yield a; - yield b; - }; -} - -fn main() {} diff --git a/tests/ui/generator/yield-subtype.stderr b/tests/ui/generator/yield-subtype.stderr deleted file mode 100644 index 97862e91c..000000000 --- a/tests/ui/generator/yield-subtype.stderr +++ /dev/null @@ -1,14 +0,0 @@ -warning: unused generator that must be used - --> $DIR/yield-subtype.rs:11:5 - | -LL | / || { -LL | | yield a; -LL | | yield b; -LL | | }; - | |_____^ - | - = note: generators are lazy and do nothing unless resumed - = note: `#[warn(unused_must_use)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/generator/yield-while-iterating.rs b/tests/ui/generator/yield-while-iterating.rs deleted file mode 100644 index 985e5d8bd..000000000 --- a/tests/ui/generator/yield-while-iterating.rs +++ /dev/null @@ -1,75 +0,0 @@ -#![feature(generators, generator_trait)] - -use std::ops::{GeneratorState, Generator}; -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 - // 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. - let _b = move || { - for p in &x { //~ ERROR - yield(); - } - }; -} - -fn yield_during_iter_borrowed_slice(x: &[i32]) { - let _b = move || { - for p in x { - yield(); - } - }; -} - -fn yield_during_iter_borrowed_slice_2() { - let mut x = vec![22_i32]; - let _b = || { - for p in &x { - yield(); - } - }; - println!("{:?}", x); -} - -fn yield_during_iter_borrowed_slice_3() { - // OK to take a mutable ref to `x` and yield - // up pointers from it: - let mut x = vec![22_i32]; - let mut b = || { - for p in &mut x { - yield p; - } - }; - Pin::new(&mut b).resume(()); -} - -fn yield_during_iter_borrowed_slice_4() { - // ...but not OK to do that while reading - // from `x` too - let mut x = vec![22_i32]; - let mut b = || { - for p in &mut x { - yield p; - } - }; - println!("{}", x[0]); //~ ERROR - Pin::new(&mut b).resume(()); -} - -fn yield_during_range_iter() { - // Should be OK. - let mut b = || { - let v = vec![1,2,3]; - let len = v.len(); - for i in 0..len { - let x = v[i]; - yield x; - } - }; - Pin::new(&mut b).resume(()); -} - -fn main() { } diff --git a/tests/ui/generator/yield-while-iterating.stderr b/tests/ui/generator/yield-while-iterating.stderr deleted file mode 100644 index b65634752..000000000 --- a/tests/ui/generator/yield-while-iterating.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/yield-while-iterating.rs:13:18 - | -LL | for p in &x { - | ^^ -LL | yield(); - | ------- possible yield occurs here - -error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/yield-while-iterating.rs:58:20 - | -LL | let mut b = || { - | -- mutable borrow occurs here -LL | for p in &mut x { - | - first borrow occurs due to use of `x` in generator -... -LL | println!("{}", x[0]); - | ^ immutable borrow occurs here -LL | Pin::new(&mut b).resume(()); - | ------ mutable borrow later used here - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0502, E0626. -For more information about an error, try `rustc --explain E0502`. diff --git a/tests/ui/generator/yield-while-local-borrowed.rs b/tests/ui/generator/yield-while-local-borrowed.rs deleted file mode 100644 index 061a64dbc..000000000 --- a/tests/ui/generator/yield-while-local-borrowed.rs +++ /dev/null @@ -1,49 +0,0 @@ -#![feature(generators, generator_trait)] - -use std::ops::{GeneratorState, Generator}; -use std::cell::Cell; -use std::pin::Pin; - -fn borrow_local_inline() { - // Not OK to yield with a borrow of a temporary. - // - // (This error occurs because the region shows up in the type of - // `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(); - println!("{}", a); - }; - Pin::new(&mut b).resume(()); -} - -fn borrow_local_inline_done() { - // No error here -- `a` is not in scope at the point of `yield`. - let mut b = move || { - { - let a = &mut 3; - } - yield(); - }; - Pin::new(&mut b).resume(()); -} - -fn borrow_local() { - // Not OK to yield with a borrow of a temporary. - // - // (This error occurs because the region shows up in the type of - // `b` and gets extended by region inference.) - let mut b = move || { - let a = 3; - { - let b = &a; - //~^ ERROR borrow may still be in use when generator yields - yield(); - println!("{}", b); - } - }; - Pin::new(&mut b).resume(()); -} - -fn main() { } diff --git a/tests/ui/generator/yield-while-local-borrowed.stderr b/tests/ui/generator/yield-while-local-borrowed.stderr deleted file mode 100644 index c1513ef9b..000000000 --- a/tests/ui/generator/yield-while-local-borrowed.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/yield-while-local-borrowed.rs:13:17 - | -LL | let a = &mut 3; - | ^^^^^^ -LL | -LL | yield(); - | ------- possible yield occurs here - -error[E0626]: borrow may still be in use when generator yields - --> $DIR/yield-while-local-borrowed.rs:40:21 - | -LL | let b = &a; - | ^^ -LL | -LL | yield(); - | ------- possible yield occurs here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0626`. diff --git a/tests/ui/generator/yield-while-ref-reborrowed.rs b/tests/ui/generator/yield-while-ref-reborrowed.rs deleted file mode 100644 index a03ef945d..000000000 --- a/tests/ui/generator/yield-while-ref-reborrowed.rs +++ /dev/null @@ -1,40 +0,0 @@ -#![feature(generators, generator_trait)] - -use std::ops::{GeneratorState, Generator}; -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. - let mut b = move || { - let a = &*x; - yield(); - println!("{}", a); - }; - Pin::new(&mut b).resume(()); -} - -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. - let mut b = move || { - let a = &mut *x; - yield(); - println!("{}", a); - }; - Pin::new(&mut b).resume(()); -} - -fn reborrow_mutable_ref_2(x: &mut i32) { - // ...but not OK to go on using `x`. - let mut b = || { - let a = &mut *x; - yield(); - println!("{}", a); - }; - println!("{}", x); //~ ERROR - Pin::new(&mut b).resume(()); -} - -fn main() { } diff --git a/tests/ui/generator/yield-while-ref-reborrowed.stderr b/tests/ui/generator/yield-while-ref-reborrowed.stderr deleted file mode 100644 index 47147f9c0..000000000 --- a/tests/ui/generator/yield-while-ref-reborrowed.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0501]: cannot borrow `x` as immutable because previous closure requires unique access - --> $DIR/yield-while-ref-reborrowed.rs:36:20 - | -LL | let mut b = || { - | -- generator construction occurs here -LL | let a = &mut *x; - | -- first borrow occurs due to use of `x` in generator -... -LL | println!("{}", x); - | ^ second borrow occurs here -LL | Pin::new(&mut b).resume(()); - | ------ first borrow later used here - | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0501`. diff --git a/tests/ui/generator/yielding-in-match-guards.rs b/tests/ui/generator/yielding-in-match-guards.rs deleted file mode 100644 index 4e89fc975..000000000 --- a/tests/ui/generator/yielding-in-match-guards.rs +++ /dev/null @@ -1,53 +0,0 @@ -// build-pass -// edition:2018 - -// This test is derived from -// https://github.com/rust-lang/rust/issues/72651#issuecomment-668720468 - -// This test demonstrates that, in `async fn g()`, -// 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. - -#![feature(if_let_guard)] - -async fn f() -> u8 { 1 } -async fn foo() -> [bool; 10] { [false; 10] } - -pub async fn g(x: u8) { - match x { - y if f().await == y => (), - _ => (), - } -} - -// #78366: check the reference to the binding is recorded even if the binding is not autorefed - -async fn h(x: usize) { - match x { - y if foo().await[y] => (), - _ => (), - } -} - -async fn i(x: u8) { - match x { - y if f().await == y + 1 => (), - _ => (), - } -} - -async fn j(x: u8) { - match x { - y if let (1, 42) = (f().await, y) => (), - _ => (), - } -} - -fn main() { - let _ = g(10); - let _ = h(9); - let _ = i(8); - let _ = j(7); -} |