Skip to content

Commit 69f5e34

Browse files
committed
Inline and remove BasicBlockData::retain_statements.
It has a single call site, and the code is clearer this way.
1 parent 627e08c commit 69f5e34

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

Diff for: compiler/rustc_middle/src/mir/mod.rs

-11
Original file line numberDiff line numberDiff line change
@@ -1365,17 +1365,6 @@ impl<'tcx> BasicBlockData<'tcx> {
13651365
self.terminator.as_mut().expect("invalid terminator state")
13661366
}
13671367

1368-
pub fn retain_statements<F>(&mut self, mut f: F)
1369-
where
1370-
F: FnMut(&mut Statement<'_>) -> bool,
1371-
{
1372-
for s in &mut self.statements {
1373-
if !f(s) {
1374-
s.make_nop();
1375-
}
1376-
}
1377-
}
1378-
13791368
pub fn visitable(&self, index: usize) -> &dyn MirVisitable<'tcx> {
13801369
if index < self.statements.len() { &self.statements[index] } else { &self.terminator }
13811370
}

Diff for: compiler/rustc_mir_transform/src/coroutine.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -393,12 +393,13 @@ impl<'tcx> MutVisitor<'tcx> for TransformVisitor<'tcx> {
393393

394394
fn visit_basic_block_data(&mut self, block: BasicBlock, data: &mut BasicBlockData<'tcx>) {
395395
// Remove StorageLive and StorageDead statements for remapped locals
396-
data.retain_statements(|s| match s.kind {
397-
StatementKind::StorageLive(l) | StatementKind::StorageDead(l) => {
398-
!self.remap.contains(l)
396+
for s in &mut data.statements {
397+
if let StatementKind::StorageLive(l) | StatementKind::StorageDead(l) = s.kind
398+
&& self.remap.contains(l)
399+
{
400+
s.make_nop();
399401
}
400-
_ => true,
401-
});
402+
}
402403

403404
let ret_val = match data.terminator().kind {
404405
TerminatorKind::Return => {

0 commit comments

Comments
 (0)