Skip to content

Commit 754b3a0

Browse files
committed
---
yaml --- r: 159753 b: refs/heads/auto c: 0b90cde h: refs/heads/master i: 159751: f1b3801 v: v3
1 parent 321f896 commit 754b3a0

File tree

12 files changed

+43
-22
lines changed

12 files changed

+43
-22
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 4ab0c588ff3adb8e9bf4209b59e08f90fe281903
13+
refs/heads/auto: 0b90cded149b74b4ceb51a7ea5d3394aeb4e06a8
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/middle/ty.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5824,7 +5824,8 @@ pub fn erase_late_bound_regions<HR>(
58245824
{
58255825
/*!
58265826
* Replace any late-bound regions bound in `value` with `'static`.
5827-
* Useful in trans.
5827+
* Useful in trans but also method lookup and a few other places
5828+
* where precise region relationships are not required.
58285829
*/
58295830

58305831
replace_late_bound_regions(tcx, value, |_, _| ty::ReStatic).0

branches/auto/src/librustc_trans/trans/base.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,9 @@ pub fn get_res_dtor(ccx: &CrateContext,
519519
let name = csearch::get_symbol(&ccx.sess().cstore, did);
520520
let class_ty = ty::lookup_item_type(tcx, parent_id).ty.subst(tcx, substs);
521521
let llty = type_of_dtor(ccx, class_ty);
522-
let dtor_ty = ty::mk_ctor_fn(ccx.tcx(), ast::DUMMY_NODE_ID,
523-
&[glue::get_drop_glue_type(ccx, t)], ty::mk_nil(ccx.tcx()));
522+
let dtor_ty = ty::mk_ctor_fn(ccx.tcx(),
523+
&[glue::get_drop_glue_type(ccx, t)],
524+
ty::mk_nil(ccx.tcx()));
524525
get_extern_fn(ccx,
525526
&mut *ccx.externs().borrow_mut(),
526527
name.as_slice(),

branches/auto/src/librustc_trans/trans/callee.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,8 @@ pub fn trans_fn_ref_with_substs(
432432
substs.repr(tcx));
433433

434434
assert!(substs.types.all(|t| !ty::type_needs_infer(*t)));
435+
assert!(substs.types.all(|t| !ty::type_has_escaping_regions(*t)));
436+
let substs = substs.erase_regions();
435437

436438
// Load the info for the appropriate trait if necessary.
437439
match ty::trait_of_item(tcx, def_id) {
@@ -470,8 +472,9 @@ pub fn trans_fn_ref_with_substs(
470472
default methods");
471473

472474
// Compute the first substitution
473-
let first_subst = make_substs_for_receiver_types(
474-
tcx, &*trait_ref, &*method);
475+
let first_subst =
476+
make_substs_for_receiver_types(tcx, &*trait_ref, &*method)
477+
.erase_regions();
475478

476479
// And compose them
477480
let new_substs = first_subst.subst(tcx, &substs);
@@ -661,7 +664,7 @@ pub fn trans_lang_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
661664
trans_fn_ref_with_substs_to_callee(bcx,
662665
did,
663666
0,
664-
subst::Substs::empty())
667+
subst::Substs::trans_empty())
665668
},
666669
ArgVals(args),
667670
dest)

branches/auto/src/librustc_trans/trans/closure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ pub fn trans_unboxed_closure<'blk, 'tcx>(
486486
let llfn = get_or_create_declaration_if_unboxed_closure(
487487
bcx,
488488
closure_id,
489-
&bcx.fcx.param_substs.substs).unwrap();
489+
bcx.fcx.param_substs.substs()).unwrap();
490490

491491
let function_type = (*bcx.tcx().unboxed_closures.borrow())[closure_id]
492492
.closure_type

branches/auto/src/librustc_trans/trans/common.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,21 @@ pub type ExternMap = FnvHashMap<String, ValueRef>;
191191
// Here `self_ty` is the real type of the self parameter to this method. It
192192
// will only be set in the case of default methods.
193193
pub struct param_substs {
194-
pub substs: subst::Substs,
194+
substs: subst::Substs,
195195
}
196196

197197
impl param_substs {
198+
pub fn new(substs: subst::Substs) -> param_substs {
199+
assert!(substs.types.all(|t| !ty::type_needs_infer(*t)));
200+
assert!(substs.types.all(|t| !ty::type_has_params(*t)));
201+
assert!(substs.types.all(|t| !ty::type_has_escaping_regions(*t)));
202+
param_substs { substs: substs.erase_regions() }
203+
}
204+
205+
pub fn substs(&self) -> &subst::Substs {
206+
&self.substs
207+
}
208+
198209
pub fn empty() -> param_substs {
199210
param_substs {
200211
substs: subst::Substs::trans_empty(),
@@ -822,6 +833,8 @@ pub fn fulfill_obligation(ccx: &CrateContext,
822833
None => { }
823834
}
824835

836+
debug!("trans fulfill_obligation: trait_ref={}", trait_ref.repr(ccx.tcx()));
837+
825838
ty::populate_implementations_for_trait_if_necessary(tcx, trait_ref.def_id);
826839
let infcx = infer::new_infer_ctxt(tcx);
827840

branches/auto/src/librustc_trans/trans/debuginfo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
14101410
file_metadata: DIFile,
14111411
name_to_append_suffix_to: &mut String)
14121412
-> DIArray {
1413-
let self_type = param_substs.substs.self_ty();
1413+
let self_type = param_substs.substs().self_ty();
14141414

14151415
// Only true for static default methods:
14161416
let has_self_type = self_type.is_some();
@@ -1467,7 +1467,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
14671467
}
14681468

14691469
// Handle other generic parameters
1470-
let actual_types = param_substs.substs.types.get_slice(subst::FnSpace);
1470+
let actual_types = param_substs.substs().types.get_slice(subst::FnSpace);
14711471
for (index, &ast::TyParam{ ident, .. }) in generics.ty_params.iter().enumerate() {
14721472
let actual_type = actual_types[index];
14731473
// Add actual type name to <...> clause of function name

branches/auto/src/librustc_trans/trans/expr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,12 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
329329
bcx.ty_to_string(unsized_ty)).as_slice())
330330
},
331331
&ty::UnsizeVtable(ty::TyTrait { ref principal, .. }, _) => {
332-
let substs = principal.substs.with_self_ty(unsized_ty);
332+
let substs = principal.substs.with_self_ty(unsized_ty).erase_regions();
333333
let trait_ref =
334334
Rc::new(ty::TraitRef { def_id: principal.def_id,
335335
substs: substs });
336336
let trait_ref =
337-
trait_ref.subst(bcx.tcx(), &bcx.fcx.param_substs.substs);
337+
trait_ref.subst(bcx.tcx(), bcx.fcx.param_substs.substs());
338338
let box_ty = mk_ty(unsized_ty);
339339
PointerCast(bcx,
340340
meth::get_vtable(bcx, box_ty, trait_ref),
@@ -1122,7 +1122,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
11221122
.map(|t| (*t).clone())
11231123
.unwrap();
11241124
let trait_ref =
1125-
trait_ref.subst(bcx.tcx(), &bcx.fcx.param_substs.substs);
1125+
trait_ref.subst(bcx.tcx(), bcx.fcx.param_substs.substs());
11261126
let datum = unpack_datum!(bcx, trans(bcx, &**val));
11271127
meth::trans_trait_cast(bcx, datum, expr.id,
11281128
trait_ref, dest)

branches/auto/src/librustc_trans/trans/foreign.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
536536
let _icx = push_ctxt("foreign::build_foreign_fn");
537537

538538
let fnty = ty::node_id_to_type(ccx.tcx(), id);
539-
let mty = fnty.subst(ccx.tcx(), &param_substs.substs);
539+
let mty = fnty.subst(ccx.tcx(), param_substs.substs());
540540
let tys = foreign_types_for_fn_ty(ccx, mty);
541541

542542
unsafe { // unsafe because we call LLVM operations
@@ -558,7 +558,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
558558
let _icx = push_ctxt("foreign::foreign::build_rust_fn");
559559
let tcx = ccx.tcx();
560560
let t = ty::node_id_to_type(tcx, id).subst(
561-
ccx.tcx(), &param_substs.substs);
561+
ccx.tcx(), param_substs.substs());
562562

563563
let ps = ccx.tcx().map.with_path(id, |path| {
564564
let abi = Some(ast_map::PathName(special_idents::clownshoe_abi.name));

branches/auto/src/librustc_trans/trans/glue.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,9 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
287287
val, *ty);
288288
}
289289

290-
let dtor_ty = ty::mk_ctor_fn(variant_cx.tcx(), ast::DUMMY_NODE_ID,
291-
&[get_drop_glue_type(bcx.ccx(), t)], ty::mk_nil(bcx.tcx()));
290+
let dtor_ty = ty::mk_ctor_fn(bcx.tcx(),
291+
&[get_drop_glue_type(bcx.ccx(), t)],
292+
ty::mk_nil(bcx.tcx()));
292293
let (_, variant_cx) = invoke(variant_cx, dtor_addr, args, dtor_ty, None, false);
293294

294295
variant_cx.fcx.pop_and_trans_custom_cleanup_scope(variant_cx, field_scope);

branches/auto/src/librustc_trans/trans/meth.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,11 @@ pub fn trans_method_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
137137
}) => {
138138
let trait_ref =
139139
Rc::new(trait_ref.subst(bcx.tcx(),
140-
&bcx.fcx.param_substs.substs));
140+
bcx.fcx.param_substs.substs()));
141141
let span = bcx.tcx().map.span(method_call.expr_id);
142+
debug!("method_call={} trait_ref={}",
143+
method_call,
144+
trait_ref.repr(bcx.tcx()));
142145
let origin = fulfill_obligation(bcx.ccx(),
143146
span,
144147
(*trait_ref).clone());

branches/auto/src/librustc_trans/trans/monomorphize.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ pub fn monomorphic_fn(ccx: &CrateContext,
6363
None => ()
6464
}
6565

66-
let psubsts = param_substs {
67-
substs: (*real_substs).clone(),
68-
};
66+
debug!("creating param_substs with real_substs={}", real_substs.repr(ccx.tcx()));
67+
let psubsts = param_substs::new((*real_substs).clone());
6968

7069
debug!("monomorphic_fn(\
7170
fn_id={}, \

0 commit comments

Comments
 (0)