diff options
| author | Kalle Wachsmuth <kalle.wachsmuth@gmail.com> | 2024-03-24 14:53:58 +0100 |
|---|---|---|
| committer | Kalle Wachsmuth <kalle.wachsmuth@gmail.com> | 2024-04-10 18:51:09 +0200 |
| commit | 277e61854eaad456816730bb0a75d85a3a460d96 (patch) | |
| tree | 34d1b374129e249e88133c7b711bdcb433bf9f44 /compiler/rustc_middle/src | |
| parent | db3a5c58739137036f85cee036c1b63af2517093 (diff) | |
| download | rust-277e61854eaad456816730bb0a75d85a3a460d96.tar.gz rust-277e61854eaad456816730bb0a75d85a3a460d96.zip | |
introduce `Mutability::ptr_str`
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/mir/pretty.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/print/pretty.rs | 8 |
2 files changed, 2 insertions, 13 deletions
diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index 41df2e3b587..15bd5c08965 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -978,12 +978,7 @@ impl<'tcx> Debug for Rvalue<'tcx> { CopyForDeref(ref place) => write!(fmt, "deref_copy {place:#?}"), AddressOf(mutability, ref place) => { - let kind_str = match mutability { - Mutability::Mut => "mut", - Mutability::Not => "const", - }; - - write!(fmt, "&raw {kind_str} {place:?}") + write!(fmt, "&raw {mut_str} {place:?}", mut_str = mutability.ptr_str()) } Aggregate(ref kind, ref places) => { diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 20ebd87c3d4..0bd009cd51d 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -671,13 +671,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { p!("(", print(ty), ") is ", write("{pat:?}")) } ty::RawPtr(ty, mutbl) => { - p!(write( - "*{} ", - match mutbl { - hir::Mutability::Mut => "mut", - hir::Mutability::Not => "const", - } - )); + p!(write("*{} ", mutbl.ptr_str())); p!(print(ty)) } ty::Ref(r, ty, mutbl) => { |
