Skip to content

Commit bf02c57

Browse files
committed
simplify UniversalRegions::to_region_vid to just consult the map
This doesn't actually fix the bug, but seems better.
1 parent 27ede55 commit bf02c57

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/librustc_mir/borrow_check/nll/universal_regions.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -799,10 +799,12 @@ impl<'tcx> UniversalRegionIndices<'tcx> {
799799
/// during initialization. Relies on the `indices` map having been
800800
/// fully initialized.
801801
pub fn to_region_vid(&self, r: ty::Region<'tcx>) -> RegionVid {
802-
match r {
803-
ty::ReEarlyBound(..) | ty::ReStatic => *self.indices.get(&r).unwrap(),
804-
ty::ReVar(..) => r.to_region_vid(),
805-
_ => bug!("cannot convert `{:?}` to a region vid", r),
802+
if let ty::ReVar(..) = r {
803+
r.to_region_vid()
804+
} else {
805+
*self.indices.get(&r).unwrap_or_else(|| {
806+
bug!("cannot convert `{:?}` to a region vid", r)
807+
})
806808
}
807809
}
808810

0 commit comments

Comments
 (0)