-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Check non-Send/Sync upvars captured by generator #71923
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e07f63e
add testcase for issue-70818
csmoe fb81c42
make yield span optional
csmoe a5d103f
record upvar into GeneratorInteriorTypeCause
csmoe d4bdcfd
don't record upvars into generator interior
csmoe 382a963
filter upvars that cause trait obligation
csmoe d2e5a8e
bless issue-70818 test case
csmoe c9e1465
checking on either interior or upvar
csmoe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,9 @@ | ||
// edition:2018 | ||
|
||
use std::future::Future; | ||
fn foo<T: Send, U>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send { | ||
//~^ Error future cannot be sent between threads safely | ||
async { (ty, ty1) } | ||
} | ||
|
||
fn main() {} |
This file contains hidden or 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,23 @@ | ||
error: future cannot be sent between threads safely | ||
--> $DIR/issue-70818.rs:4:38 | ||
| | ||
LL | fn foo<T: Send, U>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` | ||
LL | | ||
LL | async { (ty, ty1) } | ||
| ------------------- this returned value is of type `impl std::future::Future` | ||
| | ||
= help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `U` | ||
note: captured value is not `Send` | ||
--> $DIR/issue-70818.rs:6:18 | ||
| | ||
LL | async { (ty, ty1) } | ||
| ^^^ has type `U` which is not `Send` | ||
= note: the return type of a function must have a statically known size | ||
help: consider restricting type parameter `U` | ||
| | ||
LL | fn foo<T: Send, U: std::marker::Send>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send { | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.