diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-10-20 12:11:06 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-20 12:11:06 +0900 |
| commit | 378ca5e640180eee0c380ef1128799492dcb1ee0 (patch) | |
| tree | 01665ec9a1be78a158f668b4edb56dfc19a07bcd /compiler | |
| parent | 6df79bf8a8e32c68fd226888c27a989f2b0f55cf (diff) | |
| parent | 39867f3c9fea0e01b5b199d8c2b6b0889284cc85 (diff) | |
| download | rust-378ca5e640180eee0c380ef1128799492dcb1ee0.tar.gz rust-378ca5e640180eee0c380ef1128799492dcb1ee0.zip | |
Rollup merge of #77931 - aticu:fix_60336, r=petrochenkov
Fix false positive for `unused_parens` lint Fixes #60336
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_lint/src/unused.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index 4bff7f317cb..2409069031d 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -751,13 +751,20 @@ impl UnusedDelimLint for UnusedParens { if !Self::is_expr_delims_necessary(inner, followed_by_block) && value.attrs.is_empty() && !value.span.from_expansion() + && (ctx != UnusedDelimsCtx::LetScrutineeExpr + || match inner.kind { + ast::ExprKind::Binary( + rustc_span::source_map::Spanned { node, .. }, + _, + _, + ) if node.lazy() => false, + _ => true, + }) { self.emit_unused_delims_expr(cx, value, ctx, left_pos, right_pos) } } ast::ExprKind::Let(_, ref expr) => { - // FIXME(#60336): Properly handle `let true = (false && true)` - // actually needing the parenthesis. self.check_unused_delims_expr( cx, expr, |
