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

Recover from missing semicolon based on the found token #59866

Merged
merged 2 commits into from Apr 13, 2019

Conversation

Projects
None yet
5 participants
@estebank
Copy link
Contributor

commented Apr 11, 2019

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 `()`
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 `()`
```
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Apr 11, 2019

r? @petrochenkov

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

@NieDzejkob

This comment has been minimized.

Copy link
Contributor

commented Apr 11, 2019

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

@petrochenkov

This comment has been minimized.

Copy link
Contributor

commented Apr 11, 2019

I think I agree with @NieDzejkob's comment.

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

commented Apr 11, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:0a522208:start=1555017948065683441,finish=1555018064662934039,duration=116597250598
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
[00:06:14]    Compiling rustc_macros v0.1.0 (/checkout/src/librustc_macros)
[00:06:15] error: unused variable: `expects_semi`
[00:06:15]    --> src/libsyntax/parse/parser.rs:799:17
[00:06:15]     |
[00:06:15] 799 |             let expects_semi = expected.iter().any(|t| match t {
[00:06:15]     |                 ^^^^^^^^^^^^ help: consider prefixing with an underscore: `_expects_semi`
[00:06:15]     = note: `-D unused-variables` implied by `-D warnings`
[00:06:15] 
[00:06:15] error: aborting due to previous error
[00:06:15] 

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@estebank estebank force-pushed the estebank:recover-missing-semi branch from d5a1223 to 9b6b3d6 Apr 11, 2019

@petrochenkov

This comment has been minimized.

Copy link
Contributor

commented Apr 11, 2019

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

commented Apr 11, 2019

📌 Commit 9b6b3d6 has been approved by petrochenkov

Centril added a commit to Centril/rust that referenced this pull request Apr 12, 2019

Rollup merge of rust-lang#59866 - estebank:recover-missing-semi, r=pe…
…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 `()`
```

bors added a commit that referenced this pull request Apr 13, 2019

Auto merge of #59922 - Centril:rollup-0qmx4jg, r=Centril
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:master Apr 13, 2019

1 check passed

Travis CI - Pull Request Build Passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.