Skip to content
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

Improve async-await/generator obligation errors in some cases #70679

Merged
merged 12 commits into from
Apr 14, 2020

Conversation

tmandry
Copy link
Member

@tmandry tmandry commented Apr 2, 2020

Fixes #68112.

This change is best read one commit at a time (I add a test at the beginning and update it in each change after).

The test2 function is a case I found while writing the test that we don't handle with this code yet. I don't attempt to fix it in this PR, but it's a good candidate for future work.

r? @davidtwco, @nikomatsakis

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 2, 2020
Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good. Left some thoughts.

src/test/ui/async-await/async-fn-nonsend.stderr Outdated Show resolved Hide resolved
src/test/ui/async-await/issue-68112.stderr Outdated Show resolved Hide resolved
src/test/ui/async-await/issue-68112.stderr Outdated Show resolved Hide resolved
src/test/ui/async-await/issue-68112.stderr Outdated Show resolved Hide resolved
src/test/ui/async-await/issue-68112.stderr Outdated Show resolved Hide resolved
@davidtwco
Copy link
Member

r? @nikomatsakis

@tmandry
Copy link
Member Author

tmandry commented Apr 8, 2020

@nikomatsakis I updated the wording, what do you think? It's a little repetitive in some places, but by and large I think it's for the best.

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these are looking much better, yes.

= help: the trait `std::marker::Sync` is not implemented for `std::cell::RefCell<i32>`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::sync::Arc<std::cell::RefCell<i32>>`
= note: required because it appears within the type `[generator@$DIR/issue-68112.rs:38:5: 41:6 t:std::sync::Arc<std::cell::RefCell<i32>> {()}]`
= note: required because it appears within the type `impl std::ops::Generator`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this backtrace is confusing, but that's a separate issue I think =)

@@ -5,14 +5,14 @@ LL | fn spawn<T: Send>(_: T) {}
| ----- ---- required by this bound in `spawn`
...
LL | spawn(async {
| ^^^^^ future is not `Send`
| ^^^^^ future created by async block is not `Send`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems good to me

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Apr 10, 2020

📌 Commit 889cfe1 has been approved by nikomatsakis

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 10, 2020
Centril added a commit to Centril/rust that referenced this pull request Apr 11, 2020
Improve async-await/generator obligation errors in some cases

Fixes rust-lang#68112.

This change is best read one commit at a time (I add a test at the beginning and update it in each change after).

The `test2` function is a case I found while writing the test that we don't handle with this code yet. I don't attempt to fix it in this PR, but it's a good candidate for future work.

r? @davidtwco, @nikomatsakis
@bors
Copy link
Contributor

bors commented Apr 12, 2020

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout issue-68112 (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self issue-68112 --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
Auto-merging src/test/ui/generator/not-send-sync.stderr
Auto-merging src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.stderr
Auto-merging src/test/ui/async-await/issue-67252-unnamed-future.stderr
Auto-merging src/test/ui/async-await/issue-64130-non-send-future-diags.stderr
Auto-merging src/test/ui/async-await/issue-64130-3-other.stderr
Auto-merging src/test/ui/async-await/issue-64130-2-send.stderr
Auto-merging src/test/ui/async-await/issue-64130-1-sync.stderr
Auto-merging src/test/ui/async-await/async-fn-nonsend.stderr
Auto-merging src/librustc_typeck/check/expr.rs
Auto-merging src/librustc_trait_selection/traits/error_reporting/suggestions.rs
CONFLICT (content): Merge conflict in src/librustc_trait_selection/traits/error_reporting/suggestions.rs
Automatic merge failed; fix conflicts and then commit the result.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 12, 2020
@bors
Copy link
Contributor

bors commented Apr 12, 2020

☔ The latest upstream changes (presumably #69707) made this pull request unmergeable. Please resolve the merge conflicts.

@tmandry
Copy link
Member Author

tmandry commented Apr 14, 2020

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Apr 14, 2020

📌 Commit 4326d95 has been approved by nikomatsakis

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 14, 2020
@bors
Copy link
Contributor

bors commented Apr 14, 2020

⌛ Testing commit 4326d95 with merge a3ef360...

@bors
Copy link
Contributor

bors commented Apr 14, 2020

☀️ Test successful - checks-azure
Approved by: nikomatsakis
Pushing a3ef360 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 14, 2020
@bors bors merged commit a3ef360 into rust-lang:master Apr 14, 2020
@tmandry tmandry deleted the issue-68112 branch April 14, 2020 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explanation for why future is not Send is wrong
6 participants