Rollup merge of #91956 - notriddle:notriddle/unused-parens-range, r=nagisa

fix(rustc_lint): better detect when parens are necessary

Fixes #90807
This commit is contained in:
Matthias Krüger 2021-12-19 00:38:41 +01:00 committed by GitHub
commit 48915315d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 1 deletions

View file

@ -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),
})
}