Skip to content

Commit d0a1bf5

Browse files
committed
rustc: make util::ppaux private.
1 parent 800ddb3 commit d0a1bf5

File tree

8 files changed

+23
-27
lines changed

8 files changed

+23
-27
lines changed

src/librustc/infer/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
768768
}
769769

770770
/// For generic types with parameters with defaults, remove the parameters corresponding to
771-
/// the defaults. This repeats a lot of the logic found in `PrintCx::parameterized`.
771+
/// the defaults. This repeats a lot of the logic found in `ty::print::pretty`.
772772
fn strip_generic_default_params(
773773
&self,
774774
def_id: DefId,

src/librustc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub mod ty;
135135
pub mod util {
136136
pub mod captures;
137137
pub mod common;
138-
pub mod ppaux;
138+
mod ppaux;
139139
pub mod nodemap;
140140
pub mod profiling;
141141
pub mod bug;

src/librustc/mir/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::ty::{
3434
self, AdtDef, CanonicalUserTypeAnnotations, ClosureSubsts, GeneratorSubsts, Region, Ty, TyCtxt,
3535
UserTypeAnnotationIndex,
3636
};
37-
use crate::util::ppaux;
37+
use crate::ty::print::{FmtPrinter, Printer, PrintCx};
3838

3939
pub use crate::mir::interpret::AssertMessage;
4040

@@ -2406,7 +2406,12 @@ impl<'tcx> Debug for Rvalue<'tcx> {
24062406
AggregateKind::Adt(adt_def, variant, substs, _user_ty, _) => {
24072407
let variant_def = &adt_def.variants[variant];
24082408

2409-
ppaux::parameterized(fmt, variant_def.did, substs, Namespace::ValueNS)?;
2409+
let f = &mut *fmt;
2410+
PrintCx::with_tls_tcx(FmtPrinter::new(f, Namespace::ValueNS), |cx| {
2411+
let substs = cx.tcx.lift(&substs).expect("could not lift for printing");
2412+
cx.print_def_path(variant_def.did, Some(substs), iter::empty())?;
2413+
Ok(())
2414+
})?;
24102415

24112416
match variant_def.ctor_kind {
24122417
CtorKind::Const => Ok(()),

src/librustc/traits/structural_impls.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ impl<'tcx> fmt::Display for traits::WhereClause<'tcx> {
165165
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
166166
use crate::traits::WhereClause::*;
167167

168-
// Bypass ppaux because it does not print out anonymous regions.
168+
// Bypass `ty::print` because it does not print out anonymous regions.
169+
// FIXME(eddyb) implement a custom `PrettyPrinter`, or move this to `ty::print`.
169170
fn write_region_name<'tcx>(
170171
r: ty::Region<'tcx>,
171172
fmt: &mut fmt::Formatter<'_>
@@ -256,7 +257,7 @@ impl fmt::Display for traits::QuantifierKind {
256257
}
257258

258259
/// Collect names for regions / types bound by a quantified goal / clause.
259-
/// This collector does not try to do anything clever like in ppaux, it's just used
260+
/// This collector does not try to do anything clever like in `ty::print`, it's just used
260261
/// for debug output in tests anyway.
261262
struct BoundNamesCollector {
262263
// Just sort by name because `BoundRegion::BrNamed` does not have a `BoundVar` index anyway.

src/librustc/ty/instance.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use crate::hir::Unsafety;
22
use crate::hir::def::Namespace;
33
use crate::hir::def_id::DefId;
44
use crate::ty::{self, Ty, PolyFnSig, TypeFoldable, SubstsRef, TyCtxt};
5+
use crate::ty::print::{FmtPrinter, Printer, PrintCx};
56
use crate::traits;
67
use rustc_target::spec::abi::Abi;
78
use rustc_macros::HashStable;
8-
use crate::util::ppaux;
99

1010
use std::fmt;
1111
use std::iter;
@@ -176,7 +176,12 @@ impl<'tcx> InstanceDef<'tcx> {
176176

177177
impl<'tcx> fmt::Display for Instance<'tcx> {
178178
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
179-
ppaux::parameterized(f, self.def_id(), self.substs, Namespace::ValueNS)?;
179+
PrintCx::with_tls_tcx(FmtPrinter::new(&mut *f, Namespace::ValueNS), |cx| {
180+
let substs = cx.tcx.lift(&self.substs).expect("could not lift for printing");
181+
cx.print_def_path(self.def_id(), Some(substs), iter::empty())?;
182+
Ok(())
183+
})?;
184+
180185
match self.def {
181186
InstanceDef::Item(_) => Ok(()),
182187
InstanceDef::VtableShim(_) => {

src/librustc/ty/print/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ impl<'gcx, 'tcx, P: PrettyPrinter> PrintCx<'_, 'gcx, 'tcx, P> {
11631163
}
11641164
}
11651165

1166-
if self.config.is_verbose {
1166+
if self.tcx.sess.verbose() {
11671167
p!(write(
11681168
" closure_kind_ty={:?} closure_sig_ty={:?}",
11691169
substs.closure_kind_ty(did, self.tcx),

src/librustc/util/ppaux.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::hir;
22
use crate::hir::def::Namespace;
3-
use crate::hir::def_id::DefId;
4-
use crate::ty::subst::{Kind, SubstsRef, UnpackedKind};
3+
use crate::ty::subst::{Kind, UnpackedKind};
54
use crate::ty::{self, ParamConst, Ty};
65
use crate::ty::print::{FmtPrinter, PrettyPrinter, PrintCx, Print, Printer};
76
use crate::mir::interpret::ConstValue;
@@ -142,19 +141,6 @@ macro_rules! define_scoped_cx {
142141
};
143142
}
144143

145-
pub fn parameterized<F: fmt::Write>(
146-
f: &mut F,
147-
did: DefId,
148-
substs: SubstsRef<'_>,
149-
ns: Namespace,
150-
) -> fmt::Result {
151-
PrintCx::with_tls_tcx(FmtPrinter::new(f, ns), |cx| {
152-
let substs = cx.tcx.lift(&substs).expect("could not lift for printing");
153-
cx.print_def_path(did, Some(substs), iter::empty())?;
154-
Ok(())
155-
})
156-
}
157-
158144
define_print! {
159145
('tcx) &'tcx ty::List<ty::ExistentialPredicate<'tcx>>, (self, cx) {
160146
display {

src/librustc_mir/monomorphize/item.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,8 @@ impl<'a, 'tcx> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
216216
// These keys are used by the handwritten auto-tests, so they need to be
217217
// predictable and human-readable.
218218
//
219-
// Note: A lot of this could looks very similar to what's already in the
220-
// ppaux module. It would be good to refactor things so we only have one
221-
// parameterizable implementation for printing types.
219+
// Note: A lot of this could looks very similar to what's already in `ty::print`.
220+
// FIXME(eddyb) implement a custom `PrettyPrinter` for this.
222221

223222
/// Same as `unique_type_name()` but with the result pushed onto the given
224223
/// `output` parameter.

0 commit comments

Comments
 (0)