diff --git a/tests/ui/async-await/async-await-let-else.drop_tracking_mir.stderr b/tests/ui/async-await/async-await-let-else.drop_tracking_mir.stderr index d3c5e80a30d..c284bbfb1cc 100644 --- a/tests/ui/async-await/async-await-let-else.drop_tracking_mir.stderr +++ b/tests/ui/async-await/async-await-let-else.drop_tracking_mir.stderr @@ -12,30 +12,43 @@ LL | let r = Rc::new(()); | - has type `Rc<()>` which is not `Send` LL | bar().await | ^^^^^^ await occurs here, with `r` maybe used later -LL | }; - | - `r` is later dropped here note: required by a bound in `is_send` --> $DIR/async-await-let-else.rs:19:15 | LL | fn is_send(_: T) {} | ^^^^ required by this bound in `is_send` -error: future cannot be sent between threads safely +error[E0277]: `Rc<()>` cannot be sent between threads safely --> $DIR/async-await-let-else.rs:50:13 | +LL | async fn foo2(x: Option) { + | - within this `impl Future` +... LL | is_send(foo2(Some(true))); - | ^^^^^^^^^^^^^^^^ future returned by `foo2` is not `Send` + | ------- ^^^^^^^^^^^^^^^^ `Rc<()>` cannot be sent between threads safely + | | + | required by a bound introduced by this call | = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:23:26 +note: required because it's used within this `async fn` body + --> $DIR/async-await-let-else.rs:27:29 | -LL | bar2(Rc::new(())).await - | ----------- ^^^^^^ await occurs here, with `Rc::new(())` maybe used later - | | - | has type `Rc<()>` which is not `Send` -LL | }; - | - `Rc::new(())` is later dropped here +LL | async fn bar2(_: T) -> ! { + | _____________________________^ +LL | | panic!() +LL | | } + | |_^ + = note: required because it captures the following types: `impl Future` +note: required because it's used within this `async fn` body + --> $DIR/async-await-let-else.rs:21:32 + | +LL | async fn foo2(x: Option) { + | ________________________________^ +LL | | let Some(_) = x else { +LL | | bar2(Rc::new(())).await +LL | | }; +LL | | } + | |_^ note: required by a bound in `is_send` --> $DIR/async-await-let-else.rs:19:15 | @@ -53,9 +66,8 @@ note: future is not `Send` as this value is used across an await --> $DIR/async-await-let-else.rs:33:28 | LL | (Rc::new(()), bar().await); - | ----------- ^^^^^^ - `Rc::new(())` is later dropped here - | | | - | | await occurs here, with `Rc::new(())` maybe used later + | ----------- ^^^^^^ await occurs here, with `Rc::new(())` maybe used later + | | | has type `Rc<()>` which is not `Send` note: required by a bound in `is_send` --> $DIR/async-await-let-else.rs:19:15 @@ -77,9 +89,6 @@ LL | let r = Rc::new(()); | - has type `Rc<()>` which is not `Send` LL | bar().await; | ^^^^^^ await occurs here, with `r` maybe used later -... -LL | }; - | - `r` is later dropped here note: required by a bound in `is_send` --> $DIR/async-await-let-else.rs:19:15 | @@ -88,3 +97,4 @@ LL | fn is_send(_: T) {} error: aborting due to 4 previous errors +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/async-error-span.drop_tracking.stderr b/tests/ui/async-await/async-error-span.drop_tracking.stderr index 083da1cec73..c6257cb324d 100644 --- a/tests/ui/async-await/async-error-span.drop_tracking.stderr +++ b/tests/ui/async-await/async-error-span.drop_tracking.stderr @@ -14,7 +14,7 @@ LL | let a; | ^ cannot infer type | note: the type is part of the `async fn` body because of this `await` - --> $DIR/async-error-span.rs:17:17 + --> $DIR/async-error-span.rs:19:17 | LL | get_future().await; | ^^^^^^ diff --git a/tests/ui/async-await/async-error-span.drop_tracking_mir.stderr b/tests/ui/async-await/async-error-span.drop_tracking_mir.stderr index 083da1cec73..2f29ee6cdb0 100644 --- a/tests/ui/async-await/async-error-span.drop_tracking_mir.stderr +++ b/tests/ui/async-await/async-error-span.drop_tracking_mir.stderr @@ -7,19 +7,18 @@ LL | fn get_future() -> impl Future { = help: the trait `Future` is not implemented for `()` = note: () must be a future or must implement `IntoFuture` to be awaited -error[E0698]: type inside `async fn` body must be known in this context +error[E0282]: type annotations needed --> $DIR/async-error-span.rs:16:9 | LL | let a; - | ^ cannot infer type + | ^ | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/async-error-span.rs:17:17 +help: consider giving `a` an explicit type | -LL | get_future().await; - | ^^^^^^ +LL | let a: /* Type */; + | ++++++++++++ error: aborting due to 2 previous errors -Some errors have detailed explanations: E0277, E0698. +Some errors have detailed explanations: E0277, E0282. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/async-error-span.no_drop_tracking.stderr b/tests/ui/async-await/async-error-span.no_drop_tracking.stderr index 083da1cec73..c6257cb324d 100644 --- a/tests/ui/async-await/async-error-span.no_drop_tracking.stderr +++ b/tests/ui/async-await/async-error-span.no_drop_tracking.stderr @@ -14,7 +14,7 @@ LL | let a; | ^ cannot infer type | note: the type is part of the `async fn` body because of this `await` - --> $DIR/async-error-span.rs:17:17 + --> $DIR/async-error-span.rs:19:17 | LL | get_future().await; | ^^^^^^ diff --git a/tests/ui/async-await/async-error-span.rs b/tests/ui/async-await/async-error-span.rs index 29b58ebc3a4..c9ecf359e3d 100644 --- a/tests/ui/async-await/async-error-span.rs +++ b/tests/ui/async-await/async-error-span.rs @@ -13,7 +13,9 @@ fn get_future() -> impl Future { } async fn foo() { - let a; //~ ERROR type inside `async fn` body must be known in this context + let a; + //[no_drop_tracking,drop_tracking]~^ ERROR type inside `async fn` body must be known in this context + //[drop_tracking_mir]~^^ ERROR type annotations needed get_future().await; } diff --git a/tests/ui/async-await/async-error-span.stderr b/tests/ui/async-await/async-error-span.stderr deleted file mode 100644 index 083da1cec73..00000000000 --- a/tests/ui/async-await/async-error-span.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0277]: `()` is not a future - --> $DIR/async-error-span.rs:10:20 - | -LL | fn get_future() -> impl Future { - | ^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not a future - | - = help: the trait `Future` is not implemented for `()` - = note: () must be a future or must implement `IntoFuture` to be awaited - -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/async-error-span.rs:16:9 - | -LL | let a; - | ^ cannot infer type - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/async-error-span.rs:17:17 - | -LL | get_future().await; - | ^^^^^^ - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0277, E0698. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/async-fn-nonsend.drop_tracking_mir.stderr b/tests/ui/async-await/async-fn-nonsend.drop_tracking_mir.stderr index 5cec21d890e..57a01280145 100644 --- a/tests/ui/async-await/async-fn-nonsend.drop_tracking_mir.stderr +++ b/tests/ui/async-await/async-fn-nonsend.drop_tracking_mir.stderr @@ -1,26 +1,3 @@ -error: future cannot be sent between threads safely - --> $DIR/async-fn-nonsend.rs:70:17 - | -LL | assert_send(local_dropped_before_await()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `local_dropped_before_await` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:27:10 - | -LL | let x = non_send(); - | - has type `impl Debug` which is not `Send` -LL | drop(x); -LL | fut().await; - | ^^^^^^ await occurs here, with `x` maybe used later -LL | } - | - `x` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/async-fn-nonsend.rs:67:24 - | -LL | fn assert_send(_: impl Send) {} - | ^^^^ required by this bound in `assert_send` - error: future cannot be sent between threads safely --> $DIR/async-fn-nonsend.rs:72:17 | @@ -32,12 +9,9 @@ note: future is not `Send` as this value is used across an await --> $DIR/async-fn-nonsend.rs:36:25 | LL | match Some(non_send()) { - | ---------- has type `impl Debug` which is not `Send` + | ---------------- has type `Option` which is not `Send` LL | Some(_) => fut().await, - | ^^^^^^ await occurs here, with `non_send()` maybe used later -... -LL | } - | - `non_send()` is later dropped here + | ^^^^^^ await occurs here, with `Some(non_send())` maybe used later note: required by a bound in `assert_send` --> $DIR/async-fn-nonsend.rs:67:24 | @@ -59,62 +33,11 @@ LL | let f: &mut std::fmt::Formatter = &mut get_formatter(); ... LL | fut().await; | ^^^^^^ await occurs here, with `get_formatter()` maybe used later -LL | } -LL | } - | - `get_formatter()` is later dropped here note: required by a bound in `assert_send` --> $DIR/async-fn-nonsend.rs:67:24 | LL | fn assert_send(_: impl Send) {} | ^^^^ required by this bound in `assert_send` -error: future cannot be sent between threads safely - --> $DIR/async-fn-nonsend.rs:76:17 - | -LL | assert_send(non_sync_with_method_call_panic()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `non_sync_with_method_call_panic` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `dyn std::fmt::Write` -note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:56:14 - | -LL | let f: &mut std::fmt::Formatter = panic!(); - | - has type `&mut Formatter<'_>` which is not `Send` -LL | if non_sync().fmt(f).unwrap() == () { -LL | fut().await; - | ^^^^^^ await occurs here, with `f` maybe used later -LL | } -LL | } - | - `f` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/async-fn-nonsend.rs:67:24 - | -LL | fn assert_send(_: impl Send) {} - | ^^^^ required by this bound in `assert_send` - -error: future cannot be sent between threads safely - --> $DIR/async-fn-nonsend.rs:78:17 - | -LL | assert_send(non_sync_with_method_call_infinite_loop()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `non_sync_with_method_call_infinite_loop` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `dyn std::fmt::Write` -note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:63:14 - | -LL | let f: &mut std::fmt::Formatter = loop {}; - | - has type `&mut Formatter<'_>` which is not `Send` -LL | if non_sync().fmt(f).unwrap() == () { -LL | fut().await; - | ^^^^^^ await occurs here, with `f` maybe used later -LL | } -LL | } - | - `f` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/async-fn-nonsend.rs:67:24 - | -LL | fn assert_send(_: impl Send) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 5 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/async-await/async-fn-nonsend.rs b/tests/ui/async-await/async-fn-nonsend.rs index 77c957d0592..ed440bd0182 100644 --- a/tests/ui/async-await/async-fn-nonsend.rs +++ b/tests/ui/async-await/async-fn-nonsend.rs @@ -68,13 +68,13 @@ fn assert_send(_: impl Send) {} pub fn pass_assert() { assert_send(local_dropped_before_await()); - //[no_drop_tracking,drop_tracking_mir]~^ ERROR future cannot be sent between threads safely + //[no_drop_tracking]~^ ERROR future cannot be sent between threads safely assert_send(non_send_temporary_in_match()); //~^ ERROR future cannot be sent between threads safely assert_send(non_sync_with_method_call()); //~^ ERROR future cannot be sent between threads safely assert_send(non_sync_with_method_call_panic()); - //[no_drop_tracking,drop_tracking_mir]~^ ERROR future cannot be sent between threads safely + //[no_drop_tracking]~^ ERROR future cannot be sent between threads safely assert_send(non_sync_with_method_call_infinite_loop()); - //[no_drop_tracking,drop_tracking_mir]~^ ERROR future cannot be sent between threads safely + //[no_drop_tracking]~^ ERROR future cannot be sent between threads safely } diff --git a/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking_mir.stderr b/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking_mir.stderr index e2bba812d05..b89d8680407 100644 --- a/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking_mir.stderr +++ b/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking_mir.stderr @@ -13,8 +13,6 @@ LL | let mut info = self.info_result.clone(); ... LL | let _ = send_element(element).await; | ^^^^^^ await occurs here, with `mut info` maybe used later -LL | } - | - `mut info` is later dropped here note: required by a bound in `assert_send` --> $DIR/drop-track-field-assign-nonsend.rs:40:19 | diff --git a/tests/ui/async-await/field-assign-nonsend.drop_tracking_mir.stderr b/tests/ui/async-await/field-assign-nonsend.drop_tracking_mir.stderr index ac461a671a8..8c9d14d624c 100644 --- a/tests/ui/async-await/field-assign-nonsend.drop_tracking_mir.stderr +++ b/tests/ui/async-await/field-assign-nonsend.drop_tracking_mir.stderr @@ -13,8 +13,6 @@ LL | let mut info = self.info_result.clone(); ... LL | let _ = send_element(element).await; | ^^^^^^ await occurs here, with `mut info` maybe used later -LL | } - | - `mut info` is later dropped here note: required by a bound in `assert_send` --> $DIR/field-assign-nonsend.rs:40:19 | diff --git a/tests/ui/async-await/issue-64130-1-sync.drop_tracking.stderr b/tests/ui/async-await/issue-64130-1-sync.drop_tracking.stderr index 8d5169a6302..c4c7f26c7c7 100644 --- a/tests/ui/async-await/issue-64130-1-sync.drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-1-sync.drop_tracking.stderr @@ -1,5 +1,5 @@ error: future cannot be shared between threads safely - --> $DIR/issue-64130-1-sync.rs:24:13 + --> $DIR/issue-64130-1-sync.rs:25:13 | LL | is_sync(bar()); | ^^^^^ future returned by `bar` is not `Sync` @@ -12,6 +12,7 @@ LL | let x = Foo; | - has type `Foo` which is not `Sync` LL | baz().await; | ^^^^^^ await occurs here, with `x` maybe used later +LL | drop(x); LL | } | - `x` is later dropped here note: required by a bound in `is_sync` diff --git a/tests/ui/async-await/issue-64130-1-sync.drop_tracking_mir.stderr b/tests/ui/async-await/issue-64130-1-sync.drop_tracking_mir.stderr index 8d5169a6302..6f43b568a7a 100644 --- a/tests/ui/async-await/issue-64130-1-sync.drop_tracking_mir.stderr +++ b/tests/ui/async-await/issue-64130-1-sync.drop_tracking_mir.stderr @@ -1,5 +1,5 @@ error: future cannot be shared between threads safely - --> $DIR/issue-64130-1-sync.rs:24:13 + --> $DIR/issue-64130-1-sync.rs:25:13 | LL | is_sync(bar()); | ^^^^^ future returned by `bar` is not `Sync` @@ -12,8 +12,6 @@ LL | let x = Foo; | - has type `Foo` which is not `Sync` LL | baz().await; | ^^^^^^ await occurs here, with `x` maybe used later -LL | } - | - `x` is later dropped here note: required by a bound in `is_sync` --> $DIR/issue-64130-1-sync.rs:14:15 | diff --git a/tests/ui/async-await/issue-64130-1-sync.no_drop_tracking.stderr b/tests/ui/async-await/issue-64130-1-sync.no_drop_tracking.stderr index 8d5169a6302..c4c7f26c7c7 100644 --- a/tests/ui/async-await/issue-64130-1-sync.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-1-sync.no_drop_tracking.stderr @@ -1,5 +1,5 @@ error: future cannot be shared between threads safely - --> $DIR/issue-64130-1-sync.rs:24:13 + --> $DIR/issue-64130-1-sync.rs:25:13 | LL | is_sync(bar()); | ^^^^^ future returned by `bar` is not `Sync` @@ -12,6 +12,7 @@ LL | let x = Foo; | - has type `Foo` which is not `Sync` LL | baz().await; | ^^^^^^ await occurs here, with `x` maybe used later +LL | drop(x); LL | } | - `x` is later dropped here note: required by a bound in `is_sync` diff --git a/tests/ui/async-await/issue-64130-1-sync.rs b/tests/ui/async-await/issue-64130-1-sync.rs index 67c99c48172..44646e0e5f2 100644 --- a/tests/ui/async-await/issue-64130-1-sync.rs +++ b/tests/ui/async-await/issue-64130-1-sync.rs @@ -16,6 +16,7 @@ fn is_sync(t: T) { } async fn bar() { let x = Foo; baz().await; + drop(x); } async fn baz() { } diff --git a/tests/ui/async-await/issue-64130-2-send.drop_tracking.stderr b/tests/ui/async-await/issue-64130-2-send.drop_tracking.stderr index f6505cad69e..b6a73c2a5cb 100644 --- a/tests/ui/async-await/issue-64130-2-send.drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-2-send.drop_tracking.stderr @@ -4,12 +4,12 @@ error: future cannot be sent between threads safely LL | is_send(bar()); | ^^^^^ future returned by `bar` is not `Send` | - = help: within `impl Future`, the trait `Send` is not implemented for `Foo` + = note: the trait bound `Unique: Send` is not satisfied note: future is not `Send` as this value is used across an await --> $DIR/issue-64130-2-send.rs:18:10 | -LL | let x = Foo; - | - has type `Foo` which is not `Send` +LL | let x = Box::new(Foo); + | - has type `Box` which is not `Send` LL | baz().await; | ^^^^^^ await occurs here, with `x` maybe used later LL | } @@ -19,6 +19,10 @@ note: required by a bound in `is_send` | LL | fn is_send(t: T) { } | ^^^^ required by this bound in `is_send` +help: consider borrowing here + | +LL | is_send(&bar()); + | + error: aborting due to previous error diff --git a/tests/ui/async-await/issue-64130-2-send.drop_tracking_mir.stderr b/tests/ui/async-await/issue-64130-2-send.drop_tracking_mir.stderr index f6505cad69e..560560f6036 100644 --- a/tests/ui/async-await/issue-64130-2-send.drop_tracking_mir.stderr +++ b/tests/ui/async-await/issue-64130-2-send.drop_tracking_mir.stderr @@ -4,21 +4,23 @@ error: future cannot be sent between threads safely LL | is_send(bar()); | ^^^^^ future returned by `bar` is not `Send` | - = help: within `impl Future`, the trait `Send` is not implemented for `Foo` + = note: the trait bound `Unique: Send` is not satisfied note: future is not `Send` as this value is used across an await --> $DIR/issue-64130-2-send.rs:18:10 | -LL | let x = Foo; - | - has type `Foo` which is not `Send` +LL | let x = Box::new(Foo); + | - has type `Box` which is not `Send` LL | baz().await; | ^^^^^^ await occurs here, with `x` maybe used later -LL | } - | - `x` is later dropped here note: required by a bound in `is_send` --> $DIR/issue-64130-2-send.rs:14:15 | LL | fn is_send(t: T) { } | ^^^^ required by this bound in `is_send` +help: consider borrowing here + | +LL | is_send(&bar()); + | + error: aborting due to previous error diff --git a/tests/ui/async-await/issue-64130-2-send.no_drop_tracking.stderr b/tests/ui/async-await/issue-64130-2-send.no_drop_tracking.stderr index f6505cad69e..b6a73c2a5cb 100644 --- a/tests/ui/async-await/issue-64130-2-send.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-2-send.no_drop_tracking.stderr @@ -4,12 +4,12 @@ error: future cannot be sent between threads safely LL | is_send(bar()); | ^^^^^ future returned by `bar` is not `Send` | - = help: within `impl Future`, the trait `Send` is not implemented for `Foo` + = note: the trait bound `Unique: Send` is not satisfied note: future is not `Send` as this value is used across an await --> $DIR/issue-64130-2-send.rs:18:10 | -LL | let x = Foo; - | - has type `Foo` which is not `Send` +LL | let x = Box::new(Foo); + | - has type `Box` which is not `Send` LL | baz().await; | ^^^^^^ await occurs here, with `x` maybe used later LL | } @@ -19,6 +19,10 @@ note: required by a bound in `is_send` | LL | fn is_send(t: T) { } | ^^^^ required by this bound in `is_send` +help: consider borrowing here + | +LL | is_send(&bar()); + | + error: aborting due to previous error diff --git a/tests/ui/async-await/issue-64130-2-send.rs b/tests/ui/async-await/issue-64130-2-send.rs index 2cb379fe881..d6d855bac07 100644 --- a/tests/ui/async-await/issue-64130-2-send.rs +++ b/tests/ui/async-await/issue-64130-2-send.rs @@ -14,7 +14,7 @@ impl !Send for Foo {} fn is_send(t: T) { } async fn bar() { - let x = Foo; + let x = Box::new(Foo); baz().await; } diff --git a/tests/ui/async-await/issue-64130-3-other.drop_tracking.stderr b/tests/ui/async-await/issue-64130-3-other.drop_tracking.stderr index cb36a3811b2..d65aae8cc3f 100644 --- a/tests/ui/async-await/issue-64130-3-other.drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-3-other.drop_tracking.stderr @@ -10,8 +10,8 @@ LL | is_qux(bar()); note: future does not implement `Qux` as this value is used across an await --> $DIR/issue-64130-3-other.rs:21:10 | -LL | let x = Foo; - | - has type `Foo` which does not implement `Qux` +LL | let x = Box::new(Foo); + | - has type `Box` which does not implement `Qux` LL | baz().await; | ^^^^^^ await occurs here, with `x` maybe used later LL | } diff --git a/tests/ui/async-await/issue-64130-3-other.drop_tracking_mir.stderr b/tests/ui/async-await/issue-64130-3-other.drop_tracking_mir.stderr index cb36a3811b2..8fed69d9d88 100644 --- a/tests/ui/async-await/issue-64130-3-other.drop_tracking_mir.stderr +++ b/tests/ui/async-await/issue-64130-3-other.drop_tracking_mir.stderr @@ -10,12 +10,10 @@ LL | is_qux(bar()); note: future does not implement `Qux` as this value is used across an await --> $DIR/issue-64130-3-other.rs:21:10 | -LL | let x = Foo; - | - has type `Foo` which does not implement `Qux` +LL | let x = Box::new(Foo); + | - has type `Box` which does not implement `Qux` LL | baz().await; | ^^^^^^ await occurs here, with `x` maybe used later -LL | } - | - `x` is later dropped here note: required by a bound in `is_qux` --> $DIR/issue-64130-3-other.rs:17:14 | diff --git a/tests/ui/async-await/issue-64130-3-other.no_drop_tracking.stderr b/tests/ui/async-await/issue-64130-3-other.no_drop_tracking.stderr index cb36a3811b2..d65aae8cc3f 100644 --- a/tests/ui/async-await/issue-64130-3-other.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-3-other.no_drop_tracking.stderr @@ -10,8 +10,8 @@ LL | is_qux(bar()); note: future does not implement `Qux` as this value is used across an await --> $DIR/issue-64130-3-other.rs:21:10 | -LL | let x = Foo; - | - has type `Foo` which does not implement `Qux` +LL | let x = Box::new(Foo); + | - has type `Box` which does not implement `Qux` LL | baz().await; | ^^^^^^ await occurs here, with `x` maybe used later LL | } diff --git a/tests/ui/async-await/issue-64130-3-other.rs b/tests/ui/async-await/issue-64130-3-other.rs index 6c242a60e1c..92d3b7c81fb 100644 --- a/tests/ui/async-await/issue-64130-3-other.rs +++ b/tests/ui/async-await/issue-64130-3-other.rs @@ -17,7 +17,7 @@ impl !Qux for Foo {} fn is_qux(t: T) {} async fn bar() { - let x = Foo; + let x = Box::new(Foo); baz().await; } diff --git a/tests/ui/async-await/issue-64130-4-async-move.drop_tracking_mir.stderr b/tests/ui/async-await/issue-64130-4-async-move.drop_tracking_mir.stderr deleted file mode 100644 index 884619f4dd6..00000000000 --- a/tests/ui/async-await/issue-64130-4-async-move.drop_tracking_mir.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/issue-64130-4-async-move.rs:20:17 - | -LL | pub fn foo() -> impl Future + Send { - | ^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` - | - = help: the trait `Sync` is not implemented for `(dyn Any + Send + 'static)` -note: future is not `Send` as this value is used across an await - --> $DIR/issue-64130-4-async-move.rs:27:31 - | -LL | match client.status() { - | ------ has type `&Client` which is not `Send` -LL | 200 => { -LL | let _x = get().await; - | ^^^^^^ await occurs here, with `client` maybe used later -... -LL | } - | - `client` is later dropped here -help: consider moving this into a `let` binding to create a shorter lived borrow - --> $DIR/issue-64130-4-async-move.rs:25:15 - | -LL | match client.status() { - | ^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr b/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr index 884619f4dd6..0bc7cb2f2ac 100644 --- a/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr @@ -1,5 +1,5 @@ error: future cannot be sent between threads safely - --> $DIR/issue-64130-4-async-move.rs:20:17 + --> $DIR/issue-64130-4-async-move.rs:21:17 | LL | pub fn foo() -> impl Future + Send { | ^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` diff --git a/tests/ui/async-await/issue-64130-4-async-move.rs b/tests/ui/async-await/issue-64130-4-async-move.rs index 13dceabb62f..bcb297aaa02 100644 --- a/tests/ui/async-await/issue-64130-4-async-move.rs +++ b/tests/ui/async-await/issue-64130-4-async-move.rs @@ -2,6 +2,7 @@ // 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 // [drop_tracking] check-pass use std::any::Any; @@ -19,7 +20,6 @@ async fn get() {} pub fn foo() -> impl Future + Send { //[no_drop_tracking]~^ ERROR future cannot be sent between threads safely - //[drop_tracking_mir]~^^ ERROR future cannot be sent between threads safely let client = Client(Box::new(true)); async move { match client.status() { diff --git a/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking.stderr b/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking.stderr index e7a302fb3ef..fc8bcc8ae79 100644 --- a/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking.stderr +++ b/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking.stderr @@ -3,21 +3,23 @@ error: future cannot be sent between threads safely | LL | spawn(async { | ___________^ -LL | | let _a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` +LL | | let a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` LL | | AFuture.await; +LL | | drop(a); LL | | }); | |_____^ future created by async block is not `Send` | - = help: within `[async block@$DIR/issue-67252-unnamed-future.rs:21:11: 24:6]`, the trait `Send` is not implemented for `*mut ()` + = help: within `[async block@$DIR/issue-67252-unnamed-future.rs:21:11: 25:6]`, the trait `Send` is not implemented for `*mut ()` note: future is not `Send` as this value is used across an await --> $DIR/issue-67252-unnamed-future.rs:23:16 | -LL | let _a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` - | -- has type `*mut ()` which is not `Send` +LL | let a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` + | - has type `*mut ()` which is not `Send` LL | AFuture.await; - | ^^^^^^ await occurs here, with `_a` maybe used later + | ^^^^^^ await occurs here, with `a` maybe used later +LL | drop(a); LL | }); - | - `_a` is later dropped here + | - `a` is later dropped here note: required by a bound in `spawn` --> $DIR/issue-67252-unnamed-future.rs:9:13 | diff --git a/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking_mir.stderr b/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking_mir.stderr index e7a302fb3ef..a3ef7add116 100644 --- a/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking_mir.stderr +++ b/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking_mir.stderr @@ -1,23 +1,17 @@ error: future cannot be sent between threads safely - --> $DIR/issue-67252-unnamed-future.rs:21:11 + --> $DIR/issue-67252-unnamed-future.rs:21:5 | -LL | spawn(async { - | ___________^ -LL | | let _a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` -LL | | AFuture.await; -LL | | }); - | |_____^ future created by async block is not `Send` +LL | spawn(async { + | ^^^^^ future created by async block is not `Send` | - = help: within `[async block@$DIR/issue-67252-unnamed-future.rs:21:11: 24:6]`, the trait `Send` is not implemented for `*mut ()` + = help: within `[async block@$DIR/issue-67252-unnamed-future.rs:21:11: 25:6]`, the trait `Send` is not implemented for `*mut ()` note: future is not `Send` as this value is used across an await --> $DIR/issue-67252-unnamed-future.rs:23:16 | -LL | let _a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` - | -- has type `*mut ()` which is not `Send` +LL | let a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` + | - has type `*mut ()` which is not `Send` LL | AFuture.await; - | ^^^^^^ await occurs here, with `_a` maybe used later -LL | }); - | - `_a` is later dropped here + | ^^^^^^ await occurs here, with `a` maybe used later note: required by a bound in `spawn` --> $DIR/issue-67252-unnamed-future.rs:9:13 | diff --git a/tests/ui/async-await/issue-67252-unnamed-future.no_drop_tracking.stderr b/tests/ui/async-await/issue-67252-unnamed-future.no_drop_tracking.stderr index e7a302fb3ef..fc8bcc8ae79 100644 --- a/tests/ui/async-await/issue-67252-unnamed-future.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-67252-unnamed-future.no_drop_tracking.stderr @@ -3,21 +3,23 @@ error: future cannot be sent between threads safely | LL | spawn(async { | ___________^ -LL | | let _a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` +LL | | let a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` LL | | AFuture.await; +LL | | drop(a); LL | | }); | |_____^ future created by async block is not `Send` | - = help: within `[async block@$DIR/issue-67252-unnamed-future.rs:21:11: 24:6]`, the trait `Send` is not implemented for `*mut ()` + = help: within `[async block@$DIR/issue-67252-unnamed-future.rs:21:11: 25:6]`, the trait `Send` is not implemented for `*mut ()` note: future is not `Send` as this value is used across an await --> $DIR/issue-67252-unnamed-future.rs:23:16 | -LL | let _a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` - | -- has type `*mut ()` which is not `Send` +LL | let a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` + | - has type `*mut ()` which is not `Send` LL | AFuture.await; - | ^^^^^^ await occurs here, with `_a` maybe used later + | ^^^^^^ await occurs here, with `a` maybe used later +LL | drop(a); LL | }); - | - `_a` is later dropped here + | - `a` is later dropped here note: required by a bound in `spawn` --> $DIR/issue-67252-unnamed-future.rs:9:13 | diff --git a/tests/ui/async-await/issue-67252-unnamed-future.rs b/tests/ui/async-await/issue-67252-unnamed-future.rs index 658f059cf81..bb9ad77cef3 100644 --- a/tests/ui/async-await/issue-67252-unnamed-future.rs +++ b/tests/ui/async-await/issue-67252-unnamed-future.rs @@ -19,8 +19,9 @@ impl Future for AFuture{ async fn foo() { spawn(async { //~ ERROR future cannot be sent between threads safely - let _a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` + let a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` AFuture.await; + drop(a); }); } diff --git a/tests/ui/async-await/issue-68112.drop_tracking_mir.stderr b/tests/ui/async-await/issue-68112.drop_tracking_mir.stderr index 35b7341f63a..7a9242cbaf5 100644 --- a/tests/ui/async-await/issue-68112.drop_tracking_mir.stderr +++ b/tests/ui/async-await/issue-68112.drop_tracking_mir.stderr @@ -1,8 +1,8 @@ error: future cannot be sent between threads safely - --> $DIR/issue-68112.rs:37:18 + --> $DIR/issue-68112.rs:37:5 | LL | require_send(send_fut); - | ^^^^^^^^ future created by async block is not `Send` + | ^^^^^^^^^^^^ future created by async block 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 @@ -18,10 +18,10 @@ LL | fn require_send(_: impl Send) {} | ^^^^ required by this bound in `require_send` error: future cannot be sent between threads safely - --> $DIR/issue-68112.rs:46:18 + --> $DIR/issue-68112.rs:46:5 | LL | require_send(send_fut); - | ^^^^^^^^ future created by async block is not `Send` + | ^^^^^^^^^^^^ future created by async block 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 @@ -37,12 +37,10 @@ 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:65:18 + --> $DIR/issue-68112.rs:65:5 | LL | require_send(send_fut); - | ------------ ^^^^^^^^ `RefCell` cannot be shared between threads safely - | | - | required by a bound introduced by this call + | ^^^^^^^^^^^^ `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 @@ -60,7 +58,7 @@ note: required because it appears within the type `impl Future impl Future>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `ResumeTy`, `impl Future>>`, `()`, `i32`, `Ready` + = note: required because it captures the following types: `impl Future>>`, `Ready` note: required because it's used within this `async` block --> $DIR/issue-68112.rs:60:20 | diff --git a/tests/ui/async-await/issue-68112.rs b/tests/ui/async-await/issue-68112.rs index 7f0a135a159..19119ae0fc1 100644 --- a/tests/ui/async-await/issue-68112.rs +++ b/tests/ui/async-await/issue-68112.rs @@ -14,7 +14,7 @@ use std::{ fn require_send(_: impl Send) {} struct Ready(Option); -impl Future for Ready { +impl Future for Ready { type Output = T; fn poll(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll { Poll::Ready(self.0.take().unwrap()) diff --git a/tests/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr b/tests/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr index ea61daa5a16..721234aa4a7 100644 --- a/tests/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr +++ b/tests/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr @@ -7,7 +7,7 @@ LL | fn foo(tx: std::sync::mpsc::Sender) -> impl Future + Send { = help: the trait `Sync` is not implemented for `Sender` = note: required for `&Sender` to implement `Send` note: required because it's used within this closure - --> $DIR/issue-70935-complex-spans.rs:18:13 + --> $DIR/issue-70935-complex-spans.rs:17:13 | LL | baz(|| async{ | ^^ @@ -20,7 +20,7 @@ LL | | } | |_^ = note: required because it captures the following types: `ResumeTy`, `impl Future`, `()` note: required because it's used within this `async` block - --> $DIR/issue-70935-complex-spans.rs:17:5 + --> $DIR/issue-70935-complex-spans.rs:16:5 | LL | / async move { LL | | baz(|| async{ diff --git a/tests/ui/async-await/issue-70935-complex-spans.drop_tracking_mir.stderr b/tests/ui/async-await/issue-70935-complex-spans.drop_tracking_mir.stderr index 6c48e6db457..c636be15a58 100644 --- a/tests/ui/async-await/issue-70935-complex-spans.drop_tracking_mir.stderr +++ b/tests/ui/async-await/issue-70935-complex-spans.drop_tracking_mir.stderr @@ -1,21 +1,34 @@ -error: future cannot be sent between threads safely +error[E0277]: `Sender` cannot be shared between threads safely --> $DIR/issue-70935-complex-spans.rs:13:45 | LL | fn foo(tx: std::sync::mpsc::Sender) -> impl Future + Send { - | ^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` + | ^^^^^^^^^^^^^^^^^^ `Sender` cannot be shared between threads safely | = help: the trait `Sync` is not implemented for `Sender` -note: future is not `Send` as this value is used across an await - --> $DIR/issue-70935-complex-spans.rs:20:11 + = note: required for `&Sender` to implement `Send` +note: required because it's used within this closure + --> $DIR/issue-70935-complex-spans.rs:17:13 | -LL | baz(|| async{ - | _____________- +LL | baz(|| async{ + | ^^ +note: required because it's used within this `async fn` body + --> $DIR/issue-70935-complex-spans.rs:10:67 + | +LL | async fn baz(_c: impl FnMut() -> T) where T: Future { + | ___________________________________________________________________^ +LL | | } + | |_^ + = note: required because it captures the following types: `impl Future` +note: required because it's used within this `async` block + --> $DIR/issue-70935-complex-spans.rs:16:5 + | +LL | / async move { +LL | | baz(|| async{ LL | | foo(tx.clone()); LL | | }).await; - | | - ^^^^^^- the value is later dropped here - | | | | - | |_________| await occurs here, with the value maybe used later - | has type `[closure@$DIR/issue-70935-complex-spans.rs:18:13: 18:15]` which is not `Send` +LL | | } + | |_____^ error: aborting due to previous error +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/issue-70935-complex-spans.no_drop_tracking.stderr b/tests/ui/async-await/issue-70935-complex-spans.no_drop_tracking.stderr index 6c48e6db457..8036d82daa4 100644 --- a/tests/ui/async-await/issue-70935-complex-spans.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-70935-complex-spans.no_drop_tracking.stderr @@ -6,7 +6,7 @@ LL | fn foo(tx: std::sync::mpsc::Sender) -> impl Future + Send { | = help: the trait `Sync` is not implemented for `Sender` note: future is not `Send` as this value is used across an await - --> $DIR/issue-70935-complex-spans.rs:20:11 + --> $DIR/issue-70935-complex-spans.rs:19:11 | LL | baz(|| async{ | _____________- @@ -15,7 +15,7 @@ LL | | }).await; | | - ^^^^^^- the value is later dropped here | | | | | |_________| await occurs here, with the value maybe used later - | has type `[closure@$DIR/issue-70935-complex-spans.rs:18:13: 18:15]` which is not `Send` + | has type `[closure@$DIR/issue-70935-complex-spans.rs:17:13: 17:15]` which is not `Send` error: aborting due to previous error diff --git a/tests/ui/async-await/issue-70935-complex-spans.rs b/tests/ui/async-await/issue-70935-complex-spans.rs index 76cd293b05b..78625bd393d 100644 --- a/tests/ui/async-await/issue-70935-complex-spans.rs +++ b/tests/ui/async-await/issue-70935-complex-spans.rs @@ -12,8 +12,7 @@ async fn baz(_c: impl FnMut() -> T) where T: Future { fn foo(tx: std::sync::mpsc::Sender) -> impl Future + Send { //[no_drop_tracking]~^ ERROR future cannot be sent between threads safely - //[drop_tracking]~^^ ERROR `Sender` cannot be shared between threads - //[drop_tracking_mir]~^^^ ERROR future cannot be sent between threads safely + //[drop_tracking,drop_tracking_mir]~^^ ERROR `Sender` cannot be shared between threads async move { baz(|| async{ foo(tx.clone()); diff --git a/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.drop_tracking_mir.stderr b/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.drop_tracking_mir.stderr deleted file mode 100644 index 8b75d95a68e..00000000000 --- a/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.drop_tracking_mir.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/issue-65436-raw-ptr-not-send.rs:16:17 - | -LL | assert_send(async { - | _________________^ -LL | | -LL | | -LL | | bar(Foo(std::ptr::null())).await; -LL | | }) - | |_____^ future created by async block is not `Send` - | - = help: within `[async block@$DIR/issue-65436-raw-ptr-not-send.rs:16:17: 20:6]`, the trait `Send` is not implemented for `*const u8` -note: future is not `Send` as this value is used across an await - --> $DIR/issue-65436-raw-ptr-not-send.rs:19:35 - | -LL | bar(Foo(std::ptr::null())).await; - | ---------------- ^^^^^^- `std::ptr::null()` is later dropped here - | | | - | | await occurs here, with `std::ptr::null()` maybe used later - | has type `*const u8` which is not `Send` -help: consider moving this into a `let` binding to create a shorter lived borrow - --> $DIR/issue-65436-raw-ptr-not-send.rs:19:13 - | -LL | bar(Foo(std::ptr::null())).await; - | ^^^^^^^^^^^^^^^^^^^^^ -note: required by a bound in `assert_send` - --> $DIR/issue-65436-raw-ptr-not-send.rs:13:19 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr b/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr index 8b75d95a68e..8745bdd973b 100644 --- a/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr +++ b/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr @@ -1,15 +1,14 @@ error: future cannot be sent between threads safely - --> $DIR/issue-65436-raw-ptr-not-send.rs:16:17 + --> $DIR/issue-65436-raw-ptr-not-send.rs:17:17 | LL | assert_send(async { | _________________^ LL | | -LL | | LL | | bar(Foo(std::ptr::null())).await; LL | | }) | |_____^ future created by async block is not `Send` | - = help: within `[async block@$DIR/issue-65436-raw-ptr-not-send.rs:16:17: 20:6]`, the trait `Send` is not implemented for `*const u8` + = help: within `[async block@$DIR/issue-65436-raw-ptr-not-send.rs:17:17: 20:6]`, the trait `Send` is not implemented for `*const u8` note: future is not `Send` as this value is used across an await --> $DIR/issue-65436-raw-ptr-not-send.rs:19:35 | @@ -24,7 +23,7 @@ help: consider moving this into a `let` binding to create a shorter lived borrow LL | bar(Foo(std::ptr::null())).await; | ^^^^^^^^^^^^^^^^^^^^^ note: required by a bound in `assert_send` - --> $DIR/issue-65436-raw-ptr-not-send.rs:13:19 + --> $DIR/issue-65436-raw-ptr-not-send.rs:14:19 | LL | fn assert_send(_: T) {} | ^^^^ required by this bound in `assert_send` diff --git a/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.rs b/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.rs index 630e0e4eebe..d7ef929517c 100644 --- a/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.rs +++ b/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.rs @@ -3,6 +3,7 @@ // [drop_tracking] compile-flags: -Zdrop-tracking // [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // [drop_tracking] check-pass +// [drop_tracking_mir] check-pass struct Foo(*const u8); @@ -15,7 +16,6 @@ fn assert_send(_: T) {} fn main() { assert_send(async { //[no_drop_tracking]~^ ERROR future cannot be sent between threads safely - //[drop_tracking_mir]~^^ ERROR future cannot be sent between threads safely bar(Foo(std::ptr::null())).await; }) } diff --git a/tests/ui/async-await/send-bound-async-closure.rs b/tests/ui/async-await/send-bound-async-closure.rs new file mode 100644 index 00000000000..4e9e7309be0 --- /dev/null +++ b/tests/ui/async-await/send-bound-async-closure.rs @@ -0,0 +1,37 @@ +// edition: 2021 +// check-pass + +// This test verifies that we do not create a query cycle when typechecking has several inference +// variables that point to the same generator interior type. + +use std::future::Future; +use std::pin::Pin; +use std::task::{Context, Poll}; + +type ChannelTask = Pin + Send>>; + +pub fn register_message_type() -> ChannelTask { + Box::pin(async move { + let f = |__cx: &mut Context<'_>| Poll::<()>::Pending; + PollFn { f }.await + }) +} + +struct PollFn { + f: F, +} + +impl Unpin for PollFn {} + +impl Future for PollFn +where + F: FnMut(&mut Context<'_>) -> Poll, +{ + type Output = T; + + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + (&mut self.f)(cx) + } +} + +fn main() {} diff --git a/tests/ui/async-await/unresolved_type_param.drop_tracking.stderr b/tests/ui/async-await/unresolved_type_param.drop_tracking.stderr index 64a31b5fc32..912e2b34c05 100644 --- a/tests/ui/async-await/unresolved_type_param.drop_tracking.stderr +++ b/tests/ui/async-await/unresolved_type_param.drop_tracking.stderr @@ -1,35 +1,35 @@ error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:13:5 + --> $DIR/unresolved_type_param.rs:12:5 | LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:13:10 + --> $DIR/unresolved_type_param.rs:12:10 | LL | bar().await; | ^^^^^^ error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:13:5 + --> $DIR/unresolved_type_param.rs:12:5 | LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:13:10 + --> $DIR/unresolved_type_param.rs:12:10 | LL | bar().await; | ^^^^^^ error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:13:5 + --> $DIR/unresolved_type_param.rs:12:5 | LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:13:10 + --> $DIR/unresolved_type_param.rs:12:10 | LL | bar().await; | ^^^^^^ diff --git a/tests/ui/async-await/unresolved_type_param.drop_tracking_mir.stderr b/tests/ui/async-await/unresolved_type_param.drop_tracking_mir.stderr index 64a31b5fc32..95c79946831 100644 --- a/tests/ui/async-await/unresolved_type_param.drop_tracking_mir.stderr +++ b/tests/ui/async-await/unresolved_type_param.drop_tracking_mir.stderr @@ -1,39 +1,14 @@ -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:13:5 +error[E0282]: type annotations needed + --> $DIR/unresolved_type_param.rs:12:5 | LL | bar().await; - | ^^^ cannot infer type for type parameter `T` declared on the function `bar` + | ^^^ cannot infer type of the type parameter `T` declared on the function `bar` | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:13:10 +help: consider specifying the generic argument | -LL | bar().await; - | ^^^^^^ +LL | bar::().await; + | +++++ -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:13:5 - | -LL | bar().await; - | ^^^ cannot infer type for type parameter `T` declared on the function `bar` - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:13:10 - | -LL | bar().await; - | ^^^^^^ +error: aborting due to previous error -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:13:5 - | -LL | bar().await; - | ^^^ cannot infer type for type parameter `T` declared on the function `bar` - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:13:10 - | -LL | bar().await; - | ^^^^^^ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0698`. +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/async-await/unresolved_type_param.no_drop_tracking.stderr b/tests/ui/async-await/unresolved_type_param.no_drop_tracking.stderr index 64a31b5fc32..16d618caa57 100644 --- a/tests/ui/async-await/unresolved_type_param.no_drop_tracking.stderr +++ b/tests/ui/async-await/unresolved_type_param.no_drop_tracking.stderr @@ -1,39 +1,63 @@ error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:13:5 + --> $DIR/unresolved_type_param.rs:12:5 | LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:13:10 + --> $DIR/unresolved_type_param.rs:12:10 | LL | bar().await; | ^^^^^^ error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:13:5 + --> $DIR/unresolved_type_param.rs:12:5 | LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:13:10 + --> $DIR/unresolved_type_param.rs:12:10 | LL | bar().await; | ^^^^^^ error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:13:5 + --> $DIR/unresolved_type_param.rs:12:5 | LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:13:10 + --> $DIR/unresolved_type_param.rs:12:10 | LL | bar().await; | ^^^^^^ -error: aborting due to 3 previous errors +error[E0698]: type inside `async fn` body must be known in this context + --> $DIR/unresolved_type_param.rs:12:5 + | +LL | bar().await; + | ^^^ cannot infer type for type parameter `T` declared on the function `bar` + | +note: the type is part of the `async fn` body because of this `await` + --> $DIR/unresolved_type_param.rs:12:10 + | +LL | bar().await; + | ^^^^^^ + +error[E0698]: type inside `async fn` body must be known in this context + --> $DIR/unresolved_type_param.rs:12:5 + | +LL | bar().await; + | ^^^ cannot infer type for type parameter `T` declared on the function `bar` + | +note: the type is part of the `async fn` body because of this `await` + --> $DIR/unresolved_type_param.rs:12:10 + | +LL | bar().await; + | ^^^^^^ + +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0698`. diff --git a/tests/ui/async-await/unresolved_type_param.rs b/tests/ui/async-await/unresolved_type_param.rs index c9e77f0c3ea..ca0a92b9434 100644 --- a/tests/ui/async-await/unresolved_type_param.rs +++ b/tests/ui/async-await/unresolved_type_param.rs @@ -5,23 +5,32 @@ // Error message should pinpoint the type parameter T as needing to be bound // (rather than give a general error message) // edition:2018 -// compile-flags: -Zdrop-tracking async fn bar() -> () {} async fn foo() { bar().await; - //~^ ERROR type inside `async fn` body must be known in this context - //~| ERROR type inside `async fn` body must be known in this context - //~| ERROR type inside `async fn` body must be known in this context - //~| NOTE cannot infer type for type parameter `T` - //~| NOTE cannot infer type for type parameter `T` - //~| NOTE cannot infer type for type parameter `T` - //~| NOTE the type is part of the `async fn` body because of this `await` - //~| NOTE the type is part of the `async fn` body because of this `await` - //~| NOTE the type is part of the `async fn` body because of this `await` - //~| NOTE in this expansion of desugaring of `await` - //~| NOTE in this expansion of desugaring of `await` - //~| NOTE in this expansion of desugaring of `await` + //[drop_tracking_mir]~^ ERROR type annotations needed + //[drop_tracking_mir]~| NOTE cannot infer type of the type parameter `T` + //[no_drop_tracking,drop_tracking]~^^^ ERROR type inside `async fn` body must be known in this context + //[no_drop_tracking,drop_tracking]~| ERROR type inside `async fn` body must be known in this context + //[no_drop_tracking,drop_tracking]~| ERROR type inside `async fn` body must be known in this context + //[no_drop_tracking,drop_tracking]~| NOTE cannot infer type for type parameter `T` + //[no_drop_tracking,drop_tracking]~| NOTE cannot infer type for type parameter `T` + //[no_drop_tracking,drop_tracking]~| NOTE cannot infer type for type parameter `T` + //[no_drop_tracking,drop_tracking]~| NOTE the type is part of the `async fn` body because of this `await` + //[no_drop_tracking,drop_tracking]~| NOTE the type is part of the `async fn` body because of this `await` + //[no_drop_tracking,drop_tracking]~| NOTE the type is part of the `async fn` body because of this `await` + //[no_drop_tracking,drop_tracking]~| NOTE in this expansion of desugaring of `await` + //[no_drop_tracking,drop_tracking]~| NOTE in this expansion of desugaring of `await` + //[no_drop_tracking,drop_tracking]~| NOTE in this expansion of desugaring of `await` + //[no_drop_tracking]~^^^^^^^^^^^^^^^ ERROR type inside `async fn` body must be known in this context + //[no_drop_tracking]~| ERROR type inside `async fn` body must be known in this context + //[no_drop_tracking]~| NOTE cannot infer type for type parameter `T` + //[no_drop_tracking]~| NOTE cannot infer type for type parameter `T` + //[no_drop_tracking]~| NOTE the type is part of the `async fn` body because of this `await` + //[no_drop_tracking]~| NOTE the type is part of the `async fn` body because of this `await` + //[no_drop_tracking]~| NOTE in this expansion of desugaring of `await` + //[no_drop_tracking]~| NOTE in this expansion of desugaring of `await` } fn main() {} 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 index 1a05bfe4f0e..35698a98dbd 100644 --- a/tests/ui/generator/drop-tracking-parent-expression.drop_tracking_mir.stderr +++ b/tests/ui/generator/drop-tracking-parent-expression.drop_tracking_mir.stderr @@ -1,91 +1,8 @@ error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:27:25 + --> $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 `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` + | ^^^^^^^^^^^ generator is not `Send` ... LL | / type_combinations!( LL | | // OK @@ -105,8 +22,6 @@ LL | let g = move || match drop($name::Client { ..$name::Client::d ... 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 @@ -124,51 +39,10 @@ LL | fn assert_send(_thing: T) {} = 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 + --> $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: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` + | ^^^^^^^^^^^ generator is not `Send` ... LL | / type_combinations!( LL | | // OK @@ -188,8 +62,6 @@ LL | let g = move || match drop($name::Client { ..$name::Client::d ... 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 @@ -207,51 +79,10 @@ LL | fn assert_send(_thing: T) {} = 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 + --> $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: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` + | ^^^^^^^^^^^ generator is not `Send` ... LL | / type_combinations!( LL | | // OK @@ -271,8 +102,6 @@ LL | let g = move || match drop($name::Client { ..$name::Client::d ... 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 @@ -289,46 +118,5 @@ 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 +error: aborting due to 3 previous errors diff --git a/tests/ui/generator/drop-tracking-parent-expression.rs b/tests/ui/generator/drop-tracking-parent-expression.rs index 61e81330b09..ed9ac6d11ad 100644 --- a/tests/ui/generator/drop-tracking-parent-expression.rs +++ b/tests/ui/generator/drop-tracking-parent-expression.rs @@ -21,14 +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,drop_tracking_mir]~^^^^ 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`, @@ -38,10 +38,10 @@ macro_rules! type_combinations { _ => yield, }; assert_send(g); - //[no_drop_tracking,drop_tracking_mir]~^ ERROR cannot be sent between threads - //[no_drop_tracking,drop_tracking_mir]~| ERROR cannot be sent between threads - //[no_drop_tracking,drop_tracking_mir]~| ERROR cannot be sent between threads - //[no_drop_tracking,drop_tracking_mir]~| 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 + //[no_drop_tracking]~| ERROR cannot be sent between threads } )* } } diff --git a/tests/ui/generator/issue-57017.drop_tracking_mir.stderr b/tests/ui/generator/issue-57017.drop_tracking_mir.stderr deleted file mode 100644 index 4bba20bbae0..00000000000 --- a/tests/ui/generator/issue-57017.drop_tracking_mir.stderr +++ /dev/null @@ -1,248 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/issue-57017.rs:30: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:28: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:50: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:42: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:39:21: 39: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:40: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:50: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:30: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:28: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:50: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:42: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:39:21: 39: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:40: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:50: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:30: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:28: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:50: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:42: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:39:21: 39: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:40: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:50: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.no_drop_tracking.stderr b/tests/ui/generator/issue-57017.no_drop_tracking.stderr index 4bba20bbae0..06d2d23b9ef 100644 --- a/tests/ui/generator/issue-57017.no_drop_tracking.stderr +++ b/tests/ui/generator/issue-57017.no_drop_tracking.stderr @@ -1,5 +1,5 @@ error: generator cannot be sent between threads safely - --> $DIR/issue-57017.rs:30:25 + --> $DIR/issue-57017.rs:31:25 | LL | assert_send(g); | ^ generator is not `Send` @@ -15,7 +15,7 @@ LL | | ); | = 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:28:28 + --> $DIR/issue-57017.rs:29:28 | LL | let g = move || match drop(&$name::unsync::Client::default()) { | --------------------------------- has type `©::unsync::Client` which is not `Send` @@ -33,14 +33,14 @@ LL | | } LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:50:19 + --> $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:42:25 + --> $DIR/issue-57017.rs:43:25 | LL | assert_send(g); | ^ generator is not `Send` @@ -54,9 +54,9 @@ LL | | } LL | | ); | |_____- in this macro invocation | - = help: within `[generator@$DIR/issue-57017.rs:39:21: 39:28]`, the trait `Send` is not implemented for `copy::unsend::Client` + = 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:40:28 + --> $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` @@ -74,14 +74,14 @@ LL | | } LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:50:19 + --> $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:30:25 + --> $DIR/issue-57017.rs:31:25 | LL | assert_send(g); | ^ generator is not `Send` @@ -97,7 +97,7 @@ LL | | ); | = 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:28:28 + --> $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` @@ -115,14 +115,14 @@ LL | | } LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:50:19 + --> $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:42:25 + --> $DIR/issue-57017.rs:43:25 | LL | assert_send(g); | ^ generator is not `Send` @@ -136,9 +136,9 @@ LL | | } LL | | ); | |_____- in this macro invocation | - = help: within `[generator@$DIR/issue-57017.rs:39:21: 39:28]`, the trait `Send` is not implemented for `derived_drop::unsend::Client` + = 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:40:28 + --> $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` @@ -156,14 +156,14 @@ LL | | } LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:50:19 + --> $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:30:25 + --> $DIR/issue-57017.rs:31:25 | LL | assert_send(g); | ^ generator is not `Send` @@ -179,7 +179,7 @@ LL | | ); | = 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:28:28 + --> $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` @@ -197,14 +197,14 @@ LL | | } LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:50:19 + --> $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:42:25 + --> $DIR/issue-57017.rs:43:25 | LL | assert_send(g); | ^ generator is not `Send` @@ -218,9 +218,9 @@ LL | | } LL | | ); | |_____- in this macro invocation | - = help: within `[generator@$DIR/issue-57017.rs:39:21: 39:28]`, the trait `Send` is not implemented for `significant_drop::unsend::Client` + = 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:40:28 + --> $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` @@ -238,7 +238,7 @@ LL | | } LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:50:19 + --> $DIR/issue-57017.rs:51:19 | LL | fn assert_send(_thing: T) {} | ^^^^ required by this bound in `assert_send` diff --git a/tests/ui/generator/issue-57017.rs b/tests/ui/generator/issue-57017.rs index bcd6d226788..03b00ac99ad 100644 --- a/tests/ui/generator/issue-57017.rs +++ b/tests/ui/generator/issue-57017.rs @@ -2,6 +2,7 @@ // [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)] @@ -28,9 +29,9 @@ macro_rules! type_combinations { _status => yield, }; assert_send(g); - //[no_drop_tracking,drop_tracking_mir]~^ ERROR generator cannot be sent between threads safely - //[no_drop_tracking,drop_tracking_mir]~| ERROR generator cannot be sent between threads safely - //[no_drop_tracking,drop_tracking_mir]~| 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 + //[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 @@ -40,9 +41,9 @@ macro_rules! type_combinations { _status => yield, }; assert_send(g); - //[no_drop_tracking,drop_tracking_mir]~^ ERROR generator cannot be sent between threads safely - //[no_drop_tracking,drop_tracking_mir]~| ERROR generator cannot be sent between threads safely - //[no_drop_tracking,drop_tracking_mir]~| 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 + //[no_drop_tracking]~| ERROR generator cannot be sent between threads safely } )* } } diff --git a/tests/ui/generator/issue-57478.drop_tracking_mir.stderr b/tests/ui/generator/issue-57478.drop_tracking_mir.stderr deleted file mode 100644 index a253cafe24d..00000000000 --- a/tests/ui/generator/issue-57478.drop_tracking_mir.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/issue-57478.rs:12:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | -LL | | let guard = Foo; -LL | | drop(guard); -LL | | yield; -LL | | }) - | |_____^ generator is not `Send` - | - = help: within `[generator@$DIR/issue-57478.rs:12:17: 12: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.no_drop_tracking.stderr b/tests/ui/generator/issue-57478.no_drop_tracking.stderr index a253cafe24d..612dd9c37f7 100644 --- a/tests/ui/generator/issue-57478.no_drop_tracking.stderr +++ b/tests/ui/generator/issue-57478.no_drop_tracking.stderr @@ -1,17 +1,16 @@ error: generator cannot be sent between threads safely - --> $DIR/issue-57478.rs:12:17 + --> $DIR/issue-57478.rs:13:17 | LL | assert_send(|| { | _________________^ LL | | -LL | | LL | | let guard = Foo; LL | | drop(guard); LL | | yield; LL | | }) | |_____^ generator is not `Send` | - = help: within `[generator@$DIR/issue-57478.rs:12:17: 12:19]`, the trait `Send` is not implemented for `Foo` + = 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 | diff --git a/tests/ui/generator/issue-57478.rs b/tests/ui/generator/issue-57478.rs index cf5350ecbb9..3c23b599271 100644 --- a/tests/ui/generator/issue-57478.rs +++ b/tests/ui/generator/issue-57478.rs @@ -2,6 +2,7 @@ // [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)] @@ -11,7 +12,6 @@ impl !Send for Foo {} fn main() { assert_send(|| { //[no_drop_tracking]~^ ERROR generator cannot be sent between threads safely - //[drop_tracking_mir]~^^ ERROR generator cannot be sent between threads safely let guard = Foo; drop(guard); yield; diff --git a/tests/ui/generator/issue-68112.drop_tracking_mir.stderr b/tests/ui/generator/issue-68112.drop_tracking_mir.stderr index 282eac1b686..a83522b714d 100644 --- a/tests/ui/generator/issue-68112.drop_tracking_mir.stderr +++ b/tests/ui/generator/issue-68112.drop_tracking_mir.stderr @@ -1,8 +1,8 @@ error: generator cannot be sent between threads safely - --> $DIR/issue-68112.rs:43:18 + --> $DIR/issue-68112.rs:43:5 | LL | require_send(send_gen); - | ^^^^^^^^ generator is not `Send` + | ^^^^^^^^^^^^ 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 @@ -14,9 +14,6 @@ LL | let _non_send_gen = make_non_send_generator(); 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 | @@ -24,12 +21,10 @@ 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 + --> $DIR/issue-68112.rs:67:5 | LL | require_send(send_gen); - | ------------ ^^^^^^^^ `RefCell` cannot be shared between threads safely - | | - | required by a bound introduced by this call + | ^^^^^^^^^^^^ `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 @@ -49,7 +44,7 @@ note: required because it appears within the type `impl Generator impl Generator>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `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 | diff --git a/tests/ui/generator/issue-68112.rs b/tests/ui/generator/issue-68112.rs index c3fe09be57f..48b53b7693d 100644 --- a/tests/ui/generator/issue-68112.rs +++ b/tests/ui/generator/issue-68112.rs @@ -11,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> { @@ -39,7 +39,7 @@ 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` @@ -68,7 +68,7 @@ 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 } diff --git a/tests/ui/generator/not-send-sync.drop_tracking.stderr b/tests/ui/generator/not-send-sync.drop_tracking.stderr index a15ee404474..718fd42245a 100644 --- a/tests/ui/generator/not-send-sync.drop_tracking.stderr +++ b/tests/ui/generator/not-send-sync.drop_tracking.stderr @@ -1,58 +1,60 @@ -error[E0277]: `Cell` cannot be shared between threads safely - --> $DIR/not-send-sync.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: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead - = note: required for `&Cell` to implement `Send` -note: required because it's used within this generator - --> $DIR/not-send-sync.rs:19:17 - | -LL | assert_send(|| { - | ^^ -note: required by a bound in `assert_send` - --> $DIR/not-send-sync.rs:10: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:12:17 + --> $DIR/not-send-sync.rs:17:17 | LL | assert_sync(|| { | _________________^ LL | | -LL | | let a = Cell::new(2); +LL | | let a = NotSync; LL | | yield; +LL | | drop(a); LL | | }); | |_____^ generator is not `Sync` | - = help: within `[generator@$DIR/not-send-sync.rs:12:17: 12:19]`, the trait `Sync` is not implemented for `Cell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead + = 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:15:9 + --> $DIR/not-send-sync.rs:20:9 | -LL | let a = Cell::new(2); - | - has type `Cell` which is not `Sync` +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:9:23 + --> $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 -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/not-send-sync.drop_tracking_mir.stderr b/tests/ui/generator/not-send-sync.drop_tracking_mir.stderr index a15ee404474..66f01ae37d8 100644 --- a/tests/ui/generator/not-send-sync.drop_tracking_mir.stderr +++ b/tests/ui/generator/not-send-sync.drop_tracking_mir.stderr @@ -1,58 +1,42 @@ -error[E0277]: `Cell` cannot be shared between threads safely - --> $DIR/not-send-sync.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: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead - = note: required for `&Cell` to implement `Send` -note: required because it's used within this generator - --> $DIR/not-send-sync.rs:19:17 - | -LL | assert_send(|| { - | ^^ -note: required by a bound in `assert_send` - --> $DIR/not-send-sync.rs:10: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:12:17 + --> $DIR/not-send-sync.rs:17:5 | -LL | assert_sync(|| { - | _________________^ -LL | | -LL | | let a = Cell::new(2); -LL | | yield; -LL | | }); - | |_____^ generator is not `Sync` +LL | assert_sync(|| { + | ^^^^^^^^^^^ generator is not `Sync` | - = help: within `[generator@$DIR/not-send-sync.rs:12:17: 12:19]`, the trait `Sync` is not implemented for `Cell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead + = 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:15:9 + --> $DIR/not-send-sync.rs:20:9 | -LL | let a = Cell::new(2); - | - has type `Cell` which is not `Sync` +LL | let a = NotSync; + | - has type `NotSync` 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:9:23 + --> $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 -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/not-send-sync.no_drop_tracking.stderr b/tests/ui/generator/not-send-sync.no_drop_tracking.stderr index a15ee404474..718fd42245a 100644 --- a/tests/ui/generator/not-send-sync.no_drop_tracking.stderr +++ b/tests/ui/generator/not-send-sync.no_drop_tracking.stderr @@ -1,58 +1,60 @@ -error[E0277]: `Cell` cannot be shared between threads safely - --> $DIR/not-send-sync.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: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead - = note: required for `&Cell` to implement `Send` -note: required because it's used within this generator - --> $DIR/not-send-sync.rs:19:17 - | -LL | assert_send(|| { - | ^^ -note: required by a bound in `assert_send` - --> $DIR/not-send-sync.rs:10: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:12:17 + --> $DIR/not-send-sync.rs:17:17 | LL | assert_sync(|| { | _________________^ LL | | -LL | | let a = Cell::new(2); +LL | | let a = NotSync; LL | | yield; +LL | | drop(a); LL | | }); | |_____^ generator is not `Sync` | - = help: within `[generator@$DIR/not-send-sync.rs:12:17: 12:19]`, the trait `Sync` is not implemented for `Cell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead + = 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:15:9 + --> $DIR/not-send-sync.rs:20:9 | -LL | let a = Cell::new(2); - | - has type `Cell` which is not `Sync` +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:9:23 + --> $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 -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/not-send-sync.rs b/tests/ui/generator/not-send-sync.rs index aadb2935701..8794db452b4 100644 --- a/tests/ui/generator/not-send-sync.rs +++ b/tests/ui/generator/not-send-sync.rs @@ -2,8 +2,13 @@ // [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) {} @@ -11,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/parent-expression.drop_tracking_mir.stderr b/tests/ui/generator/parent-expression.drop_tracking_mir.stderr index 2e1313a8004..bf814456427 100644 --- a/tests/ui/generator/parent-expression.drop_tracking_mir.stderr +++ b/tests/ui/generator/parent-expression.drop_tracking_mir.stderr @@ -1,91 +1,8 @@ error: generator cannot be sent between threads safely - --> $DIR/parent-expression.rs:27:25 + --> $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 `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` + | ^^^^^^^^^^^ generator is not `Send` ... LL | / type_combinations!( LL | | // OK @@ -105,8 +22,6 @@ LL | let g = move || match drop($name::Client { ..$name::Client::d ... 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 @@ -124,51 +39,10 @@ LL | fn assert_send(_thing: T) {} = 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 + --> $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: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` + | ^^^^^^^^^^^ generator is not `Send` ... LL | / type_combinations!( LL | | // OK @@ -188,8 +62,6 @@ LL | let g = move || match drop($name::Client { ..$name::Client::d ... 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 @@ -207,51 +79,10 @@ LL | fn assert_send(_thing: T) {} = 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 + --> $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: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` + | ^^^^^^^^^^^ generator is not `Send` ... LL | / type_combinations!( LL | | // OK @@ -271,8 +102,6 @@ LL | let g = move || match drop($name::Client { ..$name::Client::d ... 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 @@ -289,46 +118,5 @@ 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 +error: aborting due to 3 previous errors diff --git a/tests/ui/generator/parent-expression.rs b/tests/ui/generator/parent-expression.rs index 61e81330b09..239034e3d4e 100644 --- a/tests/ui/generator/parent-expression.rs +++ b/tests/ui/generator/parent-expression.rs @@ -28,7 +28,7 @@ macro_rules! type_combinations { //~^ ERROR cannot be sent between threads //~| ERROR cannot be sent between threads //~| ERROR cannot be sent between threads - //[no_drop_tracking,drop_tracking_mir]~^^^^ 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`, @@ -38,10 +38,10 @@ macro_rules! type_combinations { _ => yield, }; assert_send(g); - //[no_drop_tracking,drop_tracking_mir]~^ ERROR cannot be sent between threads - //[no_drop_tracking,drop_tracking_mir]~| ERROR cannot be sent between threads - //[no_drop_tracking,drop_tracking_mir]~| ERROR cannot be sent between threads - //[no_drop_tracking,drop_tracking_mir]~| 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 + //[no_drop_tracking]~| ERROR cannot be sent between threads } )* } } diff --git a/tests/ui/generator/partial-drop.drop_tracking.stderr b/tests/ui/generator/partial-drop.drop_tracking.stderr index e3c19264ee8..f1b25cb8c34 100644 --- a/tests/ui/generator/partial-drop.drop_tracking.stderr +++ b/tests/ui/generator/partial-drop.drop_tracking.stderr @@ -1,17 +1,16 @@ error: generator cannot be sent between threads safely - --> $DIR/partial-drop.rs:16:17 + --> $DIR/partial-drop.rs:17: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:16:17: 16:19]`, the trait `Send` is not implemented for `Foo` + = 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 | @@ -23,7 +22,7 @@ LL | yield; LL | }); | - `guard` is later dropped here note: required by a bound in `assert_send` - --> $DIR/partial-drop.rs:44:19 + --> $DIR/partial-drop.rs:33:19 | LL | fn assert_send(_: T) {} | ^^^^ required by this bound in `assert_send` @@ -34,16 +33,16 @@ error: generator cannot be sent between threads safely LL | assert_send(|| { | _________________^ LL | | -LL | | // FIXME: it would be nice to make this work. 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:31:9 + --> $DIR/partial-drop.rs:29:9 | LL | let guard = Bar { foo: Foo, x: 42 }; | ----- has type `Bar` which is not `Send` @@ -53,40 +52,10 @@ LL | yield; LL | }); | - `guard` is later dropped here note: required by a bound in `assert_send` - --> $DIR/partial-drop.rs:44:19 + --> $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:34: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:34:17: 34: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:40: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:44:19 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/generator/partial-drop.drop_tracking_mir.stderr b/tests/ui/generator/partial-drop.drop_tracking_mir.stderr deleted file mode 100644 index fa901b1977a..00000000000 --- a/tests/ui/generator/partial-drop.drop_tracking_mir.stderr +++ /dev/null @@ -1,92 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/partial-drop.rs:16: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:16:17: 16: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:44: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 | | // 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: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:31: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:44: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:34: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:34:17: 34: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:40: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:44: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/partial-drop.no_drop_tracking.stderr b/tests/ui/generator/partial-drop.no_drop_tracking.stderr index fa901b1977a..91152b5ea6f 100644 --- a/tests/ui/generator/partial-drop.no_drop_tracking.stderr +++ b/tests/ui/generator/partial-drop.no_drop_tracking.stderr @@ -1,17 +1,16 @@ error: generator cannot be sent between threads safely - --> $DIR/partial-drop.rs:16:17 + --> $DIR/partial-drop.rs:17: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:16:17: 16:19]`, the trait `Send` is not implemented for `Foo` + = 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 | @@ -23,7 +22,7 @@ LL | yield; LL | }); | - `guard` is later dropped here note: required by a bound in `assert_send` - --> $DIR/partial-drop.rs:44:19 + --> $DIR/partial-drop.rs:33:19 | LL | fn assert_send(_: T) {} | ^^^^ required by this bound in `assert_send` @@ -34,46 +33,16 @@ error: generator cannot be sent between threads safely LL | assert_send(|| { | _________________^ LL | | -LL | | // FIXME: it would be nice to make this work. 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:31: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:44: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:34: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:34:17: 34: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:40:9 + --> $DIR/partial-drop.rs:29:9 | LL | let Bar { foo, x } = guard; | --- has type `Foo` which is not `Send` @@ -83,10 +52,10 @@ LL | yield; LL | }); | - `foo` is later dropped here note: required by a bound in `assert_send` - --> $DIR/partial-drop.rs:44:19 + --> $DIR/partial-drop.rs:33:19 | LL | fn assert_send(_: T) {} | ^^^^ required by this bound in `assert_send` -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/generator/partial-drop.rs b/tests/ui/generator/partial-drop.rs index e7f85df5877..1d3ae075d43 100644 --- a/tests/ui/generator/partial-drop.rs +++ b/tests/ui/generator/partial-drop.rs @@ -1,6 +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 +// [drop_tracking_mir] check-pass #![feature(negative_impls, generators)] @@ -14,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 e3c19264ee8..00000000000 --- 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:16: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:16:17: 16: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:44: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 | | // 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: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:31: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:44: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:34: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:34:17: 34: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:40: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:44: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_mir.stderr b/tests/ui/generator/print/generator-print-verbose-1.drop_tracking_mir.stderr index 7d0a201699b..c045b1441c1 100644 --- 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 @@ -1,8 +1,8 @@ error: generator cannot be sent between threads safely - --> $DIR/generator-print-verbose-1.rs:40:18 + --> $DIR/generator-print-verbose-1.rs:40:5 | LL | require_send(send_gen); - | ^^^^^^^^ generator is not `Send` + | ^^^^^^^^^^^^ 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 @@ -13,8 +13,6 @@ 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 | @@ -22,12 +20,10 @@ 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 + --> $DIR/generator-print-verbose-1.rs:59:5 | LL | require_send(send_gen); - | ------------ ^^^^^^^^ `RefCell` cannot be shared between threads safely - | | - | required by a bound introduced by this call + | ^^^^^^^^^^^^ `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 @@ -47,7 +43,7 @@ note: required because it appears within the type `Opaque(DefId(0:36 ~ generator | 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 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 | diff --git a/tests/ui/generator/print/generator-print-verbose-1.rs b/tests/ui/generator/print/generator-print-verbose-1.rs index d0acff8c93f..c7052c7d1b0 100644 --- a/tests/ui/generator/print/generator-print-verbose-1.rs +++ b/tests/ui/generator/print/generator-print-verbose-1.rs @@ -15,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-2.drop_tracking.stderr b/tests/ui/generator/print/generator-print-verbose-2.drop_tracking.stderr index 0df978e47dc..1f2e530f6f5 100644 --- a/tests/ui/generator/print/generator-print-verbose-2.drop_tracking.stderr +++ b/tests/ui/generator/print/generator-print-verbose-2.drop_tracking.stderr @@ -1,58 +1,60 @@ -error[E0277]: `Cell` cannot be shared between threads safely - --> $DIR/generator-print-verbose-2.rs:22: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: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead - = note: required for `&'_#4r Cell` to implement `Send` -note: required because it's used within this generator - --> $DIR/generator-print-verbose-2.rs:22:17 - | -LL | assert_send(|| { - | ^^ -note: required by a bound in `assert_send` - --> $DIR/generator-print-verbose-2.rs:13: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:15:17 + --> $DIR/generator-print-verbose-2.rs:20:17 | LL | assert_sync(|| { | _________________^ LL | | -LL | | let a = Cell::new(2); +LL | | let a = NotSync; LL | | yield; +LL | | drop(a); LL | | }); | |_____^ generator is not `Sync` | - = help: within `[main::{closure#0} upvar_tys=() {Cell, ()}]`, the trait `Sync` is not implemented for `Cell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead + = 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:18:9 + --> $DIR/generator-print-verbose-2.rs:23:9 | -LL | let a = Cell::new(2); - | - has type `Cell` which is not `Sync` +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:12:23 + --> $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 -For more information about this error, try `rustc --explain E0277`. 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 index 0df978e47dc..354369f1954 100644 --- 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 @@ -1,58 +1,42 @@ -error[E0277]: `Cell` cannot be shared between threads safely - --> $DIR/generator-print-verbose-2.rs:22: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: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead - = note: required for `&'_#4r Cell` to implement `Send` -note: required because it's used within this generator - --> $DIR/generator-print-verbose-2.rs:22:17 - | -LL | assert_send(|| { - | ^^ -note: required by a bound in `assert_send` - --> $DIR/generator-print-verbose-2.rs:13: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:15:17 + --> $DIR/generator-print-verbose-2.rs:20:5 | -LL | assert_sync(|| { - | _________________^ -LL | | -LL | | let a = Cell::new(2); -LL | | yield; -LL | | }); - | |_____^ generator is not `Sync` +LL | assert_sync(|| { + | ^^^^^^^^^^^ generator is not `Sync` | - = help: within `[main::{closure#0} upvar_tys=() {Cell, ()}]`, the trait `Sync` is not implemented for `Cell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead + = 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:18:9 + --> $DIR/generator-print-verbose-2.rs:23:9 | -LL | let a = Cell::new(2); - | - has type `Cell` which is not `Sync` +LL | let a = NotSync; + | - has type `NotSync` 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:12:23 + --> $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 -For more information about this error, try `rustc --explain E0277`. 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 index 0df978e47dc..1f2e530f6f5 100644 --- 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 @@ -1,58 +1,60 @@ -error[E0277]: `Cell` cannot be shared between threads safely - --> $DIR/generator-print-verbose-2.rs:22: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: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead - = note: required for `&'_#4r Cell` to implement `Send` -note: required because it's used within this generator - --> $DIR/generator-print-verbose-2.rs:22:17 - | -LL | assert_send(|| { - | ^^ -note: required by a bound in `assert_send` - --> $DIR/generator-print-verbose-2.rs:13: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:15:17 + --> $DIR/generator-print-verbose-2.rs:20:17 | LL | assert_sync(|| { | _________________^ LL | | -LL | | let a = Cell::new(2); +LL | | let a = NotSync; LL | | yield; +LL | | drop(a); LL | | }); | |_____^ generator is not `Sync` | - = help: within `[main::{closure#0} upvar_tys=() {Cell, ()}]`, the trait `Sync` is not implemented for `Cell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead + = 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:18:9 + --> $DIR/generator-print-verbose-2.rs:23:9 | -LL | let a = Cell::new(2); - | - has type `Cell` which is not `Sync` +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:12:23 + --> $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 -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/print/generator-print-verbose-2.rs b/tests/ui/generator/print/generator-print-verbose-2.rs index 74b9811b50b..ab29db6e09c 100644 --- a/tests/ui/generator/print/generator-print-verbose-2.rs +++ b/tests/ui/generator/print/generator-print-verbose-2.rs @@ -5,8 +5,13 @@ // 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) {} @@ -14,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/impl-trait/issue-55872-2.drop_tracking_mir.stderr b/tests/ui/impl-trait/issue-55872-2.drop_tracking_mir.stderr index 477c964bd40..c14bb5cc914 100644 --- a/tests/ui/impl-trait/issue-55872-2.drop_tracking_mir.stderr +++ b/tests/ui/impl-trait/issue-55872-2.drop_tracking_mir.stderr @@ -4,5 +4,11 @@ error: type parameter `T` is part of concrete type but not used in parameter lis LL | async {} | ^^^^^^^^ -error: aborting due to previous error +error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias + --> $DIR/issue-55872-2.rs:17:9 + | +LL | async {} + | ^^^^^^^^ + +error: aborting due to 2 previous errors diff --git a/tests/ui/impl-trait/issue-55872-2.rs b/tests/ui/impl-trait/issue-55872-2.rs index 1696ead0d8d..cbc7b5d62e1 100644 --- a/tests/ui/impl-trait/issue-55872-2.rs +++ b/tests/ui/impl-trait/issue-55872-2.rs @@ -16,6 +16,7 @@ impl Bar for S { fn foo() -> Self::E { async {} //~^ ERROR type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias + //[drop_tracking_mir]~^^ ERROR type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias } } diff --git a/tests/ui/impl-trait/issues/infinite-impl-trait-issue-38064.stderr b/tests/ui/impl-trait/issues/infinite-impl-trait-issue-38064.stderr index 16a1262ec27..92a3290622e 100644 --- a/tests/ui/impl-trait/issues/infinite-impl-trait-issue-38064.stderr +++ b/tests/ui/impl-trait/issues/infinite-impl-trait-issue-38064.stderr @@ -8,13 +8,13 @@ LL | Foo(bar()) | ---------- returning here with type `Foo` ... LL | fn bar() -> impl Quux { - | --------- returning this opaque type `Foo` + | --------- returning this type `Foo` error[E0720]: cannot resolve opaque type --> $DIR/infinite-impl-trait-issue-38064.rs:14:13 | LL | fn foo() -> impl Quux { - | --------- returning this opaque type `Bar` + | --------- returning this type `Bar` ... LL | fn bar() -> impl Quux { | ^^^^^^^^^ recursive opaque type diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr index 43118ae3854..662c74bcdc0 100644 --- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr +++ b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr @@ -112,16 +112,8 @@ LL | (substs_change::<&T>(),) error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:76:24 | -LL | fn generator_hold() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | / move || { -LL | | let x = generator_hold(); - | | - generator captures itself here -LL | | yield; -LL | | x; -LL | | } - | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:78:5: 78:12]` +LL | fn generator_hold() -> impl Sized { + | ^^^^^^^^^^ recursive opaque type error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:90:26 diff --git a/tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr index 18880f5a757..262657da5fe 100644 --- a/tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr @@ -1,14 +1,16 @@ error: `No` held across a suspend point, but should not be - --> $DIR/dedup.rs:19:13 + --> $DIR/dedup.rs:19:9 | -LL | wheeee(&No {}).await; - | ^^^^^ ------ the value is held across this suspend point +LL | let no = No {}; + | ^^ +LL | wheeee(&no).await; + | ------ the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/dedup.rs:19:13 + --> $DIR/dedup.rs:19:9 | -LL | wheeee(&No {}).await; - | ^^^^^ +LL | let no = No {}; + | ^^ note: the lint level is defined here --> $DIR/dedup.rs:6:9 | diff --git a/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr index 18880f5a757..262657da5fe 100644 --- a/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr +++ b/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr @@ -1,14 +1,16 @@ error: `No` held across a suspend point, but should not be - --> $DIR/dedup.rs:19:13 + --> $DIR/dedup.rs:19:9 | -LL | wheeee(&No {}).await; - | ^^^^^ ------ the value is held across this suspend point +LL | let no = No {}; + | ^^ +LL | wheeee(&no).await; + | ------ the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/dedup.rs:19:13 + --> $DIR/dedup.rs:19:9 | -LL | wheeee(&No {}).await; - | ^^^^^ +LL | let no = No {}; + | ^^ note: the lint level is defined here --> $DIR/dedup.rs:6:9 | diff --git a/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr index 18880f5a757..7ed43d25719 100644 --- a/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr @@ -1,19 +1,33 @@ error: `No` held across a suspend point, but should not be - --> $DIR/dedup.rs:19:13 + --> $DIR/dedup.rs:19:9 | -LL | wheeee(&No {}).await; - | ^^^^^ ------ the value is held across this suspend point +LL | let no = No {}; + | ^^ +LL | wheeee(&no).await; + | ------ the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/dedup.rs:19:13 + --> $DIR/dedup.rs:19:9 | -LL | wheeee(&No {}).await; - | ^^^^^ +LL | let no = No {}; + | ^^ note: the lint level is defined here --> $DIR/dedup.rs:6:9 | LL | #![deny(must_not_suspend)] | ^^^^^^^^^^^^^^^^ -error: aborting due to previous error +error: `No` held across a suspend point, but should not be + --> $DIR/dedup.rs:20:13 + | +LL | wheeee(&no).await; + | ^^ ------ the value is held across this suspend point + | +help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point + --> $DIR/dedup.rs:20:13 + | +LL | wheeee(&no).await; + | ^^ + +error: aborting due to 2 previous errors diff --git a/tests/ui/lint/must_not_suspend/dedup.rs b/tests/ui/lint/must_not_suspend/dedup.rs index 6e49ee52bd9..96bdb7715b1 100644 --- a/tests/ui/lint/must_not_suspend/dedup.rs +++ b/tests/ui/lint/must_not_suspend/dedup.rs @@ -16,7 +16,9 @@ async fn wheeee(t: T) { } async fn yes() { - wheeee(&No {}).await; //~ ERROR `No` held across + let no = No {}; //~ ERROR `No` held across + wheeee(&no).await; //[no_drop_tracking]~ ERROR `No` held across + drop(no); } fn main() { diff --git a/tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr index e9bfa08b5dd..e3628ca5e49 100644 --- a/tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr +++ b/tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr @@ -1,22 +1,22 @@ -error: `Umm` held across a suspend point, but should not be - --> $DIR/ref.rs:22:26 +error: reference to `Umm` held across a suspend point, but should not be + --> $DIR/ref.rs:22:13 | LL | let guard = &mut self.u; - | ^^^^^^ + | ^^^^^ LL | LL | other().await; | ------ the value is held across this suspend point | note: You gotta use Umm's, ya know? - --> $DIR/ref.rs:22:26 + --> $DIR/ref.rs:22:13 | LL | let guard = &mut self.u; - | ^^^^^^ + | ^^^^^ help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/ref.rs:22:26 + --> $DIR/ref.rs:22:13 | LL | let guard = &mut self.u; - | ^^^^^^ + | ^^^^^ note: the lint level is defined here --> $DIR/ref.rs:7:9 | diff --git a/tests/ui/lint/must_not_suspend/ref.rs b/tests/ui/lint/must_not_suspend/ref.rs index 8784ffbc634..d05dcb83ac5 100644 --- a/tests/ui/lint/must_not_suspend/ref.rs +++ b/tests/ui/lint/must_not_suspend/ref.rs @@ -23,6 +23,7 @@ impl Bar { other().await; + let _g = &*guard; *guard = Umm { i: 2 } } } diff --git a/tests/ui/lint/must_not_suspend/trait.rs b/tests/ui/lint/must_not_suspend/trait.rs index b6ccae0d249..cc3ae298dbb 100644 --- a/tests/ui/lint/must_not_suspend/trait.rs +++ b/tests/ui/lint/must_not_suspend/trait.rs @@ -25,6 +25,9 @@ pub async fn uhoh() { let _guard2 = r#dyn(); //~ ERROR boxed `Wow` trait object held across other().await; + + drop(_guard1); + drop(_guard2); } fn main() { diff --git a/tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr index 50ca292c2f6..f89b3e341fd 100644 --- a/tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr @@ -1,5 +1,5 @@ error: `Umm` held across a suspend point, but should not be - --> $DIR/unit.rs:23:9 + --> $DIR/unit.rs:22:9 | LL | let _guard = bar(); | ^^^^^^ @@ -7,12 +7,12 @@ LL | other().await; | ------ the value is held across this suspend point | note: You gotta use Umm's, ya know? - --> $DIR/unit.rs:23:9 + --> $DIR/unit.rs:22:9 | LL | let _guard = bar(); | ^^^^^^ help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/unit.rs:23:9 + --> $DIR/unit.rs:22:9 | LL | let _guard = bar(); | ^^^^^^ diff --git a/tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr index 50ca292c2f6..f89b3e341fd 100644 --- a/tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr +++ b/tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr @@ -1,5 +1,5 @@ error: `Umm` held across a suspend point, but should not be - --> $DIR/unit.rs:23:9 + --> $DIR/unit.rs:22:9 | LL | let _guard = bar(); | ^^^^^^ @@ -7,12 +7,12 @@ LL | other().await; | ------ the value is held across this suspend point | note: You gotta use Umm's, ya know? - --> $DIR/unit.rs:23:9 + --> $DIR/unit.rs:22:9 | LL | let _guard = bar(); | ^^^^^^ help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/unit.rs:23:9 + --> $DIR/unit.rs:22:9 | LL | let _guard = bar(); | ^^^^^^ diff --git a/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr index 50ca292c2f6..f89b3e341fd 100644 --- a/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr @@ -1,5 +1,5 @@ error: `Umm` held across a suspend point, but should not be - --> $DIR/unit.rs:23:9 + --> $DIR/unit.rs:22:9 | LL | let _guard = bar(); | ^^^^^^ @@ -7,12 +7,12 @@ LL | other().await; | ------ the value is held across this suspend point | note: You gotta use Umm's, ya know? - --> $DIR/unit.rs:23:9 + --> $DIR/unit.rs:22:9 | LL | let _guard = bar(); | ^^^^^^ help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/unit.rs:23:9 + --> $DIR/unit.rs:22:9 | LL | let _guard = bar(); | ^^^^^^ diff --git a/tests/ui/lint/must_not_suspend/unit.rs b/tests/ui/lint/must_not_suspend/unit.rs index 8903f8a6d05..fbc51b36681 100644 --- a/tests/ui/lint/must_not_suspend/unit.rs +++ b/tests/ui/lint/must_not_suspend/unit.rs @@ -10,7 +10,6 @@ struct Umm { i: i64 } - fn bar() -> Umm { Umm { i: 1 @@ -22,6 +21,7 @@ async fn other() {} pub async fn uhoh() { let _guard = bar(); //~ ERROR `Umm` held across other().await; + drop(_guard); } fn main() { diff --git a/tests/ui/lint/must_not_suspend/warn.rs b/tests/ui/lint/must_not_suspend/warn.rs index b5002cb9f60..5a4863169ea 100644 --- a/tests/ui/lint/must_not_suspend/warn.rs +++ b/tests/ui/lint/must_not_suspend/warn.rs @@ -23,6 +23,7 @@ async fn other() {} pub async fn uhoh() { let _guard = bar(); //~ WARNING `Umm` held across other().await; + drop(_guard); } fn main() {