Skip to content

Commit 6a33221

Browse files
committed
Improve pretty-printing of references in MIR.
1 parent 5223544 commit 6a33221

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/librustc/mir/repr.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,6 @@ impl<'tcx> Debug for Rvalue<'tcx> {
721721
match *self {
722722
Use(ref lvalue) => write!(fmt, "{:?}", lvalue),
723723
Repeat(ref a, ref b) => write!(fmt, "[{:?}; {:?}]", a, b),
724-
Ref(ref a, bk, ref b) => write!(fmt, "&{:?} {:?} {:?}", a, bk, b),
725724
Len(ref a) => write!(fmt, "Len({:?})", a),
726725
Cast(ref kind, ref lv, ref ty) => write!(fmt, "{:?} as {:?} ({:?})", lv, ty, kind),
727726
BinaryOp(ref op, ref a, ref b) => write!(fmt, "{:?}({:?}, {:?})", op, a, b),
@@ -731,6 +730,14 @@ impl<'tcx> Debug for Rvalue<'tcx> {
731730
Slice { ref input, from_start, from_end } =>
732731
write!(fmt, "{:?}[{:?}..-{:?}]", input, from_start, from_end),
733732

733+
Ref(_, borrow_kind, ref lv) => {
734+
let kind_str = match borrow_kind {
735+
BorrowKind::Shared => "",
736+
BorrowKind::Mut | BorrowKind::Unique => "mut ",
737+
};
738+
write!(fmt, "&{}{:?}", kind_str, lv)
739+
}
740+
734741
Aggregate(ref kind, ref lvs) => {
735742
use self::AggregateKind::*;
736743

0 commit comments

Comments
 (0)