Skip to content

Commit 13154b8

Browse files
---
yaml --- r: 277828 b: refs/heads/try c: d24ead0 h: refs/heads/master
1 parent ba3dc93 commit 13154b8

File tree

2 files changed

+50
-53
lines changed

2 files changed

+50
-53
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 6dbb0e86aec11050480beb76eade6fb805010ba7
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
4-
refs/heads/try: 2564199d8f50e1f6e5c915bf258999354c6f1262
4+
refs/heads/try: d24ead0f93799c7c6646739396daf68ac46d7309
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/librustc_trans/collector.rs

Lines changed: 49 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(ccx: &CrateContext<'a, 'tcx>,
397397
}
398398
TransItem::Fn(instance) => {
399399
// Keep track of the monomorphization recursion depth
400-
recursion_depth_reset = Some(check_recursion_limit(ccx,
400+
recursion_depth_reset = Some(check_recursion_limit(ccx.tcx(),
401401
instance,
402402
recursion_depths));
403403

@@ -420,7 +420,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(ccx: &CrateContext<'a, 'tcx>,
420420
}
421421
}
422422

423-
record_references(ccx, starting_point, &neighbors[..], reference_map);
423+
record_references(ccx.tcx(), starting_point, &neighbors[..], reference_map);
424424

425425
for neighbour in neighbors {
426426
collect_items_rec(ccx, neighbour, visited, recursion_depths, reference_map);
@@ -433,23 +433,23 @@ fn collect_items_rec<'a, 'tcx: 'a>(ccx: &CrateContext<'a, 'tcx>,
433433
debug!("END collect_items_rec({})", starting_point.to_string(ccx.tcx()));
434434
}
435435

436-
fn record_references<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
437-
caller: TransItem<'tcx>,
438-
callees: &[TransItem<'tcx>],
439-
reference_map: &mut ReferenceMap<'tcx>) {
436+
fn record_references<'tcx>(tcx: &TyCtxt<'tcx>,
437+
caller: TransItem<'tcx>,
438+
callees: &[TransItem<'tcx>],
439+
reference_map: &mut ReferenceMap<'tcx>) {
440440
let iter = callees.into_iter()
441441
.map(|callee| {
442442
let is_inlining_candidate = callee.is_from_extern_crate() ||
443-
callee.requests_inline(ccx.tcx());
443+
callee.requests_inline(tcx);
444444
(*callee, is_inlining_candidate)
445445
});
446446
reference_map.record_references(caller, iter);
447447
}
448448

449-
fn check_recursion_limit<'a, 'tcx: 'a>(ccx: &CrateContext<'a, 'tcx>,
450-
instance: Instance<'tcx>,
451-
recursion_depths: &mut DefIdMap<usize>)
452-
-> (DefId, usize) {
449+
fn check_recursion_limit<'tcx>(tcx: &TyCtxt<'tcx>,
450+
instance: Instance<'tcx>,
451+
recursion_depths: &mut DefIdMap<usize>)
452+
-> (DefId, usize) {
453453
let recursion_depth = recursion_depths.get(&instance.def)
454454
.map(|x| *x)
455455
.unwrap_or(0);
@@ -458,13 +458,13 @@ fn check_recursion_limit<'a, 'tcx: 'a>(ccx: &CrateContext<'a, 'tcx>,
458458
// Code that needs to instantiate the same function recursively
459459
// more than the recursion limit is assumed to be causing an
460460
// infinite expansion.
461-
if recursion_depth > ccx.sess().recursion_limit.get() {
461+
if recursion_depth > tcx.sess.recursion_limit.get() {
462462
let error = format!("reached the recursion limit while instantiating `{}`",
463463
instance);
464-
if let Some(node_id) = ccx.tcx().map.as_local_node_id(instance.def) {
465-
ccx.sess().span_fatal(ccx.tcx().map.span(node_id), &error);
464+
if let Some(node_id) = tcx.map.as_local_node_id(instance.def) {
465+
tcx.sess.span_fatal(tcx.map.span(node_id), &error);
466466
} else {
467-
ccx.sess().fatal(&error);
467+
tcx.sess.fatal(&error);
468468
}
469469
}
470470

@@ -488,8 +488,8 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
488488
match *rvalue {
489489
mir::Rvalue::Aggregate(mir::AggregateKind::Closure(def_id,
490490
ref substs), _) => {
491-
assert!(can_have_local_instance(self.ccx, def_id));
492-
let trans_item = create_fn_trans_item(self.ccx,
491+
assert!(can_have_local_instance(self.ccx.tcx(), def_id));
492+
let trans_item = create_fn_trans_item(self.ccx.tcx(),
493493
def_id,
494494
substs.func_substs,
495495
self.param_substs);
@@ -527,9 +527,9 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
527527
.require(ExchangeMallocFnLangItem)
528528
.unwrap_or_else(|e| self.ccx.sess().fatal(&e));
529529

530-
assert!(can_have_local_instance(self.ccx, exchange_malloc_fn_def_id));
530+
assert!(can_have_local_instance(self.ccx.tcx(), exchange_malloc_fn_def_id));
531531
let exchange_malloc_fn_trans_item =
532-
create_fn_trans_item(self.ccx,
532+
create_fn_trans_item(self.ccx.tcx(),
533533
exchange_malloc_fn_def_id,
534534
&Substs::empty(),
535535
self.param_substs);
@@ -596,7 +596,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
596596
// result in a translation item ...
597597
if can_result_in_trans_item(self.ccx, callee_def_id) {
598598
// ... and create one if it does.
599-
let trans_item = create_fn_trans_item(self.ccx,
599+
let trans_item = create_fn_trans_item(self.ccx.tcx(),
600600
callee_def_id,
601601
callee_substs,
602602
self.param_substs);
@@ -631,18 +631,18 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
631631
return false;
632632
}
633633

634-
can_have_local_instance(ccx, def_id)
634+
can_have_local_instance(ccx.tcx(), def_id)
635635
}
636636
}
637637
}
638638

639-
fn can_have_local_instance<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
640-
def_id: DefId)
641-
-> bool {
639+
fn can_have_local_instance<'tcx>(tcx: &TyCtxt<'tcx>,
640+
def_id: DefId)
641+
-> bool {
642642
// Take a look if we have the definition available. If not, we
643643
// will not emit code for this item in the local crate, and thus
644644
// don't create a translation item for it.
645-
def_id.is_local() || ccx.sess().cstore.is_item_mir_available(def_id)
645+
def_id.is_local() || tcx.sess.cstore.is_item_mir_available(def_id)
646646
}
647647

648648
fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
@@ -667,9 +667,9 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
667667
.require(ExchangeFreeFnLangItem)
668668
.unwrap_or_else(|e| ccx.sess().fatal(&e));
669669

670-
assert!(can_have_local_instance(ccx, exchange_free_fn_def_id));
670+
assert!(can_have_local_instance(ccx.tcx(), exchange_free_fn_def_id));
671671
let exchange_free_fn_trans_item =
672-
create_fn_trans_item(ccx,
672+
create_fn_trans_item(ccx.tcx(),
673673
exchange_free_fn_def_id,
674674
&Substs::empty(),
675675
&Substs::empty());
@@ -706,8 +706,8 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
706706
_ => bug!()
707707
};
708708

709-
if can_have_local_instance(ccx, destructor_did) {
710-
let trans_item = create_fn_trans_item(ccx,
709+
if can_have_local_instance(ccx.tcx(), destructor_did) {
710+
let trans_item = create_fn_trans_item(ccx.tcx(),
711711
destructor_did,
712712
substs,
713713
&Substs::empty());
@@ -961,29 +961,27 @@ fn find_vtable_types_for_unsizing<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
961961
}
962962
}
963963

964-
fn create_fn_trans_item<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
965-
def_id: DefId,
966-
fn_substs: &Substs<'tcx>,
967-
param_substs: &Substs<'tcx>)
968-
-> TransItem<'tcx>
969-
{
964+
fn create_fn_trans_item<'tcx>(tcx: &TyCtxt<'tcx>,
965+
def_id: DefId,
966+
fn_substs: &Substs<'tcx>,
967+
param_substs: &Substs<'tcx>)
968+
-> TransItem<'tcx> {
970969
debug!("create_fn_trans_item(def_id={}, fn_substs={:?}, param_substs={:?})",
971-
def_id_to_string(ccx.tcx(), def_id),
970+
def_id_to_string(tcx, def_id),
972971
fn_substs,
973972
param_substs);
974973

975974
// We only get here, if fn_def_id either designates a local item or
976975
// an inlineable external item. Non-inlineable external items are
977976
// ignored because we don't want to generate any code for them.
978-
let concrete_substs = monomorphize::apply_param_substs(ccx.tcx(),
977+
let concrete_substs = monomorphize::apply_param_substs(tcx,
979978
param_substs,
980979
fn_substs);
981-
let concrete_substs = ccx.tcx().erase_regions(&concrete_substs);
980+
let concrete_substs = tcx.erase_regions(&concrete_substs);
982981

983982
let trans_item =
984983
TransItem::Fn(Instance::new(def_id,
985-
&ccx.tcx().mk_substs(concrete_substs)));
986-
984+
&tcx.mk_substs(concrete_substs)));
987985
return trans_item;
988986
}
989987

@@ -1014,8 +1012,8 @@ fn create_trans_items_for_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
10141012
.filter_map(|opt_impl_method| opt_impl_method)
10151013
// create translation items
10161014
.filter_map(|impl_method| {
1017-
if can_have_local_instance(ccx, impl_method.method.def_id) {
1018-
Some(create_fn_trans_item(ccx,
1015+
if can_have_local_instance(ccx.tcx(), impl_method.method.def_id) {
1016+
Some(create_fn_trans_item(ccx.tcx(),
10191017
impl_method.method.def_id,
10201018
&impl_method.substs,
10211019
&Substs::empty()))
@@ -1063,7 +1061,7 @@ impl<'b, 'a, 'v> hir_visit::Visitor<'v> for RootCollector<'b, 'a, 'v> {
10631061

10641062
hir::ItemImpl(..) => {
10651063
if self.mode == TransItemCollectionMode::Eager {
1066-
create_trans_items_for_default_impls(self.ccx,
1064+
create_trans_items_for_default_impls(self.ccx.tcx(),
10671065
item,
10681066
self.output);
10691067
}
@@ -1149,9 +1147,9 @@ impl<'b, 'a, 'v> hir_visit::Visitor<'v> for RootCollector<'b, 'a, 'v> {
11491147
}
11501148
}
11511149

1152-
fn create_trans_items_for_default_impls<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
1153-
item: &'tcx hir::Item,
1154-
output: &mut Vec<TransItem<'tcx>>) {
1150+
fn create_trans_items_for_default_impls<'tcx>(tcx: &TyCtxt<'tcx>,
1151+
item: &'tcx hir::Item,
1152+
output: &mut Vec<TransItem<'tcx>>) {
11551153
match item.node {
11561154
hir::ItemImpl(_,
11571155
_,
@@ -1163,11 +1161,10 @@ fn create_trans_items_for_default_impls<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
11631161
return
11641162
}
11651163

1166-
let tcx = ccx.tcx();
11671164
let impl_def_id = tcx.map.local_def_id(item.id);
11681165

11691166
debug!("create_trans_items_for_default_impls(item={})",
1170-
def_id_to_string(ccx.tcx(), impl_def_id));
1167+
def_id_to_string(tcx, impl_def_id));
11711168

11721169
if let Some(trait_ref) = tcx.impl_trait_ref(impl_def_id) {
11731170
let default_impls = tcx.provided_trait_methods(trait_ref.def_id);
@@ -1194,13 +1191,13 @@ fn create_trans_items_for_default_impls<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
11941191
assert!(mth.is_provided);
11951192

11961193
let predicates = mth.method.predicates.predicates.subst(tcx, &mth.substs);
1197-
if !normalize_and_test_predicates(ccx.tcx(), predicates.into_vec()) {
1194+
if !normalize_and_test_predicates(tcx, predicates.into_vec()) {
11981195
continue;
11991196
}
12001197

1201-
if can_have_local_instance(ccx, default_impl.def_id) {
1202-
let empty_substs = ccx.tcx().mk_substs(ccx.tcx().erase_regions(mth.substs));
1203-
let item = create_fn_trans_item(ccx,
1198+
if can_have_local_instance(tcx, default_impl.def_id) {
1199+
let empty_substs = tcx.mk_substs(tcx.erase_regions(mth.substs));
1200+
let item = create_fn_trans_item(tcx,
12041201
default_impl.def_id,
12051202
callee_substs,
12061203
empty_substs);

0 commit comments

Comments
 (0)