infer: Turn normalize_associated_type into a method on TyCtxt.

This commit is contained in:
Eduard Burtescu 2016-03-11 02:33:20 +02:00
parent 0907c198c4
commit 6e290998c3
13 changed files with 55 additions and 62 deletions

View File

@ -523,18 +523,19 @@ pub struct CombinedSnapshot {
} }
// NOTE: Callable from trans only! // NOTE: Callable from trans only!
pub fn normalize_associated_type<'tcx,T>(tcx: &TyCtxt<'tcx>, value: &T) -> T impl<'tcx> TyCtxt<'tcx> {
pub fn normalize_associated_type<T>(&self, value: &T) -> T
where T : TypeFoldable<'tcx> where T : TypeFoldable<'tcx>
{ {
debug!("normalize_associated_type(t={:?})", value); debug!("normalize_associated_type(t={:?})", value);
let value = tcx.erase_regions(value); let value = self.erase_regions(value);
if !value.has_projection_types() { if !value.has_projection_types() {
return value; return value;
} }
let infcx = InferCtxt::new(tcx, &tcx.tables, None, ProjectionMode::Any); let infcx = InferCtxt::new(self, &self.tables, None, ProjectionMode::Any);
let mut selcx = traits::SelectionContext::new(&infcx); let mut selcx = traits::SelectionContext::new(&infcx);
let cause = traits::ObligationCause::dummy(); let cause = traits::ObligationCause::dummy();
let traits::Normalized { value: result, obligations } = let traits::Normalized { value: result, obligations } =
@ -552,6 +553,7 @@ pub fn normalize_associated_type<'tcx,T>(tcx: &TyCtxt<'tcx>, value: &T) -> T
drain_fulfillment_cx_or_panic(DUMMY_SP, &infcx, &mut fulfill_cx, &result) drain_fulfillment_cx_or_panic(DUMMY_SP, &infcx, &mut fulfill_cx, &result)
} }
}
pub fn drain_fulfillment_cx_or_panic<'a,'tcx,T>(span: Span, pub fn drain_fulfillment_cx_or_panic<'a,'tcx,T>(span: Span,
infcx: &InferCtxt<'a,'tcx>, infcx: &InferCtxt<'a,'tcx>,
@ -1617,7 +1619,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
substs); substs);
if self.normalize { if self.normalize {
normalize_associated_type(&self.tcx, &closure_ty) self.tcx.normalize_associated_type(&closure_ty)
} else { } else {
closure_ty closure_ty
} }

View File

@ -11,7 +11,6 @@
#![allow(non_snake_case)] #![allow(non_snake_case)]
use rustc::hir::def_id::DefId; use rustc::hir::def_id::DefId;
use rustc::infer;
use rustc::ty::subst::Substs; use rustc::ty::subst::Substs;
use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::{self, Ty, TyCtxt};
use middle::const_val::ConstVal; use middle::const_val::ConstVal;
@ -439,7 +438,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
} }
for field in &def.struct_variant().fields { for field in &def.struct_variant().fields {
let field_ty = infer::normalize_associated_type(cx, &field.ty(cx, substs)); let field_ty = cx.normalize_associated_type(&field.ty(cx, substs));
let r = self.check_type_for_ffi(cache, field_ty); let r = self.check_type_for_ffi(cache, field_ty);
match r { match r {
FfiSafe => {} FfiSafe => {}
@ -494,7 +493,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
// Check the contained variants. // Check the contained variants.
for variant in &def.variants { for variant in &def.variants {
for field in &variant.fields { for field in &variant.fields {
let arg = infer::normalize_associated_type(cx, &field.ty(cx, substs)); let arg = cx.normalize_associated_type(&field.ty(cx, substs));
let r = self.check_type_for_ffi(cache, arg); let r = self.check_type_for_ffi(cache, arg);
match r { match r {
FfiSafe => {} FfiSafe => {}
@ -596,7 +595,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
fn check_type_for_ffi_and_report_errors(&mut self, sp: Span, ty: Ty<'tcx>) { fn check_type_for_ffi_and_report_errors(&mut self, sp: Span, ty: Ty<'tcx>) {
// it is only OK to use this function because extern fns cannot have // it is only OK to use this function because extern fns cannot have
// any generic types right now: // any generic types right now:
let ty = infer::normalize_associated_type(self.cx.tcx, &ty); let ty = self.cx.tcx.normalize_associated_type(&ty);
match self.check_type_for_ffi(&mut FnvHashSet(), ty) { match self.check_type_for_ffi(&mut FnvHashSet(), ty) {
FfiResult::FfiSafe => {} FfiResult::FfiSafe => {}

View File

@ -36,7 +36,6 @@ use llvm::{BasicBlockRef, Linkage, ValueRef, Vector, get_param};
use llvm; use llvm;
use rustc::cfg; use rustc::cfg;
use rustc::hir::def_id::DefId; use rustc::hir::def_id::DefId;
use rustc::infer;
use middle::lang_items::{LangItem, ExchangeMallocFnLangItem, StartFnLangItem}; use middle::lang_items::{LangItem, ExchangeMallocFnLangItem, StartFnLangItem};
use middle::weak_lang_items; use middle::weak_lang_items;
use rustc::hir::pat_util::simple_name; use rustc::hir::pat_util::simple_name;
@ -1923,7 +1922,7 @@ pub fn trans_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
let fn_ty = ccx.tcx().lookup_item_type(def_id).ty; let fn_ty = ccx.tcx().lookup_item_type(def_id).ty;
let fn_ty = monomorphize::apply_param_substs(ccx.tcx(), param_substs, &fn_ty); let fn_ty = monomorphize::apply_param_substs(ccx.tcx(), param_substs, &fn_ty);
let sig = ccx.tcx().erase_late_bound_regions(fn_ty.fn_sig()); let sig = ccx.tcx().erase_late_bound_regions(fn_ty.fn_sig());
let sig = infer::normalize_associated_type(ccx.tcx(), &sig); let sig = ccx.tcx().normalize_associated_type(&sig);
let abi = fn_ty.fn_abi(); let abi = fn_ty.fn_abi();
trans_closure(ccx, trans_closure(ccx,
decl, decl,
@ -1947,7 +1946,7 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
let ccx = bcx.fcx.ccx; let ccx = bcx.fcx.ccx;
let sig = ccx.tcx().erase_late_bound_regions(&ctor_ty.fn_sig()); let sig = ccx.tcx().erase_late_bound_regions(&ctor_ty.fn_sig());
let sig = infer::normalize_associated_type(ccx.tcx(), &sig); let sig = ccx.tcx().normalize_associated_type(&sig);
let result_ty = sig.output.unwrap(); let result_ty = sig.output.unwrap();
// Get location to store the result. If the user does not care about // Get location to store the result. If the user does not care about
@ -2017,7 +2016,7 @@ pub fn trans_ctor_shim<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
let ctor_ty = monomorphize::apply_param_substs(ccx.tcx(), param_substs, &ctor_ty); let ctor_ty = monomorphize::apply_param_substs(ccx.tcx(), param_substs, &ctor_ty);
let sig = ccx.tcx().erase_late_bound_regions(&ctor_ty.fn_sig()); let sig = ccx.tcx().erase_late_bound_regions(&ctor_ty.fn_sig());
let sig = infer::normalize_associated_type(ccx.tcx(), &sig); let sig = ccx.tcx().normalize_associated_type(&sig);
let fn_ty = FnType::new(ccx, Abi::Rust, &sig, &[]); let fn_ty = FnType::new(ccx, Abi::Rust, &sig, &[]);
let (arena, fcx): (TypedArena<_>, FunctionContext); let (arena, fcx): (TypedArena<_>, FunctionContext);

View File

@ -22,7 +22,6 @@ use back::symbol_names;
use llvm::{self, ValueRef, get_params}; use llvm::{self, ValueRef, get_params};
use middle::cstore::LOCAL_CRATE; use middle::cstore::LOCAL_CRATE;
use rustc::hir::def_id::DefId; use rustc::hir::def_id::DefId;
use rustc::infer;
use rustc::ty::subst; use rustc::ty::subst;
use rustc::traits; use rustc::traits;
use rustc::hir::map as hir_map; use rustc::hir::map as hir_map;
@ -221,7 +220,7 @@ impl<'tcx> Callee<'tcx> {
extra_args: &[Ty<'tcx>]) -> FnType { extra_args: &[Ty<'tcx>]) -> FnType {
let abi = self.ty.fn_abi(); let abi = self.ty.fn_abi();
let sig = ccx.tcx().erase_late_bound_regions(self.ty.fn_sig()); let sig = ccx.tcx().erase_late_bound_regions(self.ty.fn_sig());
let sig = infer::normalize_associated_type(ccx.tcx(), &sig); let sig = ccx.tcx().normalize_associated_type(&sig);
let mut fn_ty = FnType::unadjusted(ccx, abi, &sig, extra_args); let mut fn_ty = FnType::unadjusted(ccx, abi, &sig, extra_args);
if let Virtual(_) = self.data { if let Virtual(_) = self.data {
// Don't pass the vtable, it's not an argument of the virtual fn. // Don't pass the vtable, it's not an argument of the virtual fn.
@ -361,7 +360,7 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
} }
}; };
let sig = tcx.erase_late_bound_regions(sig); let sig = tcx.erase_late_bound_regions(sig);
let sig = infer::normalize_associated_type(ccx.tcx(), &sig); let sig = ccx.tcx().normalize_associated_type(&sig);
let tuple_input_ty = tcx.mk_tup(sig.inputs.to_vec()); let tuple_input_ty = tcx.mk_tup(sig.inputs.to_vec());
let sig = ty::FnSig { let sig = ty::FnSig {
inputs: vec![bare_fn_ty_maybe_ref, inputs: vec![bare_fn_ty_maybe_ref,
@ -491,7 +490,7 @@ fn get_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
let fn_ptr_ty = match ty.sty { let fn_ptr_ty = match ty.sty {
ty::TyFnDef(_, _, fty) => { ty::TyFnDef(_, _, fty) => {
// Create a fn pointer with the normalized signature. // Create a fn pointer with the normalized signature.
tcx.mk_fn_ptr(infer::normalize_associated_type(tcx, fty)) tcx.mk_fn_ptr(tcx.normalize_associated_type(fty))
} }
_ => bug!("expected fn item type, found {}", ty) _ => bug!("expected fn item type, found {}", ty)
}; };
@ -623,7 +622,7 @@ fn trans_call_inner<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
let abi = callee.ty.fn_abi(); let abi = callee.ty.fn_abi();
let sig = callee.ty.fn_sig(); let sig = callee.ty.fn_sig();
let output = bcx.tcx().erase_late_bound_regions(&sig.output()); let output = bcx.tcx().erase_late_bound_regions(&sig.output());
let output = infer::normalize_associated_type(bcx.tcx(), &output); let output = bcx.tcx().normalize_associated_type(&output);
let extra_args = match args { let extra_args = match args {
ArgExprs(args) if abi != Abi::RustCall => { ArgExprs(args) if abi != Abi::RustCall => {

View File

@ -12,7 +12,7 @@ use arena::TypedArena;
use back::symbol_names; use back::symbol_names;
use llvm::{ValueRef, get_param, get_params}; use llvm::{ValueRef, get_param, get_params};
use rustc::hir::def_id::DefId; use rustc::hir::def_id::DefId;
use rustc::infer::{self, InferCtxt}; use rustc::infer::InferCtxt;
use rustc::traits::ProjectionMode; use rustc::traits::ProjectionMode;
use abi::{Abi, FnType}; use abi::{Abi, FnType};
use adt; use adt;
@ -158,7 +158,7 @@ fn get_or_create_closure_declaration<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
let infcx = InferCtxt::normalizing(tcx, &tcx.tables, ProjectionMode::Any); let infcx = InferCtxt::normalizing(tcx, &tcx.tables, ProjectionMode::Any);
let sig = &infcx.closure_type(closure_id, &substs).sig; let sig = &infcx.closure_type(closure_id, &substs).sig;
let sig = tcx.erase_late_bound_regions(sig); let sig = tcx.erase_late_bound_regions(sig);
let sig = infer::normalize_associated_type(tcx, &sig); let sig = tcx.normalize_associated_type(&sig);
let closure_type = tcx.mk_closure_from_closure_substs(closure_id, Box::new(substs)); let closure_type = tcx.mk_closure_from_closure_substs(closure_id, Box::new(substs));
let function_type = tcx.mk_fn_ptr(ty::BareFnTy { let function_type = tcx.mk_fn_ptr(ty::BareFnTy {
unsafety: hir::Unsafety::Normal, unsafety: hir::Unsafety::Normal,
@ -224,7 +224,7 @@ pub fn trans_closure_expr<'a, 'tcx>(dest: Dest<'a, 'tcx>,
let function_type = infcx.closure_type(closure_def_id, closure_substs); let function_type = infcx.closure_type(closure_def_id, closure_substs);
let sig = tcx.erase_late_bound_regions(&function_type.sig); let sig = tcx.erase_late_bound_regions(&function_type.sig);
let sig = infer::normalize_associated_type(ccx.tcx(), &sig); let sig = ccx.tcx().normalize_associated_type(&sig);
let closure_type = tcx.mk_closure_from_closure_substs(closure_def_id, let closure_type = tcx.mk_closure_from_closure_substs(closure_def_id,
Box::new(closure_substs.clone())); Box::new(closure_substs.clone()));
@ -369,7 +369,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
sig.0.inputs[0] = closure_ty; sig.0.inputs[0] = closure_ty;
let sig = tcx.erase_late_bound_regions(&sig); let sig = tcx.erase_late_bound_regions(&sig);
let sig = infer::normalize_associated_type(ccx.tcx(), &sig); let sig = ccx.tcx().normalize_associated_type(&sig);
let fn_ty = FnType::new(ccx, abi, &sig, &[]); let fn_ty = FnType::new(ccx, abi, &sig, &[]);
let llonce_fn_ty = tcx.mk_fn_ptr(ty::BareFnTy { let llonce_fn_ty = tcx.mk_fn_ptr(ty::BareFnTy {

View File

@ -24,7 +24,6 @@ use llvm::{self, ValueRef};
use llvm::debuginfo::{DIType, DIFile, DIScope, DIDescriptor, DICompositeType}; use llvm::debuginfo::{DIType, DIFile, DIScope, DIDescriptor, DICompositeType};
use rustc::hir::def_id::DefId; use rustc::hir::def_id::DefId;
use rustc::infer;
use rustc::hir::pat_util; use rustc::hir::pat_util;
use rustc::ty::subst; use rustc::ty::subst;
use rustc::hir::map as hir_map; use rustc::hir::map as hir_map;
@ -263,7 +262,7 @@ impl<'tcx> TypeMap<'tcx> {
unique_type_id.push_str(" fn("); unique_type_id.push_str(" fn(");
let sig = cx.tcx().erase_late_bound_regions(sig); let sig = cx.tcx().erase_late_bound_regions(sig);
let sig = infer::normalize_associated_type(cx.tcx(), &sig); let sig = cx.tcx().normalize_associated_type(&sig);
for &parameter_type in &sig.inputs { for &parameter_type in &sig.inputs {
let parameter_type_id = let parameter_type_id =

View File

@ -34,7 +34,6 @@ use rustc::hir;
use abi::Abi; use abi::Abi;
use common::{NodeIdAndSpan, CrateContext, FunctionContext, Block, BlockAndBuilder}; use common::{NodeIdAndSpan, CrateContext, FunctionContext, Block, BlockAndBuilder};
use monomorphize::Instance; use monomorphize::Instance;
use rustc::infer::normalize_associated_type;
use rustc::ty::{self, Ty}; use rustc::ty::{self, Ty};
use session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo}; use session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
use util::nodemap::{DefIdMap, NodeMap, FnvHashMap, FnvHashSet}; use util::nodemap::{DefIdMap, NodeMap, FnvHashMap, FnvHashSet};
@ -369,7 +368,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
name_to_append_suffix_to.push('<'); name_to_append_suffix_to.push('<');
for (i, &actual_type) in actual_types.iter().enumerate() { for (i, &actual_type) in actual_types.iter().enumerate() {
let actual_type = normalize_associated_type(cx.tcx(), &actual_type); let actual_type = cx.tcx().normalize_associated_type(&actual_type);
// Add actual type name to <...> clause of function name // Add actual type name to <...> clause of function name
let actual_type_name = compute_debuginfo_type_name(cx, let actual_type_name = compute_debuginfo_type_name(cx,
actual_type, actual_type,
@ -385,7 +384,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// Again, only create type information if full debuginfo is enabled // Again, only create type information if full debuginfo is enabled
let template_params: Vec<_> = if cx.sess().opts.debuginfo == FullDebugInfo { let template_params: Vec<_> = if cx.sess().opts.debuginfo == FullDebugInfo {
generics.types.as_slice().iter().enumerate().map(|(i, param)| { generics.types.as_slice().iter().enumerate().map(|(i, param)| {
let actual_type = normalize_associated_type(cx.tcx(), &actual_types[i]); let actual_type = cx.tcx().normalize_associated_type(&actual_types[i]);
let actual_type_metadata = type_metadata(cx, actual_type, codemap::DUMMY_SP); let actual_type_metadata = type_metadata(cx, actual_type, codemap::DUMMY_SP);
let name = CString::new(param.name.as_str().as_bytes()).unwrap(); let name = CString::new(param.name.as_str().as_bytes()).unwrap();
unsafe { unsafe {

View File

@ -12,7 +12,6 @@
use common::CrateContext; use common::CrateContext;
use rustc::hir::def_id::DefId; use rustc::hir::def_id::DefId;
use rustc::infer;
use rustc::ty::subst; use rustc::ty::subst;
use rustc::ty::{self, Ty}; use rustc::ty::{self, Ty};
@ -114,7 +113,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
output.push_str("fn("); output.push_str("fn(");
let sig = cx.tcx().erase_late_bound_regions(sig); let sig = cx.tcx().erase_late_bound_regions(sig);
let sig = infer::normalize_associated_type(cx.tcx(), &sig); let sig = cx.tcx().normalize_associated_type(&sig);
if !sig.inputs.is_empty() { if !sig.inputs.is_empty() {
for &parameter_type in &sig.inputs { for &parameter_type in &sig.inputs {
push_debuginfo_type_name(cx, parameter_type, true, output); push_debuginfo_type_name(cx, parameter_type, true, output);

View File

@ -21,7 +21,6 @@
//! * When in doubt, define. //! * When in doubt, define.
use llvm::{self, ValueRef}; use llvm::{self, ValueRef};
use rustc::ty; use rustc::ty;
use rustc::infer;
use abi::{Abi, FnType}; use abi::{Abi, FnType};
use attributes; use attributes;
use context::CrateContext; use context::CrateContext;
@ -105,7 +104,7 @@ pub fn declare_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str,
debug!("declare_rust_fn(name={:?}, fn_type={:?})", name, fn_type); debug!("declare_rust_fn(name={:?}, fn_type={:?})", name, fn_type);
let abi = fn_type.fn_abi(); let abi = fn_type.fn_abi();
let sig = ccx.tcx().erase_late_bound_regions(fn_type.fn_sig()); let sig = ccx.tcx().erase_late_bound_regions(fn_type.fn_sig());
let sig = infer::normalize_associated_type(ccx.tcx(), &sig); let sig = ccx.tcx().normalize_associated_type(&sig);
debug!("declare_rust_fn (after region erasure) sig={:?}", sig); debug!("declare_rust_fn (after region erasure) sig={:?}", sig);
let fty = FnType::new(ccx, abi, &sig, &[]); let fty = FnType::new(ccx, abi, &sig, &[]);

View File

@ -15,7 +15,6 @@ use intrinsics::{self, Intrinsic};
use libc; use libc;
use llvm; use llvm;
use llvm::{ValueRef, TypeKind}; use llvm::{ValueRef, TypeKind};
use rustc::infer;
use rustc::ty::subst; use rustc::ty::subst;
use rustc::ty::subst::FnSpace; use rustc::ty::subst::FnSpace;
use abi::{Abi, FnType}; use abi::{Abi, FnType};
@ -114,7 +113,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
let (def_id, substs, sig) = match callee_ty.sty { let (def_id, substs, sig) = match callee_ty.sty {
ty::TyFnDef(def_id, substs, fty) => { ty::TyFnDef(def_id, substs, fty) => {
let sig = tcx.erase_late_bound_regions(&fty.sig); let sig = tcx.erase_late_bound_regions(&fty.sig);
(def_id, substs, infer::normalize_associated_type(tcx, &sig)) (def_id, substs, tcx.normalize_associated_type(&sig))
} }
_ => bug!("expected fn item type, found {}", callee_ty) _ => bug!("expected fn item type, found {}", callee_ty)
}; };
@ -1352,7 +1351,7 @@ fn generic_simd_intrinsic<'blk, 'tcx, 'a>
let tcx = bcx.tcx(); let tcx = bcx.tcx();
let sig = tcx.erase_late_bound_regions(callee_ty.fn_sig()); let sig = tcx.erase_late_bound_regions(callee_ty.fn_sig());
let sig = infer::normalize_associated_type(tcx, &sig); let sig = tcx.normalize_associated_type(&sig);
let arg_tys = sig.inputs; let arg_tys = sig.inputs;
// every intrinsic takes a SIMD vector as its first argument // every intrinsic takes a SIMD vector as its first argument

View File

@ -14,7 +14,7 @@ use arena::TypedArena;
use back::symbol_names; use back::symbol_names;
use llvm::{ValueRef, get_params}; use llvm::{ValueRef, get_params};
use rustc::hir::def_id::DefId; use rustc::hir::def_id::DefId;
use rustc::infer::{self, InferCtxt}; use rustc::infer::InferCtxt;
use rustc::ty::subst::{FnSpace, Subst, Substs}; use rustc::ty::subst::{FnSpace, Subst, Substs};
use rustc::ty::subst; use rustc::ty::subst;
use rustc::traits::{self, ProjectionMode}; use rustc::traits::{self, ProjectionMode};
@ -86,7 +86,7 @@ pub fn trans_object_shim<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
method_ty); method_ty);
let sig = tcx.erase_late_bound_regions(&method_ty.fn_sig()); let sig = tcx.erase_late_bound_regions(&method_ty.fn_sig());
let sig = infer::normalize_associated_type(tcx, &sig); let sig = tcx.normalize_associated_type(&sig);
let fn_ty = FnType::new(ccx, method_ty.fn_abi(), &sig, &[]); let fn_ty = FnType::new(ccx, method_ty.fn_abi(), &sig, &[]);
let function_name = let function_name =

View File

@ -12,7 +12,6 @@ use back::symbol_names;
use llvm::ValueRef; use llvm::ValueRef;
use llvm; use llvm;
use rustc::hir::def_id::DefId; use rustc::hir::def_id::DefId;
use rustc::infer::normalize_associated_type;
use rustc::ty::subst; use rustc::ty::subst;
use rustc::ty::subst::{Subst, Substs}; use rustc::ty::subst::{Subst, Substs};
use rustc::ty::{self, Ty, TypeFoldable, TyCtxt}; use rustc::ty::{self, Ty, TypeFoldable, TyCtxt};
@ -197,7 +196,7 @@ pub fn apply_param_substs<'tcx,T>(tcx: &TyCtxt<'tcx>,
where T : TypeFoldable<'tcx> where T : TypeFoldable<'tcx>
{ {
let substituted = value.subst(tcx, param_substs); let substituted = value.subst(tcx, param_substs);
normalize_associated_type(tcx, &substituted) tcx.normalize_associated_type(&substituted)
} }
@ -207,5 +206,5 @@ pub fn field_ty<'tcx>(tcx: &TyCtxt<'tcx>,
f: ty::FieldDef<'tcx>) f: ty::FieldDef<'tcx>)
-> Ty<'tcx> -> Ty<'tcx>
{ {
normalize_associated_type(tcx, &f.ty(tcx, param_substs)) tcx.normalize_associated_type(&f.ty(tcx, param_substs))
} }

View File

@ -11,7 +11,7 @@
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]
use rustc::hir::def_id::DefId; use rustc::hir::def_id::DefId;
use rustc::infer::{self, InferCtxt}; use rustc::infer::InferCtxt;
use rustc::ty::subst; use rustc::ty::subst;
use abi::FnType; use abi::FnType;
use adt; use adt;
@ -296,7 +296,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
ty::TyFnDef(..) => Type::nil(cx), ty::TyFnDef(..) => Type::nil(cx),
ty::TyFnPtr(f) => { ty::TyFnPtr(f) => {
let sig = cx.tcx().erase_late_bound_regions(&f.sig); let sig = cx.tcx().erase_late_bound_regions(&f.sig);
let sig = infer::normalize_associated_type(cx.tcx(), &sig); let sig = cx.tcx().normalize_associated_type(&sig);
FnType::new(cx, f.abi, &sig, &[]).llvm_type(cx).ptr_to() FnType::new(cx, f.abi, &sig, &[]).llvm_type(cx).ptr_to()
} }
ty::TyTuple(ref tys) if tys.is_empty() => Type::nil(cx), ty::TyTuple(ref tys) if tys.is_empty() => Type::nil(cx),