about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2016-10-03 12:39:42 -0400
committerNiko Matsakis <niko@alum.mit.edu>2016-11-01 14:04:14 -0400
commitce340af738909feae304f6617bcef55bbb8b7101 (patch)
tree611f26bb19311dbec9efdb97edda72da1c6ca15f
parentf3cc3749271cf21e9f133e7d48136efed11f3be4 (diff)
downloadrust-ce340af738909feae304f6617bcef55bbb8b7101.tar.gz
rust-ce340af738909feae304f6617bcef55bbb8b7101.zip
move outlives_components onto tcx
-rw-r--r--src/librustc/ty/outlives.rs22
-rw-r--r--src/librustc/ty/wf.rs3
-rw-r--r--src/librustc_typeck/check/regionck.rs2
3 files changed, 11 insertions, 16 deletions
diff --git a/src/librustc/ty/outlives.rs b/src/librustc/ty/outlives.rs
index a4edd3b93c9..51feab9d40c 100644
--- a/src/librustc/ty/outlives.rs
+++ b/src/librustc/ty/outlives.rs
@@ -12,8 +12,7 @@
 // refers to rules defined in RFC 1214 (`OutlivesFooBar`), so see that
 // RFC for reference.
 
-use infer::InferCtxt;
-use ty::{self, Ty, TypeFoldable};
+use ty::{self, Ty, TyCtxt, TypeFoldable};
 
 #[derive(Debug)]
 pub enum Component<'tcx> {
@@ -55,9 +54,9 @@ pub enum Component<'tcx> {
     EscapingProjection(Vec<Component<'tcx>>),
 }
 
-impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
+impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
     /// Returns all the things that must outlive `'a` for the condition
-    /// `ty0: 'a` to hold.
+    /// `ty0: 'a` to hold. Note that `ty0` must be a **fully resolved type**.
     pub fn outlives_components(&self, ty0: Ty<'tcx>)
                                -> Vec<Component<'tcx>> {
         let mut components = vec![];
@@ -148,16 +147,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
                 }
             }
 
-            // If we encounter an inference variable, try to resolve it
-            // and proceed with resolved version. If we cannot resolve it,
-            // then record the unresolved variable as a component.
-            ty::TyInfer(_) => {
-                let ty = self.resolve_type_vars_if_possible(&ty);
-                if let ty::TyInfer(infer_ty) = ty.sty {
-                    out.push(Component::UnresolvedInferenceVariable(infer_ty));
-                } else {
-                    self.compute_components(ty, out);
-                }
+            // We assume that inference variables are fully resolved.
+            // So, if we encounter an inference variable, just record
+            // the unresolved variable as a component.
+            ty::TyInfer(infer_ty) => {
+                out.push(Component::UnresolvedInferenceVariable(infer_ty));
             }
 
             // Most types do not introduce any region binders, nor
diff --git a/src/librustc/ty/wf.rs b/src/librustc/ty/wf.rs
index 1135199d225..1392855fdb6 100644
--- a/src/librustc/ty/wf.rs
+++ b/src/librustc/ty/wf.rs
@@ -178,7 +178,8 @@ pub fn implied_bounds<'a, 'gcx, 'tcx>(
                         match infcx.tcx.no_late_bound_regions(data) {
                             None => vec![],
                             Some(ty::OutlivesPredicate(ty_a, r_b)) => {
-                                let components = infcx.outlives_components(ty_a);
+                                let ty_a = infcx.resolve_type_vars_if_possible(&ty_a);
+                                let components = infcx.tcx.outlives_components(ty_a);
                                 implied_bounds_from_components(r_b, components)
                             }
                         },
diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs
index 939deee27c6..23201acf8ee 100644
--- a/src/librustc_typeck/check/regionck.rs
+++ b/src/librustc_typeck/check/regionck.rs
@@ -1474,7 +1474,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
 
         assert!(!ty.has_escaping_regions());
 
-        let components = self.outlives_components(ty);
+        let components = self.tcx.outlives_components(ty);
         self.components_must_outlive(origin, components, region);
     }