]> git.lizzy.rs Git - rust.git/commitdiff
Extract skolemize_regions() helper function.
authorNiko Matsakis <niko@alum.mit.edu>
Wed, 10 Dec 2014 23:09:50 +0000 (18:09 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Fri, 19 Dec 2014 08:29:30 +0000 (03:29 -0500)
src/librustc/middle/infer/higher_ranked/mod.rs

index d462c223bc65b2174241ac3cf2342353a07b4a35..c1320b6042ab0fb0a016af7cdbfe23a2dc558b66 100644 (file)
@@ -74,17 +74,7 @@ fn higher_ranked_sub<T>(&self, a: &T, b: &T) -> cres<'tcx, T>
 
             // Second, we instantiate each bound region in the supertype with a
             // fresh concrete region.
-            let (b_prime, skol_map) = {
-                replace_late_bound_regions(self.tcx(), b, |br, _| {
-                    let skol =
-                        self.infcx().region_vars.new_skolemized(
-                            br, &snapshot.region_vars_snapshot);
-                    debug!("Bound region {} skolemized to {}",
-                           bound_region_to_string(self.tcx(), "", false, br),
-                           skol);
-                    skol
-                })
-            };
+            let (b_prime, skol_map) = skolemize_regions(self.infcx(), b, snapshot);
 
             debug!("a_prime={}", a_prime.repr(self.tcx()));
             debug!("b_prime={}", b_prime.repr(self.tcx()));
@@ -538,3 +528,23 @@ fn region_vars_confined_to_snapshot(&self,
         region_vars
     }
 }
+
+fn skolemize_regions<'a,'tcx,HR>(infcx: &InferCtxt<'a,'tcx>,
+                                 value: &HR,
+                                 snapshot: &CombinedSnapshot)
+                                 -> (HR, FnvHashMap<ty::BoundRegion,ty::Region>)
+    where HR : HigherRankedFoldable<'tcx>
+{
+    replace_late_bound_regions(infcx.tcx, value, |br, _| {
+        let skol =
+            infcx.region_vars.new_skolemized(
+                br,
+                &snapshot.region_vars_snapshot);
+
+        debug!("Bound region {} skolemized to {}",
+               bound_region_to_string(infcx.tcx, "", false, br),
+               skol);
+
+        skol
+    })
+}