Fix match_same_arms in stable_mir
This commit is contained in:
parent
f6648f252a
commit
f708d6de79
3 changed files with 24 additions and 38 deletions
|
@ -189,7 +189,9 @@ fn pretty_terminator_head<W: Write>(writer: &mut W, terminator: &TerminatorKind)
|
||||||
fn pretty_successor_labels(terminator: &TerminatorKind) -> Vec<String> {
|
fn pretty_successor_labels(terminator: &TerminatorKind) -> Vec<String> {
|
||||||
use self::TerminatorKind::*;
|
use self::TerminatorKind::*;
|
||||||
match terminator {
|
match terminator {
|
||||||
Resume | Abort | Return | Unreachable => vec![],
|
Call { target: None, unwind: UnwindAction::Cleanup(_), .. }
|
||||||
|
| InlineAsm { destination: None, .. } => vec!["unwind".into()],
|
||||||
|
Resume | Abort | Return | Unreachable | Call { target: None, unwind: _, .. } => vec![],
|
||||||
Goto { .. } => vec!["".to_string()],
|
Goto { .. } => vec!["".to_string()],
|
||||||
SwitchInt { targets, .. } => targets
|
SwitchInt { targets, .. } => targets
|
||||||
.branches()
|
.branches()
|
||||||
|
@ -197,19 +199,15 @@ fn pretty_successor_labels(terminator: &TerminatorKind) -> Vec<String> {
|
||||||
.chain(iter::once("otherwise".into()))
|
.chain(iter::once("otherwise".into()))
|
||||||
.collect(),
|
.collect(),
|
||||||
Drop { unwind: UnwindAction::Cleanup(_), .. } => vec!["return".into(), "unwind".into()],
|
Drop { unwind: UnwindAction::Cleanup(_), .. } => vec!["return".into(), "unwind".into()],
|
||||||
Drop { unwind: _, .. } => vec!["return".into()],
|
|
||||||
Call { target: Some(_), unwind: UnwindAction::Cleanup(_), .. } => {
|
Call { target: Some(_), unwind: UnwindAction::Cleanup(_), .. } => {
|
||||||
vec!["return".into(), "unwind".into()]
|
vec!["return".into(), "unwind".into()]
|
||||||
}
|
}
|
||||||
Call { target: Some(_), unwind: _, .. } => vec!["return".into()],
|
Drop { unwind: _, .. } | Call { target: Some(_), unwind: _, .. } => vec!["return".into()],
|
||||||
Call { target: None, unwind: UnwindAction::Cleanup(_), .. } => vec!["unwind".into()],
|
|
||||||
Call { target: None, unwind: _, .. } => vec![],
|
|
||||||
Assert { unwind: UnwindAction::Cleanup(_), .. } => {
|
Assert { unwind: UnwindAction::Cleanup(_), .. } => {
|
||||||
vec!["success".into(), "unwind".into()]
|
vec!["success".into(), "unwind".into()]
|
||||||
}
|
}
|
||||||
Assert { unwind: _, .. } => vec!["success".into()],
|
Assert { unwind: _, .. } => vec!["success".into()],
|
||||||
InlineAsm { destination: Some(_), .. } => vec!["goto".into(), "unwind".into()],
|
InlineAsm { destination: Some(_), .. } => vec!["goto".into(), "unwind".into()],
|
||||||
InlineAsm { destination: None, .. } => vec!["unwind".into()],
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -194,27 +194,17 @@ pub trait MirVisitor {
|
||||||
self.visit_place(place, PlaceContext::MUTATING, location);
|
self.visit_place(place, PlaceContext::MUTATING, location);
|
||||||
self.visit_rvalue(rvalue, location);
|
self.visit_rvalue(rvalue, location);
|
||||||
}
|
}
|
||||||
StatementKind::FakeRead(_, place) => {
|
StatementKind::FakeRead(_, place) | StatementKind::PlaceMention(place) => {
|
||||||
self.visit_place(place, PlaceContext::NON_MUTATING, location);
|
self.visit_place(place, PlaceContext::NON_MUTATING, location);
|
||||||
}
|
}
|
||||||
StatementKind::SetDiscriminant { place, .. } => {
|
StatementKind::SetDiscriminant { place, .. }
|
||||||
|
| StatementKind::Deinit(place)
|
||||||
|
| StatementKind::Retag(_, place) => {
|
||||||
self.visit_place(place, PlaceContext::MUTATING, location);
|
self.visit_place(place, PlaceContext::MUTATING, location);
|
||||||
}
|
}
|
||||||
StatementKind::Deinit(place) => {
|
StatementKind::StorageLive(local) | StatementKind::StorageDead(local) => {
|
||||||
self.visit_place(place, PlaceContext::MUTATING, location);
|
|
||||||
}
|
|
||||||
StatementKind::StorageLive(local) => {
|
|
||||||
self.visit_local(local, PlaceContext::NON_USE, location);
|
self.visit_local(local, PlaceContext::NON_USE, location);
|
||||||
}
|
}
|
||||||
StatementKind::StorageDead(local) => {
|
|
||||||
self.visit_local(local, PlaceContext::NON_USE, location);
|
|
||||||
}
|
|
||||||
StatementKind::Retag(_, place) => {
|
|
||||||
self.visit_place(place, PlaceContext::MUTATING, location);
|
|
||||||
}
|
|
||||||
StatementKind::PlaceMention(place) => {
|
|
||||||
self.visit_place(place, PlaceContext::NON_MUTATING, location);
|
|
||||||
}
|
|
||||||
StatementKind::AscribeUserType { place, projections, variance: _ } => {
|
StatementKind::AscribeUserType { place, projections, variance: _ } => {
|
||||||
self.visit_place(place, PlaceContext::NON_USE, location);
|
self.visit_place(place, PlaceContext::NON_USE, location);
|
||||||
self.visit_user_type_projection(projections);
|
self.visit_user_type_projection(projections);
|
||||||
|
@ -234,8 +224,7 @@ pub trait MirVisitor {
|
||||||
self.visit_operand(count, location);
|
self.visit_operand(count, location);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
StatementKind::ConstEvalCounter => {}
|
StatementKind::ConstEvalCounter | StatementKind::Nop => {}
|
||||||
StatementKind::Nop => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,14 +293,15 @@ pub trait MirVisitor {
|
||||||
location: Location,
|
location: Location,
|
||||||
) {
|
) {
|
||||||
match elem {
|
match elem {
|
||||||
ProjectionElem::Deref => {}
|
ProjectionElem::Downcast(_idx) => {}
|
||||||
|
ProjectionElem::ConstantIndex { offset: _, min_length: _, from_end: _ }
|
||||||
|
| ProjectionElem::Deref
|
||||||
|
| ProjectionElem::Subslice { from: _, to: _, from_end: _ } => {}
|
||||||
ProjectionElem::Field(_idx, ty) => self.visit_ty(ty, location),
|
ProjectionElem::Field(_idx, ty) => self.visit_ty(ty, location),
|
||||||
ProjectionElem::Index(local) => self.visit_local(local, ptx, location),
|
ProjectionElem::Index(local) => self.visit_local(local, ptx, location),
|
||||||
ProjectionElem::ConstantIndex { offset: _, min_length: _, from_end: _ } => {}
|
ProjectionElem::OpaqueCast(ty) | ProjectionElem::Subtype(ty) => {
|
||||||
ProjectionElem::Subslice { from: _, to: _, from_end: _ } => {}
|
self.visit_ty(ty, location)
|
||||||
ProjectionElem::Downcast(_idx) => {}
|
}
|
||||||
ProjectionElem::OpaqueCast(ty) => self.visit_ty(ty, location),
|
|
||||||
ProjectionElem::Subtype(ty) => self.visit_ty(ty, location),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,7 @@ impl Visitable for Ty {
|
||||||
match self.kind() {
|
match self.kind() {
|
||||||
super::ty::TyKind::RigidTy(ty) => ty.visit(visitor)?,
|
super::ty::TyKind::RigidTy(ty) => ty.visit(visitor)?,
|
||||||
super::ty::TyKind::Alias(_, alias) => alias.args.visit(visitor)?,
|
super::ty::TyKind::Alias(_, alias) => alias.args.visit(visitor)?,
|
||||||
super::ty::TyKind::Param(_) => {}
|
super::ty::TyKind::Param(_) | super::ty::TyKind::Bound(_, _) => {}
|
||||||
super::ty::TyKind::Bound(_, _) => {}
|
|
||||||
}
|
}
|
||||||
ControlFlow::Continue(())
|
ControlFlow::Continue(())
|
||||||
}
|
}
|
||||||
|
@ -48,8 +47,7 @@ impl Visitable for TyConst {
|
||||||
}
|
}
|
||||||
fn super_visit<V: Visitor>(&self, visitor: &mut V) -> ControlFlow<V::Break> {
|
fn super_visit<V: Visitor>(&self, visitor: &mut V) -> ControlFlow<V::Break> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
crate::ty::TyConstKind::Param(_) => {}
|
crate::ty::TyConstKind::Param(_) | crate::ty::TyConstKind::Bound(_, _) => {}
|
||||||
crate::ty::TyConstKind::Bound(_, _) => {}
|
|
||||||
crate::ty::TyConstKind::Unevaluated(_, args) => args.visit(visitor)?,
|
crate::ty::TyConstKind::Unevaluated(_, args) => args.visit(visitor)?,
|
||||||
crate::ty::TyConstKind::Value(ty, alloc) => {
|
crate::ty::TyConstKind::Value(ty, alloc) => {
|
||||||
alloc.visit(visitor)?;
|
alloc.visit(visitor)?;
|
||||||
|
@ -166,17 +164,17 @@ impl Visitable for RigidTy {
|
||||||
reg.visit(visitor);
|
reg.visit(visitor);
|
||||||
ty.visit(visitor)
|
ty.visit(visitor)
|
||||||
}
|
}
|
||||||
RigidTy::FnDef(_, args) => args.visit(visitor),
|
RigidTy::Adt(_, args)
|
||||||
|
| RigidTy::Closure(_, args)
|
||||||
|
| RigidTy::Coroutine(_, args, _)
|
||||||
|
| RigidTy::CoroutineWitness(_, args)
|
||||||
|
| RigidTy::FnDef(_, args) => args.visit(visitor),
|
||||||
RigidTy::FnPtr(sig) => sig.visit(visitor),
|
RigidTy::FnPtr(sig) => sig.visit(visitor),
|
||||||
RigidTy::Closure(_, args) => args.visit(visitor),
|
|
||||||
RigidTy::Coroutine(_, args, _) => args.visit(visitor),
|
|
||||||
RigidTy::CoroutineWitness(_, args) => args.visit(visitor),
|
|
||||||
RigidTy::Dynamic(pred, r, _) => {
|
RigidTy::Dynamic(pred, r, _) => {
|
||||||
pred.visit(visitor)?;
|
pred.visit(visitor)?;
|
||||||
r.visit(visitor)
|
r.visit(visitor)
|
||||||
}
|
}
|
||||||
RigidTy::Tuple(fields) => fields.visit(visitor),
|
RigidTy::Tuple(fields) => fields.visit(visitor),
|
||||||
RigidTy::Adt(_, args) => args.visit(visitor),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue