mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Resolve merge conflicts. This changes should really be integrated back to their respective
commits but oh dear what a pain.
This commit is contained in:
parent
05eb2eeb61
commit
7ed0e23209
@ -222,9 +222,10 @@ fn assemble_candidates_from_object_type<'cx,'tcx>(
|
||||
ty::ty_trait(ref data) => data,
|
||||
_ => { return; }
|
||||
};
|
||||
let env_predicates = data.projection_bounds_with_self_ty(self_ty).iter()
|
||||
.map(|p| p.as_predicate())
|
||||
.collect();
|
||||
let projection_bounds = data.projection_bounds_with_self_ty(selcx.tcx(), self_ty);
|
||||
let env_predicates = projection_bounds.iter()
|
||||
.map(|p| p.as_predicate())
|
||||
.collect();
|
||||
assemble_candidates_from_predicates(selcx, obligation, candidate_set, env_predicates)
|
||||
}
|
||||
|
||||
|
@ -791,7 +791,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
projection_trait_ref.repr(self.tcx()));
|
||||
|
||||
let trait_def = ty::lookup_trait_def(self.tcx(), projection_trait_ref.def_id);
|
||||
let bounds = trait_def.generics.to_bounds(self.tcx(), &projection_trait_ref.substs);
|
||||
let bounds = trait_def.generics.to_bounds(self.tcx(), projection_trait_ref.substs);
|
||||
debug!("match_projection_obligation_against_bounds_from_trait: \
|
||||
bounds={}",
|
||||
bounds.repr(self.tcx()));
|
||||
|
@ -914,7 +914,7 @@ impl<'tcx> ctxt<'tcx> {
|
||||
sty_debug_print!(
|
||||
self,
|
||||
ty_enum, ty_uniq, ty_vec, ty_ptr, ty_rptr, ty_bare_fn, ty_closure, ty_trait,
|
||||
ty_struct, ty_unboxed_closure, ty_tup, ty_param, ty_open, ty_infer);
|
||||
ty_struct, ty_unboxed_closure, ty_tup, ty_param, ty_open, ty_infer, ty_projection);
|
||||
|
||||
println!("Substs interner: #{}", self.substs_interner.borrow().len());
|
||||
println!("BareFnTy interner: #{}", self.bare_fn_interner.borrow().len());
|
||||
@ -1352,7 +1352,7 @@ pub enum sty<'tcx> {
|
||||
|
||||
ty_closure(Box<ClosureTy<'tcx>>),
|
||||
ty_trait(Box<TyTrait<'tcx>>),
|
||||
ty_struct(DefId, Substs<'tcx>),
|
||||
ty_struct(DefId, &'tcx Substs<'tcx>),
|
||||
|
||||
ty_unboxed_closure(DefId, &'tcx Region, &'tcx Substs<'tcx>),
|
||||
|
||||
@ -1402,7 +1402,9 @@ impl<'tcx> TyTrait<'tcx> {
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn projection_bounds_with_self_ty(&self, self_ty: Ty<'tcx>)
|
||||
pub fn projection_bounds_with_self_ty(&self,
|
||||
tcx: &ctxt<'tcx>,
|
||||
self_ty: Ty<'tcx>)
|
||||
-> Vec<ty::PolyProjectionPredicate<'tcx>>
|
||||
{
|
||||
// otherwise the escaping regions would be captured by the binders
|
||||
@ -1411,10 +1413,10 @@ impl<'tcx> TyTrait<'tcx> {
|
||||
self.bounds.projection_bounds.iter()
|
||||
.map(|in_poly_projection_predicate| {
|
||||
let in_projection_ty = &in_poly_projection_predicate.0.projection_ty;
|
||||
let substs = tcx.mk_substs(in_projection_ty.trait_ref.substs.with_self_ty(self_ty));
|
||||
let trait_ref =
|
||||
Rc::new(ty::TraitRef::new(
|
||||
in_projection_ty.trait_ref.def_id,
|
||||
in_projection_ty.trait_ref.substs.with_self_ty(self_ty)));
|
||||
Rc::new(ty::TraitRef::new(in_projection_ty.trait_ref.def_id,
|
||||
substs));
|
||||
let projection_ty = ty::ProjectionTy {
|
||||
trait_ref: trait_ref,
|
||||
item_name: in_projection_ty.item_name
|
||||
@ -2286,7 +2288,7 @@ pub fn mk_ctxt<'tcx>(s: Session,
|
||||
|
||||
ctxt {
|
||||
arenas: arenas,
|
||||
interner: RefCell::new(FnvHashMap::new()),
|
||||
interner: RefCell::new(interner),
|
||||
substs_interner: RefCell::new(FnvHashMap::new()),
|
||||
bare_fn_interner: RefCell::new(FnvHashMap::new()),
|
||||
region_interner: RefCell::new(FnvHashMap::new()),
|
||||
@ -2386,7 +2388,7 @@ impl<'tcx> ctxt<'tcx> {
|
||||
// and returns the box as cast to an unsafe ptr (see comments for Ty above).
|
||||
pub fn mk_t<'tcx>(cx: &ctxt<'tcx>, st: sty<'tcx>) -> Ty<'tcx> {
|
||||
let mut interner = cx.interner.borrow_mut();
|
||||
intern_ty(cx.type_arena, &mut *interner, st)
|
||||
intern_ty(&cx.arenas.type_, &mut *interner, st)
|
||||
}
|
||||
|
||||
fn intern_ty<'tcx>(type_arena: &'tcx TypedArena<TyS<'tcx>>,
|
||||
@ -2501,12 +2503,12 @@ impl FlagComputation {
|
||||
|
||||
&ty_projection(ref data) => {
|
||||
self.add_flags(HAS_PROJECTION);
|
||||
self.add_substs(&data.trait_ref.substs);
|
||||
self.add_substs(data.trait_ref.substs);
|
||||
}
|
||||
|
||||
&ty_trait(box TyTrait { ref principal, ref bounds }) => {
|
||||
let mut computation = FlagComputation::new();
|
||||
computation.add_substs(&principal.0.substs);
|
||||
computation.add_substs(principal.0.substs);
|
||||
self.add_bound_computation(&computation);
|
||||
|
||||
self.add_bounds(bounds);
|
||||
|
@ -428,7 +428,7 @@ impl<'tcx> TypeMap<'tcx> {
|
||||
from_def_id_and_substs(self,
|
||||
cx,
|
||||
trait_data.principal_def_id(),
|
||||
&trait_data.principal.0.substs,
|
||||
trait_data.principal.0.substs,
|
||||
&mut unique_type_id);
|
||||
},
|
||||
ty::ty_bare_fn(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) => {
|
||||
@ -3819,7 +3819,7 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
},
|
||||
ty::ty_trait(ref trait_data) => {
|
||||
push_item_name(cx, trait_data.principal_def_id(), false, output);
|
||||
push_type_params(cx, &trait_data.principal.0.substs, output);
|
||||
push_type_params(cx, trait_data.principal.0.substs, output);
|
||||
},
|
||||
ty::ty_bare_fn(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) => {
|
||||
if unsafety == ast::Unsafety::Unsafe {
|
||||
|
@ -321,7 +321,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
&ty::UnsizeVtable(ty::TyTrait { ref principal, .. }, _) => {
|
||||
// Note that we preserve binding levels here:
|
||||
let substs = principal.0.substs.with_self_ty(unadjusted_ty).erase_regions();
|
||||
let substs = tcx.tcx().mk_substs(substs);
|
||||
let substs = bcx.tcx().mk_substs(substs);
|
||||
let trait_ref =
|
||||
ty::Binder(Rc::new(ty::TraitRef { def_id: principal.def_id(),
|
||||
substs: substs }));
|
||||
|
@ -348,6 +348,7 @@ impl<'a,'tcx> TypeFolder<'tcx> for AssociatedTypeNormalizer<'a,'tcx> {
|
||||
|
||||
let tcx = self.selcx.tcx();
|
||||
let substs = data.trait_ref.substs.clone().erase_regions();
|
||||
let substs = self.tcx().mk_substs(substs);
|
||||
assert!(substs.types.iter().all(|&t| (!ty::type_has_params(t) &&
|
||||
!ty::type_has_self(t))));
|
||||
let trait_ref = Rc::new(ty::TraitRef::new(data.trait_ref.def_id, substs));
|
||||
|
@ -172,7 +172,9 @@ fn deduce_unboxed_closure_expectations_from_expected_type<'a,'tcx>(
|
||||
{
|
||||
match expected_ty.sty {
|
||||
ty::ty_trait(ref object_type) => {
|
||||
let trait_ref = object_type.principal_trait_ref_with_self_ty(fcx.tcx().types.err);
|
||||
let trait_ref =
|
||||
object_type.principal_trait_ref_with_self_ty(fcx.tcx(),
|
||||
fcx.tcx().types.err);
|
||||
deduce_unboxed_closure_expectations_from_trait_ref(fcx, &trait_ref)
|
||||
}
|
||||
ty::ty_infer(ty::TyVar(vid)) => {
|
||||
|
@ -199,7 +199,7 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>,
|
||||
let fn_sig = fcx.infcx().replace_late_bound_regions_with_fresh_var(span,
|
||||
infer::FnCall,
|
||||
&method_ty.fty.sig).0;
|
||||
let fn_sig = fcx.instantiate_type_scheme(span, &trait_ref.substs, &fn_sig);
|
||||
let fn_sig = fcx.instantiate_type_scheme(span, trait_ref.substs, &fn_sig);
|
||||
let transformed_self_ty = fn_sig.inputs[0];
|
||||
let fty = ty::mk_bare_fn(tcx, None, tcx.mk_bare_fn(ty::BareFnTy {
|
||||
sig: ty::Binder(fn_sig),
|
||||
|
@ -1194,9 +1194,12 @@ fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
impl_m_span,
|
||||
impl_m_body_id,
|
||||
&impl_sig);
|
||||
let impl_fty = ty::mk_bare_fn(tcx, None, ty::BareFnTy { unsafety: impl_m.fty.unsafety,
|
||||
abi: impl_m.fty.abi,
|
||||
sig: ty::Binder(impl_sig) });
|
||||
let impl_fty =
|
||||
ty::mk_bare_fn(tcx,
|
||||
None,
|
||||
tcx.mk_bare_fn(ty::BareFnTy { unsafety: impl_m.fty.unsafety,
|
||||
abi: impl_m.fty.abi,
|
||||
sig: ty::Binder(impl_sig) }));
|
||||
debug!("compare_impl_method: impl_fty={}",
|
||||
impl_fty.repr(tcx));
|
||||
|
||||
@ -1210,9 +1213,12 @@ fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
impl_m_span,
|
||||
impl_m_body_id,
|
||||
&trait_sig);
|
||||
let trait_fty = ty::mk_bare_fn(tcx, None, ty::BareFnTy { unsafety: trait_m.fty.unsafety,
|
||||
abi: trait_m.fty.abi,
|
||||
sig: ty::Binder(trait_sig) });
|
||||
let trait_fty =
|
||||
ty::mk_bare_fn(tcx,
|
||||
None,
|
||||
tcx.mk_bare_fn(ty::BareFnTy { unsafety: trait_m.fty.unsafety,
|
||||
abi: trait_m.fty.abi,
|
||||
sig: ty::Binder(trait_sig) }));
|
||||
|
||||
debug!("compare_impl_method: trait_fty={}",
|
||||
trait_fty.repr(tcx));
|
||||
|
@ -131,7 +131,7 @@ impl<'a, 'tcx> Wf<'a, 'tcx> {
|
||||
// this seems like a minimal requirement:
|
||||
let trait_def = ty::lookup_trait_def(self.tcx, data.trait_ref.def_id);
|
||||
self.accumulate_from_adt(ty, data.trait_ref.def_id,
|
||||
&trait_def.generics, &data.trait_ref.substs)
|
||||
&trait_def.generics, data.trait_ref.substs)
|
||||
}
|
||||
|
||||
ty::ty_tup(ref tuptys) => {
|
||||
|
@ -389,7 +389,8 @@ pub fn register_object_cast_obligations<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
||||
}
|
||||
|
||||
// Finally, create obligations for the projection predicates.
|
||||
let projection_bounds = object_trait.projection_bounds_with_self_ty(referent_ty);
|
||||
let projection_bounds =
|
||||
object_trait.projection_bounds_with_self_ty(fcx.tcx(), referent_ty);
|
||||
for projection_bound in projection_bounds.iter() {
|
||||
let projection_obligation =
|
||||
Obligation::new(cause.clone(), projection_bound.as_predicate());
|
||||
|
@ -838,8 +838,6 @@ pub fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
generics,
|
||||
items);
|
||||
|
||||
assert_eq!(mk_item_substs(ccx, &ty_generics), substs);
|
||||
|
||||
let self_param_ty = ty::ParamTy::for_self();
|
||||
|
||||
let bounds = compute_bounds(ccx,
|
||||
@ -1476,7 +1474,7 @@ pub fn ty_of_foreign_fn_decl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
sig: ty::Binder(ty::FnSig {inputs: input_tys,
|
||||
output: output,
|
||||
variadic: decl.variadic}),
|
||||
});
|
||||
}));
|
||||
let scheme = TypeScheme {
|
||||
generics: ty_generics_for_fn_or_method,
|
||||
ty: t_fn
|
||||
|
@ -787,12 +787,13 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
||||
trait_ref.def_id,
|
||||
trait_def.generics.types.as_slice(),
|
||||
trait_def.generics.regions.as_slice(),
|
||||
&trait_ref.substs,
|
||||
trait_ref.substs,
|
||||
variance);
|
||||
}
|
||||
|
||||
ty::ty_trait(ref data) => {
|
||||
let trait_ref = data.principal_trait_ref_with_self_ty(self.tcx().types.err);
|
||||
let trait_ref = data.principal_trait_ref_with_self_ty(self.tcx(),
|
||||
self.tcx().types.err);
|
||||
let trait_def = ty::lookup_trait_def(self.tcx(), trait_ref.def_id());
|
||||
|
||||
// Traits never declare region parameters in the self
|
||||
@ -815,7 +816,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
||||
}
|
||||
|
||||
ty::ty_param(ref data) => {
|
||||
let def_id = generics.types.get(data.space, data.idx).def_id;
|
||||
let def_id = generics.types.get(data.space, data.idx as uint).def_id;
|
||||
assert_eq!(def_id.krate, ast::LOCAL_CRATE);
|
||||
match self.terms_cx.inferred_map.get(&def_id.node) {
|
||||
Some(&index) => {
|
||||
|
Loading…
Reference in New Issue
Block a user