mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
fix(rustc_lint): mark the parens around (1..loop {})
as unused
This commit is contained in:
parent
6b7fcf720a
commit
f4a0321c03
@ -479,7 +479,7 @@ trait UnusedDelimLint {
|
||||
&& match &inner.kind {
|
||||
ExprKind::Ret(_) | ExprKind::Break(..) | ExprKind::Yield(..) => true,
|
||||
ExprKind::Range(_lhs, Some(rhs), _limits) => {
|
||||
!classify::expr_requires_semi_to_be_stmt(&rhs)
|
||||
matches!(rhs.kind, ExprKind::Block(..))
|
||||
}
|
||||
_ => parser::contains_exterior_struct_lit(&inner),
|
||||
})
|
||||
|
@ -0,0 +1,9 @@
|
||||
// Make sure unused parens lint emit is emitted for loop and match.
|
||||
// See https://github.com/rust-lang/rust/issues/90807
|
||||
// and https://github.com/rust-lang/rust/pull/91956#discussion_r771647953
|
||||
#![deny(unused_parens)]
|
||||
|
||||
fn main() {
|
||||
for _ in (1..loop { break 2 }) {} //~ERROR
|
||||
for _ in (1..match () { () => 2 }) {} //~ERROR
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
error: unnecessary parentheses around `for` iterator expression
|
||||
--> $DIR/issue-90807-unused-paren-error.rs:7:14
|
||||
|
|
||||
LL | for _ in (1..loop { break 2 }) {}
|
||||
| ^ ^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/issue-90807-unused-paren-error.rs:4:9
|
||||
|
|
||||
LL | #![deny(unused_parens)]
|
||||
| ^^^^^^^^^^^^^
|
||||
help: remove these parentheses
|
||||
|
|
||||
LL - for _ in (1..loop { break 2 }) {}
|
||||
LL + for _ in 1..loop { break 2 } {}
|
||||
|
|
||||
|
||||
error: unnecessary parentheses around `for` iterator expression
|
||||
--> $DIR/issue-90807-unused-paren-error.rs:8:14
|
||||
|
|
||||
LL | for _ in (1..match () { () => 2 }) {}
|
||||
| ^ ^
|
||||
|
|
||||
help: remove these parentheses
|
||||
|
|
||||
LL - for _ in (1..match () { () => 2 }) {}
|
||||
LL + for _ in 1..match () { () => 2 } {}
|
||||
|
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
Loading…
Reference in New Issue
Block a user