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

Fix suggestion from incorrect move async to async move. #63699

Merged
merged 1 commit into from
Aug 20, 2019

Conversation

gilescope
Copy link
Contributor

PR for #61920. Happy with the test. There must be a better implementation though - possibly a MIR visitor to estabilsh a span that doesn't include the async keyword?

@rust-highfive
Copy link
Collaborator

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 19, 2019
@eddyb
Copy link
Member

eddyb commented Aug 19, 2019

r? @estebank or @petrochenkov

@rust-highfive rust-highfive assigned estebank and unassigned eddyb Aug 19, 2019
@rust-highfive

This comment has been minimized.

@estebank
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 19, 2019

📌 Commit ef3e66d has been approved by estebank

@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 Aug 19, 2019
Centril added a commit to Centril/rust that referenced this pull request Aug 19, 2019
…estebank

Fix suggestion from incorrect `move async` to `async move`.

PR for rust-lang#61920. Happy with the test. There must be a better implementation though - possibly a MIR visitor to estabilsh a span that doesn't include the `async` keyword?
bors added a commit that referenced this pull request Aug 19, 2019
Rollup of 5 pull requests

Successful merges:

 - #63252 (Remove recommendation about idiomatic syntax for Arc::clone)
 - #63376 (use different lifetime name for object-lifetime-default elision)
 - #63620 (Use constraint span when lowering associated types)
 - #63699 (Fix suggestion from incorrect `move async` to `async move`.)
 - #63704 ( Fixed: error: unnecessary trailing semicolon)

Failed merges:

r? @ghost
@bors bors merged commit ef3e66d into rust-lang:master Aug 20, 2019
@bors
Copy link
Contributor

bors commented Aug 20, 2019

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

@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 Aug 20, 2019
@@ -1190,7 +1190,16 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
);

let suggestion = match tcx.sess.source_map().span_to_snippet(args_span) {
Ok(string) => format!("move {}", string),
Ok(mut string) => {
if string.starts_with("async ") {
Copy link
Contributor

@jakubadamw jakubadamw Aug 20, 2019

Choose a reason for hiding this comment

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

This is a rather error-prone way of checking this that will fail with:

async
|x| {}

or

async\t|x|

I don't think this should be looking at the code snippet but rather trace with self.tcx whether this closure was an async one before lowering. I sadly cannot tell you off the top of my head how to do it and cannot look at the code at this very moment but maybe someone else can chim in. @estebank?

Copy link
Contributor

Choose a reason for hiding this comment

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

That is true. Ideally you'd want to get the original node, but I don't think you can. An alternative that keeps operating on the string (less than ideal, as already established) would be to use string.split_whitespace().next() which would yield Some("async") for the cases we care about in a pretty foolproof way.

Copy link
Contributor

Choose a reason for hiding this comment

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

String operations for these checks is not ideal, but sometimes we have no way around them unless we track more things from the AST onwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants