From 84a43f0e3aa9b76bc9cef952d25b41ed1e5e0a94 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 25 Apr 2023 07:42:09 +0000 Subject: [PATCH] Rewrite nested `if` conditions into a single match --- compiler/rustc_middle/src/ty/util.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index c2affa24446..97e1f69057e 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -473,16 +473,17 @@ impl<'tcx> TyCtxt<'tcx> { let mut seen = GrowableBitSet::default(); for arg in substs { match arg.unpack() { - GenericArgKind::Lifetime(lt) => { - if ignore_regions == CheckRegions::OnlyEarlyBound { - let ty::ReEarlyBound(p) = lt.kind() else { - return Err(NotUniqueParam::NotParam(lt.into())) - }; + GenericArgKind::Lifetime(lt) => match (ignore_regions, lt.kind()) { + (CheckRegions::OnlyEarlyBound, ty::ReEarlyBound(p)) => { if !seen.insert(p.index) { return Err(NotUniqueParam::DuplicateParam(lt.into())); } } - } + (CheckRegions::OnlyEarlyBound, _) => { + return Err(NotUniqueParam::NotParam(lt.into())); + } + (CheckRegions::No, _) => {} + }, GenericArgKind::Type(t) => match t.kind() { ty::Param(p) => { if !seen.insert(p.index) {