[go: nahoru, domu]

Skip to content

Commit

Permalink
Make UsageMap::get_user_items infallible.
Browse files Browse the repository at this point in the history
It's nicer this way.
  • Loading branch information
nnethercote committed Jul 6, 2023
1 parent d9c13cd commit 142075a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_monomorphize/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ impl<'tcx> UsageMap<'tcx> {
assert!(self.used_map.insert(user_item, used_items).is_none());
}

pub fn get_user_items(&self, item: MonoItem<'tcx>) -> Option<&[MonoItem<'tcx>]> {
self.user_map.get(&item).map(|items| items.as_slice())
pub fn get_user_items(&self, item: MonoItem<'tcx>) -> &[MonoItem<'tcx>] {
self.user_map.get(&item).map(|items| items.as_slice()).unwrap_or(&[])
}

/// Internally iterate over all inlined items used by `item`.
Expand Down
28 changes: 14 additions & 14 deletions compiler/rustc_monomorphize/src/partitioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,20 +495,20 @@ fn internalize_symbols<'tcx>(
if !single_codegen_unit {
debug_assert_eq!(mono_item_placements[item], home_cgu);

if let Some(user_items) = cx.usage_map.get_user_items(*item) {
if user_items
.iter()
.filter_map(|user_item| {
// Some user mono items might not have been
// instantiated. We can safely ignore those.
mono_item_placements.get(user_item)
})
.any(|placement| *placement != home_cgu)
{
// Found a user from another CGU, so skip to the next item
// without marking this one as internal.
continue;
}
if cx
.usage_map
.get_user_items(*item)
.iter()
.filter_map(|user_item| {
// Some user mono items might not have been
// instantiated. We can safely ignore those.
mono_item_placements.get(user_item)
})
.any(|placement| *placement != home_cgu)
{
// Found a user from another CGU, so skip to the next item
// without marking this one as internal.
continue;
}
}

Expand Down

0 comments on commit 142075a

Please sign in to comment.