remove visit_terminator_kind from MIR visitor
This commit is contained in:
parent
f315c35a77
commit
0bcefd9b5e
@ -234,8 +234,8 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
|
||||
self.visit_rvalue(rvalue, location);
|
||||
}
|
||||
|
||||
fn visit_terminator_kind(&mut self, kind: &mir::TerminatorKind<'tcx>, location: Location) {
|
||||
let check = match *kind {
|
||||
fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, location: Location) {
|
||||
let check = match terminator.kind {
|
||||
mir::TerminatorKind::Call { func: mir::Operand::Constant(ref c), ref args, .. } => {
|
||||
match c.literal.ty.kind {
|
||||
ty::FnDef(did, _) => Some((did, args)),
|
||||
@ -259,7 +259,7 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
|
||||
}
|
||||
}
|
||||
|
||||
self.super_terminator_kind(kind, location);
|
||||
self.super_terminator(terminator, location);
|
||||
}
|
||||
|
||||
fn visit_place(&mut self, place: &mir::Place<'tcx>, context: PlaceContext, location: Location) {
|
||||
|
@ -108,12 +108,6 @@ macro_rules! make_mir_visitor {
|
||||
self.super_terminator(terminator, location);
|
||||
}
|
||||
|
||||
fn visit_terminator_kind(&mut self,
|
||||
kind: & $($mutability)? TerminatorKind<'tcx>,
|
||||
location: Location) {
|
||||
self.super_terminator_kind(kind, location);
|
||||
}
|
||||
|
||||
fn visit_assert_message(&mut self,
|
||||
msg: & $($mutability)? AssertMessage<'tcx>,
|
||||
location: Location) {
|
||||
@ -413,16 +407,10 @@ macro_rules! make_mir_visitor {
|
||||
|
||||
fn super_terminator(&mut self,
|
||||
terminator: &$($mutability)? Terminator<'tcx>,
|
||||
location: Location) {
|
||||
source_location: Location) {
|
||||
let Terminator { source_info, kind } = terminator;
|
||||
|
||||
self.visit_source_info(source_info);
|
||||
self.visit_terminator_kind(kind, location);
|
||||
}
|
||||
|
||||
fn super_terminator_kind(&mut self,
|
||||
kind: & $($mutability)? TerminatorKind<'tcx>,
|
||||
source_location: Location) {
|
||||
match kind {
|
||||
TerminatorKind::Goto { .. } |
|
||||
TerminatorKind::Resume |
|
||||
|
@ -2,7 +2,7 @@ use rustc_data_structures::graph::dominators::Dominators;
|
||||
use rustc_middle::mir::visit::Visitor;
|
||||
use rustc_middle::mir::{BasicBlock, Body, Location, Place, Rvalue};
|
||||
use rustc_middle::mir::{BorrowKind, Mutability, Operand};
|
||||
use rustc_middle::mir::{InlineAsmOperand, TerminatorKind};
|
||||
use rustc_middle::mir::{InlineAsmOperand, Terminator, TerminatorKind};
|
||||
use rustc_middle::mir::{Statement, StatementKind};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
|
||||
@ -112,10 +112,10 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
|
||||
self.super_statement(statement, location);
|
||||
}
|
||||
|
||||
fn visit_terminator_kind(&mut self, kind: &TerminatorKind<'tcx>, location: Location) {
|
||||
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
|
||||
self.check_activations(location);
|
||||
|
||||
match kind {
|
||||
match &terminator.kind {
|
||||
TerminatorKind::SwitchInt { ref discr, switch_ty: _, values: _, targets: _ } => {
|
||||
self.consume_operand(location, discr);
|
||||
}
|
||||
@ -222,7 +222,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
self.super_terminator_kind(kind, location);
|
||||
self.super_terminator(terminator, location);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
use rustc_middle::mir::visit::{PlaceContext, Visitor};
|
||||
use rustc_middle::mir::{Local, Location, Place, Statement, StatementKind, TerminatorKind};
|
||||
use rustc_middle::mir::{
|
||||
Local, Location, Place, Statement, StatementKind, Terminator, TerminatorKind,
|
||||
};
|
||||
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
|
||||
@ -62,9 +64,9 @@ impl GatherUsedMutsVisitor<'_, '_, '_> {
|
||||
}
|
||||
|
||||
impl<'visit, 'cx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'tcx> {
|
||||
fn visit_terminator_kind(&mut self, kind: &TerminatorKind<'tcx>, _location: Location) {
|
||||
debug!("visit_terminator_kind: kind={:?}", kind);
|
||||
match &kind {
|
||||
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, _location: Location) {
|
||||
debug!("visit_terminator: terminator={:?}", terminator);
|
||||
match &terminator.kind {
|
||||
TerminatorKind::Call { destination: Some((into, _)), .. } => {
|
||||
self.remove_never_initialized_mut_locals(*into);
|
||||
}
|
||||
@ -73,6 +75,8 @@ impl<'visit, 'cx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'tc
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
// FIXME: no super_terminator?
|
||||
}
|
||||
|
||||
fn visit_statement(&mut self, statement: &Statement<'tcx>, _location: Location) {
|
||||
@ -84,6 +88,8 @@ impl<'visit, 'cx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'tc
|
||||
);
|
||||
self.remove_never_initialized_mut_locals(*into);
|
||||
}
|
||||
|
||||
// FIXME: no super_statement?
|
||||
}
|
||||
|
||||
fn visit_local(&mut self, local: &Local, place_context: PlaceContext, location: Location) {
|
||||
@ -101,5 +107,7 @@ impl<'visit, 'cx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'tc
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: no super_local?
|
||||
}
|
||||
}
|
||||
|
@ -616,11 +616,11 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
|
||||
self.super_const(constant);
|
||||
}
|
||||
|
||||
fn visit_terminator_kind(&mut self, kind: &mir::TerminatorKind<'tcx>, location: Location) {
|
||||
debug!("visiting terminator {:?} @ {:?}", kind, location);
|
||||
fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, location: Location) {
|
||||
debug!("visiting terminator {:?} @ {:?}", terminator, location);
|
||||
|
||||
let tcx = self.tcx;
|
||||
match *kind {
|
||||
match terminator.kind {
|
||||
mir::TerminatorKind::Call { ref func, .. } => {
|
||||
let callee_ty = func.ty(self.body, tcx);
|
||||
let callee_ty = self.monomorphize(callee_ty);
|
||||
@ -663,7 +663,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
|
||||
| mir::TerminatorKind::FalseUnwind { .. } => bug!(),
|
||||
}
|
||||
|
||||
self.super_terminator_kind(kind, location);
|
||||
self.super_terminator(terminator, location);
|
||||
}
|
||||
|
||||
fn visit_local(
|
||||
|
@ -121,11 +121,12 @@ where
|
||||
self.super_assign(place, rvalue, location);
|
||||
}
|
||||
|
||||
fn visit_terminator_kind(&mut self, kind: &mir::TerminatorKind<'tcx>, location: Location) {
|
||||
fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, location: Location) {
|
||||
// The effect of assignment to the return place in `TerminatorKind::Call` is not applied
|
||||
// here; that occurs in `apply_call_return_effect`.
|
||||
|
||||
if let mir::TerminatorKind::DropAndReplace { value, location: dest, .. } = kind {
|
||||
if let mir::TerminatorKind::DropAndReplace { value, location: dest, .. } = &terminator.kind
|
||||
{
|
||||
let qualif = qualifs::in_operand::<Q, _>(
|
||||
self.ccx,
|
||||
&mut |l| self.qualifs_per_local.contains(l),
|
||||
@ -139,7 +140,7 @@ where
|
||||
|
||||
// We need to assign qualifs to the dropped location before visiting the operand that
|
||||
// replaces it since qualifs can be cleared on move.
|
||||
self.super_terminator_kind(kind, location);
|
||||
self.super_terminator(terminator, location);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,13 +93,13 @@ impl<'tcx> MutVisitor<'tcx> for RenameLocalVisitor<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_terminator_kind(&mut self, kind: &mut TerminatorKind<'tcx>, location: Location) {
|
||||
match kind {
|
||||
fn visit_terminator(&mut self, terminator: &mut Terminator<'tcx>, location: Location) {
|
||||
match terminator.kind {
|
||||
TerminatorKind::Return => {
|
||||
// Do not replace the implicit `_0` access here, as that's not possible. The
|
||||
// transform already handles `return` correctly.
|
||||
}
|
||||
_ => self.super_terminator_kind(kind, location),
|
||||
_ => self.super_terminator(terminator, location),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -731,14 +731,14 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_terminator_kind(&mut self, kind: &mut TerminatorKind<'tcx>, loc: Location) {
|
||||
fn visit_terminator(&mut self, terminator: &mut Terminator<'tcx>, loc: Location) {
|
||||
// Don't try to modify the implicit `_0` access on return (`return` terminators are
|
||||
// replaced down below anyways).
|
||||
if !matches!(kind, TerminatorKind::Return) {
|
||||
self.super_terminator_kind(kind, loc);
|
||||
if !matches!(terminator.kind, TerminatorKind::Return) {
|
||||
self.super_terminator(terminator, loc);
|
||||
}
|
||||
|
||||
match *kind {
|
||||
match terminator.kind {
|
||||
TerminatorKind::GeneratorDrop | TerminatorKind::Yield { .. } => bug!(),
|
||||
TerminatorKind::Goto { ref mut target } => {
|
||||
*target = self.update_target(*target);
|
||||
@ -782,11 +782,11 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
TerminatorKind::Return => {
|
||||
*kind = TerminatorKind::Goto { target: self.return_block };
|
||||
terminator.kind = TerminatorKind::Goto { target: self.return_block };
|
||||
}
|
||||
TerminatorKind::Resume => {
|
||||
if let Some(tgt) = self.cleanup_block {
|
||||
*kind = TerminatorKind::Goto { target: tgt }
|
||||
terminator.kind = TerminatorKind::Goto { target: tgt }
|
||||
}
|
||||
}
|
||||
TerminatorKind::Abort => {}
|
||||
|
@ -34,10 +34,10 @@ impl<'tcx> MutVisitor<'tcx> for NoLandingPads<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
fn visit_terminator_kind(&mut self, kind: &mut TerminatorKind<'tcx>, location: Location) {
|
||||
if let Some(unwind) = kind.unwind_mut() {
|
||||
fn visit_terminator(&mut self, terminator: &mut Terminator<'tcx>, location: Location) {
|
||||
if let Some(unwind) = terminator.kind.unwind_mut() {
|
||||
unwind.take();
|
||||
}
|
||||
self.super_terminator_kind(kind, location);
|
||||
self.super_terminator(terminator, location);
|
||||
}
|
||||
}
|
||||
|
@ -216,10 +216,10 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_terminator_kind(&mut self, kind: &TerminatorKind<'tcx>, location: Location) {
|
||||
self.super_terminator_kind(kind, location);
|
||||
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
|
||||
self.super_terminator(terminator, location);
|
||||
|
||||
match *kind {
|
||||
match terminator.kind {
|
||||
TerminatorKind::Call { ref func, .. } => {
|
||||
if let ty::FnDef(def_id, _) = func.ty(self.ccx.body, self.ccx.tcx).kind {
|
||||
let fn_sig = self.ccx.tcx.fn_sig(def_id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user