-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop considering moved-out locals when computing auto traits for gene…
…rators
- Loading branch information
Showing
5 changed files
with
136 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
tests/ui/async-await/temp-borrow-nonsend.drop_tracking.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
error: future cannot be sent between threads safely | ||
--> $DIR/temp-borrow-nonsend.rs:25:17 | ||
| | ||
LL | assert_send(test()); | ||
| ^^^^^^ future returned by `test` is not `Send` | ||
| | ||
= help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `*const ()` | ||
note: future is not `Send` as this value is used across an await | ||
--> $DIR/temp-borrow-nonsend.rs:19:11 | ||
| | ||
LL | let b = B(PhantomData); | ||
| - has type `B` which is not `Send` | ||
... | ||
LL | foo().await; | ||
| ^^^^^ await occurs here, with `b` maybe used later | ||
LL | } | ||
| - `b` is later dropped here | ||
note: required by a bound in `assert_send` | ||
--> $DIR/temp-borrow-nonsend.rs:22:19 | ||
| | ||
LL | fn assert_send<T: Send>(_: T) {} | ||
| ^^^^ required by this bound in `assert_send` | ||
|
||
error: aborting due to previous error | ||
|
25 changes: 25 additions & 0 deletions
25
tests/ui/async-await/temp-borrow-nonsend.no_drop_tracking.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
error: future cannot be sent between threads safely | ||
--> $DIR/temp-borrow-nonsend.rs:25:17 | ||
| | ||
LL | assert_send(test()); | ||
| ^^^^^^ future returned by `test` is not `Send` | ||
| | ||
= help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `*const ()` | ||
note: future is not `Send` as this value is used across an await | ||
--> $DIR/temp-borrow-nonsend.rs:19:11 | ||
| | ||
LL | let b = B(PhantomData); | ||
| - has type `B` which is not `Send` | ||
... | ||
LL | foo().await; | ||
| ^^^^^ await occurs here, with `b` maybe used later | ||
LL | } | ||
| - `b` is later dropped here | ||
note: required by a bound in `assert_send` | ||
--> $DIR/temp-borrow-nonsend.rs:22:19 | ||
| | ||
LL | fn assert_send<T: Send>(_: T) {} | ||
| ^^^^ required by this bound in `assert_send` | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// revisions: no_drop_tracking drop_tracking drop_tracking_mir | ||
// [drop_tracking_mir] check-pass | ||
// [drop_tracking] compile-flags: -Zdrop-tracking | ||
// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir | ||
// edition:2021 | ||
|
||
use core::marker::PhantomData; | ||
|
||
struct B(PhantomData<*const ()>); | ||
|
||
fn do_sth(_: &B) {} | ||
|
||
async fn foo() {} | ||
|
||
async fn test() { | ||
let b = B(PhantomData); | ||
do_sth(&b); | ||
drop(b); | ||
foo().await; | ||
} | ||
|
||
fn assert_send<T: Send>(_: T) {} | ||
|
||
fn main() { | ||
assert_send(test()); | ||
//[no_drop_tracking]~^ cannot be sent between threads safely | ||
//[drop_tracking]~^^ cannot be sent between threads safely | ||
} |