-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
C-bug
Category: This is a bug.
D-invalid-suggestion
Diagnostics: A structured suggestion resulting in incorrect code.
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 |
rustbot
added
the
D-invalid-suggestion
Diagnostics: A structured suggestion resulting in incorrect code.
label
Oct 23, 2022
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 |
Manishearth
added a commit
to Manishearth/rust
that referenced
this issue
Nov 11, 2022
…-parentheses, r=estebank Fix unused lint and parser caring about spaces to won't produce invalid code Fixes rust-lang#103435
Manishearth
added a commit
to Manishearth/rust
that referenced
this issue
Nov 11, 2022
…-parentheses, r=estebank Fix unused lint and parser caring about spaces to won't produce invalid code Fixes rust-lang#103435
Manishearth
added a commit
to Manishearth/rust
that referenced
this issue
Nov 11, 2022
…-parentheses, r=estebank Fix unused lint and parser caring about spaces to won't produce invalid code Fixes rust-lang#103435
Aaron1011
pushed a commit
to Aaron1011/rust
that referenced
this issue
Jan 6, 2023
…-parentheses, r=estebank Fix unused lint and parser caring about spaces to won't produce invalid code Fixes rust-lang#103435
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
C-bug
Category: This is a bug.
D-invalid-suggestion
Diagnostics: A structured suggestion resulting in incorrect code.
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: