Skip to content

Commit

Permalink
Show name in opaque type debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
detrumi committed Apr 16, 2020
1 parent f438d7e commit 27445a0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions chalk-integration/src/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ impl LowerProgram for Program {
associated_ty_values,
associated_ty_data,
opaque_ty_ids,
opaque_ty_kinds,
opaque_ty_data,
custom_clauses,
};
Expand Down
9 changes: 6 additions & 3 deletions chalk-integration/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ pub struct Program {
// From opaque type name to item-id. Used during lowering only.
pub opaque_ty_ids: BTreeMap<Identifier, OpaqueTyId<ChalkIr>>,

/// For each opaque type:
pub opaque_ty_kinds: BTreeMap<OpaqueTyId<ChalkIr>, TypeKind>,

/// For each opaque type:
pub opaque_ty_data: BTreeMap<OpaqueTyId<ChalkIr>, Arc<OpaqueTyDatum<ChalkIr>>>,

Expand Down Expand Up @@ -120,8 +123,8 @@ impl tls::DebugContext for Program {
opaque_ty_id: OpaqueTyId<ChalkIr>,
fmt: &mut fmt::Formatter<'_>,
) -> Result<(), fmt::Error> {
if let Some(d) = self.opaque_ty_data.get(&opaque_ty_id) {
write!(fmt, "{:?}", d.bound.skip_binders().hidden_ty)
if let Some(k) = self.opaque_ty_kinds.get(&opaque_ty_id) {
write!(fmt, "{}", k.name)
} else {
fmt.debug_struct("InvalidItemId")
.field("index", &opaque_ty_id.0)
Expand Down Expand Up @@ -162,7 +165,7 @@ impl tls::DebugContext for Program {
opaque_ty: &OpaqueTy<ChalkIr>,
fmt: &mut fmt::Formatter<'_>,
) -> Result<(), fmt::Error> {
write!(fmt, "impl {:?}", opaque_ty.opaque_ty_id)
write!(fmt, "{:?}", opaque_ty.opaque_ty_id)
}

fn debug_ty(&self, ty: &Ty<ChalkIr>, fmt: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
Expand Down
2 changes: 1 addition & 1 deletion chalk-ir/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl<I: Interner> Debug for TypeName<I> {
match self {
TypeName::Struct(id) => write!(fmt, "{:?}", id),
TypeName::AssociatedType(assoc_ty) => write!(fmt, "{:?}", assoc_ty),
TypeName::OpaqueType(opaque_ty) => write!(fmt, "{:?}", opaque_ty),
TypeName::OpaqueType(opaque_ty) => write!(fmt, "!{:?}", opaque_ty),
TypeName::Error => write!(fmt, "{{error}}"),
}
}
Expand Down

0 comments on commit 27445a0

Please sign in to comment.