Skip to content

Self overlapping error message ("unexpected tokenxpected") #41155

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

Closed
est31 opened this issue Apr 8, 2017 · 3 comments
Closed

Self overlapping error message ("unexpected tokenxpected") #41155

est31 opened this issue Apr 8, 2017 · 3 comments
Labels
regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone

Comments

@est31
Copy link
Member

est31 commented Apr 8, 2017

This (invalid) code:

impl S {
	pub
}

Produces the following, okay error message on beta:

rustc 1.17.0-beta.3 (ca3d11832 2017-04-05)
error: expected one of `(`, `const`, `default`, `extern`, `fn`, `type`, or `unsafe`, found `}`
 --> <anon>:3:1
  |
3 | }
  | ^

error: aborting due to previous error

But on nightly, you get a bad, self overriding one:

rustc 1.18.0-nightly (50c186419 2017-04-06)
error: expected one of `(`, `const`, `default`, `extern`, `fn`, `type`, or `unsafe`, found `}`
 --> <anon>:3:1
  |
2 |   	pub
  |  _____- starting here...
3 | | }
  | | ^.unexpected tokenxpected one of 7 possible tokens here

error: aborting due to previous error

Note the "unexpected tokenxpected one of 7 possible tokens here". Possibly the "starting here" is not required either.

cc @estebank

@estebank
Copy link
Contributor

estebank commented Apr 8, 2017

There might be two problems:

@arielb1 arielb1 added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 8, 2017
@ben0x539
Copy link
Contributor

ben0x539 commented Apr 8, 2017

Ran into this with what minifies to

  ()
  let _ = ();
  |
2 |       ()
  |  _______- starting here...
3 | |     let _ = ();
  | |  ...^^^iunexpected tokend one of `.`, `;`, `?`, `}`, or an operator here

or

  f()
  g();
2 |       f()
  |  ________- starting here...
3 | |     g();
  | |  ...^nunexpected tokented one of `.`, `;`, `?`, `}`, or an operator here

Adding these because I almost filed a duplicate issue because searching for "iunexpected tokend" didn't give any results.

@alexcrichton alexcrichton modified the milestone: 1.18 Apr 10, 2017
bors added a commit that referenced this issue Apr 11, 2017
Point at only one char on `Span::next_point`

Avoid pointing at two chars so the diagnostic output doesn't display a
multiline span when starting beyond a line end.

Fix #41155.

Instead of

```rust
error: expected one of `(`, `const`, `default`, `extern`, `fn`, `type`, or `unsafe`, found `}`
 --> <anon>:3:1
  |
1 |   impl S {	pub
  |  _____________- starting here...
2 | |
  | |  ...ending here: expected one of 7 possible tokens here
3 |   }
  |   ^ unexpected token
```

show

```rust
error: expected one of `(`, `const`, `default`, `extern`, `fn`, `type`, or `unsafe`, found `}`
  --> <anon>:13:1
   |
12 |     pub
   |        - expected one of 7 possible tokens here
13 | }
   | ^ unexpected token
```
@est31
Copy link
Member Author

est31 commented Apr 11, 2017

Thanks @estebank for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants