Skip to content

Commit 4f7d26a

Browse files
committed
implement debug properly
1 parent 474c413 commit 4f7d26a

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

‎compiler/rustc_type_ir/src/predicate.rs‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ impl CompressedTraitRefs {
863863
/// So we don't, and assume that it's enough to fold/visit into the `self_ty`. This works because
864864
/// the traits represented by [`ClauseKind::CompressedTrait`] don't have generic args or anything
865865
/// complicated. A normal fold/visit of them will effectively only care about `self_ty`.
866-
#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
866+
#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
867867
#[derive(TypeVisitable_Generic, GenericTypeVisitable, TypeFoldable_Generic)]
868868
#[cfg_attr(
869869
feature = "nightly",
@@ -877,6 +877,17 @@ pub struct CompressedTraitClause<I: Interner> {
877877
pub compressed_trait_refs: CompressedTraitRefs,
878878
}
879879

880+
impl<I: Interner> fmt::Debug for CompressedTraitClause<I> {
881+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
882+
write!(
883+
f,
884+
"{:?} as {}",
885+
self.self_ty,
886+
self.compressed_trait_refs.iter_names().map(|i| i.0).collect::<Vec<_>>().join(",")
887+
)
888+
}
889+
}
890+
880891
impl<I: Interner> CompressedTraitClause<I> {
881892
/// Returns `Some` if the passed clause is eligible to be represented as a `CommonClause`.
882893
/// Only a few clauses are, but those clauses are exceedingly common.

‎compiler/rustc_type_ir/src/predicate_kind.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ impl<I: Interner> fmt::Debug for ClauseKind<I> {
133133
ClauseKind::UnstableFeature(feature_name) => {
134134
write!(f, "UnstableFeature({feature_name:?})")
135135
}
136-
ClauseKind::CompressedTrait(_) => {
137-
todo!()
136+
ClauseKind::CompressedTrait(c) => {
137+
write!(f, "CompressedTrait({c:?})")
138138
}
139139
}
140140
}

0 commit comments

Comments
 (0)