Skip to content

Commit

Permalink
Rename Statement::successors to cleanup_target
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Mar 25, 2017
1 parent 78a856b commit 49b486b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/librustc/mir/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ fn calculate_successors(mir: &Mir) -> IndexVec<Block, Vec<Block>> {
let mut result = IndexVec::from_elem(vec![], mir.basic_blocks());
for (bb, data) in mir.basic_blocks().iter_enumerated() {
for stmt in &data.statements {
for &tgt in stmt.successors().iter() {
result[bb].push(tgt);
if let Some(cleanup) = stmt.cleanup_target() {
result[bb].push(cleanup);
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,21 +735,21 @@ impl<'tcx> Statement<'tcx> {
self.kind = StatementKind::Nop
}

pub fn successors(&self) -> Cow<[Block]> {
pub fn cleanup_target(&self) -> Option<Block> {
match self.kind {
StatementKind::Assert { cleanup: Some(unwind), .. } => {
vec![unwind].into_cow()
Some(unwind)
}
_ => (&[]).into_cow(),
_ => None
}
}

pub fn successors_mut(&mut self) -> Vec<&mut Block> {
pub fn cleanup_target_mut(&mut self) -> Option<&mut Block> {
match self.kind {
StatementKind::Assert { cleanup: Some(ref mut unwind), .. } => {
vec![unwind]
Some(unwind)
}
_ => Vec::new(),
_ => None
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/transform/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ pub fn remove_dead_blocks(mir: &mut Mir) {

for block in basic_blocks {
for stmt in &mut block.statements {
for tgt in stmt.successors_mut() {
*tgt = replacements[tgt.index()];
if let Some(cleanup) = stmt.cleanup_target_mut() {
*cleanup = replacements[cleanup.index()];
}
}

Expand Down

0 comments on commit 49b486b

Please sign in to comment.