FakeReadCause,
RetagKind,
SourceScope,
- SourceScopeData,
SourceScopeLocalData,
UserTypeAnnotationIndex,
}
let kind = match self.kind {
Goto { target } => Goto { target },
- SwitchInt { ref discr, switch_ty, ref values, ref targets } => SwitchInt {
+ SwitchInt { ref discr, switch_ty, ref targets } => SwitchInt {
discr: discr.fold_with(folder),
switch_ty: switch_ty.fold_with(folder),
- values: values.clone(),
targets: targets.clone(),
},
Drop { ref place, target, unwind } => {
Terminator { source_info: self.source_info, kind }
}
- fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
+ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
use crate::mir::TerminatorKind::*;
match self.kind {
SwitchInt { ref discr, switch_ty, .. } => {
- discr.visit_with(visitor) || switch_ty.visit_with(visitor)
+ discr.visit_with(visitor)?;
+ switch_ty.visit_with(visitor)
}
Drop { ref place, .. } => place.visit_with(visitor),
DropAndReplace { ref place, ref value, .. } => {
- place.visit_with(visitor) || value.visit_with(visitor)
+ place.visit_with(visitor)?;
+ value.visit_with(visitor)
}
Yield { ref value, .. } => value.visit_with(visitor),
Call { ref func, ref args, ref destination, .. } => {
- let dest = if let Some((ref loc, _)) = *destination {
- loc.visit_with(visitor)
- } else {
- false
+ if let Some((ref loc, _)) = *destination {
+ loc.visit_with(visitor)?;
};
- dest || func.visit_with(visitor) || args.visit_with(visitor)
+ func.visit_with(visitor)?;
+ args.visit_with(visitor)
}
Assert { ref cond, ref msg, .. } => {
- if cond.visit_with(visitor) {
- use AssertKind::*;
- match msg {
- BoundsCheck { ref len, ref index } => {
- len.visit_with(visitor) || index.visit_with(visitor)
- }
- Overflow(_, l, r) => l.visit_with(visitor) || r.visit_with(visitor),
- OverflowNeg(op) | DivisionByZero(op) | RemainderByZero(op) => {
- op.visit_with(visitor)
- }
- ResumedAfterReturn(_) | ResumedAfterPanic(_) => false,
+ cond.visit_with(visitor)?;
+ use AssertKind::*;
+ match msg {
+ BoundsCheck { ref len, ref index } => {
+ len.visit_with(visitor)?;
+ index.visit_with(visitor)
+ }
+ Overflow(_, l, r) => {
+ l.visit_with(visitor)?;
+ r.visit_with(visitor)
+ }
+ OverflowNeg(op) | DivisionByZero(op) | RemainderByZero(op) => {
+ op.visit_with(visitor)
}
- } else {
- false
+ ResumedAfterReturn(_) | ResumedAfterPanic(_) => ControlFlow::CONTINUE,
}
}
InlineAsm { ref operands, .. } => operands.visit_with(visitor),
| GeneratorDrop
| Unreachable
| FalseEdge { .. }
- | FalseUnwind { .. } => false,
+ | FalseUnwind { .. } => ControlFlow::CONTINUE,
}
}
}
*self
}
- fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> bool {
- false
+ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<()> {
+ ControlFlow::CONTINUE
}
}
Place { local: self.local.fold_with(folder), projection: self.projection.fold_with(folder) }
}
- fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
- self.local.visit_with(visitor) || self.projection.visit_with(visitor)
+ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
+ self.local.visit_with(visitor)?;
+ self.projection.visit_with(visitor)
}
}
folder.tcx().intern_place_elems(&v)
}
- fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
- self.iter().any(|t| t.visit_with(visitor))
+ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
+ self.iter().try_for_each(|t| t.visit_with(visitor))
}
}
}
}
- fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
+ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
use crate::mir::Rvalue::*;
match *self {
Use(ref op) => op.visit_with(visitor),
Repeat(ref op, _) => op.visit_with(visitor),
ThreadLocalRef(did) => did.visit_with(visitor),
- Ref(region, _, ref place) => region.visit_with(visitor) || place.visit_with(visitor),
+ Ref(region, _, ref place) => {
+ region.visit_with(visitor)?;
+ place.visit_with(visitor)
+ }
AddressOf(_, ref place) => place.visit_with(visitor),
Len(ref place) => place.visit_with(visitor),
- Cast(_, ref op, ty) => op.visit_with(visitor) || ty.visit_with(visitor),
+ Cast(_, ref op, ty) => {
+ op.visit_with(visitor)?;
+ ty.visit_with(visitor)
+ }
BinaryOp(_, ref rhs, ref lhs) | CheckedBinaryOp(_, ref rhs, ref lhs) => {
- rhs.visit_with(visitor) || lhs.visit_with(visitor)
+ rhs.visit_with(visitor)?;
+ lhs.visit_with(visitor)
}
UnaryOp(_, ref val) => val.visit_with(visitor),
Discriminant(ref place) => place.visit_with(visitor),
NullaryOp(_, ty) => ty.visit_with(visitor),
Aggregate(ref kind, ref fields) => {
- (match **kind {
- AggregateKind::Array(ty) => ty.visit_with(visitor),
- AggregateKind::Tuple => false,
+ match **kind {
+ AggregateKind::Array(ty) => {
+ ty.visit_with(visitor)?;
+ }
+ AggregateKind::Tuple => {}
AggregateKind::Adt(_, _, substs, user_ty, _) => {
- substs.visit_with(visitor) || user_ty.visit_with(visitor)
+ substs.visit_with(visitor)?;
+ user_ty.visit_with(visitor)?;
+ }
+ AggregateKind::Closure(_, substs) => {
+ substs.visit_with(visitor)?;
}
- AggregateKind::Closure(_, substs) => substs.visit_with(visitor),
- AggregateKind::Generator(_, substs, _) => substs.visit_with(visitor),
- }) || fields.visit_with(visitor)
+ AggregateKind::Generator(_, substs, _) => {
+ substs.visit_with(visitor)?;
+ }
+ }
+ fields.visit_with(visitor)
}
}
}
}
}
- fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
+ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
match *self {
Operand::Copy(ref place) | Operand::Move(ref place) => place.visit_with(visitor),
Operand::Constant(ref c) => c.visit_with(visitor),
}
}
- fn super_visit_with<Vs: TypeVisitor<'tcx>>(&self, visitor: &mut Vs) -> bool {
+ fn super_visit_with<Vs: TypeVisitor<'tcx>>(&self, visitor: &mut Vs) -> ControlFlow<()> {
use crate::mir::ProjectionElem::*;
match self {
Field(_, ty) => ty.visit_with(visitor),
Index(v) => v.visit_with(visitor),
- _ => false,
+ _ => ControlFlow::CONTINUE,
}
}
}
fn super_fold_with<F: TypeFolder<'tcx>>(&self, _: &mut F) -> Self {
*self
}
- fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> bool {
- false
+ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<()> {
+ ControlFlow::CONTINUE
}
}
fn super_fold_with<F: TypeFolder<'tcx>>(&self, _: &mut F) -> Self {
*self
}
- fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> bool {
- false
+ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<()> {
+ ControlFlow::CONTINUE
}
}
fn super_fold_with<F: TypeFolder<'tcx>>(&self, _: &mut F) -> Self {
self.clone()
}
- fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> bool {
- false
+ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<()> {
+ ControlFlow::CONTINUE
}
}
literal: self.literal.fold_with(folder),
}
}
- fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
+ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
self.literal.visit_with(visitor)
}
}