rust/compiler/rustc_parse/src/parser
Dylan DPC 299c2fc695
Rollup merge of #80160 - diondokter:move_async_fix, r=davidtwco
Implemented a compiler diagnostic for move async mistake

Fixes #79694

First time contributing, so I hope I'm doing everything right.
(If not, please correct me!)

This code performs a check when a move capture clause is parsed. The check is to detect if the user has reversed the async move keywords and to provide a diagnostic with a suggestion to fix it.

Checked code:
```rust
fn main() {
    move async { };
}
```

Previous output:
```txt
PS C:\Repos\move_async_test> cargo build
   Compiling move_async_test v0.1.0 (C:\Repos\move_async_test)
error: expected one of `|` or `||`, found keyword `async`
 --> src\main.rs:2:10
  |
2 |     move async { };
  |          ^^^^^ expected one of `|` or `||`

error: aborting due to previous error

error: could not compile `move_async_test`
```

New output:
```txt
PS C:\Repos\move_async_test> cargo +dev build
   Compiling move_async_test v0.1.0 (C:\Repos\move_async_test)
error: the order of `move` and `async` is incorrect
 --> src\main.rs:2:13
  |
2 |     let _ = move async { };
  |             ^^^^^^^^^^
  |
help: try switching the order
  |
2 |     let _ = async move { };
  |             ^^^^^^^^^^

error: aborting due to previous error

error: could not compile `move_async_test`
```

Is there a file/module where these kind of things are tested?
Would love some feedback 😄
2020-12-25 03:39:35 +01:00
..
attr.rs rustc_parse: restore pub vis on parse_attribute 2020-11-26 12:54:09 -06:00
diagnostics.rs Implemented a compiler diagnostic for move async mistake 2020-12-21 12:57:08 +01:00
expr.rs Rollup merge of #80160 - diondokter:move_async_fix, r=davidtwco 2020-12-25 03:39:35 +01:00
generics.rs Gracefully handle confusing -> with : in function return type 2020-12-03 18:19:42 +01:00
item.rs Auto merge of #77035 - mibac138:fn-fat-arrow-return, r=davidtwco 2020-12-19 01:47:05 +00:00
mod.rs implement edition-specific :pat behavior for 2015/18 2020-12-19 07:13:36 -06:00
nonterminal.rs implement edition-specific :pat behavior for 2015/18 2020-12-19 07:13:36 -06:00
pat.rs implement edition-specific :pat behavior for 2015/18 2020-12-19 07:13:36 -06:00
path.rs Gracefully handle confusing -> with : in function return type 2020-12-03 18:19:42 +01:00
stmt.rs implement edition-specific :pat behavior for 2015/18 2020-12-19 07:13:36 -06:00
ty.rs Address review comments 2020-12-17 14:12:48 +01:00