Skip to content

Commit 2b789be

Browse files
committed
rustc: make util::ppaux private.
1 parent 4e1af5e commit 2b789be

File tree

7 files changed

+22
-26
lines changed

7 files changed

+22
-26
lines changed

src/librustc/infer/error_reporting/mod.rs

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

762762
/// For generic types with parameters with defaults, remove the parameters corresponding to
763-
/// the defaults. This repeats a lot of the logic found in `PrintCx::parameterized`.
763+
/// the defaults. This repeats a lot of the logic found in `ty::print::pretty`.
764764
fn strip_generic_default_params(
765765
&self,
766766
def_id: DefId,

src/librustc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ pub mod ty;
154154
pub mod util {
155155
pub mod captures;
156156
pub mod common;
157-
pub mod ppaux;
157+
mod ppaux;
158158
pub mod nodemap;
159159
pub mod time_graph;
160160
pub mod profiling;

src/librustc/mir/mod.rs

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

3838
pub use mir::interpret::AssertMessage;
3939

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

2381-
ppaux::parameterized(fmt, variant_def.did, substs, Namespace::ValueNS)?;
2381+
let f = &mut *fmt;
2382+
PrintCx::with_tls_tcx(FmtPrinter::new(f, Namespace::ValueNS), |cx| {
2383+
let substs = cx.tcx.lift(&substs).expect("could not lift for printing");
2384+
cx.print_def_path(variant_def.did, Some(substs), iter::empty())?;
2385+
Ok(())
2386+
})?;
23822387

23832388
match variant_def.ctor_kind {
23842389
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 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,9 +2,9 @@ use hir::Unsafety;
22
use hir::def::Namespace;
33
use hir::def_id::DefId;
44
use ty::{self, Ty, PolyFnSig, TypeFoldable, Substs, TyCtxt};
5+
use ty::print::{FmtPrinter, Printer, PrintCx};
56
use traits;
67
use rustc_target::spec::abi::Abi;
7-
use util::ppaux;
88

99
use std::fmt;
1010
use std::iter;
@@ -175,7 +175,12 @@ impl<'tcx> InstanceDef<'tcx> {
175175

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

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 hir;
22
use hir::def::Namespace;
3-
use hir::def_id::DefId;
4-
use ty::subst::{Kind, Substs, UnpackedKind};
3+
use ty::subst::{Kind, UnpackedKind};
54
use ty::{self, Ty};
65
use ty::print::{FmtPrinter, PrettyPrinter, PrintCx, Print, Printer};
76

@@ -141,19 +140,6 @@ macro_rules! define_scoped_cx {
141140
};
142141
}
143142

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

src/librustc_mir/monomorphize/item.rs

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

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

0 commit comments

Comments
 (0)