Inline and remove BasicBlockData::retain_statements
.
It has a single call site, and the code is clearer this way.
This commit is contained in:
parent
627e08c909
commit
69f5e342bf
2 changed files with 6 additions and 16 deletions
|
@ -1365,17 +1365,6 @@ impl<'tcx> BasicBlockData<'tcx> {
|
||||||
self.terminator.as_mut().expect("invalid terminator state")
|
self.terminator.as_mut().expect("invalid terminator state")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn retain_statements<F>(&mut self, mut f: F)
|
|
||||||
where
|
|
||||||
F: FnMut(&mut Statement<'_>) -> bool,
|
|
||||||
{
|
|
||||||
for s in &mut self.statements {
|
|
||||||
if !f(s) {
|
|
||||||
s.make_nop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn visitable(&self, index: usize) -> &dyn MirVisitable<'tcx> {
|
pub fn visitable(&self, index: usize) -> &dyn MirVisitable<'tcx> {
|
||||||
if index < self.statements.len() { &self.statements[index] } else { &self.terminator }
|
if index < self.statements.len() { &self.statements[index] } else { &self.terminator }
|
||||||
}
|
}
|
||||||
|
|
|
@ -393,12 +393,13 @@ impl<'tcx> MutVisitor<'tcx> for TransformVisitor<'tcx> {
|
||||||
|
|
||||||
fn visit_basic_block_data(&mut self, block: BasicBlock, data: &mut BasicBlockData<'tcx>) {
|
fn visit_basic_block_data(&mut self, block: BasicBlock, data: &mut BasicBlockData<'tcx>) {
|
||||||
// Remove StorageLive and StorageDead statements for remapped locals
|
// Remove StorageLive and StorageDead statements for remapped locals
|
||||||
data.retain_statements(|s| match s.kind {
|
for s in &mut data.statements {
|
||||||
StatementKind::StorageLive(l) | StatementKind::StorageDead(l) => {
|
if let StatementKind::StorageLive(l) | StatementKind::StorageDead(l) = s.kind
|
||||||
!self.remap.contains(l)
|
&& self.remap.contains(l)
|
||||||
|
{
|
||||||
|
s.make_nop();
|
||||||
}
|
}
|
||||||
_ => true,
|
}
|
||||||
});
|
|
||||||
|
|
||||||
let ret_val = match data.terminator().kind {
|
let ret_val = match data.terminator().kind {
|
||||||
TerminatorKind::Return => {
|
TerminatorKind::Return => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue