diff --git a/compiler/rustc_middle/src/mir/traversal.rs b/compiler/rustc_middle/src/mir/traversal.rs index 9321044c14b7..049cdaab7831 100644 --- a/compiler/rustc_middle/src/mir/traversal.rs +++ b/compiler/rustc_middle/src/mir/traversal.rs @@ -296,7 +296,7 @@ pub fn reverse_postorder<'a, 'tcx>( /// of `if ::CONST`, as well as [`NullOp::UbChecks`]. /// /// [`NullOp::UbChecks`]: rustc_middle::mir::NullOp::UbChecks -fn reachable_blocks<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> BitSet { +pub fn reachable_blocks<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> BitSet { let body = tcx.instance_mir(instance.def); let mut visitor = MonoReachable { body, diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 396b5670e3f8..d83b1d7fe374 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -672,7 +672,7 @@ struct MirUsedCollector<'a, 'tcx> { visiting_call_terminator: bool, /// Set of functions for which it is OK to move large data into. skip_move_check_fns: Option>, - reachable_blocks: Option<&'tcx BitSet>, + reachable_blocks: Option>, } impl<'a, 'tcx> MirUsedCollector<'a, 'tcx> { @@ -836,6 +836,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> { fn visit_basic_block_data(&mut self, block: mir::BasicBlock, data: &mir::BasicBlockData<'tcx>) { if self .reachable_blocks + .as_ref() .expect("we should only walk blocks with CollectionMode::UsedItems") .contains(block) { @@ -1414,6 +1415,7 @@ fn collect_items_of_instance<'tcx>( // added to `used_items` in a hash set, which can efficiently query in the // `body.mentioned_items` loop below without even having to monomorphize the item. let mut used_mentioned_items = FxHashSet::>::default(); + let mut collector = MirUsedCollector { tcx, body, @@ -1424,7 +1426,7 @@ fn collect_items_of_instance<'tcx>( visiting_call_terminator: false, skip_move_check_fns: None, reachable_blocks: if mode == CollectionMode::UsedItems { - Some(tcx.reachable_blocks(instance)) + Some(rustc_middle::mir::traversal::reachable_blocks(tcx, instance)) } else { None },