Skip to content

Commit 218932c

Browse files
committed
[HACK] use Display instead of Debug in a few key places.
1 parent 63f5e68 commit 218932c

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

compiler/rustc_infer/src/traits/project.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,7 @@ impl<'tcx> ProjectionCache<'_, 'tcx> {
179179
key: ProjectionCacheKey<'tcx>,
180180
value: Normalized<'tcx, ty::Term<'tcx>>,
181181
) {
182-
debug!(
183-
"ProjectionCacheEntry::insert_ty: adding cache entry: key={:?}, value={:?}",
184-
key, value
185-
);
182+
debug!("ProjectionCacheEntry::insert: adding cache entry: {} => {}", key.ty, value);
186183
let mut map = self.map();
187184
if let Some(ProjectionCacheEntry::Recur) = map.get(&key) {
188185
debug!("Not overwriting Recur");
@@ -201,7 +198,7 @@ impl<'tcx> ProjectionCache<'_, 'tcx> {
201198
let mut map = self.map();
202199
match map.get(&key) {
203200
Some(&ProjectionCacheEntry::NormalizedTy { ref ty, complete: _ }) => {
204-
info!("ProjectionCacheEntry::complete({:?}) - completing {:?}", key, ty);
201+
info!("ProjectionCacheEntry::complete({}) - completing {}", key.ty, ty);
205202
let mut ty = ty.clone();
206203
if result.must_apply_considering_regions() {
207204
ty.obligations = vec![];
@@ -211,7 +208,7 @@ impl<'tcx> ProjectionCache<'_, 'tcx> {
211208
ref value => {
212209
// Type inference could "strand behind" old cache entries. Leave
213210
// them alone for now.
214-
info!("ProjectionCacheEntry::complete({:?}) - ignoring {:?}", key, value);
211+
info!("ProjectionCacheEntry::complete({}) - ignoring {:?}", key.ty, value);
215212
}
216213
};
217214
}

compiler/rustc_infer/src/traits/structural_impls.rs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,17 @@ impl<'tcx, T: fmt::Debug> fmt::Debug for Normalized<'tcx, T> {
1515
}
1616
}
1717

18-
impl<'tcx, O: fmt::Debug> fmt::Debug for traits::Obligation<'tcx, O> {
18+
impl<'tcx, T: fmt::Display> fmt::Display for Normalized<'tcx, T> {
19+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20+
write!(f, "{}", self.value)?;
21+
if !self.obligations.is_empty() {
22+
write!(f, " @ obligations={:?}", self.obligations)?;
23+
}
24+
Ok(())
25+
}
26+
}
27+
28+
impl<'tcx, O: fmt::Debug + fmt::Display> fmt::Debug for traits::Obligation<'tcx, O> {
1929
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2030
if ty::tls::with(|tcx| tcx.sess.verbose()) {
2131
write!(
@@ -24,7 +34,11 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for traits::Obligation<'tcx, O> {
2434
self.predicate, self.cause, self.param_env, self.recursion_depth
2535
)
2636
} else {
27-
write!(f, "Obligation(predicate={:?}, depth={})", self.predicate, self.recursion_depth)
37+
write!(f, "{}", self.predicate)?;
38+
if self.recursion_depth > 0 {
39+
write!(f, " @ depth={}", self.recursion_depth)?;
40+
}
41+
Ok(())
2842
}
2943
}
3044
}
@@ -60,7 +74,9 @@ impl<'tcx> fmt::Debug for traits::MismatchedProjectionTypes<'tcx> {
6074
///////////////////////////////////////////////////////////////////////////
6175
// TypeFoldable implementations.
6276

63-
impl<'tcx, O: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Obligation<'tcx, O> {
77+
impl<'tcx, O: TypeFoldable<'tcx> + fmt::Display> TypeFoldable<'tcx>
78+
for traits::Obligation<'tcx, O>
79+
{
6480
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
6581
Ok(traits::Obligation {
6682
cause: self.cause,
@@ -71,7 +87,9 @@ impl<'tcx, O: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Obligation<'tcx
7187
}
7288
}
7389

74-
impl<'tcx, O: TypeVisitable<'tcx>> TypeVisitable<'tcx> for traits::Obligation<'tcx, O> {
90+
impl<'tcx, O: TypeVisitable<'tcx> + fmt::Display> TypeVisitable<'tcx>
91+
for traits::Obligation<'tcx, O>
92+
{
7593
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
7694
self.predicate.visit_with(visitor)?;
7795
self.param_env.visit_with(visitor)

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,6 +2457,7 @@ forward_display_to_print! {
24572457
ty::Binder<'tcx, ty::ExistentialTraitRef<'tcx>>,
24582458
ty::Binder<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
24592459
ty::Binder<'tcx, TraitRefPrintOnlyTraitName<'tcx>>,
2460+
ty::Binder<'tcx, ty::ProjectionTy<'tcx>>,
24602461
ty::Binder<'tcx, ty::FnSig<'tcx>>,
24612462
ty::Binder<'tcx, ty::TraitPredicate<'tcx>>,
24622463
ty::Binder<'tcx, TraitPredPrintModifiersAndPath<'tcx>>,

0 commit comments

Comments
 (0)