rustc: make util::ppaux private.

This commit is contained in:
Eduard-Mihai Burtescu 2019-01-18 22:14:01 +02:00
parent 800ddb367e
commit d0a1bf5c88
8 changed files with 23 additions and 27 deletions

View File

@ -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,

View File

@ -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;

View File

@ -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(()),

View File

@ -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.

View File

@ -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(_) => {

View File

@ -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),

View File

@ -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 {

View File

@ -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.