Skip to content

Commit 7c6324c

Browse files
committed
Resolve merge conflicts. This changes should really be integrated back to their respective
commits but oh dear what a pain.
1 parent 4156214 commit 7c6324c

File tree

13 files changed

+45
-33
lines changed

13 files changed

+45
-33
lines changed

src/librustc/middle/traits/project.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,10 @@ fn assemble_candidates_from_object_type<'cx,'tcx>(
222222
ty::ty_trait(ref data) => data,
223223
_ => { return; }
224224
};
225-
let env_predicates = data.projection_bounds_with_self_ty(self_ty).iter()
226-
.map(|p| p.as_predicate())
227-
.collect();
225+
let projection_bounds = data.projection_bounds_with_self_ty(selcx.tcx(), self_ty);
226+
let env_predicates = projection_bounds.iter()
227+
.map(|p| p.as_predicate())
228+
.collect();
228229
assemble_candidates_from_predicates(selcx, obligation, candidate_set, env_predicates)
229230
}
230231

src/librustc/middle/traits/select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
791791
projection_trait_ref.repr(self.tcx()));
792792

793793
let trait_def = ty::lookup_trait_def(self.tcx(), projection_trait_ref.def_id);
794-
let bounds = trait_def.generics.to_bounds(self.tcx(), &projection_trait_ref.substs);
794+
let bounds = trait_def.generics.to_bounds(self.tcx(), projection_trait_ref.substs);
795795
debug!("match_projection_obligation_against_bounds_from_trait: \
796796
bounds={}",
797797
bounds.repr(self.tcx()));

src/librustc/middle/ty.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ impl<'tcx> ctxt<'tcx> {
914914
sty_debug_print!(
915915
self,
916916
ty_enum, ty_uniq, ty_vec, ty_ptr, ty_rptr, ty_bare_fn, ty_closure, ty_trait,
917-
ty_struct, ty_unboxed_closure, ty_tup, ty_param, ty_open, ty_infer);
917+
ty_struct, ty_unboxed_closure, ty_tup, ty_param, ty_open, ty_infer, ty_projection);
918918

919919
println!("Substs interner: #{}", self.substs_interner.borrow().len());
920920
println!("BareFnTy interner: #{}", self.bare_fn_interner.borrow().len());
@@ -1352,7 +1352,7 @@ pub enum sty<'tcx> {
13521352

13531353
ty_closure(Box<ClosureTy<'tcx>>),
13541354
ty_trait(Box<TyTrait<'tcx>>),
1355-
ty_struct(DefId, Substs<'tcx>),
1355+
ty_struct(DefId, &'tcx Substs<'tcx>),
13561356

13571357
ty_unboxed_closure(DefId, &'tcx Region, &'tcx Substs<'tcx>),
13581358

@@ -1402,7 +1402,9 @@ impl<'tcx> TyTrait<'tcx> {
14021402
}))
14031403
}
14041404

1405-
pub fn projection_bounds_with_self_ty(&self, self_ty: Ty<'tcx>)
1405+
pub fn projection_bounds_with_self_ty(&self,
1406+
tcx: &ctxt<'tcx>,
1407+
self_ty: Ty<'tcx>)
14061408
-> Vec<ty::PolyProjectionPredicate<'tcx>>
14071409
{
14081410
// otherwise the escaping regions would be captured by the binders
@@ -1411,10 +1413,10 @@ impl<'tcx> TyTrait<'tcx> {
14111413
self.bounds.projection_bounds.iter()
14121414
.map(|in_poly_projection_predicate| {
14131415
let in_projection_ty = &in_poly_projection_predicate.0.projection_ty;
1416+
let substs = tcx.mk_substs(in_projection_ty.trait_ref.substs.with_self_ty(self_ty));
14141417
let trait_ref =
1415-
Rc::new(ty::TraitRef::new(
1416-
in_projection_ty.trait_ref.def_id,
1417-
in_projection_ty.trait_ref.substs.with_self_ty(self_ty)));
1418+
Rc::new(ty::TraitRef::new(in_projection_ty.trait_ref.def_id,
1419+
substs));
14181420
let projection_ty = ty::ProjectionTy {
14191421
trait_ref: trait_ref,
14201422
item_name: in_projection_ty.item_name
@@ -2286,7 +2288,7 @@ pub fn mk_ctxt<'tcx>(s: Session,
22862288

22872289
ctxt {
22882290
arenas: arenas,
2289-
interner: RefCell::new(FnvHashMap::new()),
2291+
interner: RefCell::new(interner),
22902292
substs_interner: RefCell::new(FnvHashMap::new()),
22912293
bare_fn_interner: RefCell::new(FnvHashMap::new()),
22922294
region_interner: RefCell::new(FnvHashMap::new()),
@@ -2386,7 +2388,7 @@ impl<'tcx> ctxt<'tcx> {
23862388
// and returns the box as cast to an unsafe ptr (see comments for Ty above).
23872389
pub fn mk_t<'tcx>(cx: &ctxt<'tcx>, st: sty<'tcx>) -> Ty<'tcx> {
23882390
let mut interner = cx.interner.borrow_mut();
2389-
intern_ty(cx.type_arena, &mut *interner, st)
2391+
intern_ty(&cx.arenas.type_, &mut *interner, st)
23902392
}
23912393

23922394
fn intern_ty<'tcx>(type_arena: &'tcx TypedArena<TyS<'tcx>>,
@@ -2501,12 +2503,12 @@ impl FlagComputation {
25012503

25022504
&ty_projection(ref data) => {
25032505
self.add_flags(HAS_PROJECTION);
2504-
self.add_substs(&data.trait_ref.substs);
2506+
self.add_substs(data.trait_ref.substs);
25052507
}
25062508

25072509
&ty_trait(box TyTrait { ref principal, ref bounds }) => {
25082510
let mut computation = FlagComputation::new();
2509-
computation.add_substs(&principal.0.substs);
2511+
computation.add_substs(principal.0.substs);
25102512
self.add_bound_computation(&computation);
25112513

25122514
self.add_bounds(bounds);

src/librustc_trans/trans/debuginfo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ impl<'tcx> TypeMap<'tcx> {
428428
from_def_id_and_substs(self,
429429
cx,
430430
trait_data.principal_def_id(),
431-
&trait_data.principal.0.substs,
431+
trait_data.principal.0.substs,
432432
&mut unique_type_id);
433433
},
434434
ty::ty_bare_fn(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) => {
@@ -3825,7 +3825,7 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
38253825
},
38263826
ty::ty_trait(ref trait_data) => {
38273827
push_item_name(cx, trait_data.principal_def_id(), false, output);
3828-
push_type_params(cx, &trait_data.principal.0.substs, output);
3828+
push_type_params(cx, trait_data.principal.0.substs, output);
38293829
},
38303830
ty::ty_bare_fn(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) => {
38313831
if unsafety == ast::Unsafety::Unsafe {

src/librustc_trans/trans/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
321321
&ty::UnsizeVtable(ty::TyTrait { ref principal, .. }, _) => {
322322
// Note that we preserve binding levels here:
323323
let substs = principal.0.substs.with_self_ty(unadjusted_ty).erase_regions();
324-
let substs = tcx.tcx().mk_substs(substs);
324+
let substs = bcx.tcx().mk_substs(substs);
325325
let trait_ref =
326326
ty::Binder(Rc::new(ty::TraitRef { def_id: principal.def_id(),
327327
substs: substs }));

src/librustc_trans/trans/monomorphize.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ impl<'a,'tcx> TypeFolder<'tcx> for AssociatedTypeNormalizer<'a,'tcx> {
348348

349349
let tcx = self.selcx.tcx();
350350
let substs = data.trait_ref.substs.clone().erase_regions();
351+
let substs = self.tcx().mk_substs(substs);
351352
assert!(substs.types.iter().all(|&t| (!ty::type_has_params(t) &&
352353
!ty::type_has_self(t))));
353354
let trait_ref = Rc::new(ty::TraitRef::new(data.trait_ref.def_id, substs));

src/librustc_typeck/check/closure.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ fn deduce_unboxed_closure_expectations_from_expected_type<'a,'tcx>(
172172
{
173173
match expected_ty.sty {
174174
ty::ty_trait(ref object_type) => {
175-
let trait_ref = object_type.principal_trait_ref_with_self_ty(fcx.tcx().types.err);
175+
let trait_ref =
176+
object_type.principal_trait_ref_with_self_ty(fcx.tcx(),
177+
fcx.tcx().types.err);
176178
deduce_unboxed_closure_expectations_from_trait_ref(fcx, &trait_ref)
177179
}
178180
ty::ty_infer(ty::TyVar(vid)) => {

src/librustc_typeck/check/method/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>,
199199
let fn_sig = fcx.infcx().replace_late_bound_regions_with_fresh_var(span,
200200
infer::FnCall,
201201
&method_ty.fty.sig).0;
202-
let fn_sig = fcx.instantiate_type_scheme(span, &trait_ref.substs, &fn_sig);
202+
let fn_sig = fcx.instantiate_type_scheme(span, trait_ref.substs, &fn_sig);
203203
let transformed_self_ty = fn_sig.inputs[0];
204204
let fty = ty::mk_bare_fn(tcx, None, tcx.mk_bare_fn(ty::BareFnTy {
205205
sig: ty::Binder(fn_sig),

src/librustc_typeck/check/mod.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,9 +1194,12 @@ fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
11941194
impl_m_span,
11951195
impl_m_body_id,
11961196
&impl_sig);
1197-
let impl_fty = ty::mk_bare_fn(tcx, None, ty::BareFnTy { unsafety: impl_m.fty.unsafety,
1198-
abi: impl_m.fty.abi,
1199-
sig: ty::Binder(impl_sig) });
1197+
let impl_fty =
1198+
ty::mk_bare_fn(tcx,
1199+
None,
1200+
tcx.mk_bare_fn(ty::BareFnTy { unsafety: impl_m.fty.unsafety,
1201+
abi: impl_m.fty.abi,
1202+
sig: ty::Binder(impl_sig) }));
12001203
debug!("compare_impl_method: impl_fty={}",
12011204
impl_fty.repr(tcx));
12021205

@@ -1210,9 +1213,12 @@ fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
12101213
impl_m_span,
12111214
impl_m_body_id,
12121215
&trait_sig);
1213-
let trait_fty = ty::mk_bare_fn(tcx, None, ty::BareFnTy { unsafety: trait_m.fty.unsafety,
1214-
abi: trait_m.fty.abi,
1215-
sig: ty::Binder(trait_sig) });
1216+
let trait_fty =
1217+
ty::mk_bare_fn(tcx,
1218+
None,
1219+
tcx.mk_bare_fn(ty::BareFnTy { unsafety: trait_m.fty.unsafety,
1220+
abi: trait_m.fty.abi,
1221+
sig: ty::Binder(trait_sig) }));
12161222

12171223
debug!("compare_impl_method: trait_fty={}",
12181224
trait_fty.repr(tcx));

src/librustc_typeck/check/regionmanip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl<'a, 'tcx> Wf<'a, 'tcx> {
131131
// this seems like a minimal requirement:
132132
let trait_def = ty::lookup_trait_def(self.tcx, data.trait_ref.def_id);
133133
self.accumulate_from_adt(ty, data.trait_ref.def_id,
134-
&trait_def.generics, &data.trait_ref.substs)
134+
&trait_def.generics, data.trait_ref.substs)
135135
}
136136

137137
ty::ty_tup(ref tuptys) => {

src/librustc_typeck/check/vtable.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,8 @@ pub fn register_object_cast_obligations<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
389389
}
390390

391391
// Finally, create obligations for the projection predicates.
392-
let projection_bounds = object_trait.projection_bounds_with_self_ty(referent_ty);
392+
let projection_bounds =
393+
object_trait.projection_bounds_with_self_ty(fcx.tcx(), referent_ty);
393394
for projection_bound in projection_bounds.iter() {
394395
let projection_obligation =
395396
Obligation::new(cause.clone(), projection_bound.as_predicate());

src/librustc_typeck/collect.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,6 @@ pub fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
844844
generics,
845845
items);
846846

847-
assert_eq!(mk_item_substs(ccx, &ty_generics), substs);
848-
849847
let self_param_ty = ty::ParamTy::for_self();
850848

851849
let bounds = compute_bounds(ccx,
@@ -1478,7 +1476,7 @@ pub fn ty_of_foreign_fn_decl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
14781476
sig: ty::Binder(ty::FnSig {inputs: input_tys,
14791477
output: output,
14801478
variadic: decl.variadic}),
1481-
});
1479+
}));
14821480
let scheme = TypeScheme {
14831481
generics: ty_generics_for_fn_or_method,
14841482
ty: t_fn

src/librustc_typeck/variance.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -787,12 +787,13 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
787787
trait_ref.def_id,
788788
trait_def.generics.types.as_slice(),
789789
trait_def.generics.regions.as_slice(),
790-
&trait_ref.substs,
790+
trait_ref.substs,
791791
variance);
792792
}
793793

794794
ty::ty_trait(ref data) => {
795-
let trait_ref = data.principal_trait_ref_with_self_ty(self.tcx().types.err);
795+
let trait_ref = data.principal_trait_ref_with_self_ty(self.tcx(),
796+
self.tcx().types.err);
796797
let trait_def = ty::lookup_trait_def(self.tcx(), trait_ref.def_id());
797798

798799
// Traits never declare region parameters in the self
@@ -815,7 +816,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
815816
}
816817

817818
ty::ty_param(ref data) => {
818-
let def_id = generics.types.get(data.space, data.idx).def_id;
819+
let def_id = generics.types.get(data.space, data.idx as uint).def_id;
819820
assert_eq!(def_id.krate, ast::LOCAL_CRATE);
820821
match self.terms_cx.inferred_map.get(&def_id.node) {
821822
Some(&index) => {

0 commit comments

Comments
 (0)