Skip to content

Commit 84a43f0

Browse files
committed
Rewrite nested if conditions into a single match
1 parent 31ae7c4 commit 84a43f0

File tree

1 file changed

+7
-6
lines changed
  • compiler/rustc_middle/src/ty

1 file changed

+7
-6
lines changed

compiler/rustc_middle/src/ty/util.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -473,16 +473,17 @@ impl<'tcx> TyCtxt<'tcx> {
473473
let mut seen = GrowableBitSet::default();
474474
for arg in substs {
475475
match arg.unpack() {
476-
GenericArgKind::Lifetime(lt) => {
477-
if ignore_regions == CheckRegions::OnlyEarlyBound {
478-
let ty::ReEarlyBound(p) = lt.kind() else {
479-
return Err(NotUniqueParam::NotParam(lt.into()))
480-
};
476+
GenericArgKind::Lifetime(lt) => match (ignore_regions, lt.kind()) {
477+
(CheckRegions::OnlyEarlyBound, ty::ReEarlyBound(p)) => {
481478
if !seen.insert(p.index) {
482479
return Err(NotUniqueParam::DuplicateParam(lt.into()));
483480
}
484481
}
485-
}
482+
(CheckRegions::OnlyEarlyBound, _) => {
483+
return Err(NotUniqueParam::NotParam(lt.into()));
484+
}
485+
(CheckRegions::No, _) => {}
486+
},
486487
GenericArgKind::Type(t) => match t.kind() {
487488
ty::Param(p) => {
488489
if !seen.insert(p.index) {

0 commit comments

Comments
 (0)