Skip to content

Commit 27a9850

Browse files
authored
Merge pull request #400 from detrumi/opaque-ty-debug-impls
Improve opaque type debug output
2 parents 557170e + 27445a0 commit 27a9850

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

chalk-integration/src/lowering.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ impl LowerProgram for Program {
451451
associated_ty_values,
452452
associated_ty_data,
453453
opaque_ty_ids,
454+
opaque_ty_kinds,
454455
opaque_ty_data,
455456
custom_clauses,
456457
};

chalk-integration/src/program.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ pub struct Program {
4545
// From opaque type name to item-id. Used during lowering only.
4646
pub opaque_ty_ids: BTreeMap<Identifier, OpaqueTyId<ChalkIr>>,
4747

48+
/// For each opaque type:
49+
pub opaque_ty_kinds: BTreeMap<OpaqueTyId<ChalkIr>, TypeKind>,
50+
4851
/// For each opaque type:
4952
pub opaque_ty_data: BTreeMap<OpaqueTyId<ChalkIr>, Arc<OpaqueTyDatum<ChalkIr>>>,
5053

@@ -120,8 +123,8 @@ impl tls::DebugContext for Program {
120123
opaque_ty_id: OpaqueTyId<ChalkIr>,
121124
fmt: &mut fmt::Formatter<'_>,
122125
) -> Result<(), fmt::Error> {
123-
if let Some(d) = self.opaque_ty_data.get(&opaque_ty_id) {
124-
write!(fmt, "{:?}", d.bound.skip_binders().hidden_ty)
126+
if let Some(k) = self.opaque_ty_kinds.get(&opaque_ty_id) {
127+
write!(fmt, "{}", k.name)
125128
} else {
126129
fmt.debug_struct("InvalidItemId")
127130
.field("index", &opaque_ty_id.0)
@@ -162,7 +165,7 @@ impl tls::DebugContext for Program {
162165
opaque_ty: &OpaqueTy<ChalkIr>,
163166
fmt: &mut fmt::Formatter<'_>,
164167
) -> Result<(), fmt::Error> {
165-
write!(fmt, "impl {:?}", opaque_ty.opaque_ty_id)
168+
write!(fmt, "{:?}", opaque_ty.opaque_ty_id)
166169
}
167170

168171
fn debug_ty(&self, ty: &Ty<ChalkIr>, fmt: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {

chalk-ir/src/debug.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl<I: Interner> Debug for TypeName<I> {
141141
match self {
142142
TypeName::Struct(id) => write!(fmt, "{:?}", id),
143143
TypeName::AssociatedType(assoc_ty) => write!(fmt, "{:?}", assoc_ty),
144-
TypeName::OpaqueType(opaque_ty) => write!(fmt, "{:?}", opaque_ty),
144+
TypeName::OpaqueType(opaque_ty) => write!(fmt, "!{:?}", opaque_ty),
145145
TypeName::Error => write!(fmt, "{{error}}"),
146146
}
147147
}

0 commit comments

Comments
 (0)