Skip to content

Commit 6a95d90

Browse files
committed
make Repr of TraitRef more useful
1 parent ce27d02 commit 6a95d90

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/librustc/util/ppaux.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -810,8 +810,12 @@ impl<'tcx> Repr<'tcx> for ty::TraitRef<'tcx> {
810810
// to enumerate the `for<...>` etc because the debruijn index
811811
// tells you everything you need to know.
812812
let base = ty::item_path_str(tcx, self.def_id);
813-
parameterized(tcx, &base, self.substs, self.def_id, &[],
814-
|| ty::lookup_trait_def(tcx, self.def_id).generics.clone())
813+
let result = parameterized(tcx, &base, self.substs, self.def_id, &[],
814+
|| ty::lookup_trait_def(tcx, self.def_id).generics.clone());
815+
match self.substs.self_ty() {
816+
None => result,
817+
Some(sty) => format!("<{} as {}>", sty.repr(tcx), result)
818+
}
815819
}
816820
}
817821

@@ -1504,8 +1508,7 @@ impl<'tcx> UserString<'tcx> for ty::ProjectionPredicate<'tcx> {
15041508

15051509
impl<'tcx> Repr<'tcx> for ty::ProjectionTy<'tcx> {
15061510
fn repr(&self, tcx: &ctxt<'tcx>) -> String {
1507-
format!("<{} as {}>::{}",
1508-
self.trait_ref.substs.self_ty().repr(tcx),
1511+
format!("{}::{}",
15091512
self.trait_ref.repr(tcx),
15101513
self.item_name.repr(tcx))
15111514
}

0 commit comments

Comments
 (0)