diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2020-03-13 10:48:41 +0100 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2020-03-13 10:48:41 +0100 |
| commit | 306df94ed34521d3d3536e2393b466519f6dfc96 (patch) | |
| tree | fa610e63021a695d4bca98ed6fb169e0a0fc9980 | |
| parent | 6e73a14234cf1c1e7bf7a1597f1db4a518e1c6bb (diff) | |
| download | rust-306df94ed34521d3d3536e2393b466519f6dfc96.tar.gz rust-306df94ed34521d3d3536e2393b466519f6dfc96.zip | |
Print ConstKind::Bound the same as TyKind::Bound
| -rw-r--r-- | src/librustc/ty/print/pretty.rs | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs index fdd1533e130..1dade8c0e08 100644 --- a/src/librustc/ty/print/pretty.rs +++ b/src/librustc/ty/print/pretty.rs @@ -533,14 +533,7 @@ pub trait PrettyPrinter<'tcx>: ty::Error => p!(write("[type error]")), ty::Param(ref param_ty) => p!(write("{}", param_ty)), ty::Bound(debruijn, bound_ty) => match bound_ty.kind { - ty::BoundTyKind::Anon => { - if debruijn == ty::INNERMOST { - p!(write("^{}", bound_ty.var.index())) - } else { - p!(write("^{}_{}", debruijn.index(), bound_ty.var.index())) - } - } - + ty::BoundTyKind::Anon => self.pretty_print_bound_var(debruijn, bound_ty.var)?, ty::BoundTyKind::Param(p) => p!(write("{}", p)), }, ty::Adt(def, substs) => { @@ -718,6 +711,18 @@ pub trait PrettyPrinter<'tcx>: Ok(self) } + fn pretty_print_bound_var( + &mut self, + debruijn: ty::DebruijnIndex, + var: ty::BoundVar, + ) -> Result<(), Self::Error> { + if debruijn == ty::INNERMOST { + write!(self, "^{}", var.index()) + } else { + write!(self, "^{}_{}", debruijn.index(), var.index()) + } + } + fn infer_ty_name(&self, _: ty::TyVid) -> Option<String> { None } @@ -905,7 +910,10 @@ pub trait PrettyPrinter<'tcx>: return self.pretty_print_const_value(value, ct.ty, print_ty); } - ty::ConstKind::Bound(..) | ty::ConstKind::Placeholder(_) => { + ty::ConstKind::Bound(debruijn, bound_var) => { + self.pretty_print_bound_var(debruijn, bound_var)? + } + ty::ConstKind::Placeholder(_) => { // fallback if print_ty { self = self.typed_value( |
