From cf136cd3507a5e929cff8d03179c0f6d96bdb687 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 7 Jan 2015 14:04:37 -0500 Subject: [PATCH] Use the `erase_regions` helper within trans in deference to `ty_fold::erase_regions`; also erase regions whenever we normalize associated types. --- src/librustc_trans/trans/common.rs | 2 +- src/librustc_trans/trans/monomorphize.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/librustc_trans/trans/common.rs b/src/librustc_trans/trans/common.rs index bdec9ad378b2..017593f387e2 100644 --- a/src/librustc_trans/trans/common.rs +++ b/src/librustc_trans/trans/common.rs @@ -992,7 +992,7 @@ pub fn fulfill_obligation<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, let tcx = ccx.tcx(); // Remove any references to regions; this helps improve caching. -let trait_ref = ty_fold::erase_regions(tcx, trait_ref); +let trait_ref = erase_regions(tcx, &trait_ref); // First check the cache. match ccx.trait_cache().borrow().get(&trait_ref) { diff --git a/src/librustc_trans/trans/monomorphize.rs b/src/librustc_trans/trans/monomorphize.rs index e2594765f4fd..a35bae07da09 100644 --- a/src/librustc_trans/trans/monomorphize.rs +++ b/src/librustc_trans/trans/monomorphize.rs @@ -315,8 +315,10 @@ pub fn normalize_associated_type<'tcx,T>(tcx: &ty::ctxt<'tcx>, value: &T) -> T { debug!("normalize_associated_type(t={})", value.repr(tcx)); + let value = erase_regions(tcx, value); + if !value.has_projection_types() { - return value.clone(); + return value; } // FIXME(#20304) -- cache @@ -326,7 +328,7 @@ pub fn normalize_associated_type<'tcx,T>(tcx: &ty::ctxt<'tcx>, value: &T) -> T let mut selcx = traits::SelectionContext::new(&infcx, &typer); let cause = traits::ObligationCause::dummy(); let traits::Normalized { value: result, obligations } = - traits::normalize(&mut selcx, cause, value); + traits::normalize(&mut selcx, cause, &value); debug!("normalize_associated_type: result={} obligations={}", result.repr(tcx),