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 bad error message with ::< in types #36206

Merged
merged 1 commit into from Oct 28, 2016
Merged

Conversation

mcarton
Copy link
Member

@mcarton mcarton commented Sep 2, 2016

Fix #36116.

Before:

error: expected identifier, found `<`
  --> src/test/compile-fail/issue-36116.rs:16:52
   |
16 |     let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>);
   |                                                    ^

error: chained comparison operators require parentheses
  --> src/test/compile-fail/issue-36116.rs:16:52
   |
16 |     let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>);
   |                                                    ^^^^^^
   |
   = help: use `::<...>` instead of `<...>` if you meant to specify type arguments

error: expected expression, found `)`
  --> src/test/compile-fail/issue-36116.rs:16:57
   |
16 |     let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>);
   |                                                         ^

error: expected identifier, found `<`
  --> src/test/compile-fail/issue-36116.rs:20:17
   |
20 |     let g: Foo::<i32> = Foo { _a: 42 };
   |                 ^

error: aborting due to 5 previous errors

After:

error: unexpected token: `::`
  --> src/test/compile-fail/issue-36116.rs:16:50
   |
16 |     let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>);
   |                                                  ^^
   |
   = help: use `<...>` instead of `::<...>` if you meant to specify type arguments

error: unexpected token: `::`
  --> src/test/compile-fail/issue-36116.rs:20:15
   |
20 |     let g: Foo::<i32> = Foo { _a: 42 };
   |               ^^
   |
   = help: use `<...>` instead of `::<...>` if you meant to specify type arguments

error: aborting due to 2 previous errors

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pnkfelix (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@pnkfelix
Copy link
Member

(travis failure seemed spurious; i'm giving it another shot and also starting a review.)

@@ -1802,6 +1802,20 @@ impl<'a> Parser<'a> {
// First, parse an identifier.
let identifier = self.parse_path_segment_ident()?;

if
self.check(&token::ModSep) &&
Copy link
Member

Choose a reason for hiding this comment

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

stylistically I don't think we put line breaks between the if and the condition expression in cases like this.


fn main() {
let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>);
//~^ERROR unexpected token: `::`
Copy link
Member

Choose a reason for hiding this comment

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

stylistically I think we tend to separate the arrow (the ^ and the |) and the ERROR/WARN by putting a space between them.

@pnkfelix
Copy link
Member

These changes seem fine to me. I had stylistic nits that would be nice to address.

@pnkfelix
Copy link
Member

In other words, r=me once nits are addressed.

@mcarton
Copy link
Member Author

mcarton commented Sep 22, 2016

Addressed nits.

@cramertj
Copy link
Member

cramertj commented Oct 25, 2016

@pnkfelix Any reason this hasn't been merged yet? I've gotten this error a few times, and this change would make the solution much clearer.

@pnkfelix
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Oct 26, 2016

📌 Commit 17bbcac has been approved by pnkfelix

@GuillaumeGomez
Copy link
Member

It seems your code fails:

error: attempted access of field `last_span` on type `&mut parse::parser::Parser<'a>`, but no field with that name was found
    --> ../src/libsyntax/parse/parser.rs:1762:33
     |
1762 |                 let last_span = self.last_span;
     |                                 ^^^^^^^^^^^^^^

error: aborting due to previous error

Please update your code and I'll re-r+ it.

@bors: r-

bors added a commit that referenced this pull request Oct 26, 2016
Rollup of 7 pull requests

- Successful merges: #36206, #37144, #37391, #37394, #37396, #37398, #37414
- Failed merges:
@mcarton
Copy link
Member Author

mcarton commented Oct 27, 2016

@GuillaumeGomez done. Thanks for pointing that out, that field was renamed in #36470.

@pnkfelix
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Oct 27, 2016

📌 Commit 368f435 has been approved by pnkfelix

@pnkfelix
Copy link
Member

@bors r-

@pnkfelix
Copy link
Member

It has been pointed out that this commit series needs revision. It should be rebased (to remove the merge commit) and squashed into a smaller series of commits, e.g. One commit maybe

@mcarton
Copy link
Member Author

mcarton commented Oct 28, 2016

No problem, done.

@pnkfelix
Copy link
Member

Great, thanks for your patience and perseverance @mcarton

@pnkfelix
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Oct 28, 2016

📌 Commit f7cc6dc has been approved by pnkfelix

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Oct 28, 2016
Fix bad error message with `::<` in types

Fix rust-lang#36116.

Before:
```rust
error: expected identifier, found `<`
  --> src/test/compile-fail/issue-36116.rs:16:52
   |
16 |     let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>);
   |                                                    ^

error: chained comparison operators require parentheses
  --> src/test/compile-fail/issue-36116.rs:16:52
   |
16 |     let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>);
   |                                                    ^^^^^^
   |
   = help: use `::<...>` instead of `<...>` if you meant to specify type arguments

error: expected expression, found `)`
  --> src/test/compile-fail/issue-36116.rs:16:57
   |
16 |     let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>);
   |                                                         ^

error: expected identifier, found `<`
  --> src/test/compile-fail/issue-36116.rs:20:17
   |
20 |     let g: Foo::<i32> = Foo { _a: 42 };
   |                 ^

error: aborting due to 5 previous errors
```

After:
```rust
error: unexpected token: `::`
  --> src/test/compile-fail/issue-36116.rs:16:50
   |
16 |     let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>);
   |                                                  ^^
   |
   = help: use `<...>` instead of `::<...>` if you meant to specify type arguments

error: unexpected token: `::`
  --> src/test/compile-fail/issue-36116.rs:20:15
   |
20 |     let g: Foo::<i32> = Foo { _a: 42 };
   |               ^^
   |
   = help: use `<...>` instead of `::<...>` if you meant to specify type arguments

error: aborting due to 2 previous errors
```
bors added a commit that referenced this pull request Oct 28, 2016
Rollup of 5 pull requests

- Successful merges: #36206, #37343, #37430, #37436, #37441
- Failed merges:
@bors bors merged commit f7cc6dc into rust-lang:master Oct 28, 2016
@mcarton mcarton deleted the 35755 branch October 28, 2016 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants