Skip to content

Commit 49b486b

Browse files
Rename Statement::successors to cleanup_target
1 parent 78a856b commit 49b486b

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/librustc/mir/cache.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ fn calculate_successors(mir: &Mir) -> IndexVec<Block, Vec<Block>> {
8181
let mut result = IndexVec::from_elem(vec![], mir.basic_blocks());
8282
for (bb, data) in mir.basic_blocks().iter_enumerated() {
8383
for stmt in &data.statements {
84-
for &tgt in stmt.successors().iter() {
85-
result[bb].push(tgt);
84+
if let Some(cleanup) = stmt.cleanup_target() {
85+
result[bb].push(cleanup);
8686
}
8787
}
8888

src/librustc/mir/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -735,21 +735,21 @@ impl<'tcx> Statement<'tcx> {
735735
self.kind = StatementKind::Nop
736736
}
737737

738-
pub fn successors(&self) -> Cow<[Block]> {
738+
pub fn cleanup_target(&self) -> Option<Block> {
739739
match self.kind {
740740
StatementKind::Assert { cleanup: Some(unwind), .. } => {
741-
vec![unwind].into_cow()
741+
Some(unwind)
742742
}
743-
_ => (&[]).into_cow(),
743+
_ => None
744744
}
745745
}
746746

747-
pub fn successors_mut(&mut self) -> Vec<&mut Block> {
747+
pub fn cleanup_target_mut(&mut self) -> Option<&mut Block> {
748748
match self.kind {
749749
StatementKind::Assert { cleanup: Some(ref mut unwind), .. } => {
750-
vec![unwind]
750+
Some(unwind)
751751
}
752-
_ => Vec::new(),
752+
_ => None
753753
}
754754
}
755755
}

src/librustc_mir/transform/simplify.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ pub fn remove_dead_blocks(mir: &mut Mir) {
273273

274274
for block in basic_blocks {
275275
for stmt in &mut block.statements {
276-
for tgt in stmt.successors_mut() {
277-
*tgt = replacements[tgt.index()];
276+
if let Some(cleanup) = stmt.cleanup_target_mut() {
277+
*cleanup = replacements[cleanup.index()];
278278
}
279279
}
280280

0 commit comments

Comments
 (0)