You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
unused_parens false positive with if let and ranges #121070
Range expressions have a lower precedence than let expression. e.g.
fnmain(){iflet x = (0..1){}}
warning: unnecessary parentheses around `let` scrutinee expression
--> src/main.rs:2:16
|
2 | if let x = (0..1) {}
| ^ ^
|
= note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
|
2 - if let x = (0..1) {}
2 + if let x = 0..1 {}
|
Not using the parenthesis as suggested
fnmain(){iflet x = 0..1{}}
error: expected expression, found `let` statement
--> src/main.rs:2:8
|
2 | if let x = 0..1 {}
| ^^^^^^^^^
|
= note: only supported directly in conditions of `if` and `while` expressions
It would be better if let expressions just had a lower precedence, but that wouldn't be compatible with the fact the ranges are also lower than && and ||. The following:
Activity
Rollup merge of rust-lang#121075 - chenyukang:yukang-fix-121070-lint-…
Unrolled build for rust-lang#121075