From a7f3c4e6086c70f1c617bae6c157d5dc5636670f Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Thu, 28 Sep 2023 22:39:53 +0000 Subject: [PATCH] Don't resolve basic block data in `Postorder` The only usage immediately throws out the data, so. --- compiler/rustc_middle/src/mir/basic_blocks.rs | 3 +-- compiler/rustc_middle/src/mir/traversal.rs | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_middle/src/mir/basic_blocks.rs b/compiler/rustc_middle/src/mir/basic_blocks.rs index cd770c395e4..c0f02c64bbf 100644 --- a/compiler/rustc_middle/src/mir/basic_blocks.rs +++ b/compiler/rustc_middle/src/mir/basic_blocks.rs @@ -66,8 +66,7 @@ pub fn predecessors(&self) -> &Predecessors { #[inline] pub fn reverse_postorder(&self) -> &[BasicBlock] { self.cache.reverse_postorder.get_or_init(|| { - let mut rpo: Vec<_> = - Postorder::new(&self.basic_blocks, START_BLOCK).map(|(bb, _)| bb).collect(); + let mut rpo: Vec<_> = Postorder::new(&self.basic_blocks, START_BLOCK).collect(); rpo.reverse(); rpo }) diff --git a/compiler/rustc_middle/src/mir/traversal.rs b/compiler/rustc_middle/src/mir/traversal.rs index 07baaa6f90c..a89dbf991f0 100644 --- a/compiler/rustc_middle/src/mir/traversal.rs +++ b/compiler/rustc_middle/src/mir/traversal.rs @@ -188,14 +188,14 @@ fn traverse_successor(&mut self) { } } -impl<'a, 'tcx> Iterator for Postorder<'a, 'tcx> { - type Item = (BasicBlock, &'a BasicBlockData<'tcx>); +impl<'tcx> Iterator for Postorder<'_, 'tcx> { + type Item = BasicBlock; - fn next(&mut self) -> Option<(BasicBlock, &'a BasicBlockData<'tcx>)> { + fn next(&mut self) -> Option { let (bb, _) = self.visit_stack.pop()?; self.traverse_successor(); - - Some((bb, &self.basic_blocks[bb])) + + Some(bb) } fn size_hint(&self) -> (usize, Option) {