pub use super::*;
-use rustc::mir::*;
-use rustc::mir::visit::{
- PlaceContext, Visitor, NonMutatingUseContext,
-};
-use std::cell::RefCell;
use crate::dataflow::BitDenotation;
use crate::dataflow::HaveBeenBorrowedLocals;
use crate::dataflow::{DataflowResults, DataflowResultsCursor, DataflowResultsRefCursor};
+use rustc::mir::visit::{NonMutatingUseContext, PlaceContext, Visitor};
+use rustc::mir::*;
+use std::cell::RefCell;
#[derive(Copy, Clone)]
pub struct MaybeStorageLive<'a, 'tcx> {
}
impl<'a, 'tcx> MaybeStorageLive<'a, 'tcx> {
- pub fn new(body: &'a Body<'tcx>)
- -> Self {
+ pub fn new(body: &'a Body<'tcx>) -> Self {
MaybeStorageLive { body }
}
impl<'a, 'tcx> BitDenotation<'tcx> for MaybeStorageLive<'a, 'tcx> {
type Idx = Local;
- fn name() -> &'static str { "maybe_storage_live" }
+ fn name() -> &'static str {
+ "maybe_storage_live"
+ }
fn bits_per_block(&self) -> usize {
self.body.local_decls.len()
}
assert_eq!(1, self.body.arg_count);
}
- fn statement_effect(&self,
- trans: &mut GenKillSet<Local>,
- loc: Location) {
+ fn statement_effect(&self, trans: &mut GenKillSet<Local>, loc: Location) {
let stmt = &self.body[loc.block].statements[loc.statement_index];
match stmt.kind {
}
}
- fn terminator_effect(&self,
- _trans: &mut GenKillSet<Local>,
- _loc: Location) {
+ fn terminator_effect(&self, _trans: &mut GenKillSet<Local>, _loc: Location) {
// Terminators have no effect
}
) -> Self {
RequiresStorage {
body,
- borrowed_locals: RefCell::new(
- DataflowResultsCursor::new(borrowed_locals, *body)
- ),
+ borrowed_locals: RefCell::new(DataflowResultsCursor::new(borrowed_locals, *body)),
}
}
impl<'mir, 'tcx> BitDenotation<'tcx> for RequiresStorage<'mir, 'tcx> {
type Idx = Local;
- fn name() -> &'static str { "requires_storage" }
+ fn name() -> &'static str {
+ "requires_storage"
+ }
fn bits_per_block(&self) -> usize {
self.body.local_decls.len()
}
let stmt = &self.body[loc.block].statements[loc.statement_index];
match stmt.kind {
StatementKind::StorageDead(l) => sets.kill(l),
- StatementKind::Assign(box(ref place, _))
+ StatementKind::Assign(box (ref place, _))
| StatementKind::SetDiscriminant { box ref place, .. } => {
- if let PlaceBase::Local(local) = place.base {
- sets.gen(local);
- }
+ sets.gen(place.local);
}
StatementKind::InlineAsm(box InlineAsm { ref outputs, .. }) => {
- for p in &**outputs {
- if let PlaceBase::Local(local) = p.base {
- sets.gen(local);
- }
+ for place in &**outputs {
+ sets.gen(place.local);
}
}
_ => (),
fn before_terminator_effect(&self, sets: &mut GenKillSet<Local>, loc: Location) {
self.check_for_borrow(sets, loc);
- if let TerminatorKind::Call {
- destination: Some((Place { base: PlaceBase::Local(local), .. }, _)),
- ..
- } = self.body[loc.block].terminator().kind {
+ if let TerminatorKind::Call { destination: Some((Place { local, .. }, _)), .. } =
+ self.body[loc.block].terminator().kind
+ {
sets.gen(local);
}
}
// and after the call returns successfully, but not after a panic.
// Since `propagate_call_unwind` doesn't exist, we have to kill the
// destination here, and then gen it again in `propagate_call_return`.
- if let TerminatorKind::Call {
- destination: Some((ref place, _)),
- ..
- } = self.body[loc.block].terminator().kind {
+ if let TerminatorKind::Call { destination: Some((ref place, _)), .. } =
+ self.body[loc.block].terminator().kind
+ {
if let Some(local) = place.as_local() {
sets.kill(local);
}
_dest_bb: mir::BasicBlock,
dest_place: &mir::Place<'tcx>,
) {
- if let PlaceBase::Local(local) = dest_place.base {
- in_out.insert(local);
- }
+ in_out.insert(dest_place.local);
}
}
impl<'mir, 'tcx> RequiresStorage<'mir, 'tcx> {
/// Kill locals that are fully moved and have not been borrowed.
fn check_for_move(&self, sets: &mut GenKillSet<Local>, loc: Location) {
- let mut visitor = MoveVisitor {
- sets,
- borrowed_locals: &self.borrowed_locals,
- };
+ let mut visitor = MoveVisitor { sets, borrowed_locals: &self.borrowed_locals };
visitor.visit_location(self.body, loc);
}