Skip to content

Recover from missing semicolon based on the found token - #59866

Merged
bors merged 2 commits into
rust-lang:masterfrom
estebank:recover-missing-semi
Apr 13, 2019
Merged

Recover from missing semicolon based on the found token#59866
bors merged 2 commits into
rust-lang:masterfrom
estebank:recover-missing-semi

Conversation

@estebank

Copy link
Copy Markdown
Contributor

When encountering one of a few keywords when a semicolon was
expected, suggest the semicolon and recover:

error: expected one of `.`, `;`, `?`, or an operator, found `let`
--> $DIR/recover-missing-semi.rs:4:5
|
LL | let _: usize = ()
| - help: missing semicolon here
LL |
LL | let _ = 3;
| ^^^
error[E0308]: mismatched types
--> $DIR/recover-missing-semi.rs:2:20
|
LL | let _: usize = ()
| ^^ expected usize, found ()
|
= note: expected type `usize`
found type `()`

When encountering one of a few keywords when a semicolon was
expected, suggest the semicolon and recover:
```
error: expected one of `.`, `;`, `?`, or an operator, found `let`
--> $DIR/recover-missing-semi.rs:4:5
|
LL | let _: usize = ()
| - help: missing semicolon here
LL |
LL | let _ = 3;
| ^^^
error[E0308]: mismatched types
--> $DIR/recover-missing-semi.rs:2:20
|
LL | let _: usize = ()
| ^^ expected usize, found ()
|
= note: expected type `usize`
found type `()`
```
@rust-highfive

Copy link
Copy Markdown
Contributor

r? @petrochenkov

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

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 11, 2019
@meithecatte

Copy link
Copy Markdown
Contributor

I believe it would make more sense to have the help message be tentative. Even a question mark would help: missing semicolon here?.

@petrochenkov

Copy link
Copy Markdown
Contributor

I think I agree with @NieDzejkob's comment.

Comment threadsrc/libsyntax/parse/parser.rs
@petrochenkovpetrochenkov 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-review Status: Awaiting review from the assignee but also interested parties. labels Apr 11, 2019
@rust-highfive

This comment has been minimized.

@estebank
estebankforce-pushed the recover-missing-semi branch from d5a1223 to 9b6b3d6CompareApril 11, 2019 21:45
@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Apr 11, 2019

Copy link
Copy Markdown
Collaborator

📌 Commit 9b6b3d6 has been approved by petrochenkov

@borsbors 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 11, 2019
Centril added a commit to Centril/rust that referenced this pull request Apr 12, 2019
…trochenkov
Recover from missing semicolon based on the found token
When encountering one of a few keywords when a semicolon was
expected, suggest the semicolon and recover:
```
error: expected one of `.`, `;`, `?`, or an operator, found `let`
--> $DIR/recover-missing-semi.rs:4:5
|
LL | let _: usize = ()
| - help: missing semicolon here
LL |
LL | let _ = 3;
| ^^^
error[E0308]: mismatched types
--> $DIR/recover-missing-semi.rs:2:20
|
LL | let _: usize = ()
| ^^ expected usize, found ()
|
= note: expected type `usize`
found type `()`
```
@CentrilCentril mentioned this pull request Apr 12, 2019
bors added a commit that referenced this pull request Apr 13, 2019
Rollup of 8 pull requests
Successful merges:
- #59781 (Remove check_match from const_eval)
- #59820 (proc_macro: stop using LEB128 for RPC.)
- #59846 (clarify what the item is in "not a module" error)
- #59847 (Error when using `catch` after `try`)
- #59859 (Suggest removing `?` to resolve type errors.)
- #59862 (Tweak unstable diagnostic output)
- #59866 (Recover from missing semicolon based on the found token)
- #59892 (Impl RawFd conversion traits for WASI TcpListener, TcpStream and UdpSocket)
Failed merges:
r? @ghost
@bors
bors merged commit 9b6b3d6 into rust-lang:masterApr 13, 2019
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: 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.

5 participants

@estebank@rust-highfive@meithecatte@petrochenkov@bors