-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Syntax: Recover on for ( $pat in $expr ) $block
#62928
Syntax: Recover on for ( $pat in $expr ) $block
#62928
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
731cd32
to
ee903d4
Compare
ee903d4
to
56b39fb
Compare
I'll take a look at it later today. |
| --------------^ | ||
| | | ||
| opening `(` | ||
| help: remove parenthesis in `for` loop: `elem in vec` |
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.
I'm not entirely happy with the wording:
- The span pointing at the opening brace is slightly redundant.
- The issue is already known to be the superfluous parenthesis, so it thee maim message could be
incorrect parenthesis surrounding for head
or similar (probably something more user friendly). - The primary span points at the closing parenthesis but it doesn't have a label.
- Suggestions that have very subtle changes sometimes make people not pay attention to the text, in this case people might not realize the lack of parenthesis in the suggested code.
- We have two errors pointing at the problem here (the prior "
in
not expected" error, but it's ok emitting both for now)
IMO something like the following would be better:
error: unnecessary parenthesis surroundinig `for` loop head
--> $DIR/recover-for-loop-parens-around-head.rs:10:23
|
LL | for ( elem in vec ) {
| ^ ^ help: remove these surrounding parenthesis
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.
Filed #63113 for following up.
📌 Commit 56b39fb has been approved by |
…ead, r=estebank Syntax: Recover on `for ( $pat in $expr ) $block` Fixes rust-lang#62724 by adding some recovery: ``` error: unexpected closing `)` --> $DIR/recover-for-loop-parens-around-head.rs:10:23 | LL | for ( elem in vec ) { | --------------^ | | | opening `(` | help: remove parenthesis in `for` loop: `elem in vec` ``` The last 2 commits are drive-by cleanups. r? @estebank
…ead, r=estebank Syntax: Recover on `for ( $pat in $expr ) $block` Fixes rust-lang#62724 by adding some recovery: ``` error: unexpected closing `)` --> $DIR/recover-for-loop-parens-around-head.rs:10:23 | LL | for ( elem in vec ) { | --------------^ | | | opening `(` | help: remove parenthesis in `for` loop: `elem in vec` ``` The last 2 commits are drive-by cleanups. r? @estebank
…ead, r=estebank Syntax: Recover on `for ( $pat in $expr ) $block` Fixes rust-lang#62724 by adding some recovery: ``` error: unexpected closing `)` --> $DIR/recover-for-loop-parens-around-head.rs:10:23 | LL | for ( elem in vec ) { | --------------^ | | | opening `(` | help: remove parenthesis in `for` loop: `elem in vec` ``` The last 2 commits are drive-by cleanups. r? @estebank
…ead, r=estebank Syntax: Recover on `for ( $pat in $expr ) $block` Fixes rust-lang#62724 by adding some recovery: ``` error: unexpected closing `)` --> $DIR/recover-for-loop-parens-around-head.rs:10:23 | LL | for ( elem in vec ) { | --------------^ | | | opening `(` | help: remove parenthesis in `for` loop: `elem in vec` ``` The last 2 commits are drive-by cleanups. r? @estebank
Rollup of 12 pull requests Successful merges: - #61965 (Remove mentions of removed `offset_to` method from `align_offset` docs) - #62928 (Syntax: Recover on `for ( $pat in $expr ) $block`) - #63000 (Impl Debug for Chars) - #63083 (Make generic parameters always use modern hygiene) - #63087 (Add very simple edition check to tidy.) - #63093 (Properly check the defining scope of existential types) - #63096 (Add tests for some `existential_type` ICEs) - #63099 (vxworks: Remove Linux-specific comments.) - #63106 (ci: Skip installing SWIG/xz on OSX ) - #63108 (Add links to None in Option doc) - #63109 (std: Fix a failing `fs` test on Windows) - #63111 (Add syntactic and semantic tests for rest patterns, i.e. `..`) Failed merges: r? @ghost
Fixes #62724 by adding some recovery:
The last 2 commits are drive-by cleanups.
r? @estebank