-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Conversation
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. |
(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) && |
There was a problem hiding this comment.
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: `::` |
There was a problem hiding this comment.
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.
These changes seem fine to me. I had stylistic nits that would be nice to address. |
In other words, r=me once nits are addressed. |
Addressed nits. |
@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. |
@bors r+ rollup |
📌 Commit 17bbcac has been approved by |
It seems your code fails:
Please update your code and I'll re-r+ it. @bors: r- |
@GuillaumeGomez done. Thanks for pointing that out, that field was renamed in #36470. |
@bors r+ rollup |
📌 Commit 368f435 has been approved by |
@bors r- |
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 |
No problem, done. |
Great, thanks for your patience and perseverance @mcarton |
@bors r+ rollup |
📌 Commit f7cc6dc has been approved by |
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 ```
Fix #36116.
Before:
After: