diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2020-01-05 19:52:56 +0100 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2020-01-07 17:47:49 +0100 |
| commit | 56a0aec07fa998e43702216a7e18133af481c076 (patch) | |
| tree | d207e733d8b581c7e05ded869b9c013c597790eb | |
| parent | a80bff87c19cf91deafefc8fdaace71f77727258 (diff) | |
| download | rust-56a0aec07fa998e43702216a7e18133af481c076.tar.gz rust-56a0aec07fa998e43702216a7e18133af481c076.zip | |
Move subst_and_normalize_erasing_regionsto rustc::ty.
| -rw-r--r-- | src/librustc/traits/codegen/mod.rs | 26 | ||||
| -rw-r--r-- | src/librustc/ty/normalize_erasing_regions.rs | 24 |
2 files changed, 24 insertions, 26 deletions
diff --git a/src/librustc/traits/codegen/mod.rs b/src/librustc/traits/codegen/mod.rs index 8bd3f3141d5..8a264a79fb6 100644 --- a/src/librustc/traits/codegen/mod.rs +++ b/src/librustc/traits/codegen/mod.rs @@ -8,7 +8,6 @@ use crate::traits::{ 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> { diff --git a/src/librustc/ty/normalize_erasing_regions.rs b/src/librustc/ty/normalize_erasing_regions.rs index 2fa52e8810b..dc64482907f 100644 --- a/src/librustc/ty/normalize_erasing_regions.rs +++ b/src/librustc/ty/normalize_erasing_regions.rs @@ -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 @@ impl<'tcx> TyCtxt<'tcx> { 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> { |
