Skip to content

Commit 3ea88b7

Browse files
committed
Auto merge of #608 - Areredify:ptr_debug_print, r=jackh726,detrumi
fix debug print of pointer types Fixes confusing debug print of pointer types, previously `&'a T` it was printed as `Not<!0_0, T>` and `*const T` was printed as `Not<T>`, which was not ideal.
2 parents 758e38b + 3434f66 commit 3ea88b7

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

chalk-ir/src/debug.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,22 @@ impl<I: Interner> Debug for TypeName<I> {
186186
TypeName::OpaqueType(opaque_ty) => write!(fmt, "!{:?}", opaque_ty),
187187
TypeName::Slice => write!(fmt, "{{slice}}"),
188188
TypeName::FnDef(fn_def) => write!(fmt, "{:?}", fn_def),
189-
TypeName::Raw(mutability) => write!(fmt, "{:?}", mutability),
190-
TypeName::Ref(mutability) => write!(fmt, "{:?}", mutability),
189+
TypeName::Ref(mutability) => write!(
190+
fmt,
191+
"{}",
192+
match mutability {
193+
Mutability::Mut => "{{&mut}}",
194+
Mutability::Not => "{{&}}",
195+
}
196+
),
197+
TypeName::Raw(mutability) => write!(
198+
fmt,
199+
"{}",
200+
match mutability {
201+
Mutability::Mut => "{{*mut}}",
202+
Mutability::Not => "{{*const}}",
203+
}
204+
),
191205
TypeName::Never => write!(fmt, "Never"),
192206
TypeName::Array => write!(fmt, "{{array}}"),
193207
TypeName::Closure(id) => write!(fmt, "{{closure:{:?}}}", id),

0 commit comments

Comments
 (0)