diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-12-19 00:38:41 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-19 00:38:41 +0100 |
| commit | 48915315d2306bbec25c449771fae0ea0538678c (patch) | |
| tree | 64b537c07e696f2482cf3a006f34eb4d53f42608 /compiler | |
| parent | 6b62bf381464f90d177292416a11b2929765a30d (diff) | |
| parent | f4a0321c03884d2f7e71e9850c7524cabdb73c7c (diff) | |
| download | rust-48915315d2306bbec25c449771fae0ea0538678c.tar.gz rust-48915315d2306bbec25c449771fae0ea0538678c.zip | |
Rollup merge of #91956 - notriddle:notriddle/unused-parens-range, r=nagisa
fix(rustc_lint): better detect when parens are necessary Fixes #90807
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_lint/src/unused.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index ed24b94e2fd..8e1c9b6394a 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -478,8 +478,11 @@ trait UnusedDelimLint { lhs_needs_parens || (followed_by_block - && match inner.kind { + && match &inner.kind { ExprKind::Ret(_) | ExprKind::Break(..) | ExprKind::Yield(..) => true, + ExprKind::Range(_lhs, Some(rhs), _limits) => { + matches!(rhs.kind, ExprKind::Block(..)) + } _ => parser::contains_exterior_struct_lit(&inner), }) } |
