about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2018-01-11 06:03:51 -0500
committerNiko Matsakis <niko@alum.mit.edu>2018-01-11 06:05:05 -0500
commitbf02c57b16264ce332c799237c58eb8bf1c299c0 (patch)
tree9812ecb6e483e42a50ea979c06cc158907a81172 /src
parent27ede55414e01f13c6869a8763da207e544cc6ad (diff)
downloadrust-bf02c57b16264ce332c799237c58eb8bf1c299c0.tar.gz
rust-bf02c57b16264ce332c799237c58eb8bf1c299c0.zip
simplify `UniversalRegions::to_region_vid` to just consult the map
This doesn't actually fix the bug, but seems better.
Diffstat (limited to 'src')
-rw-r--r--src/librustc_mir/borrow_check/nll/universal_regions.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/librustc_mir/borrow_check/nll/universal_regions.rs b/src/librustc_mir/borrow_check/nll/universal_regions.rs
index 45604d52958..0e329266ea1 100644
--- a/src/librustc_mir/borrow_check/nll/universal_regions.rs
+++ b/src/librustc_mir/borrow_check/nll/universal_regions.rs
@@ -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)
+            })
         }
     }