diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-05-26 07:28:02 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-05-26 07:28:02 +1000 |
| commit | e6b99a6521535d79a53b2111f236f82fae0b123e (patch) | |
| tree | ad67dafff39406dc132e9f14578dde35cd8fb084 /compiler/rustc_monomorphize | |
| parent | ed216e2f22896e753f481f40f876e1197c0de43d (diff) | |
| download | rust-e6b99a6521535d79a53b2111f236f82fae0b123e.tar.gz rust-e6b99a6521535d79a53b2111f236f82fae0b123e.zip | |
Add struct for the return type of `place_root_mono_items`.
As per review request.
Diffstat (limited to 'compiler/rustc_monomorphize')
| -rw-r--r-- | compiler/rustc_monomorphize/src/partitioning/default.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_monomorphize/src/partitioning/mod.rs | 12 |
2 files changed, 13 insertions, 6 deletions
diff --git a/compiler/rustc_monomorphize/src/partitioning/default.rs b/compiler/rustc_monomorphize/src/partitioning/default.rs index 362e21eaecd..603b3ddc106 100644 --- a/compiler/rustc_monomorphize/src/partitioning/default.rs +++ b/compiler/rustc_monomorphize/src/partitioning/default.rs @@ -15,7 +15,7 @@ use rustc_span::symbol::Symbol; use super::PartitioningCx; use crate::collector::InliningMap; -use crate::partitioning::{MonoItemPlacement, Partition}; +use crate::partitioning::{MonoItemPlacement, Partition, PlacedRootMonoItems}; pub struct DefaultPartitioning; @@ -24,7 +24,7 @@ impl<'tcx> Partition<'tcx> for DefaultPartitioning { &mut self, cx: &PartitioningCx<'_, 'tcx>, mono_items: &mut I, - ) -> (Vec<CodegenUnit<'tcx>>, FxHashSet<MonoItem<'tcx>>, FxHashSet<MonoItem<'tcx>>) + ) -> PlacedRootMonoItems<'tcx> where I: Iterator<Item = MonoItem<'tcx>>, { @@ -89,7 +89,8 @@ impl<'tcx> Partition<'tcx> for DefaultPartitioning { codegen_units.insert(codegen_unit_name, CodegenUnit::new(codegen_unit_name)); } - (codegen_units.into_values().collect(), roots, internalization_candidates) + let codegen_units = codegen_units.into_values().collect(); + PlacedRootMonoItems { codegen_units, roots, internalization_candidates } } fn merge_codegen_units( diff --git a/compiler/rustc_monomorphize/src/partitioning/mod.rs b/compiler/rustc_monomorphize/src/partitioning/mod.rs index ac161bc82d9..d0b23ca9ea4 100644 --- a/compiler/rustc_monomorphize/src/partitioning/mod.rs +++ b/compiler/rustc_monomorphize/src/partitioning/mod.rs @@ -128,7 +128,7 @@ impl<'tcx> Partition<'tcx> for Partitioner { &mut self, cx: &PartitioningCx<'_, 'tcx>, mono_items: &mut I, - ) -> (Vec<CodegenUnit<'tcx>>, FxHashSet<MonoItem<'tcx>>, FxHashSet<MonoItem<'tcx>>) + ) -> PlacedRootMonoItems<'tcx> where I: Iterator<Item = MonoItem<'tcx>>, { @@ -188,12 +188,18 @@ struct PartitioningCx<'a, 'tcx> { inlining_map: &'a InliningMap<'tcx>, } +pub struct PlacedRootMonoItems<'tcx> { + codegen_units: Vec<CodegenUnit<'tcx>>, + roots: FxHashSet<MonoItem<'tcx>>, + internalization_candidates: FxHashSet<MonoItem<'tcx>>, +} + trait Partition<'tcx> { fn place_root_mono_items<I>( &mut self, cx: &PartitioningCx<'_, 'tcx>, mono_items: &mut I, - ) -> (Vec<CodegenUnit<'tcx>>, FxHashSet<MonoItem<'tcx>>, FxHashSet<MonoItem<'tcx>>) + ) -> PlacedRootMonoItems<'tcx> where I: Iterator<Item = MonoItem<'tcx>>; @@ -247,7 +253,7 @@ where // In the first step, we place all regular monomorphizations into their // respective 'home' codegen unit. Regular monomorphizations are all // functions and statics defined in the local crate. - let (mut codegen_units, roots, internalization_candidates) = { + let PlacedRootMonoItems { mut codegen_units, roots, internalization_candidates } = { let _prof_timer = tcx.prof.generic_activity("cgu_partitioning_place_roots"); partitioner.place_root_mono_items(cx, mono_items) }; |
