Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix match_same_arms in stable_mir - rustfmt
  • Loading branch information
practicalrs committed Oct 14, 2024
commit ce4f7b5c0487db27ca1dcf56e94788dbd3105090
8 changes: 3 additions & 5 deletions compiler/stable_mir/src/mir/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use fmt::{Display, Formatter};
use super::{AssertMessage, BinOp, BorrowKind, FakeBorrowKind, TerminatorKind};
use crate::mir::{Operand, Place, Rvalue, StatementKind, UnwindAction, VarDebugInfoContents};
use crate::ty::{IndexedVal, MirConst, Ty, TyConst};
use crate::{Body, Mutability, with};
use crate::{with, Body, Mutability};

impl Display for Ty {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
Expand Down Expand Up @@ -191,8 +191,7 @@ fn pretty_successor_labels(terminator: &TerminatorKind) -> Vec<String> {
match terminator {
Call { target: None, unwind: UnwindAction::Cleanup(_), .. }
| InlineAsm { destination: None, .. } => vec!["unwind".into()],
Resume | Abort | Return | Unreachable
| Call { target: None, unwind: _, .. } => vec![],
Resume | Abort | Return | Unreachable | Call { target: None, unwind: _, .. } => vec![],
Goto { .. } => vec!["".to_string()],
SwitchInt { targets, .. } => targets
.branches()
Expand All @@ -203,8 +202,7 @@ fn pretty_successor_labels(terminator: &TerminatorKind) -> Vec<String> {
Call { target: Some(_), unwind: UnwindAction::Cleanup(_), .. } => {
vec!["return".into(), "unwind".into()]
}
Drop { unwind: _, .. }
| Call { target: Some(_), unwind: _, .. } => vec!["return".into()],
Drop { unwind: _, .. } | Call { target: Some(_), unwind: _, .. } => vec!["return".into()],
Assert { unwind: UnwindAction::Cleanup(_), .. } => {
vec!["success".into(), "unwind".into()]
}
Expand Down
14 changes: 6 additions & 8 deletions compiler/stable_mir/src/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,15 @@ pub trait MirVisitor {
self.visit_place(place, PlaceContext::MUTATING, location);
self.visit_rvalue(rvalue, location);
}
StatementKind::FakeRead(_, place)
| StatementKind::PlaceMention(place) => {
StatementKind::FakeRead(_, place) | StatementKind::PlaceMention(place) => {
self.visit_place(place, PlaceContext::NON_MUTATING, location);
}
StatementKind::SetDiscriminant { place, .. }
| StatementKind::Deinit(place)
| StatementKind::Retag(_, place) => {
self.visit_place(place, PlaceContext::MUTATING, location);
}
StatementKind::StorageLive(local)
| StatementKind::StorageDead(local) => {
StatementKind::StorageLive(local) | StatementKind::StorageDead(local) => {
self.visit_local(local, PlaceContext::NON_USE, location);
}
StatementKind::AscribeUserType { place, projections, variance: _ } => {
Expand All @@ -226,8 +224,7 @@ pub trait MirVisitor {
self.visit_operand(count, location);
}
},
StatementKind::ConstEvalCounter
| StatementKind::Nop => {}
StatementKind::ConstEvalCounter | StatementKind::Nop => {}
}
}

Expand Down Expand Up @@ -302,8 +299,9 @@ pub trait MirVisitor {
| ProjectionElem::Subslice { from: _, to: _, from_end: _ } => {}
ProjectionElem::Field(_idx, ty) => self.visit_ty(ty, location),
ProjectionElem::Index(local) => self.visit_local(local, ptx, location),
ProjectionElem::OpaqueCast(ty)
| ProjectionElem::Subtype(ty) => self.visit_ty(ty, location),
ProjectionElem::OpaqueCast(ty) | ProjectionElem::Subtype(ty) => {
self.visit_ty(ty, location)
}
}
}

Expand Down
8 changes: 3 additions & 5 deletions compiler/stable_mir/src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use super::ty::{
Allocation, Binder, ConstDef, ExistentialPredicate, FnSig, GenericArgKind, GenericArgs,
MirConst, Promoted, Region, RigidTy, TermKind, Ty, UnevaluatedConst,
};
use crate::Opaque;
use crate::ty::TyConst;
use crate::Opaque;

pub trait Visitor: Sized {
type Break;
Expand Down Expand Up @@ -35,8 +35,7 @@ impl Visitable for Ty {
match self.kind() {
super::ty::TyKind::RigidTy(ty) => ty.visit(visitor)?,
super::ty::TyKind::Alias(_, alias) => alias.args.visit(visitor)?,
super::ty::TyKind::Param(_)
| super::ty::TyKind::Bound(_, _) => {}
super::ty::TyKind::Param(_) | super::ty::TyKind::Bound(_, _) => {}
}
ControlFlow::Continue(())
}
Expand All @@ -48,8 +47,7 @@ impl Visitable for TyConst {
}
fn super_visit<V: Visitor>(&self, visitor: &mut V) -> ControlFlow<V::Break> {
match &self.kind {
crate::ty::TyConstKind::Param(_)
| crate::ty::TyConstKind::Bound(_, _) => {}
crate::ty::TyConstKind::Param(_) | crate::ty::TyConstKind::Bound(_, _) => {}
crate::ty::TyConstKind::Unevaluated(_, args) => args.visit(visitor)?,
crate::ty::TyConstKind::Value(ty, alloc) => {
alloc.visit(visitor)?;
Expand Down