-
Notifications
You must be signed in to change notification settings - Fork 13.3k
false positive for unused_parens
in a let-else
#131655
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
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
L-unused_parens
Lint: unused_parens
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
I think it should suggest: let Some(_x) = x!() else { return }; |
different macros have different implications in regards to what parentheses are to be used with them, it shouldn't be a concern of the compiler |
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
May 1, 2025
handle paren in macro expand for let-init-else expr Fixes rust-lang#131655 This PR modifies the codegen logic of the macro expansion within `let-init-else` expression: - Before: The expression `let xxx = (mac! {}) else {}` expands to `let xxx = (expanded_ast) else {}`. - After: The same expression expands to `let xxx = expanded_ast else {}`. An alternative solution to this issue could involve handling the source code directly when encountering unused parentheses in `let-init-else` expressions. However, this approach might be more cumbersome due to the absence of the necessary data structure. r? `@petrochenkov`
Zalathar
added a commit
to Zalathar/rust
that referenced
this issue
May 1, 2025
handle paren in macro expand for let-init-else expr Fixes rust-lang#131655 This PR modifies the codegen logic of the macro expansion within `let-init-else` expression: - Before: The expression `let xxx = (mac! {}) else {}` expands to `let xxx = (expanded_ast) else {}`. - After: The same expression expands to `let xxx = expanded_ast else {}`. An alternative solution to this issue could involve handling the source code directly when encountering unused parentheses in `let-init-else` expressions. However, this approach might be more cumbersome due to the absence of the necessary data structure. r? ``@petrochenkov``
Zalathar
added a commit
to Zalathar/rust
that referenced
this issue
May 1, 2025
handle paren in macro expand for let-init-else expr Fixes rust-lang#131655 This PR modifies the codegen logic of the macro expansion within `let-init-else` expression: - Before: The expression `let xxx = (mac! {}) else {}` expands to `let xxx = (expanded_ast) else {}`. - After: The same expression expands to `let xxx = expanded_ast else {}`. An alternative solution to this issue could involve handling the source code directly when encountering unused parentheses in `let-init-else` expressions. However, this approach might be more cumbersome due to the absence of the necessary data structure. r? ```@petrochenkov```
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this issue
May 2, 2025
Rollup merge of rust-lang#134034 - bvanjoi:issue-131655, r=petrochenkov handle paren in macro expand for let-init-else expr Fixes rust-lang#131655 This PR modifies the codegen logic of the macro expansion within `let-init-else` expression: - Before: The expression `let xxx = (mac! {}) else {}` expands to `let xxx = (expanded_ast) else {}`. - After: The same expression expands to `let xxx = expanded_ast else {}`. An alternative solution to this issue could involve handling the source code directly when encountering unused parentheses in `let-init-else` expressions. However, this approach might be more cumbersome due to the absence of the necessary data structure. r? `@petrochenkov`
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-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
L-unused_parens
Lint: unused_parens
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Current output
Desired output
nothing
Rationale and extra context
No response
Other cases
No response
Rust Version
rustc 1.83.0-nightly (6b9676b 2024-10-12)
binary: rustc
commit-hash: 6b9676b
commit-date: 2024-10-12
host: aarch64-apple-darwin
release: 1.83.0-nightly
LLVM version: 19.1.1
Anything else?
This was an issue on a nightly from 7th of August as well
The text was updated successfully, but these errors were encountered: