1
Fork 0

Rollup merge of #77931 - aticu:fix_60336, r=petrochenkov

Fix false positive for `unused_parens` lint

Fixes #60336
This commit is contained in:
Yuki Okushi 2020-10-20 12:11:06 +09:00 committed by GitHub
commit 378ca5e640
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 6 deletions

View file

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