X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc%2Fty%2Fprint%2Fpretty.rs;h=db539f9195c9d399f8aa4b4427c96968865445e2;hb=ae31436ac739d2fe9fdb45fec1364db6007bd359;hp=9091de55b7d8ea5f4762e9f3f25e3a239c7170c3;hpb=b6d6391218d434b50ef04962cce66f3fd0d0ee94;p=rust.git diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs index 9091de55b7d..db539f9195c 100644 --- a/src/librustc/ty/print/pretty.rs +++ b/src/librustc/ty/print/pretty.rs @@ -831,7 +831,11 @@ fn pretty_fn_sig( Ok(self) } - fn pretty_print_const(mut self, ct: &'tcx ty::Const<'tcx>) -> Result { + fn pretty_print_const( + mut self, + ct: &'tcx ty::Const<'tcx>, + print_ty: bool, + ) -> Result { define_scoped_cx!(self); if self.tcx().sess.verbose() { @@ -839,6 +843,15 @@ fn pretty_print_const(mut self, ct: &'tcx ty::Const<'tcx>) -> Result {{ + p!(write("_")); + if print_ty { + p!(write(": "), print(ct.ty)); + } + }}; + } + match (ct.val, &ct.ty.kind) { (_, ty::FnDef(did, substs)) => p!(print_value_path(*did, substs)), (ty::ConstKind::Unevaluated(did, substs, promoted), _) => { @@ -857,22 +870,27 @@ fn pretty_print_const(mut self, ct: &'tcx ty::Const<'tcx>) -> Result p!(write("_: "), print(ct.ty)), + (ty::ConstKind::Infer(..), _) => print_underscore!(), (ty::ConstKind::Param(ParamConst { name, .. }), _) => p!(write("{}", name)), - (ty::ConstKind::Value(value), _) => return self.pretty_print_const_value(value, ct.ty), + (ty::ConstKind::Value(value), _) => { + return self.pretty_print_const_value(value, ct.ty, print_ty); + } _ => { // fallback - p!(write("{:?} : ", ct.val), print(ct.ty)) + p!(write("{:?}", ct.val)); + if print_ty { + p!(write(": "), print(ct.ty)); + } } }; Ok(self) @@ -882,6 +900,7 @@ fn pretty_print_const_value( mut self, ct: ConstValue<'tcx>, ty: Ty<'tcx>, + print_ty: bool, ) -> Result { define_scoped_cx!(self); @@ -988,7 +1007,10 @@ fn pretty_print_const_value( }; if !printed { // fallback - p!(write("{:?} : ", ct), print(ty)) + p!(write("{:?}", ct)); + if print_ty { + p!(write(": "), print(ty)); + } } } }; @@ -1162,7 +1184,7 @@ fn print_dyn_existential( } fn print_const(self, ct: &'tcx ty::Const<'tcx>) -> Result { - self.pretty_print_const(ct) + self.pretty_print_const(ct, true) } fn path_crate(mut self, cnum: CrateNum) -> Result { @@ -1588,7 +1610,7 @@ impl<'tcx, T, U, P: PrettyPrinter<'tcx>> Print<'tcx, P> for ty::OutlivesPredicat type Error = P::Error; fn print(&self, mut cx: P) -> Result { define_scoped_cx!(cx); - p!(print(self.0), write(" : "), print(self.1)); + p!(print(self.0), write(": "), print(self.1)); Ok(cx) } }