simplify UniversalRegions::to_region_vid to just consult the map

This doesn't actually fix the bug, but seems better.
This commit is contained in:
Niko Matsakis 2018-01-11 06:03:51 -05:00
parent 27ede55414
commit bf02c57b16

View File

@ -799,10 +799,12 @@ impl<'tcx> UniversalRegionIndices<'tcx> {
/// during initialization. Relies on the `indices` map having been
/// fully initialized.
pub fn to_region_vid(&self, r: ty::Region<'tcx>) -> RegionVid {
match r {
ty::ReEarlyBound(..) | ty::ReStatic => *self.indices.get(&r).unwrap(),
ty::ReVar(..) => r.to_region_vid(),
_ => bug!("cannot convert `{:?}` to a region vid", r),
if let ty::ReVar(..) = r {
r.to_region_vid()
} else {
*self.indices.get(&r).unwrap_or_else(|| {
bug!("cannot convert `{:?}` to a region vid", r)
})
}
}