Skip to content

Commit 5940689

Browse files
committed
move single-use function
1 parent 58bd0ea commit 5940689

File tree

2 files changed

+45
-45
lines changed

2 files changed

+45
-45
lines changed

src/librustc_mir/monomorphize/mod.rs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,50 +8,6 @@ pub mod collector;
88
pub mod item;
99
pub mod partitioning;
1010

11-
#[inline(never)] // give this a place in the profiler
12-
pub fn assert_symbols_are_distinct<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>, mono_items: I)
13-
where I: Iterator<Item=&'a MonoItem<'tcx>>
14-
{
15-
let mut symbols: Vec<_> = mono_items.map(|mono_item| {
16-
(mono_item, mono_item.symbol_name(tcx))
17-
}).collect();
18-
19-
symbols.sort_by_key(|sym| sym.1);
20-
21-
for pair in symbols.windows(2) {
22-
let sym1 = &pair[0].1;
23-
let sym2 = &pair[1].1;
24-
25-
if sym1 == sym2 {
26-
let mono_item1 = pair[0].0;
27-
let mono_item2 = pair[1].0;
28-
29-
let span1 = mono_item1.local_span(tcx);
30-
let span2 = mono_item2.local_span(tcx);
31-
32-
// Deterministically select one of the spans for error reporting
33-
let span = match (span1, span2) {
34-
(Some(span1), Some(span2)) => {
35-
Some(if span1.lo().0 > span2.lo().0 {
36-
span1
37-
} else {
38-
span2
39-
})
40-
}
41-
(span1, span2) => span1.or(span2),
42-
};
43-
44-
let error_message = format!("symbol `{}` is already defined", sym1);
45-
46-
if let Some(span) = span {
47-
tcx.sess.span_fatal(span, &error_message)
48-
} else {
49-
tcx.sess.fatal(&error_message)
50-
}
51-
}
52-
}
53-
}
54-
5511
pub fn custom_coerce_unsize_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
5612
source_ty: Ty<'tcx>,
5713
target_ty: Ty<'tcx>)

src/librustc_mir/monomorphize/partitioning.rs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,50 @@ fn debug_dump<'a, 'b, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
882882
}
883883
}
884884

885+
#[inline(never)] // give this a place in the profiler
886+
fn assert_symbols_are_distinct<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>, mono_items: I)
887+
where I: Iterator<Item=&'a MonoItem<'tcx>>
888+
{
889+
let mut symbols: Vec<_> = mono_items.map(|mono_item| {
890+
(mono_item, mono_item.symbol_name(tcx))
891+
}).collect();
892+
893+
symbols.sort_by_key(|sym| sym.1);
894+
895+
for pair in symbols.windows(2) {
896+
let sym1 = &pair[0].1;
897+
let sym2 = &pair[1].1;
898+
899+
if sym1 == sym2 {
900+
let mono_item1 = pair[0].0;
901+
let mono_item2 = pair[1].0;
902+
903+
let span1 = mono_item1.local_span(tcx);
904+
let span2 = mono_item2.local_span(tcx);
905+
906+
// Deterministically select one of the spans for error reporting
907+
let span = match (span1, span2) {
908+
(Some(span1), Some(span2)) => {
909+
Some(if span1.lo().0 > span2.lo().0 {
910+
span1
911+
} else {
912+
span2
913+
})
914+
}
915+
(span1, span2) => span1.or(span2),
916+
};
917+
918+
let error_message = format!("symbol `{}` is already defined", sym1);
919+
920+
if let Some(span) = span {
921+
tcx.sess.span_fatal(span, &error_message)
922+
} else {
923+
tcx.sess.fatal(&error_message)
924+
}
925+
}
926+
}
927+
}
928+
885929
fn collect_and_partition_mono_items<'a, 'tcx>(
886930
tcx: TyCtxt<'a, 'tcx, 'tcx>,
887931
cnum: CrateNum,
@@ -922,7 +966,7 @@ fn collect_and_partition_mono_items<'a, 'tcx>(
922966

923967
tcx.sess.abort_if_errors();
924968

925-
crate::monomorphize::assert_symbols_are_distinct(tcx, items.iter());
969+
assert_symbols_are_distinct(tcx, items.iter());
926970

927971
let strategy = if tcx.sess.opts.incremental.is_some() {
928972
PartitioningStrategy::PerModule

0 commit comments

Comments
 (0)