From d5a7ec0929dc438a78716585ceff827d51c8a32f Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 7 Nov 2020 23:45:36 +0000 Subject: [PATCH] Unreachable subpatterns are rare We may as well leave early when we know there's nothing to report. --- compiler/rustc_mir_build/src/thir/pattern/check_match.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index c6fd7bcbf90d..4766e7d178d1 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -389,6 +389,8 @@ fn check_arms<'p, 'tcx>( hir::MatchSource::AwaitDesugar | hir::MatchSource::TryDesugar => {} } } + Useful(unreachables) if unreachables.is_empty() => {} + // The arm is reachable, but contains unreachable subpatterns (from or-patterns). Useful(unreachables) => { let mut unreachables: Vec<_> = unreachables.into_iter().flatten().collect(); // Emit lints in the order in which they occur in the file.