]> git.lizzy.rs Git - rust.git/commitdiff
Move subst_and_normalize_erasing_regionsto rustc::ty.
authorCamille GILLOT <gillot.camille@gmail.com>
Sun, 5 Jan 2020 18:52:56 +0000 (19:52 +0100)
committerCamille GILLOT <gillot.camille@gmail.com>
Tue, 7 Jan 2020 16:47:49 +0000 (17:47 +0100)
src/librustc/traits/codegen/mod.rs
src/librustc/ty/normalize_erasing_regions.rs

index 8bd3f3141d53d6b963e0579cb3dff0cd4f212ffc..8a264a79fb6c27cc8d82861e9cd323c640315c88 100644 (file)
@@ -8,7 +8,6 @@
     FulfillmentContext, Obligation, ObligationCause, SelectionContext, TraitEngine, Vtable,
 };
 use crate::ty::fold::TypeFoldable;
-use crate::ty::subst::{Subst, SubstsRef};
 use crate::ty::{self, TyCtxt};
 
 /// Attempts to resolve an obligation to a vtable. The result is
@@ -76,31 +75,6 @@ pub fn codegen_fulfill_obligation<'tcx>(
     })
 }
 
-impl<'tcx> TyCtxt<'tcx> {
-    /// Monomorphizes a type from the AST by first applying the
-    /// in-scope substitutions and then normalizing any associated
-    /// types.
-    pub fn subst_and_normalize_erasing_regions<T>(
-        self,
-        param_substs: SubstsRef<'tcx>,
-        param_env: ty::ParamEnv<'tcx>,
-        value: &T,
-    ) -> T
-    where
-        T: TypeFoldable<'tcx>,
-    {
-        debug!(
-            "subst_and_normalize_erasing_regions(\
-             param_substs={:?}, \
-             value={:?}, \
-             param_env={:?})",
-            param_substs, value, param_env,
-        );
-        let substituted = value.subst(self, param_substs);
-        self.normalize_erasing_regions(param_env, substituted)
-    }
-}
-
 // # Global Cache
 
 impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
index 2fa52e8810bd99621a3f2011a398b5ef56655bb1..dc64482907f756a0b972161b726d0d7f03520db5 100644 (file)
@@ -8,6 +8,7 @@
 //! within. (This underlying query is what is cached.)
 
 use crate::ty::fold::{TypeFoldable, TypeFolder};
+use crate::ty::subst::{Subst, SubstsRef};
 use crate::ty::{self, Ty, TyCtxt};
 
 impl<'tcx> TyCtxt<'tcx> {
@@ -60,6 +61,29 @@ pub fn normalize_erasing_late_bound_regions<T>(
         let value = self.erase_late_bound_regions(value);
         self.normalize_erasing_regions(param_env, value)
     }
+
+    /// Monomorphizes a type from the AST by first applying the
+    /// in-scope substitutions and then normalizing any associated
+    /// types.
+    pub fn subst_and_normalize_erasing_regions<T>(
+        self,
+        param_substs: SubstsRef<'tcx>,
+        param_env: ty::ParamEnv<'tcx>,
+        value: &T,
+    ) -> T
+    where
+        T: TypeFoldable<'tcx>,
+    {
+        debug!(
+            "subst_and_normalize_erasing_regions(\
+             param_substs={:?}, \
+             value={:?}, \
+             param_env={:?})",
+            param_substs, value, param_env,
+        );
+        let substituted = value.subst(self, param_substs);
+        self.normalize_erasing_regions(param_env, substituted)
+    }
 }
 
 struct NormalizeAfterErasingRegionsFolder<'tcx> {