-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Compiler warns to remove parentheses producing invalid code #103435
Comments
fn main() {
if let(Some(_)) = Some(1) {
}
} which gives the error-introducing suggestion:
|
The warning is correct: it is unnecessary to put parens around the entire The suggestion should be:
|
@rustbot label +A-diagnostics |
@rustbot label D-invalid-suggestion |
Another case: fn main() {
for(_x) in 1..10 { }
} warning: unnecessary parentheses around pattern
--> src/main.rs:2:8
|
2 | for(_x) in 1..10 { }
| ^ ^
|
= note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
|
2 - for(_x) in 1..10 { }
2 + for_x in 1..10 { }
| I guess we may have some other cases for |
@rustbot claim |
…-parentheses, r=estebank Fix unused lint and parser caring about spaces to won't produce invalid code Fixes rust-lang#103435
…-parentheses, r=estebank Fix unused lint and parser caring about spaces to won't produce invalid code Fixes rust-lang#103435
…-parentheses, r=estebank Fix unused lint and parser caring about spaces to won't produce invalid code Fixes rust-lang#103435
…-parentheses, r=estebank Fix unused lint and parser caring about spaces to won't produce invalid code Fixes rust-lang#103435
I tried this code:
I expected to see no compiler warning on the
if let(Some(rt_child)) = rt_child
line.Instead, this happened:
Meta
here is a rust playground link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9d2bfd8156a76f0a565f0caf81b52d80
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: