Skip to content

Commit b48ba02

Browse files
MaikKleinarielb1
authored andcommitted
Rename more functions from trans to monomorphize
1 parent d4b372d commit b48ba02

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

src/librustc_mir/monomorphize/collector.rs

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
368368
let instance = Instance::mono(tcx, def_id);
369369

370370
// Sanity check whether this ended up being collected accidentally
371-
debug_assert!(should_trans_locally(tcx, &instance));
371+
debug_assert!(should_monomorphize_locally(tcx, &instance));
372372

373373
let ty = instance.ty(tcx);
374374
visit_drop_use(tcx, ty, true, &mut neighbors);
@@ -379,7 +379,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
379379
}
380380
MonoItem::Fn(instance) => {
381381
// Sanity check whether this ended up being collected accidentally
382-
debug_assert!(should_trans_locally(tcx, &instance));
382+
debug_assert!(should_monomorphize_locally(tcx, &instance));
383383

384384
// Keep track of the monomorphization recursion depth
385385
recursion_depth_reset = Some(check_recursion_limit(tcx,
@@ -411,13 +411,13 @@ fn record_accesses<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
411411
caller: MonoItem<'tcx>,
412412
callees: &[MonoItem<'tcx>],
413413
inlining_map: &mut InliningMap<'tcx>) {
414-
let is_inlining_candidate = |trans_item: &MonoItem<'tcx>| {
415-
trans_item.instantiation_mode(tcx) == InstantiationMode::LocalCopy
414+
let is_inlining_candidate = |mono_item: &MonoItem<'tcx>| {
415+
mono_item.instantiation_mode(tcx) == InstantiationMode::LocalCopy
416416
};
417417

418418
let accesses = callees.into_iter()
419-
.map(|trans_item| {
420-
(*trans_item, is_inlining_candidate(trans_item))
419+
.map(|mono_item| {
420+
(*mono_item, is_inlining_candidate(mono_item))
421421
});
422422

423423
inlining_map.record_accesses(caller, accesses);
@@ -541,7 +541,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
541541
ty::TyClosure(def_id, substs) => {
542542
let instance = monomorphize::resolve_closure(
543543
self.tcx, def_id, substs, ty::ClosureKind::FnOnce);
544-
self.output.push(create_fn_trans_item(instance));
544+
self.output.push(create_fn_mono_item(instance));
545545
}
546546
_ => bug!(),
547547
}
@@ -553,8 +553,8 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
553553
.require(ExchangeMallocFnLangItem)
554554
.unwrap_or_else(|e| tcx.sess.fatal(&e));
555555
let instance = Instance::mono(tcx, exchange_malloc_fn_def_id);
556-
if should_trans_locally(tcx, &instance) {
557-
self.output.push(create_fn_trans_item(instance));
556+
if should_monomorphize_locally(tcx, &instance) {
557+
self.output.push(create_fn_mono_item(instance));
558558
}
559559
}
560560
_ => { /* not interesting */ }
@@ -644,7 +644,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
644644

645645
let tcx = self.tcx;
646646
let instance = Instance::mono(tcx, static_.def_id);
647-
if should_trans_locally(tcx, &instance) {
647+
if should_monomorphize_locally(tcx, &instance) {
648648
let node_id = tcx.hir.as_local_node_id(static_.def_id).unwrap();
649649
self.output.push(MonoItem::Static(node_id));
650650
}
@@ -682,7 +682,7 @@ fn visit_instance_use<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
682682
output: &mut Vec<MonoItem<'tcx>>)
683683
{
684684
debug!("visit_item_use({:?}, is_direct_call={:?})", instance, is_direct_call);
685-
if !should_trans_locally(tcx, &instance) {
685+
if !should_monomorphize_locally(tcx, &instance) {
686686
return
687687
}
688688

@@ -696,26 +696,26 @@ fn visit_instance_use<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
696696
ty::InstanceDef::DropGlue(_, None) => {
697697
// don't need to emit shim if we are calling directly.
698698
if !is_direct_call {
699-
output.push(create_fn_trans_item(instance));
699+
output.push(create_fn_mono_item(instance));
700700
}
701701
}
702702
ty::InstanceDef::DropGlue(_, Some(_)) => {
703-
output.push(create_fn_trans_item(instance));
703+
output.push(create_fn_mono_item(instance));
704704
}
705705
ty::InstanceDef::ClosureOnceShim { .. } |
706706
ty::InstanceDef::Item(..) |
707707
ty::InstanceDef::FnPtrShim(..) |
708708
ty::InstanceDef::CloneShim(..) => {
709-
output.push(create_fn_trans_item(instance));
709+
output.push(create_fn_mono_item(instance));
710710
}
711711
}
712712
}
713713

714714
// Returns true if we should translate an instance in the local crate.
715715
// Returns false if we can just link to the upstream crate and therefore don't
716-
// need a translation item.
717-
fn should_trans_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: &Instance<'tcx>)
718-
-> bool {
716+
// need a mono item.
717+
fn should_monomorphize_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: &Instance<'tcx>)
718+
-> bool {
719719
let def_id = match instance.def {
720720
ty::InstanceDef::Item(def_id) => def_id,
721721
ty::InstanceDef::ClosureOnceShim { .. } |
@@ -739,7 +739,7 @@ fn should_trans_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: &Instan
739739
false
740740
} else {
741741
if !tcx.is_mir_available(def_id) {
742-
bug!("Cannot create local trans-item for {:?}", def_id)
742+
bug!("Cannot create local mono-item for {:?}", def_id)
743743
}
744744
true
745745
}
@@ -834,8 +834,8 @@ fn find_vtable_types_for_unsizing<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
834834
}
835835
}
836836

837-
fn create_fn_trans_item<'a, 'tcx>(instance: Instance<'tcx>) -> MonoItem<'tcx> {
838-
debug!("create_fn_trans_item(instance={})", instance);
837+
fn create_fn_mono_item<'a, 'tcx>(instance: Instance<'tcx>) -> MonoItem<'tcx> {
838+
debug!("create_fn_mono_item(instance={})", instance);
839839
MonoItem::Fn(instance)
840840
}
841841

@@ -861,8 +861,8 @@ fn create_mono_items_for_vtable_methods<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
861861
ty::ParamEnv::empty(traits::Reveal::All),
862862
def_id,
863863
substs).unwrap())
864-
.filter(|&instance| should_trans_locally(tcx, &instance))
865-
.map(|instance| create_fn_trans_item(instance));
864+
.filter(|&instance| should_monomorphize_locally(tcx, &instance))
865+
.map(|instance| create_fn_mono_item(instance));
866866
output.extend(methods);
867867
}
868868
// Also add the destructor
@@ -1009,7 +1009,7 @@ fn create_mono_items_for_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
10091009

10101010
let impl_def_id = tcx.hir.local_def_id(item.id);
10111011

1012-
debug!("create_trans_items_for_default_impls(item={})",
1012+
debug!("create_mono_items_for_default_impls(item={})",
10131013
def_id_to_string(tcx, impl_def_id));
10141014

10151015
if let Some(trait_ref) = tcx.impl_trait_ref(impl_def_id) {
@@ -1032,9 +1032,10 @@ fn create_mono_items_for_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
10321032
method.def_id,
10331033
callee_substs).unwrap();
10341034

1035-
let trans_item = create_fn_trans_item(instance);
1036-
if trans_item.is_instantiable(tcx) && should_trans_locally(tcx, &instance) {
1037-
output.push(trans_item);
1035+
let mono_item = create_fn_mono_item(instance);
1036+
if mono_item.is_instantiable(tcx)
1037+
&& should_monomorphize_locally(tcx, &instance) {
1038+
output.push(mono_item);
10381039
}
10391040
}
10401041
}

0 commit comments

Comments
 (0)