Skip to content

Commit e6b99a6

Browse files
committed
Add struct for the return type of place_root_mono_items.
As per review request.
1 parent ed216e2 commit e6b99a6

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

compiler/rustc_monomorphize/src/partitioning/default.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_span::symbol::Symbol;
1515

1616
use super::PartitioningCx;
1717
use crate::collector::InliningMap;
18-
use crate::partitioning::{MonoItemPlacement, Partition};
18+
use crate::partitioning::{MonoItemPlacement, Partition, PlacedRootMonoItems};
1919

2020
pub struct DefaultPartitioning;
2121

@@ -24,7 +24,7 @@ impl<'tcx> Partition<'tcx> for DefaultPartitioning {
2424
&mut self,
2525
cx: &PartitioningCx<'_, 'tcx>,
2626
mono_items: &mut I,
27-
) -> (Vec<CodegenUnit<'tcx>>, FxHashSet<MonoItem<'tcx>>, FxHashSet<MonoItem<'tcx>>)
27+
) -> PlacedRootMonoItems<'tcx>
2828
where
2929
I: Iterator<Item = MonoItem<'tcx>>,
3030
{
@@ -89,7 +89,8 @@ impl<'tcx> Partition<'tcx> for DefaultPartitioning {
8989
codegen_units.insert(codegen_unit_name, CodegenUnit::new(codegen_unit_name));
9090
}
9191

92-
(codegen_units.into_values().collect(), roots, internalization_candidates)
92+
let codegen_units = codegen_units.into_values().collect();
93+
PlacedRootMonoItems { codegen_units, roots, internalization_candidates }
9394
}
9495

9596
fn merge_codegen_units(

compiler/rustc_monomorphize/src/partitioning/mod.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl<'tcx> Partition<'tcx> for Partitioner {
128128
&mut self,
129129
cx: &PartitioningCx<'_, 'tcx>,
130130
mono_items: &mut I,
131-
) -> (Vec<CodegenUnit<'tcx>>, FxHashSet<MonoItem<'tcx>>, FxHashSet<MonoItem<'tcx>>)
131+
) -> PlacedRootMonoItems<'tcx>
132132
where
133133
I: Iterator<Item = MonoItem<'tcx>>,
134134
{
@@ -188,12 +188,18 @@ struct PartitioningCx<'a, 'tcx> {
188188
inlining_map: &'a InliningMap<'tcx>,
189189
}
190190

191+
pub struct PlacedRootMonoItems<'tcx> {
192+
codegen_units: Vec<CodegenUnit<'tcx>>,
193+
roots: FxHashSet<MonoItem<'tcx>>,
194+
internalization_candidates: FxHashSet<MonoItem<'tcx>>,
195+
}
196+
191197
trait Partition<'tcx> {
192198
fn place_root_mono_items<I>(
193199
&mut self,
194200
cx: &PartitioningCx<'_, 'tcx>,
195201
mono_items: &mut I,
196-
) -> (Vec<CodegenUnit<'tcx>>, FxHashSet<MonoItem<'tcx>>, FxHashSet<MonoItem<'tcx>>)
202+
) -> PlacedRootMonoItems<'tcx>
197203
where
198204
I: Iterator<Item = MonoItem<'tcx>>;
199205

@@ -247,7 +253,7 @@ where
247253
// In the first step, we place all regular monomorphizations into their
248254
// respective 'home' codegen unit. Regular monomorphizations are all
249255
// functions and statics defined in the local crate.
250-
let (mut codegen_units, roots, internalization_candidates) = {
256+
let PlacedRootMonoItems { mut codegen_units, roots, internalization_candidates } = {
251257
let _prof_timer = tcx.prof.generic_activity("cgu_partitioning_place_roots");
252258
partitioner.place_root_mono_items(cx, mono_items)
253259
};

0 commit comments

Comments
 (0)