Skip to content

Commit a7d246f

Browse files
committed
Auto merge of #144007 - oli-obk:early-abort, r=<try>
Early abort for unused braces check in closure bodies Try to get perf back from #136906 (comment) by doing the cheap checks first r? `@Kobzol`
2 parents 231257f + f7ab51a commit a7d246f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

compiler/rustc_lint/src/unused.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,11 @@ impl UnusedDelimLint for UnusedBraces {
14831483
) {
14841484
match value.kind {
14851485
ast::ExprKind::Block(ref inner, None)
1486-
if inner.rules == ast::BlockCheckMode::Default =>
1486+
if inner.rules == ast::BlockCheckMode::Default
1487+
&& ctx != UnusedDelimsCtx::ClosureBody
1488+
&& value.attrs.is_empty()
1489+
&& !value.span.from_expansion()
1490+
&& !inner.span.from_expansion() =>
14871491
{
14881492
// emit a warning under the following conditions:
14891493
//
@@ -1515,11 +1519,7 @@ impl UnusedDelimLint for UnusedBraces {
15151519
&& (ctx != UnusedDelimsCtx::AnonConst
15161520
|| (matches!(expr.kind, ast::ExprKind::Lit(_))
15171521
&& !expr.span.from_expansion()))
1518-
&& ctx != UnusedDelimsCtx::ClosureBody
15191522
&& !cx.sess().source_map().is_multiline(value.span)
1520-
&& value.attrs.is_empty()
1521-
&& !value.span.from_expansion()
1522-
&& !inner.span.from_expansion()
15231523
{
15241524
self.emit_unused_delims_expr(cx, value, ctx, left_pos, right_pos, is_kw)
15251525
}

0 commit comments

Comments
 (0)