Remove duplicated implementations of borrowed locals analysis
This commit is contained in:
parent
37a42258ff
commit
915f091819
4 changed files with 29 additions and 133 deletions
|
@ -145,3 +145,23 @@ where
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The set of locals that are borrowed at some point in the MIR body.
|
||||
pub fn borrowed_locals(body: &Body<'_>) -> BitSet<Local> {
|
||||
struct Borrowed(BitSet<Local>);
|
||||
|
||||
impl GenKill<Local> for Borrowed {
|
||||
#[inline]
|
||||
fn gen(&mut self, elem: Local) {
|
||||
self.0.gen(elem)
|
||||
}
|
||||
#[inline]
|
||||
fn kill(&mut self, _: Local) {
|
||||
// Ignore borrow invalidation.
|
||||
}
|
||||
}
|
||||
|
||||
let mut borrowed = Borrowed(BitSet::new_empty(body.local_decls.len()));
|
||||
TransferFunction { trans: &mut borrowed }.visit_body(body);
|
||||
borrowed.0
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ mod init_locals;
|
|||
mod liveness;
|
||||
mod storage_liveness;
|
||||
|
||||
pub use self::borrowed_locals::borrowed_locals;
|
||||
pub use self::borrowed_locals::MaybeBorrowedLocals;
|
||||
pub use self::init_locals::MaybeInitializedLocals;
|
||||
pub use self::liveness::MaybeLiveLocals;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue