From 3e3e70d529d8c7d7c4d7bc4fefc9f109393b9245 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:43 +0200 Subject: Merging upstream version 1.69.0+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/generator/addassign-yield.rs | 3 + .../auto-trait-regions.drop_tracking.stderr | 47 +++ .../auto-trait-regions.drop_tracking_mir.stderr | 47 +++ .../auto-trait-regions.no_drop_tracking.stderr | 47 +++ tests/ui/generator/auto-trait-regions.rs | 3 + tests/ui/generator/auto-trait-regions.stderr | 8 +- tests/ui/generator/borrowing.drop_tracking.stderr | 31 ++ .../generator/borrowing.drop_tracking_mir.stderr | 39 +++ .../ui/generator/borrowing.no_drop_tracking.stderr | 31 ++ tests/ui/generator/borrowing.rs | 4 + tests/ui/generator/borrowing.stderr | 4 +- ...tracking-parent-expression.drop_tracking.stderr | 128 ++++++++ ...king-parent-expression.drop_tracking_mir.stderr | 122 ++++++++ ...cking-parent-expression.no_drop_tracking.stderr | 334 +++++++++++++++++++++ .../generator/drop-tracking-parent-expression.rs | 12 +- .../drop-tracking-parent-expression.stderr | 128 -------- .../drop-tracking-yielding-in-match-guards.rs | 4 +- tests/ui/generator/dropck.stderr | 3 + .../generator-yielding-or-returning-itself.stderr | 4 +- tests/ui/generator/issue-102645.stderr | 2 +- .../issue-105084.drop_tracking_mir.stderr | 51 ++++ tests/ui/generator/issue-105084.rs | 49 +++ .../generator/issue-57017.no_drop_tracking.stderr | 248 +++++++++++++++ tests/ui/generator/issue-57017.rs | 14 +- .../generator/issue-57478.no_drop_tracking.stderr | 31 ++ tests/ui/generator/issue-57478.rs | 8 +- .../ui/generator/issue-68112.drop_tracking.stderr | 66 ++++ .../generator/issue-68112.drop_tracking_mir.stderr | 61 ++++ .../generator/issue-68112.no_drop_tracking.stderr | 66 ++++ tests/ui/generator/issue-68112.rs | 11 +- tests/ui/generator/issue-68112.stderr | 64 ---- tests/ui/generator/issue-93161.rs | 4 +- .../generator/not-send-sync.drop_tracking.stderr | 60 ++++ .../not-send-sync.drop_tracking_mir.stderr | 42 +++ .../not-send-sync.no_drop_tracking.stderr | 60 ++++ tests/ui/generator/not-send-sync.rs | 19 +- tests/ui/generator/not-send-sync.stderr | 56 ---- .../parent-expression.drop_tracking.stderr | 128 ++++++++ .../parent-expression.drop_tracking_mir.stderr | 122 ++++++++ .../parent-expression.no_drop_tracking.stderr | 334 +++++++++++++++++++++ tests/ui/generator/parent-expression.rs | 77 +++++ .../ui/generator/partial-drop.drop_tracking.stderr | 61 ++++ .../generator/partial-drop.no_drop_tracking.stderr | 61 ++++ tests/ui/generator/partial-drop.rs | 21 +- tests/ui/generator/partial-drop.stderr | 92 ------ .../generator-print-verbose-1.drop_tracking.stderr | 64 ++++ ...erator-print-verbose-1.drop_tracking_mir.stderr | 60 ++++ ...nerator-print-verbose-1.no_drop_tracking.stderr | 64 ++++ .../generator/print/generator-print-verbose-1.rs | 5 +- .../print/generator-print-verbose-1.stderr | 62 ---- .../generator-print-verbose-2.drop_tracking.stderr | 60 ++++ ...erator-print-verbose-2.drop_tracking_mir.stderr | 42 +++ ...nerator-print-verbose-2.no_drop_tracking.stderr | 60 ++++ .../generator/print/generator-print-verbose-2.rs | 19 +- .../print/generator-print-verbose-2.stderr | 56 ---- .../retain-resume-ref.drop_tracking.stderr | 13 + .../retain-resume-ref.drop_tracking_mir.stderr | 14 + .../retain-resume-ref.no_drop_tracking.stderr | 13 + tests/ui/generator/retain-resume-ref.rs | 4 + tests/ui/generator/retain-resume-ref.stderr | 2 +- .../generator/static-mut-reference-across-yield.rs | 4 +- .../type-mismatch-signature-deduction.stderr | 4 +- 62 files changed, 2845 insertions(+), 508 deletions(-) create mode 100644 tests/ui/generator/auto-trait-regions.drop_tracking.stderr create mode 100644 tests/ui/generator/auto-trait-regions.drop_tracking_mir.stderr create mode 100644 tests/ui/generator/auto-trait-regions.no_drop_tracking.stderr create mode 100644 tests/ui/generator/borrowing.drop_tracking.stderr create mode 100644 tests/ui/generator/borrowing.drop_tracking_mir.stderr create mode 100644 tests/ui/generator/borrowing.no_drop_tracking.stderr create mode 100644 tests/ui/generator/drop-tracking-parent-expression.drop_tracking.stderr create mode 100644 tests/ui/generator/drop-tracking-parent-expression.drop_tracking_mir.stderr create mode 100644 tests/ui/generator/drop-tracking-parent-expression.no_drop_tracking.stderr delete mode 100644 tests/ui/generator/drop-tracking-parent-expression.stderr create mode 100644 tests/ui/generator/issue-105084.drop_tracking_mir.stderr create mode 100644 tests/ui/generator/issue-105084.rs create mode 100644 tests/ui/generator/issue-57017.no_drop_tracking.stderr create mode 100644 tests/ui/generator/issue-57478.no_drop_tracking.stderr create mode 100644 tests/ui/generator/issue-68112.drop_tracking.stderr create mode 100644 tests/ui/generator/issue-68112.drop_tracking_mir.stderr create mode 100644 tests/ui/generator/issue-68112.no_drop_tracking.stderr delete mode 100644 tests/ui/generator/issue-68112.stderr create mode 100644 tests/ui/generator/not-send-sync.drop_tracking.stderr create mode 100644 tests/ui/generator/not-send-sync.drop_tracking_mir.stderr create mode 100644 tests/ui/generator/not-send-sync.no_drop_tracking.stderr delete mode 100644 tests/ui/generator/not-send-sync.stderr create mode 100644 tests/ui/generator/parent-expression.drop_tracking.stderr create mode 100644 tests/ui/generator/parent-expression.drop_tracking_mir.stderr create mode 100644 tests/ui/generator/parent-expression.no_drop_tracking.stderr create mode 100644 tests/ui/generator/parent-expression.rs create mode 100644 tests/ui/generator/partial-drop.drop_tracking.stderr create mode 100644 tests/ui/generator/partial-drop.no_drop_tracking.stderr delete mode 100644 tests/ui/generator/partial-drop.stderr create mode 100644 tests/ui/generator/print/generator-print-verbose-1.drop_tracking.stderr create mode 100644 tests/ui/generator/print/generator-print-verbose-1.drop_tracking_mir.stderr create mode 100644 tests/ui/generator/print/generator-print-verbose-1.no_drop_tracking.stderr delete mode 100644 tests/ui/generator/print/generator-print-verbose-1.stderr create mode 100644 tests/ui/generator/print/generator-print-verbose-2.drop_tracking.stderr create mode 100644 tests/ui/generator/print/generator-print-verbose-2.drop_tracking_mir.stderr create mode 100644 tests/ui/generator/print/generator-print-verbose-2.no_drop_tracking.stderr delete mode 100644 tests/ui/generator/print/generator-print-verbose-2.stderr create mode 100644 tests/ui/generator/retain-resume-ref.drop_tracking.stderr create mode 100644 tests/ui/generator/retain-resume-ref.drop_tracking_mir.stderr create mode 100644 tests/ui/generator/retain-resume-ref.no_drop_tracking.stderr (limited to 'tests/ui/generator') diff --git a/tests/ui/generator/addassign-yield.rs b/tests/ui/generator/addassign-yield.rs index 66f22bf31..7211367af 100644 --- a/tests/ui/generator/addassign-yield.rs +++ b/tests/ui/generator/addassign-yield.rs @@ -1,3 +1,6 @@ +// 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 diff --git a/tests/ui/generator/auto-trait-regions.drop_tracking.stderr b/tests/ui/generator/auto-trait-regions.drop_tracking.stderr new file mode 100644 index 000000000..165748d44 --- /dev/null +++ b/tests/ui/generator/auto-trait-regions.drop_tracking.stderr @@ -0,0 +1,47 @@ +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 + | + = note: consider using a `let` binding to create a longer lived value + +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 + | + = note: consider using a `let` binding to create a longer lived value + +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 new file mode 100644 index 000000000..165748d44 --- /dev/null +++ b/tests/ui/generator/auto-trait-regions.drop_tracking_mir.stderr @@ -0,0 +1,47 @@ +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 + | + = note: consider using a `let` binding to create a longer lived value + +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 + | + = note: consider using a `let` binding to create a longer lived value + +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 new file mode 100644 index 000000000..165748d44 --- /dev/null +++ b/tests/ui/generator/auto-trait-regions.no_drop_tracking.stderr @@ -0,0 +1,47 @@ +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 + | + = note: consider using a `let` binding to create a longer lived value + +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 + | + = note: consider using a `let` binding to create a longer lived value + +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 index ea4b0d554..fd13e4131 100644 --- a/tests/ui/generator/auto-trait-regions.rs +++ b/tests/ui/generator/auto-trait-regions.rs @@ -1,3 +1,6 @@ +// 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)] diff --git a/tests/ui/generator/auto-trait-regions.stderr b/tests/ui/generator/auto-trait-regions.stderr index 0b1f34aeb..165748d44 100644 --- a/tests/ui/generator/auto-trait-regions.stderr +++ b/tests/ui/generator/auto-trait-regions.stderr @@ -1,5 +1,5 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:45:24 + --> $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 @@ -12,7 +12,7 @@ LL | assert_foo(a); = note: consider using a `let` binding to create a longer lived value error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:45:35 + --> $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 @@ -25,7 +25,7 @@ LL | assert_foo(a); = note: consider using a `let` binding to create a longer lived value error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:31:5 + --> $DIR/auto-trait-regions.rs:34:5 | LL | assert_foo(gen); | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -34,7 +34,7 @@ LL | assert_foo(gen); = note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef` error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:51:5 + --> $DIR/auto-trait-regions.rs:54:5 | LL | assert_foo(gen); | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/tests/ui/generator/borrowing.drop_tracking.stderr b/tests/ui/generator/borrowing.drop_tracking.stderr new file mode 100644 index 000000000..96e3c327f --- /dev/null +++ b/tests/ui/generator/borrowing.drop_tracking.stderr @@ -0,0 +1,31 @@ +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 new file mode 100644 index 000000000..8fbad276d --- /dev/null +++ b/tests/ui/generator/borrowing.drop_tracking_mir.stderr @@ -0,0 +1,39 @@ +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 new file mode 100644 index 000000000..96e3c327f --- /dev/null +++ b/tests/ui/generator/borrowing.no_drop_tracking.stderr @@ -0,0 +1,31 @@ +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 index d36592583..29f39437f 100644 --- a/tests/ui/generator/borrowing.rs +++ b/tests/ui/generator/borrowing.rs @@ -1,3 +1,7 @@ +// 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; diff --git a/tests/ui/generator/borrowing.stderr b/tests/ui/generator/borrowing.stderr index 38e1ace8c..96e3c327f 100644 --- a/tests/ui/generator/borrowing.stderr +++ b/tests/ui/generator/borrowing.stderr @@ -1,5 +1,5 @@ error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:9:33 + --> $DIR/borrowing.rs:13:33 | LL | let _b = { | -- borrow later stored here @@ -13,7 +13,7 @@ LL | }; | - `a` dropped here while still borrowed error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:16:20 + --> $DIR/borrowing.rs:20:20 | LL | let _b = { | -- borrow later stored here diff --git a/tests/ui/generator/drop-tracking-parent-expression.drop_tracking.stderr b/tests/ui/generator/drop-tracking-parent-expression.drop_tracking.stderr new file mode 100644 index 000000000..c07906ec3 --- /dev/null +++ b/tests/ui/generator/drop-tracking-parent-expression.drop_tracking.stderr @@ -0,0 +1,128 @@ +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(_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(_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(_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 new file mode 100644 index 000000000..35698a98d --- /dev/null +++ b/tests/ui/generator/drop-tracking-parent-expression.drop_tracking_mir.stderr @@ -0,0 +1,122 @@ +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(_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(_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(_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 new file mode 100644 index 000000000..1a05bfe4f --- /dev/null +++ b/tests/ui/generator/drop-tracking-parent-expression.no_drop_tracking.stderr @@ -0,0 +1,334 @@ +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(_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(_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(_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(_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(_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(_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(_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(_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 index d40f1b8f6..ed9ac6d11 100644 --- a/tests/ui/generator/drop-tracking-parent-expression.rs +++ b/tests/ui/generator/drop-tracking-parent-expression.rs @@ -1,4 +1,7 @@ -// compile-flags: -Zdrop-tracking +// 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 { @@ -18,13 +21,14 @@ macro_rules! type_combinations { 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` + //[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`, @@ -34,6 +38,10 @@ macro_rules! type_combinations { _ => 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 } )* } } diff --git a/tests/ui/generator/drop-tracking-parent-expression.stderr b/tests/ui/generator/drop-tracking-parent-expression.stderr deleted file mode 100644 index fbf5d6e07..000000000 --- a/tests/ui/generator/drop-tracking-parent-expression.stderr +++ /dev/null @@ -1,128 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:24: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:18:21: 18: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:22: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:41:19 - | -LL | fn assert_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:24: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:18:21: 18: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:22: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:41:19 - | -LL | fn assert_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:24: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:18:21: 18: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:22: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:41:19 - | -LL | fn assert_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-yielding-in-match-guards.rs b/tests/ui/generator/drop-tracking-yielding-in-match-guards.rs index 646365e43..cbc291701 100644 --- a/tests/ui/generator/drop-tracking-yielding-in-match-guards.rs +++ b/tests/ui/generator/drop-tracking-yielding-in-match-guards.rs @@ -1,6 +1,8 @@ // build-pass // edition:2018 -// compile-flags: -Zdrop-tracking +// 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)] diff --git a/tests/ui/generator/dropck.stderr b/tests/ui/generator/dropck.stderr index 7bb188352..b9a3a124a 100644 --- a/tests/ui/generator/dropck.stderr +++ b/tests/ui/generator/dropck.stderr @@ -1,6 +1,9 @@ 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 ... diff --git a/tests/ui/generator/generator-yielding-or-returning-itself.stderr b/tests/ui/generator/generator-yielding-or-returning-itself.stderr index 8f5d2429a..a26dbf3f2 100644 --- a/tests/ui/generator/generator-yielding-or-returning-itself.stderr +++ b/tests/ui/generator/generator-yielding-or-returning-itself.stderr @@ -19,7 +19,7 @@ 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) - | ---------------------------- required by a bound in this + | ---------------------------- required by a bound in this function LL | where T: Generator | ^^^^^^^^^^ required by this bound in `want_cyclic_generator_return` @@ -44,7 +44,7 @@ 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) - | --------------------------- required by a bound in this + | --------------------------- required by a bound in this function LL | where T: Generator | ^^^^^^^^^ required by this bound in `want_cyclic_generator_yield` diff --git a/tests/ui/generator/issue-102645.stderr b/tests/ui/generator/issue-102645.stderr index f6d244029..3f9a4c2f3 100644 --- a/tests/ui/generator/issue-102645.stderr +++ b/tests/ui/generator/issue-102645.stderr @@ -4,7 +4,7 @@ error[E0061]: this method takes 1 argument but 0 arguments were supplied LL | Pin::new(&mut b).resume(); | ^^^^^^-- an argument of type `()` is missing | -note: associated function defined here +note: method defined here --> $SRC_DIR/core/src/ops/generator.rs:LL:COL help: provide the argument | diff --git a/tests/ui/generator/issue-105084.drop_tracking_mir.stderr b/tests/ui/generator/issue-105084.drop_tracking_mir.stderr new file mode 100644 index 000000000..cfc0cf7cd --- /dev/null +++ b/tests/ui/generator/issue-105084.drop_tracking_mir.stderr @@ -0,0 +1,51 @@ +error[E0382]: borrow of moved value: `g` + --> $DIR/issue-105084.rs:44: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(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:38: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:28:25 + | +LL | let t = box (5, yield); + | --------^^^^^- + | | | + | | yield occurs here, with `box (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(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 new file mode 100644 index 000000000..7c9a97b40 --- /dev/null +++ b/tests/ui/generator/issue-105084.rs @@ -0,0 +1,49 @@ +// 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(box_syntax)] + +use std::ops::Generator; +use std::pin::Pin; + +fn 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 = box (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-57017.no_drop_tracking.stderr b/tests/ui/generator/issue-57017.no_drop_tracking.stderr new file mode 100644 index 000000000..06d2d23b9 --- /dev/null +++ b/tests/ui/generator/issue-57017.no_drop_tracking.stderr @@ -0,0 +1,248 @@ +error: generator cannot be sent between threads safely + --> $DIR/issue-57017.rs:31: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:29: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:51:19 + | +LL | fn assert_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:43: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:40:21: 40: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:41: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:51:19 + | +LL | fn assert_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:31: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:29: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:51:19 + | +LL | fn assert_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:43: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:40:21: 40: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:41: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:51:19 + | +LL | fn assert_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:31: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:29: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:51:19 + | +LL | fn assert_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:43: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:40:21: 40: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:41: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:51:19 + | +LL | fn assert_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 index c0bde3b44..03b00ac99 100644 --- a/tests/ui/generator/issue-57017.rs +++ b/tests/ui/generator/issue-57017.rs @@ -1,5 +1,9 @@ -// build-pass -// compile-flags: -Zdrop-tracking +// 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)] macro_rules! type_combinations { @@ -25,6 +29,9 @@ macro_rules! type_combinations { _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 @@ -34,6 +41,9 @@ macro_rules! type_combinations { _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 } )* } } diff --git a/tests/ui/generator/issue-57478.no_drop_tracking.stderr b/tests/ui/generator/issue-57478.no_drop_tracking.stderr new file mode 100644 index 000000000..612dd9c37 --- /dev/null +++ b/tests/ui/generator/issue-57478.no_drop_tracking.stderr @@ -0,0 +1,31 @@ +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) {} + | ^^^^ 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 index 91407ea18..3c23b5992 100644 --- a/tests/ui/generator/issue-57478.rs +++ b/tests/ui/generator/issue-57478.rs @@ -1,5 +1,8 @@ -// check-pass -// compile-flags: -Zdrop-tracking +// 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)] @@ -8,6 +11,7 @@ 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; diff --git a/tests/ui/generator/issue-68112.drop_tracking.stderr b/tests/ui/generator/issue-68112.drop_tracking.stderr new file mode 100644 index 000000000..282eac1b6 --- /dev/null +++ b/tests/ui/generator/issue-68112.drop_tracking.stderr @@ -0,0 +1,66 @@ +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` + = 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>>` 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` cannot be shared between threads safely + --> $DIR/issue-68112.rs:67:18 + | +LL | require_send(send_gen); + | ------------ ^^^^^^^^ `RefCell` cannot be shared between threads safely + | | + | required by a bound introduced by this call + | + = help: the trait `Sync` is not implemented for `RefCell` + = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead + = note: required for `Arc>` 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>>` + --> $DIR/issue-68112.rs:49:30 + | +LL | pub fn make_gen2(t: T) -> impl Generator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required because it appears within the type `impl Generator>>` + --> $DIR/issue-68112.rs:57:34 + | +LL | fn make_non_send_generator2() -> impl Generator>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required because it captures the following types: `impl Generator>>`, `()` +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 new file mode 100644 index 000000000..a83522b71 --- /dev/null +++ b/tests/ui/generator/issue-68112.drop_tracking_mir.stderr @@ -0,0 +1,61 @@ +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` + = 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>>` 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` cannot be shared between threads safely + --> $DIR/issue-68112.rs:67:5 + | +LL | require_send(send_gen); + | ^^^^^^^^^^^^ `RefCell` cannot be shared between threads safely + | + = help: the trait `Sync` is not implemented for `RefCell` + = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead + = note: required for `Arc>` 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>>` + --> $DIR/issue-68112.rs:49:30 + | +LL | pub fn make_gen2(t: T) -> impl Generator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required because it appears within the type `impl Generator>>` + --> $DIR/issue-68112.rs:57:34 + | +LL | fn make_non_send_generator2() -> impl Generator>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required because it captures the following types: `impl Generator>>` +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 new file mode 100644 index 000000000..282eac1b6 --- /dev/null +++ b/tests/ui/generator/issue-68112.no_drop_tracking.stderr @@ -0,0 +1,66 @@ +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` + = 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>>` 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` cannot be shared between threads safely + --> $DIR/issue-68112.rs:67:18 + | +LL | require_send(send_gen); + | ------------ ^^^^^^^^ `RefCell` cannot be shared between threads safely + | | + | required by a bound introduced by this call + | + = help: the trait `Sync` is not implemented for `RefCell` + = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead + = note: required for `Arc>` 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>>` + --> $DIR/issue-68112.rs:49:30 + | +LL | pub fn make_gen2(t: T) -> impl Generator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required because it appears within the type `impl Generator>>` + --> $DIR/issue-68112.rs:57:34 + | +LL | fn make_non_send_generator2() -> impl Generator>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required because it captures the following types: `impl Generator>>`, `()` +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 index 21026f45c..48b53b769 100644 --- a/tests/ui/generator/issue-68112.rs +++ b/tests/ui/generator/issue-68112.rs @@ -1,3 +1,6 @@ +// 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::{ @@ -8,7 +11,7 @@ use std::{ }; pub struct Ready(Option); -impl Generator<()> for Ready { +impl Generator<()> for Ready { type Return = T; type Yield = (); fn resume(mut self: Pin<&mut Self>, _args: ()) -> GeneratorState<(), T> { @@ -36,10 +39,11 @@ fn test1() { yield; //~^ NOTE yield occurs here //~| NOTE value is used across a yield - }; //~ NOTE later dropped here + }; //[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) -> impl Generator { @@ -64,8 +68,9 @@ fn test2() { //~^ ERROR `RefCell` cannot be shared between threads safely //~| NOTE `RefCell` cannot be shared between threads safely //~| NOTE required for - //~| NOTE required by a bound introduced by this call + //[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-68112.stderr b/tests/ui/generator/issue-68112.stderr deleted file mode 100644 index eb99d42c9..000000000 --- a/tests/ui/generator/issue-68112.stderr +++ /dev/null @@ -1,64 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/issue-68112.rs:40:18 - | -LL | require_send(send_gen); - | ^^^^^^^^ generator is not `Send` - | - = help: the trait `Sync` is not implemented for `RefCell` -note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-68112.rs:36:9 - | -LL | let _non_send_gen = make_non_send_generator(); - | ------------- has type `impl Generator>>` 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:22:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error[E0277]: `RefCell` cannot be shared between threads safely - --> $DIR/issue-68112.rs:63:18 - | -LL | require_send(send_gen); - | ------------ ^^^^^^^^ `RefCell` cannot be shared between threads safely - | | - | required by a bound introduced by this call - | - = help: the trait `Sync` is not implemented for `RefCell` - = note: required for `Arc>` to implement `Send` -note: required because it's used within this generator - --> $DIR/issue-68112.rs:48:5 - | -LL | || { - | ^^ -note: required because it appears within the type `impl Generator>>` - --> $DIR/issue-68112.rs:45:30 - | -LL | pub fn make_gen2(t: T) -> impl Generator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required because it appears within the type `impl Generator>>` - --> $DIR/issue-68112.rs:53:34 - | -LL | fn make_non_send_generator2() -> impl Generator>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `impl Generator>>`, `()` -note: required because it's used within this generator - --> $DIR/issue-68112.rs:59:20 - | -LL | let send_gen = || { - | ^^ -note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:22: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-93161.rs b/tests/ui/generator/issue-93161.rs index 92305609c..8d3f7c62f 100644 --- a/tests/ui/generator/issue-93161.rs +++ b/tests/ui/generator/issue-93161.rs @@ -1,6 +1,8 @@ +// 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 -// compile-flags: -Zdrop-tracking #![feature(never_type)] diff --git a/tests/ui/generator/not-send-sync.drop_tracking.stderr b/tests/ui/generator/not-send-sync.drop_tracking.stderr new file mode 100644 index 000000000..718fd4224 --- /dev/null +++ b/tests/ui/generator/not-send-sync.drop_tracking.stderr @@ -0,0 +1,60 @@ +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) {} + | ^^^^ 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) {} + | ^^^^ 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 new file mode 100644 index 000000000..66f01ae37 --- /dev/null +++ b/tests/ui/generator/not-send-sync.drop_tracking_mir.stderr @@ -0,0 +1,42 @@ +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) {} + | ^^^^ 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) {} + | ^^^^ 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 new file mode 100644 index 000000000..718fd4224 --- /dev/null +++ b/tests/ui/generator/not-send-sync.no_drop_tracking.stderr @@ -0,0 +1,60 @@ +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) {} + | ^^^^ 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) {} + | ^^^^ 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 index 8ca5565fb..8794db452 100644 --- a/tests/ui/generator/not-send-sync.rs +++ b/tests/ui/generator/not-send-sync.rs @@ -1,6 +1,14 @@ +// 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)] -use std::cell::Cell; +struct NotSend; +struct NotSync; + +impl !Send for NotSend {} +impl !Sync for NotSync {} fn main() { fn assert_sync(_: T) {} @@ -8,14 +16,15 @@ fn main() { assert_sync(|| { //~^ ERROR: generator cannot be shared between threads safely - let a = Cell::new(2); + let a = NotSync; yield; + drop(a); }); - let a = Cell::new(2); assert_send(|| { - //~^ ERROR: E0277 - drop(&a); + //~^ ERROR: generator cannot be sent between threads safely + let a = NotSend; yield; + drop(a); }); } diff --git a/tests/ui/generator/not-send-sync.stderr b/tests/ui/generator/not-send-sync.stderr deleted file mode 100644 index a821c57b9..000000000 --- a/tests/ui/generator/not-send-sync.stderr +++ /dev/null @@ -1,56 +0,0 @@ -error[E0277]: `Cell` cannot be shared between threads safely - --> $DIR/not-send-sync.rs:16:17 - | -LL | assert_send(|| { - | _____-----------_^ - | | | - | | required by a bound introduced by this call -LL | | -LL | | drop(&a); -LL | | yield; -LL | | }); - | |_____^ `Cell` cannot be shared between threads safely - | - = help: the trait `Sync` is not implemented for `Cell` - = note: required for `&Cell` to implement `Send` -note: required because it's used within this generator - --> $DIR/not-send-sync.rs:16:17 - | -LL | assert_send(|| { - | ^^ -note: required by a bound in `assert_send` - --> $DIR/not-send-sync.rs:7:23 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: generator cannot be shared between threads safely - --> $DIR/not-send-sync.rs:9:17 - | -LL | assert_sync(|| { - | _________________^ -LL | | -LL | | let a = Cell::new(2); -LL | | yield; -LL | | }); - | |_____^ generator is not `Sync` - | - = help: within `[generator@$DIR/not-send-sync.rs:9:17: 9:19]`, the trait `Sync` is not implemented for `Cell` -note: generator is not `Sync` as this value is used across a yield - --> $DIR/not-send-sync.rs:12:9 - | -LL | let a = Cell::new(2); - | - has type `Cell` which is not `Sync` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -LL | }); - | - `a` is later dropped here -note: required by a bound in `assert_sync` - --> $DIR/not-send-sync.rs:6:23 - | -LL | fn assert_sync(_: T) {} - | ^^^^ required by this bound in `assert_sync` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/parent-expression.drop_tracking.stderr b/tests/ui/generator/parent-expression.drop_tracking.stderr new file mode 100644 index 000000000..ef489088b --- /dev/null +++ b/tests/ui/generator/parent-expression.drop_tracking.stderr @@ -0,0 +1,128 @@ +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(_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(_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(_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 new file mode 100644 index 000000000..bf8144564 --- /dev/null +++ b/tests/ui/generator/parent-expression.drop_tracking_mir.stderr @@ -0,0 +1,122 @@ +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(_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(_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(_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 new file mode 100644 index 000000000..2e1313a80 --- /dev/null +++ b/tests/ui/generator/parent-expression.no_drop_tracking.stderr @@ -0,0 +1,334 @@ +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(_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(_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(_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(_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(_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(_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(_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(_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 new file mode 100644 index 000000000..239034e3d --- /dev/null +++ b/tests/ui/generator/parent-expression.rs @@ -0,0 +1,77 @@ +// 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(_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 new file mode 100644 index 000000000..f1b25cb8c --- /dev/null +++ b/tests/ui/generator/partial-drop.drop_tracking.stderr @@ -0,0 +1,61 @@ +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) {} + | ^^^^ 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) {} + | ^^^^ 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 new file mode 100644 index 000000000..91152b5ea --- /dev/null +++ b/tests/ui/generator/partial-drop.no_drop_tracking.stderr @@ -0,0 +1,61 @@ +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) {} + | ^^^^ 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) {} + | ^^^^ 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 index c872fb7f3..1d3ae075d 100644 --- a/tests/ui/generator/partial-drop.rs +++ b/tests/ui/generator/partial-drop.rs @@ -1,4 +1,7 @@ -// compile-flags: -Zdrop-tracking +// 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)] @@ -12,26 +15,14 @@ struct Bar { fn main() { assert_send(|| { - //~^ ERROR generator cannot be sent between threads safely - // FIXME: it would be nice to make this work. + //[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(|| { - //~^ ERROR generator cannot be sent between threads safely - // FIXME: it would be nice to make this work. - let guard = Bar { foo: Foo, x: 42 }; - drop(guard); - guard.foo = Foo; - guard.x = 23; - yield; - }); - - assert_send(|| { - //~^ ERROR generator cannot be sent between threads safely - // FIXME: it would be nice to make this work. + //[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); diff --git a/tests/ui/generator/partial-drop.stderr b/tests/ui/generator/partial-drop.stderr deleted file mode 100644 index 9baafe54e..000000000 --- a/tests/ui/generator/partial-drop.stderr +++ /dev/null @@ -1,92 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/partial-drop.rs:14:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | // FIXME: it would be nice to make this work. -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:14:17: 14: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:19: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:42:19 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: generator cannot be sent between threads safely - --> $DIR/partial-drop.rs:22:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | // FIXME: it would be nice to make this work. -LL | | let guard = Bar { foo: Foo, x: 42 }; -... | -LL | | yield; -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `[generator@$DIR/partial-drop.rs:22:17: 22: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:42:19 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: generator cannot be sent between threads safely - --> $DIR/partial-drop.rs:32:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | // FIXME: it would be nice to make this work. -LL | | let guard = Bar { foo: Foo, x: 42 }; -... | -LL | | yield; -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `[generator@$DIR/partial-drop.rs:32:17: 32: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:38: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:42:19 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 3 previous errors - 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 new file mode 100644 index 000000000..7d0a20169 --- /dev/null +++ b/tests/ui/generator/print/generator-print-verbose-1.drop_tracking.stderr @@ -0,0 +1,64 @@ +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` + = 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[749a]::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` cannot be shared between threads safely + --> $DIR/generator-print-verbose-1.rs:59:18 + | +LL | require_send(send_gen); + | ------------ ^^^^^^^^ `RefCell` cannot be shared between threads safely + | | + | required by a bound introduced by this call + | + = help: the trait `Sync` is not implemented for `RefCell` + = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead + = note: required for `Arc>` 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[749a]::make_gen2::{opaque#0}), [Arc>])` + --> $DIR/generator-print-verbose-1.rs:44:30 + | +LL | pub fn make_gen2(t: T) -> impl Generator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required because it appears within the type `Opaque(DefId(0:36 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])` + --> $DIR/generator-print-verbose-1.rs:50:34 + | +LL | fn make_non_send_generator2() -> impl Generator>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required because it captures the following types: `Opaque(DefId(0:36 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])`, `()` +note: required because it's used within this generator + --> $DIR/generator-print-verbose-1.rs: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 new file mode 100644 index 000000000..c045b1441 --- /dev/null +++ b/tests/ui/generator/print/generator-print-verbose-1.drop_tracking_mir.stderr @@ -0,0 +1,60 @@ +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` + = 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[749a]::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` cannot be shared between threads safely + --> $DIR/generator-print-verbose-1.rs:59:5 + | +LL | require_send(send_gen); + | ^^^^^^^^^^^^ `RefCell` cannot be shared between threads safely + | + = help: the trait `Sync` is not implemented for `RefCell` + = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead + = note: required for `Arc>` 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[749a]::make_gen2::{opaque#0}), [Arc>])` + --> $DIR/generator-print-verbose-1.rs:44:30 + | +LL | pub fn make_gen2(t: T) -> impl Generator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required because it appears within the type `Opaque(DefId(0:36 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])` + --> $DIR/generator-print-verbose-1.rs:50:34 + | +LL | fn make_non_send_generator2() -> impl Generator>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required because it captures the following types: `Opaque(DefId(0:36 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])` +note: required because it's used within this generator + --> $DIR/generator-print-verbose-1.rs: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 new file mode 100644 index 000000000..7d0a20169 --- /dev/null +++ b/tests/ui/generator/print/generator-print-verbose-1.no_drop_tracking.stderr @@ -0,0 +1,64 @@ +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` + = 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[749a]::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` cannot be shared between threads safely + --> $DIR/generator-print-verbose-1.rs:59:18 + | +LL | require_send(send_gen); + | ------------ ^^^^^^^^ `RefCell` cannot be shared between threads safely + | | + | required by a bound introduced by this call + | + = help: the trait `Sync` is not implemented for `RefCell` + = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead + = note: required for `Arc>` 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[749a]::make_gen2::{opaque#0}), [Arc>])` + --> $DIR/generator-print-verbose-1.rs:44:30 + | +LL | pub fn make_gen2(t: T) -> impl Generator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required because it appears within the type `Opaque(DefId(0:36 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])` + --> $DIR/generator-print-verbose-1.rs:50:34 + | +LL | fn make_non_send_generator2() -> impl Generator>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required because it captures the following types: `Opaque(DefId(0:36 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])`, `()` +note: required because it's used within this generator + --> $DIR/generator-print-verbose-1.rs: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 index 89124ad72..c7052c7d1 100644 --- a/tests/ui/generator/print/generator-print-verbose-1.rs +++ b/tests/ui/generator/print/generator-print-verbose-1.rs @@ -1,3 +1,6 @@ +// 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 @@ -12,7 +15,7 @@ use std::{ }; pub struct Ready(Option); -impl Generator<()> for Ready { +impl Generator<()> for Ready { type Return = T; type Yield = (); fn resume(mut self: Pin<&mut Self>, _args: ()) -> GeneratorState<(), T> { diff --git a/tests/ui/generator/print/generator-print-verbose-1.stderr b/tests/ui/generator/print/generator-print-verbose-1.stderr deleted file mode 100644 index ebf35be58..000000000 --- a/tests/ui/generator/print/generator-print-verbose-1.stderr +++ /dev/null @@ -1,62 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/generator-print-verbose-1.rs:37:18 - | -LL | require_send(send_gen); - | ^^^^^^^^ generator is not `Send` - | - = help: the trait `Sync` is not implemented for `RefCell` -note: generator is not `Send` as this value is used across a yield - --> $DIR/generator-print-verbose-1.rs:35:9 - | -LL | let _non_send_gen = make_non_send_generator(); - | ------------- has type `Opaque(DefId(0:34 ~ generator_print_verbose_1[749a]::make_non_send_generator::{opaque#0}), [])` which is not `Send` -LL | yield; - | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later -LL | }; - | - `_non_send_gen` is later dropped here -note: required by a bound in `require_send` - --> $DIR/generator-print-verbose-1.rs:26:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error[E0277]: `RefCell` cannot be shared between threads safely - --> $DIR/generator-print-verbose-1.rs:56:18 - | -LL | require_send(send_gen); - | ------------ ^^^^^^^^ `RefCell` cannot be shared between threads safely - | | - | required by a bound introduced by this call - | - = help: the trait `Sync` is not implemented for `RefCell` - = note: required for `Arc>` to implement `Send` -note: required because it's used within this generator - --> $DIR/generator-print-verbose-1.rs:42:5 - | -LL | || { - | ^^ -note: required because it appears within the type `Opaque(DefId(0:35 ~ generator_print_verbose_1[749a]::make_gen2::{opaque#0}), [Arc>])` - --> $DIR/generator-print-verbose-1.rs:41:30 - | -LL | pub fn make_gen2(t: T) -> impl Generator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required because it appears within the type `Opaque(DefId(0:36 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])` - --> $DIR/generator-print-verbose-1.rs:47:34 - | -LL | fn make_non_send_generator2() -> impl Generator>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `Opaque(DefId(0:36 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])`, `()` -note: required because it's used within this generator - --> $DIR/generator-print-verbose-1.rs:52:20 - | -LL | let send_gen = || { - | ^^ -note: required by a bound in `require_send` - --> $DIR/generator-print-verbose-1.rs:26: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-2.drop_tracking.stderr b/tests/ui/generator/print/generator-print-verbose-2.drop_tracking.stderr new file mode 100644 index 000000000..1f2e530f6 --- /dev/null +++ b/tests/ui/generator/print/generator-print-verbose-2.drop_tracking.stderr @@ -0,0 +1,60 @@ +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) {} + | ^^^^ 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) {} + | ^^^^ 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 new file mode 100644 index 000000000..354369f19 --- /dev/null +++ b/tests/ui/generator/print/generator-print-verbose-2.drop_tracking_mir.stderr @@ -0,0 +1,42 @@ +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) {} + | ^^^^ 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) {} + | ^^^^ 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 new file mode 100644 index 000000000..1f2e530f6 --- /dev/null +++ b/tests/ui/generator/print/generator-print-verbose-2.no_drop_tracking.stderr @@ -0,0 +1,60 @@ +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) {} + | ^^^^ 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) {} + | ^^^^ 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 index d914719cb..ab29db6e0 100644 --- a/tests/ui/generator/print/generator-print-verbose-2.rs +++ b/tests/ui/generator/print/generator-print-verbose-2.rs @@ -1,9 +1,17 @@ +// 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)] -use std::cell::Cell; +struct NotSend; +struct NotSync; + +impl !Send for NotSend {} +impl !Sync for NotSync {} fn main() { fn assert_sync(_: T) {} @@ -11,14 +19,15 @@ fn main() { assert_sync(|| { //~^ ERROR: generator cannot be shared between threads safely - let a = Cell::new(2); + let a = NotSync; yield; + drop(a); }); - let a = Cell::new(2); assert_send(|| { - //~^ ERROR: E0277 - drop(&a); + //~^ ERROR: generator cannot be sent between threads safely + let a = NotSend; yield; + drop(a); }); } diff --git a/tests/ui/generator/print/generator-print-verbose-2.stderr b/tests/ui/generator/print/generator-print-verbose-2.stderr deleted file mode 100644 index 909e49c38..000000000 --- a/tests/ui/generator/print/generator-print-verbose-2.stderr +++ /dev/null @@ -1,56 +0,0 @@ -error[E0277]: `Cell` cannot be shared between threads safely - --> $DIR/generator-print-verbose-2.rs:19:17 - | -LL | assert_send(|| { - | _____-----------_^ - | | | - | | required by a bound introduced by this call -LL | | -LL | | drop(&a); -LL | | yield; -LL | | }); - | |_____^ `Cell` cannot be shared between threads safely - | - = help: the trait `Sync` is not implemented for `Cell` - = note: required for `&'_#4r Cell` to implement `Send` -note: required because it's used within this generator - --> $DIR/generator-print-verbose-2.rs:19:17 - | -LL | assert_send(|| { - | ^^ -note: required by a bound in `assert_send` - --> $DIR/generator-print-verbose-2.rs:10:23 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: generator cannot be shared between threads safely - --> $DIR/generator-print-verbose-2.rs:12:17 - | -LL | assert_sync(|| { - | _________________^ -LL | | -LL | | let a = Cell::new(2); -LL | | yield; -LL | | }); - | |_____^ generator is not `Sync` - | - = help: within `[main::{closure#0} upvar_tys=() {Cell, ()}]`, the trait `Sync` is not implemented for `Cell` -note: generator is not `Sync` as this value is used across a yield - --> $DIR/generator-print-verbose-2.rs:15:9 - | -LL | let a = Cell::new(2); - | - has type `Cell` which is not `Sync` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -LL | }); - | - `a` is later dropped here -note: required by a bound in `assert_sync` - --> $DIR/generator-print-verbose-2.rs:9:23 - | -LL | fn assert_sync(_: T) {} - | ^^^^ required by this bound in `assert_sync` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/retain-resume-ref.drop_tracking.stderr b/tests/ui/generator/retain-resume-ref.drop_tracking.stderr new file mode 100644 index 000000000..7122a951e --- /dev/null +++ b/tests/ui/generator/retain-resume-ref.drop_tracking.stderr @@ -0,0 +1,13 @@ +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 new file mode 100644 index 000000000..736ed1fb6 --- /dev/null +++ b/tests/ui/generator/retain-resume-ref.drop_tracking_mir.stderr @@ -0,0 +1,14 @@ +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 new file mode 100644 index 000000000..7122a951e --- /dev/null +++ b/tests/ui/generator/retain-resume-ref.no_drop_tracking.stderr @@ -0,0 +1,13 @@ +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 index 0606ea71c..0050d98d0 100644 --- a/tests/ui/generator/retain-resume-ref.rs +++ b/tests/ui/generator/retain-resume-ref.rs @@ -1,3 +1,7 @@ +// 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)] diff --git a/tests/ui/generator/retain-resume-ref.stderr b/tests/ui/generator/retain-resume-ref.stderr index e33310d12..7122a951e 100644 --- a/tests/ui/generator/retain-resume-ref.stderr +++ b/tests/ui/generator/retain-resume-ref.stderr @@ -1,5 +1,5 @@ error[E0499]: cannot borrow `thing` as mutable more than once at a time - --> $DIR/retain-resume-ref.rs:23:25 + --> $DIR/retain-resume-ref.rs:27:25 | LL | gen.as_mut().resume(&mut thing); | ---------- first mutable borrow occurs here diff --git a/tests/ui/generator/static-mut-reference-across-yield.rs b/tests/ui/generator/static-mut-reference-across-yield.rs index 0fa6d9cdc..4784ff49b 100644 --- a/tests/ui/generator/static-mut-reference-across-yield.rs +++ b/tests/ui/generator/static-mut-reference-across-yield.rs @@ -1,6 +1,8 @@ // build-pass -// revisions: mir thir +// 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)] diff --git a/tests/ui/generator/type-mismatch-signature-deduction.stderr b/tests/ui/generator/type-mismatch-signature-deduction.stderr index b98da1ed8..ef6d896f8 100644 --- a/tests/ui/generator/type-mismatch-signature-deduction.stderr +++ b/tests/ui/generator/type-mismatch-signature-deduction.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch-signature-deduction.rs:14:9 | LL | 5 - | ^ expected enum `Result`, found integer + | ^ expected `Result<{integer}, _>`, found integer | = note: expected enum `Result<{integer}, _>` found type `{integer}` @@ -22,7 +22,7 @@ error[E0271]: type mismatch resolving `<[generator@$DIR/type-mismatch-signature- --> $DIR/type-mismatch-signature-deduction.rs:5:13 | LL | fn foo() -> impl Generator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `Result`, found `i32` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<{integer}, _>`, found `i32` | = note: expected enum `Result<{integer}, _>` found type `i32` -- cgit v1.2.3