}
fn visit_statement(&mut self,
- block: BasicBlock,
statement: & $($mutability)? Statement<'tcx>,
location: Location) {
- self.super_statement(block, statement, location);
+ self.super_statement(statement, location);
}
fn visit_assign(&mut self,
- block: BasicBlock,
place: & $($mutability)? Place<'tcx>,
rvalue: & $($mutability)? Rvalue<'tcx>,
location: Location) {
- self.super_assign(block, place, rvalue, location);
+ self.super_assign(place, rvalue, location);
}
fn visit_terminator(&mut self,
- block: BasicBlock,
terminator: & $($mutability)? Terminator<'tcx>,
location: Location) {
- self.super_terminator(block, terminator, location);
+ self.super_terminator(terminator, location);
}
fn visit_terminator_kind(&mut self,
- block: BasicBlock,
kind: & $($mutability)? TerminatorKind<'tcx>,
location: Location) {
- self.super_terminator_kind(block, kind, location);
+ self.super_terminator_kind(kind, location);
}
fn visit_assert_message(&mut self,
let mut index = 0;
for statement in statements {
let location = Location { block: block, statement_index: index };
- self.visit_statement(block, statement, location);
+ self.visit_statement(statement, location);
index += 1;
}
if let Some(terminator) = terminator {
let location = Location { block: block, statement_index: index };
- self.visit_terminator(block, terminator, location);
+ self.visit_terminator(terminator, location);
}
}
}
fn super_statement(&mut self,
- block: BasicBlock,
statement: & $($mutability)? Statement<'tcx>,
location: Location) {
let Statement {
self.visit_source_info(source_info);
match kind {
StatementKind::Assign(place, rvalue) => {
- self.visit_assign(block, place, rvalue, location);
+ self.visit_assign(place, rvalue, location);
}
StatementKind::FakeRead(_, place) => {
self.visit_place(
}
fn super_assign(&mut self,
- _block: BasicBlock,
place: &$($mutability)? Place<'tcx>,
rvalue: &$($mutability)? Rvalue<'tcx>,
location: Location) {
}
fn super_terminator(&mut self,
- block: BasicBlock,
terminator: &$($mutability)? Terminator<'tcx>,
location: Location) {
let Terminator { source_info, kind } = terminator;
self.visit_source_info(source_info);
- self.visit_terminator_kind(block, kind, location);
+ self.visit_terminator_kind(kind, location);
}
fn super_terminator_kind(&mut self,
- block: BasicBlock,
kind: & $($mutability)? TerminatorKind<'tcx>,
source_location: Location) {
+ let block = source_location.block;
match kind {
TerminatorKind::Goto { target } => {
self.visit_branch(block, *target);
let basic_block = & $($mutability)? mir[location.block];
if basic_block.statements.len() == location.statement_index {
if let Some(ref $($mutability)? terminator) = basic_block.terminator {
- self.visit_terminator(location.block, terminator, location)
+ self.visit_terminator(terminator, location)
}
} else {
let statement = & $($mutability)?
basic_block.statements[location.statement_index];
- self.visit_statement(location.block, statement, location)
+ self.visit_statement(statement, location)
}
}
}
impl<'tcx> MirVisitable<'tcx> for Statement<'tcx> {
fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
{
- visitor.visit_statement(location.block, self, location)
+ visitor.visit_statement(self, location)
}
}
impl<'tcx> MirVisitable<'tcx> for Terminator<'tcx> {
fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
{
- visitor.visit_terminator(location.block, self, location)
+ visitor.visit_terminator(self, location)
}
}
impl<'tcx> MirVisitable<'tcx> for Option<Terminator<'tcx>> {
fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
{
- visitor.visit_terminator(location.block, self.as_ref().unwrap(), location)
+ visitor.visit_terminator(self.as_ref().unwrap(), location)
}
}
impl<'mir, 'a: 'mir, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
for LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
fn visit_assign(&mut self,
- block: mir::BasicBlock,
place: &mir::Place<'tcx>,
rvalue: &mir::Rvalue<'tcx>,
location: Location) {
- debug!("visit_assign(block={:?}, place={:?}, rvalue={:?})", block, place, rvalue);
+ debug!("visit_assign(place={:?}, rvalue={:?})", place, rvalue);
if let mir::Place::Base(mir::PlaceBase::Local(index)) = *place {
self.assign(index, location);
}
fn visit_terminator_kind(&mut self,
- block: mir::BasicBlock,
kind: &mir::TerminatorKind<'tcx>,
location: Location) {
let check = match *kind {
}
}
- self.super_terminator_kind(block, kind, location);
+ self.super_terminator_kind(kind, location);
}
fn visit_place(&mut self,
impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
fn visit_assign(
&mut self,
- block: mir::BasicBlock,
assigned_place: &mir::Place<'tcx>,
rvalue: &mir::Rvalue<'tcx>,
location: mir::Location,
}
}
- self.super_assign(block, assigned_place, rvalue, location)
+ self.super_assign(assigned_place, rvalue, location)
}
fn visit_local(
return self.super_rvalue(rvalue, location);
}
-
- fn visit_statement(
- &mut self,
- block: mir::BasicBlock,
- statement: &mir::Statement<'tcx>,
- location: Location,
- ) {
- return self.super_statement(block, statement, location);
- }
}
impl<'a, 'gcx, 'tcx> GatherBorrows<'a, 'gcx, 'tcx> {
fn visit_statement(
&mut self,
- block: BasicBlock,
statement: &Statement<'tcx>,
location: Location,
) {
));
}
- self.super_statement(block, statement, location);
+ self.super_statement(statement, location);
}
fn visit_assign(
&mut self,
- block: BasicBlock,
place: &Place<'tcx>,
rvalue: &Rvalue<'tcx>,
location: Location,
}
}
- self.super_assign(block, place, rvalue, location);
+ self.super_assign(place, rvalue, location);
}
fn visit_terminator(
&mut self,
- block: BasicBlock,
terminator: &Terminator<'tcx>,
location: Location,
) {
}
}
- self.super_terminator(block, terminator, location);
+ self.super_terminator(terminator, location);
}
fn visit_ascribe_user_ty(
impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> {
fn visit_statement(
&mut self,
- block: BasicBlock,
statement: &Statement<'tcx>,
location: Location,
) {
}
}
- self.super_statement(block, statement, location);
+ self.super_statement(statement, location);
}
fn visit_terminator(
&mut self,
- block: BasicBlock,
- terminator: &Terminator<'tcx>,
+ kind: &Terminator<'tcx>,
location: Location
) {
self.check_activations(location);
}
}
- self.super_terminator(block, terminator, location);
+ self.super_terminator(terminator, location);
}
}
use rustc::mir::visit::{PlaceContext, Visitor};
use rustc::mir::{
- BasicBlock, Local, Location, Place, PlaceBase, Statement, StatementKind, TerminatorKind
+ Local, Location, Place, PlaceBase, Statement, StatementKind, TerminatorKind
};
use rustc_data_structures::fx::FxHashSet;
impl<'visit, 'cx, 'gcx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'gcx, 'tcx> {
fn visit_terminator_kind(
&mut self,
- _block: BasicBlock,
kind: &TerminatorKind<'tcx>,
_location: Location,
) {
fn visit_statement(
&mut self,
- _block: BasicBlock,
statement: &Statement<'tcx>,
_location: Location,
) {
BorrowedLocalsVisitor {
sets,
- }.visit_statement(loc.block, stmt, loc);
+ }.visit_statement(stmt, loc);
// StorageDead invalidates all borrows and raw pointers to a local
match stmt.kind {
loc: Location) {
BorrowedLocalsVisitor {
sets,
- }.visit_terminator(loc.block, self.mir[loc.block].terminator(), loc);
+ }.visit_terminator(self.mir[loc.block].terminator(), loc);
}
fn propagate_call_return(
}
fn visit_terminator_kind(&mut self,
- block: mir::BasicBlock,
kind: &mir::TerminatorKind<'tcx>,
location: Location) {
debug!("visiting terminator {:?} @ {:?}", kind, location);
mir::TerminatorKind::FalseUnwind { .. } => bug!(),
}
- self.super_terminator_kind(block, kind, location);
+ self.super_terminator_kind(kind, location);
}
fn visit_place(&mut self,
impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
fn visit_terminator(&mut self,
- block: BasicBlock,
terminator: &Terminator<'tcx>,
location: Location)
{
}
}
}
- self.super_terminator(block, terminator, location);
+ self.super_terminator(terminator, location);
}
fn visit_statement(&mut self,
- block: BasicBlock,
statement: &Statement<'tcx>,
location: Location)
{
UnsafetyViolationKind::General)
},
}
- self.super_statement(block, statement, location);
+ self.super_statement(statement, location);
}
fn visit_rvalue(&mut self,
//! [`FakeRead`]: rustc::mir::StatementKind::FakeRead
//! [`Nop`]: rustc::mir::StatementKind::Nop
-use rustc::mir::{BasicBlock, BorrowKind, Rvalue, Location, Mir};
+use rustc::mir::{BorrowKind, Rvalue, Location, Mir};
use rustc::mir::{Statement, StatementKind};
use rustc::mir::visit::MutVisitor;
use rustc::ty::TyCtxt;
impl<'tcx> MutVisitor<'tcx> for DeleteNonCodegenStatements {
fn visit_statement(&mut self,
- block: BasicBlock,
statement: &mut Statement<'tcx>,
location: Location) {
match statement.kind {
| StatementKind::FakeRead(..) => statement.make_nop(),
_ => (),
}
- self.super_statement(block, statement, location);
+ self.super_statement(statement, location);
}
}
use rustc::hir::def::Def;
use rustc::mir::{Constant, Location, Place, PlaceBase, Mir, Operand, Rvalue, Local};
-use rustc::mir::{NullOp, UnOp, StatementKind, Statement, BasicBlock, LocalKind, Static, StaticKind};
+use rustc::mir::{NullOp, UnOp, StatementKind, Statement, LocalKind, Static, StaticKind};
use rustc::mir::{TerminatorKind, ClearCrossCrate, SourceInfo, BinOp, ProjectionElem};
use rustc::mir::visit::{Visitor, PlaceContext, MutatingUseContext, NonMutatingUseContext};
use rustc::mir::interpret::{InterpError, Scalar, GlobalId, EvalResult};
fn visit_statement(
&mut self,
- block: BasicBlock,
statement: &Statement<'tcx>,
location: Location,
) {
}
}
}
- self.super_statement(block, statement, location);
+ self.super_statement(statement, location);
}
fn visit_terminator_kind(
&mut self,
- block: BasicBlock,
kind: &TerminatorKind<'tcx>,
location: Location,
) {
- self.super_terminator_kind(block, kind, location);
+ self.super_terminator_kind(kind, location);
let source_info = *self.mir.source_info(location);
if let TerminatorKind::Assert { expected, msg, cond, .. } = kind {
if let Some(value) = self.eval_operand(cond, source_info) {
},
Operand::Constant(_) => {}
}
- let span = self.mir[block]
+ let span = self.mir[location.block]
.terminator
.as_ref()
.unwrap()
}
fn visit_statement(&mut self,
- block: BasicBlock,
statement: &mut Statement<'tcx>,
location: Location) {
- self.super_statement(block, statement, location);
+ self.super_statement(statement, location);
}
}
impl<'tcx> Visitor<'tcx> for StorageIgnored {
fn visit_statement(&mut self,
- _block: BasicBlock,
statement: &Statement<'tcx>,
_location: Location) {
match statement.kind {
}
}
- fn visit_terminator_kind(&mut self, block: BasicBlock,
+ fn visit_terminator_kind(&mut self,
kind: &mut TerminatorKind<'tcx>, loc: Location) {
- self.super_terminator_kind(block, kind, loc);
+ self.super_terminator_kind(kind, loc);
match *kind {
TerminatorKind::GeneratorDrop |
impl<'tcx> MutVisitor<'tcx> for NoLandingPads {
fn visit_terminator(&mut self,
- bb: BasicBlock,
terminator: &mut Terminator<'tcx>,
location: Location) {
if let Some(unwind) = terminator.kind.unwind_mut() {
unwind.take();
}
- self.super_terminator(bb, terminator, location);
+ self.super_terminator(terminator, location);
}
}
}
fn visit_terminator_kind(&mut self,
- bb: BasicBlock,
kind: &TerminatorKind<'tcx>,
location: Location) {
- debug!("visit_terminator_kind: bb={:?} kind={:?} location={:?}", bb, kind, location);
+ debug!("visit_terminator_kind: kind={:?} location={:?}", kind, location);
if let TerminatorKind::Call { ref func, ref args, ref destination, .. } = *kind {
if let Some((ref dest, _)) = *destination {
self.assign(dest, ValueSource::Call {
continue;
}
- let candidate = Candidate::Argument { bb, index: i };
+ let candidate = Candidate::Argument { bb: location.block, index: i };
// Since the argument is required to be constant,
// we care about constness, not promotability.
// If we checked for promotability, we'd miss out on
self.visit_operand(arg, location);
}
} else if let TerminatorKind::Drop { location: ref place, .. } = *kind {
- self.super_terminator_kind(bb, kind, location);
+ self.super_terminator_kind(kind, location);
// Deny *any* live drops anywhere other than functions.
if self.mode != Mode::Fn {
}
} else {
// Qualify any operands inside other terminators.
- self.super_terminator_kind(bb, kind, location);
+ self.super_terminator_kind(kind, location);
}
}
fn visit_assign(&mut self,
- _: BasicBlock,
dest: &Place<'tcx>,
rvalue: &Rvalue<'tcx>,
location: Location) {
self.span = source_info.span;
}
- fn visit_statement(&mut self, bb: BasicBlock, statement: &Statement<'tcx>, location: Location) {
- debug!("visit_statement: bb={:?} statement={:?} location={:?}", bb, statement, location);
+ fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) {
+ debug!("visit_statement: statement={:?} location={:?}", statement, location);
match statement.kind {
StatementKind::Assign(..) => {
- self.super_statement(bb, statement, location);
+ self.super_statement(statement, location);
}
// FIXME(eddyb) should these really do nothing?
StatementKind::FakeRead(..) |
StatementKind::Nop => {}
}
}
-
- fn visit_terminator(&mut self,
- bb: BasicBlock,
- terminator: &Terminator<'tcx>,
- location: Location) {
- debug!("visit_terminator: bb={:?} terminator={:?} location={:?}", bb, terminator, location);
- self.super_terminator(bb, terminator, location);
- }
}
pub fn provide(providers: &mut Providers<'_>) {
impl<'a, 'tcx> Visitor<'tcx> for UniformArrayMoveOutVisitor<'a, 'tcx> {
fn visit_assign(&mut self,
- block: BasicBlock,
dst_place: &Place<'tcx>,
rvalue: &Rvalue<'tcx>,
location: Location) {
}
}
}
- self.super_assign(block, dst_place, rvalue, location)
+ self.super_assign(dst_place, rvalue, location)
}
}
impl<'tcx> Visitor<'tcx> for RestoreDataCollector {
fn visit_assign(&mut self,
- block: BasicBlock,
place: &Place<'tcx>,
rvalue: &Rvalue<'tcx>,
location: Location) {
if let Rvalue::Aggregate(box AggregateKind::Array(_), _) = *rvalue {
self.candidates.push(location);
}
- self.super_assign(block, place, rvalue, location)
+ self.super_assign(place, rvalue, location)
}
fn visit_local(&mut self,
// Visit the various parts of the basic block in reverse. If we go
// forward, the logic in `add_def` and `add_use` would be wrong.
- visitor.visit_terminator(BasicBlock::new(0), b.terminator(), dummy_location);
+ visitor.visit_terminator(b.terminator(), dummy_location);
for statement in b.statements.iter().rev() {
- visitor.visit_statement(BasicBlock::new(0), statement, dummy_location);
+ visitor.visit_statement(statement, dummy_location);
}
visitor.defs_uses
)?;
write_extra(tcx, w, |visitor| {
- visitor.visit_statement(current_location.block, statement, current_location);
+ visitor.visit_statement(statement, current_location);
})?;
extra_data(PassWhere::AfterLocation(current_location), w)?;
)?;
write_extra(tcx, w, |visitor| {
- visitor.visit_terminator(current_location.block, data.terminator(), current_location);
+ visitor.visit_terminator(data.terminator(), current_location);
})?;
extra_data(PassWhere::AfterLocation(current_location), w)?;