Skip to content

Commit 142075a

Browse files
committed
Make UsageMap::get_user_items infallible.
It's nicer this way.
1 parent d9c13cd commit 142075a

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

compiler/rustc_monomorphize/src/collector.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ impl<'tcx> UsageMap<'tcx> {
231231
assert!(self.used_map.insert(user_item, used_items).is_none());
232232
}
233233

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

238238
/// Internally iterate over all inlined items used by `item`.

compiler/rustc_monomorphize/src/partitioning.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -495,20 +495,20 @@ fn internalize_symbols<'tcx>(
495495
if !single_codegen_unit {
496496
debug_assert_eq!(mono_item_placements[item], home_cgu);
497497

498-
if let Some(user_items) = cx.usage_map.get_user_items(*item) {
499-
if user_items
500-
.iter()
501-
.filter_map(|user_item| {
502-
// Some user mono items might not have been
503-
// instantiated. We can safely ignore those.
504-
mono_item_placements.get(user_item)
505-
})
506-
.any(|placement| *placement != home_cgu)
507-
{
508-
// Found a user from another CGU, so skip to the next item
509-
// without marking this one as internal.
510-
continue;
511-
}
498+
if cx
499+
.usage_map
500+
.get_user_items(*item)
501+
.iter()
502+
.filter_map(|user_item| {
503+
// Some user mono items might not have been
504+
// instantiated. We can safely ignore those.
505+
mono_item_placements.get(user_item)
506+
})
507+
.any(|placement| *placement != home_cgu)
508+
{
509+
// Found a user from another CGU, so skip to the next item
510+
// without marking this one as internal.
511+
continue;
512512
}
513513
}
514514

0 commit comments

Comments
 (0)