From 56a0aec07fa998e43702216a7e18133af481c076 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 5 Jan 2020 19:52:56 +0100 Subject: [PATCH] Move subst_and_normalize_erasing_regionsto rustc::ty. --- src/librustc/traits/codegen/mod.rs | 26 -------------------- 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 @@ 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( - 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 @@ pub fn normalize_erasing_late_bound_regions( 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( + 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> { -- 2.44.0