Skip to content

Commit

Permalink
Rollup merge of rust-lang#109506 - BoxyUwU:debugable_bound_var_printi…
Browse files Browse the repository at this point in the history
…ng, r=compiler-errors

make param bound vars visibly bound vars with -Zverbose

I was trying to debug some type/const bound var stuff and it was shockingly tricky due to the fact that even with `-Zverbose` enabled the `T` in `for<T> T: Trait` prints as `T` making it seem like its `TyKind::Param` when it is infact `TyKind::Bound`. This PR "fixes" this when `-Zverbose` is set to allow rendering it as `^T` or `^1_T` depending on binder depth.

r? ``@compiler-errors``
  • Loading branch information
matthiaskrgr authored Mar 23, 2023
2 parents 9ee96c8 + 3f7aeb3 commit eeeb44e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,11 @@ pub trait PrettyPrinter<'tcx>:
ty::BoundTyKind::Anon(bv) => {
self.pretty_print_bound_var(debruijn, ty::BoundVar::from_u32(bv))?
}
ty::BoundTyKind::Param(_, s) => p!(write("{}", s)),
ty::BoundTyKind::Param(_, s) => match self.should_print_verbose() {
true if debruijn == ty::INNERMOST => p!(write("^{}", s)),
true => p!(write("^{}_{}", debruijn.index(), s)),
false => p!(write("{}", s)),
},
},
ty::Adt(def, substs) => {
p!(print_def_path(def.did(), substs));
Expand Down

0 comments on commit eeeb44e

Please sign in to comment.