-
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
Parenthesized match guards should have a specific parser error (and suggestion) #100825
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-parser
Area: The parsing of Rust source code to an AST
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
D-invalid-suggestion
Diagnostics: A structured suggestion resulting in incorrect code.
D-verbose
Diagnostics: Too much output caused by a single piece of incorrect code.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
CAD97
added
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Aug 20, 2022
rustbot
added
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
D-verbose
Diagnostics: Too much output caused by a single piece of incorrect code.
labels
Aug 20, 2022
estebank
added
A-parser
Area: The parsing of Rust source code to an AST
D-invalid-suggestion
Diagnostics: A structured suggestion resulting in incorrect code.
labels
Aug 22, 2022
estebank
added a commit
to estebank/rust
that referenced
this issue
Nov 4, 2023
Tweak recovery of `for (pat in expr) {}` for more accurate spans. When encountering `match` arm `(pat if expr) => {}`, recover and suggest removing parentheses. Fix rust-lang#100825. Move parser recovery tests to subdirectory.
estebank
added a commit
to estebank/rust
that referenced
this issue
Nov 6, 2023
When encountering match arm (pat if expr) => {}, recover and suggest removing parentheses. Fix rust-lang#100825.
estebank
added a commit
to estebank/rust
that referenced
this issue
Nov 16, 2023
When encountering match arm (pat if expr) => {}, recover and suggest removing parentheses. Fix rust-lang#100825.
estebank
added a commit
to estebank/rust
that referenced
this issue
Nov 17, 2023
When encountering match arm (pat if expr) => {}, recover and suggest removing parentheses. Fix rust-lang#100825.
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Nov 29, 2023
Tweak parsing recovery of enums, for exprs and match arm patterns Tweak recovery of `for (pat in expr) {}` for more accurate spans. When encountering `match` arm `(pat if expr) => {}`, recover and suggest removing parentheses. Fix rust-lang#100825. When encountering malformed enums, try more localized per-variant parse recovery. Move parser recovery tests to subdirectory.
estebank
added a commit
to estebank/rust
that referenced
this issue
Nov 29, 2023
When encountering match arm (pat if expr) => {}, recover and suggest removing parentheses. Fix rust-lang#100825.
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Nov 29, 2023
Tweak parsing recovery of enums, for exprs and match arm patterns Tweak recovery of `for (pat in expr) {}` for more accurate spans. When encountering `match` arm `(pat if expr) => {}`, recover and suggest removing parentheses. Fix rust-lang#100825. When encountering malformed enums, try more localized per-variant parse recovery. Move parser recovery tests to subdirectory.
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Nov 30, 2023
Tweak parsing recovery of enums, for exprs and match arm patterns Tweak recovery of `for (pat in expr) {}` for more accurate spans. When encountering `match` arm `(pat if expr) => {}`, recover and suggest removing parentheses. Fix rust-lang#100825. When encountering malformed enums, try more localized per-variant parse recovery. Move parser recovery tests to subdirectory.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-parser
Area: The parsing of Rust source code to an AST
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
D-invalid-suggestion
Diagnostics: A structured suggestion resulting in incorrect code.
D-verbose
Diagnostics: Too much output caused by a single piece of incorrect code.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Given the following code: [playground]
The current output is:
Ideally the output should look like:
As-is, results in
unused_parens
warning. Alternative help that doesn't:Bonus points:
Stash this error while parsing and tweak it later when types are available; e.g. if the scrutinee actually is
(_, _, _)
, perhaps(_, r#if, true)
(what this currently seemingly error-recovers as) actually was meant. With a non-tuple scrutinee, though, clearly the parenthesization was meant.Support parsing parenthesized guards in nested patterns and give the nice parser error there. Note that for the guard lifting to be semantics preserving, it must not exit any alt (
|
) pattern combinations.examples
@rustbot label +D-confusing +D-verbose
(Is this D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.
? The
help
is not moving towards correct code.)The text was updated successfully, but these errors were encountered: