about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/infer/error_reporting/mod.rs2
-rw-r--r--src/librustc/lib.rs2
-rw-r--r--src/librustc/mir/mod.rs9
-rw-r--r--src/librustc/traits/structural_impls.rs5
-rw-r--r--src/librustc/ty/instance.rs9
-rw-r--r--src/librustc/ty/print/pretty.rs2
-rw-r--r--src/librustc/util/ppaux.rs16
-rw-r--r--src/librustc_mir/monomorphize/item.rs5
8 files changed, 23 insertions, 27 deletions
diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs
index ad24e15b45a..73a8721bdeb 100644
--- a/src/librustc/infer/error_reporting/mod.rs
+++ b/src/librustc/infer/error_reporting/mod.rs
@@ -768,7 +768,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
     }
 
     /// For generic types with parameters with defaults, remove the parameters corresponding to
-    /// the defaults. This repeats a lot of the logic found in `PrintCx::parameterized`.
+    /// the defaults. This repeats a lot of the logic found in `ty::print::pretty`.
     fn strip_generic_default_params(
         &self,
         def_id: DefId,
diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs
index 53f39d3ac8a..9150417a85d 100644
--- a/src/librustc/lib.rs
+++ b/src/librustc/lib.rs
@@ -135,7 +135,7 @@ pub mod ty;
 pub mod util {
     pub mod captures;
     pub mod common;
-    pub mod ppaux;
+    mod ppaux;
     pub mod nodemap;
     pub mod profiling;
     pub mod bug;
diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs
index c0f0df004c6..5e2851e08ec 100644
--- a/src/librustc/mir/mod.rs
+++ b/src/librustc/mir/mod.rs
@@ -34,7 +34,7 @@ use crate::ty::{
     self, AdtDef, CanonicalUserTypeAnnotations, ClosureSubsts, GeneratorSubsts, Region, Ty, TyCtxt,
     UserTypeAnnotationIndex,
 };
-use crate::util::ppaux;
+use crate::ty::print::{FmtPrinter, Printer, PrintCx};
 
 pub use crate::mir::interpret::AssertMessage;
 
@@ -2406,7 +2406,12 @@ impl<'tcx> Debug for Rvalue<'tcx> {
                     AggregateKind::Adt(adt_def, variant, substs, _user_ty, _) => {
                         let variant_def = &adt_def.variants[variant];
 
-                        ppaux::parameterized(fmt, variant_def.did, substs, Namespace::ValueNS)?;
+                        let f = &mut *fmt;
+                        PrintCx::with_tls_tcx(FmtPrinter::new(f, Namespace::ValueNS), |cx| {
+                            let substs = cx.tcx.lift(&substs).expect("could not lift for printing");
+                            cx.print_def_path(variant_def.did, Some(substs), iter::empty())?;
+                            Ok(())
+                        })?;
 
                         match variant_def.ctor_kind {
                             CtorKind::Const => Ok(()),
diff --git a/src/librustc/traits/structural_impls.rs b/src/librustc/traits/structural_impls.rs
index b5be1777fa0..f3a800bf46d 100644
--- a/src/librustc/traits/structural_impls.rs
+++ b/src/librustc/traits/structural_impls.rs
@@ -165,7 +165,8 @@ impl<'tcx> fmt::Display for traits::WhereClause<'tcx> {
     fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
         use crate::traits::WhereClause::*;
 
-        // Bypass ppaux because it does not print out anonymous regions.
+        // Bypass `ty::print` because it does not print out anonymous regions.
+        // FIXME(eddyb) implement a custom `PrettyPrinter`, or move this to `ty::print`.
         fn write_region_name<'tcx>(
             r: ty::Region<'tcx>,
             fmt: &mut fmt::Formatter<'_>
@@ -256,7 +257,7 @@ impl fmt::Display for traits::QuantifierKind {
 }
 
 /// Collect names for regions / types bound by a quantified goal / clause.
-/// This collector does not try to do anything clever like in ppaux, it's just used
+/// This collector does not try to do anything clever like in `ty::print`, it's just used
 /// for debug output in tests anyway.
 struct BoundNamesCollector {
     // Just sort by name because `BoundRegion::BrNamed` does not have a `BoundVar` index anyway.
diff --git a/src/librustc/ty/instance.rs b/src/librustc/ty/instance.rs
index fd0b97e98a3..b137d5f69c6 100644
--- a/src/librustc/ty/instance.rs
+++ b/src/librustc/ty/instance.rs
@@ -2,10 +2,10 @@ use crate::hir::Unsafety;
 use crate::hir::def::Namespace;
 use crate::hir::def_id::DefId;
 use crate::ty::{self, Ty, PolyFnSig, TypeFoldable, SubstsRef, TyCtxt};
+use crate::ty::print::{FmtPrinter, Printer, PrintCx};
 use crate::traits;
 use rustc_target::spec::abi::Abi;
 use rustc_macros::HashStable;
-use crate::util::ppaux;
 
 use std::fmt;
 use std::iter;
@@ -176,7 +176,12 @@ impl<'tcx> InstanceDef<'tcx> {
 
 impl<'tcx> fmt::Display for Instance<'tcx> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        ppaux::parameterized(f, self.def_id(), self.substs, Namespace::ValueNS)?;
+        PrintCx::with_tls_tcx(FmtPrinter::new(&mut *f, Namespace::ValueNS), |cx| {
+            let substs = cx.tcx.lift(&self.substs).expect("could not lift for printing");
+            cx.print_def_path(self.def_id(), Some(substs), iter::empty())?;
+            Ok(())
+        })?;
+
         match self.def {
             InstanceDef::Item(_) => Ok(()),
             InstanceDef::VtableShim(_) => {
diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs
index 325897dc042..a2e8954cf92 100644
--- a/src/librustc/ty/print/pretty.rs
+++ b/src/librustc/ty/print/pretty.rs
@@ -1163,7 +1163,7 @@ impl<'gcx, 'tcx, P: PrettyPrinter> PrintCx<'_, 'gcx, 'tcx, P> {
                     }
                 }
 
-                if self.config.is_verbose {
+                if self.tcx.sess.verbose() {
                     p!(write(
                         " closure_kind_ty={:?} closure_sig_ty={:?}",
                         substs.closure_kind_ty(did, self.tcx),
diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs
index 20df306dd2a..cb2c8acba82 100644
--- a/src/librustc/util/ppaux.rs
+++ b/src/librustc/util/ppaux.rs
@@ -1,7 +1,6 @@
 use crate::hir;
 use crate::hir::def::Namespace;
-use crate::hir::def_id::DefId;
-use crate::ty::subst::{Kind, SubstsRef, UnpackedKind};
+use crate::ty::subst::{Kind, UnpackedKind};
 use crate::ty::{self, ParamConst, Ty};
 use crate::ty::print::{FmtPrinter, PrettyPrinter, PrintCx, Print, Printer};
 use crate::mir::interpret::ConstValue;
@@ -142,19 +141,6 @@ macro_rules! define_scoped_cx {
     };
 }
 
-pub fn parameterized<F: fmt::Write>(
-    f: &mut F,
-    did: DefId,
-    substs: SubstsRef<'_>,
-    ns: Namespace,
-) -> fmt::Result {
-    PrintCx::with_tls_tcx(FmtPrinter::new(f, ns), |cx| {
-        let substs = cx.tcx.lift(&substs).expect("could not lift for printing");
-        cx.print_def_path(did, Some(substs), iter::empty())?;
-        Ok(())
-    })
-}
-
 define_print! {
     ('tcx) &'tcx ty::List<ty::ExistentialPredicate<'tcx>>, (self, cx) {
         display {
diff --git a/src/librustc_mir/monomorphize/item.rs b/src/librustc_mir/monomorphize/item.rs
index 211f9ad1735..68d13bf2dcb 100644
--- a/src/librustc_mir/monomorphize/item.rs
+++ b/src/librustc_mir/monomorphize/item.rs
@@ -216,9 +216,8 @@ impl<'a, 'tcx> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
 // These keys are used by the handwritten auto-tests, so they need to be
 // predictable and human-readable.
 //
-// Note: A lot of this could looks very similar to what's already in the
-//       ppaux module. It would be good to refactor things so we only have one
-//       parameterizable implementation for printing types.
+// Note: A lot of this could looks very similar to what's already in `ty::print`.
+// FIXME(eddyb) implement a custom `PrettyPrinter` for this.
 
 /// Same as `unique_type_name()` but with the result pushed onto the given
 /// `output` parameter.