Skip to content

Commit

Permalink
Rollup merge of #118274 - celinval:smir-fix-pretty, r=ouz-a
Browse files Browse the repository at this point in the history
Fix smir's `Ty::Ref` pretty printing

Add `&` or `&mut` to reference when generating a string for `TyKind::Ref`.

r? `@ouz-a`
  • Loading branch information
fmease authored Nov 25, 2023
2 parents a663bb9 + 60817e6 commit 20d243e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions compiler/stable_mir/src/mir/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ pub fn pretty_rvalue(rval: &Rvalue) -> String {

pub fn pretty_ty(ty: TyKind) -> String {
let mut pretty = String::new();
pretty.push_str("");
match ty {
TyKind::RigidTy(rigid_ty) => match rigid_ty {
RigidTy::Bool => "bool".to_string(),
Expand Down Expand Up @@ -215,7 +214,10 @@ pub fn pretty_ty(ty: TyKind) -> String {
pretty.push_str(&pretty_ty(ty.kind()));
pretty
}
RigidTy::Ref(_, ty, _) => pretty_ty(ty.kind()),
RigidTy::Ref(_, ty, mutability) => match mutability {
Mutability::Not => format!("&{}", pretty_ty(ty.kind())),
Mutability::Mut => format!("&mut {}", pretty_ty(ty.kind())),
},
RigidTy::FnDef(_, _) => format!("{:#?}", rigid_ty),
RigidTy::FnPtr(_) => format!("{:#?}", rigid_ty),
RigidTy::Closure(_, _) => format!("{:#?}", rigid_ty),
Expand Down

0 comments on commit 20d243e

Please sign in to comment.