Skip to content

Commit dd90af9

Browse files
committed
Rename some PrettyPrinter methods.
More consistency.
1 parent d7612dc commit dd90af9

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

compiler/rustc_const_eval/src/util/type_name.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl<'tcx> Printer<'tcx> for TypeNamePrinter<'tcx> {
8383
self_ty: Ty<'tcx>,
8484
trait_ref: Option<ty::TraitRef<'tcx>>,
8585
) -> Result<(), PrintError> {
86-
self.pretty_path_qualified(self_ty, trait_ref)
86+
self.pretty_print_path_with_qualified(self_ty, trait_ref)
8787
}
8888

8989
fn print_path_with_impl(
@@ -92,7 +92,7 @@ impl<'tcx> Printer<'tcx> for TypeNamePrinter<'tcx> {
9292
self_ty: Ty<'tcx>,
9393
trait_ref: Option<ty::TraitRef<'tcx>>,
9494
) -> Result<(), PrintError> {
95-
self.pretty_path_append_impl(
95+
self.pretty_print_path_with_impl(
9696
|cx| {
9797
print_prefix(cx)?;
9898

compiler/rustc_middle/src/mir/pretty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,7 +1969,7 @@ fn pretty_print_const_value_tcx<'tcx>(
19691969
let args = tcx.lift(args).unwrap();
19701970
let mut p = FmtPrinter::new(tcx, Namespace::ValueNS);
19711971
p.print_alloc_ids = true;
1972-
p.print_value_path(variant_def.def_id, args)?;
1972+
p.pretty_print_value_path(variant_def.def_id, args)?;
19731973
fmt.write_str(&p.into_buffer())?;
19741974

19751975
match variant_def.ctor_kind() {
@@ -2011,7 +2011,7 @@ fn pretty_print_const_value_tcx<'tcx>(
20112011
(ConstValue::ZeroSized, ty::FnDef(d, s)) => {
20122012
let mut p = FmtPrinter::new(tcx, Namespace::ValueNS);
20132013
p.print_alloc_ids = true;
2014-
p.print_value_path(*d, s)?;
2014+
p.pretty_print_value_path(*d, s)?;
20152015
fmt.write_str(&p.into_buffer())?;
20162016
return Ok(());
20172017
}

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -245,15 +245,15 @@ impl<'tcx> RegionHighlightMode<'tcx> {
245245
/// Trait for printers that pretty-print using `fmt::Write` to the printer.
246246
pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
247247
/// Like `print_def_path` but for value paths.
248-
fn print_value_path(
248+
fn pretty_print_value_path(
249249
&mut self,
250250
def_id: DefId,
251251
args: &'tcx [GenericArg<'tcx>],
252252
) -> Result<(), PrintError> {
253253
self.print_def_path(def_id, args)
254254
}
255255

256-
fn print_in_binder<T>(&mut self, value: &ty::Binder<'tcx, T>) -> Result<(), PrintError>
256+
fn pretty_print_in_binder<T>(&mut self, value: &ty::Binder<'tcx, T>) -> Result<(), PrintError>
257257
where
258258
T: Print<'tcx, Self> + TypeFoldable<TyCtxt<'tcx>>,
259259
{
@@ -644,7 +644,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
644644
Ok(true)
645645
}
646646

647-
fn pretty_path_qualified(
647+
fn pretty_print_path_with_qualified(
648648
&mut self,
649649
self_ty: Ty<'tcx>,
650650
trait_ref: Option<ty::TraitRef<'tcx>>,
@@ -679,7 +679,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
679679
})
680680
}
681681

682-
fn pretty_path_append_impl(
682+
fn pretty_print_path_with_impl(
683683
&mut self,
684684
print_prefix: impl FnOnce(&mut Self) -> Result<(), PrintError>,
685685
self_ty: Ty<'tcx>,
@@ -746,7 +746,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
746746
}
747747
sig.print(self)?;
748748
write!(self, " {{")?;
749-
self.print_value_path(def_id, args)?;
749+
self.pretty_print_value_path(def_id, args)?;
750750
write!(self, "}}")?;
751751
}
752752
}
@@ -1393,7 +1393,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
13931393
if let ty::Tuple(tys) = principal.args.type_at(0).kind() {
13941394
let mut projections = predicates.projection_bounds();
13951395
if let (Some(proj), None) = (projections.next(), projections.next()) {
1396-
p.pretty_fn_sig(
1396+
p.pretty_print_fn_sig(
13971397
tys,
13981398
false,
13991399
proj.skip_binder().term.as_type().expect("Return type was a const"),
@@ -1495,7 +1495,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
14951495
Ok(())
14961496
}
14971497

1498-
fn pretty_fn_sig(
1498+
fn pretty_print_fn_sig(
14991499
&mut self,
15001500
inputs: &[Ty<'tcx>],
15011501
c_variadic: bool,
@@ -1532,7 +1532,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
15321532
ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, args }) => {
15331533
match self.tcx().def_kind(def) {
15341534
DefKind::Const | DefKind::AssocConst => {
1535-
self.print_value_path(def, args)?;
1535+
self.pretty_print_value_path(def, args)?;
15361536
}
15371537
DefKind::AnonConst => {
15381538
if def.is_local()
@@ -1541,13 +1541,13 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
15411541
{
15421542
write!(self, "{snip}")?;
15431543
} else {
1544-
// Do not call `print_value_path` as if a parent of this anon const is
1545-
// an impl it will attempt to print out the impl trait ref i.e. `<T as
1546-
// Trait>::{constant#0}`. This would cause printing to enter an
1547-
// infinite recursion if the anon const is in the self type i.e.
1548-
// `impl<T: Default> Default for [T; 32 - 1 - 1 - 1] {` where we would
1549-
// try to print
1550-
// `<[T; /* print constant#0 again */] as // Default>::{constant#0}`.
1544+
// Do not call `pretty_print_value_path` as if a parent of this anon
1545+
// const is an impl it will attempt to print out the impl trait ref
1546+
// i.e. `<T as Trait>::{constant#0}`. This would cause printing to
1547+
// enter an infinite recursion if the anon const is in the self type
1548+
// i.e. `impl<T: Default> Default for [T; 32 - 1 - 1 - 1] {` where we
1549+
// would try to print `<[T; /* print constant#0 again */] as //
1550+
// Default>::{constant#0}`.
15511551
write!(
15521552
self,
15531553
"{}::{}",
@@ -1749,7 +1749,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
17491749
self.tcx().try_get_global_alloc(prov.alloc_id())
17501750
{
17511751
self.typed_value(
1752-
|this| this.print_value_path(instance.def_id(), instance.args),
1752+
|this| this.pretty_print_value_path(instance.def_id(), instance.args),
17531753
|this| this.print_type(ty),
17541754
" as ",
17551755
)?;
@@ -1943,7 +1943,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
19431943
let variant_idx =
19441944
contents.variant.expect("destructed const of adt without variant idx");
19451945
let variant_def = &def.variant(variant_idx);
1946-
self.print_value_path(variant_def.def_id, args)?;
1946+
self.pretty_print_value_path(variant_def.def_id, args)?;
19471947
match variant_def.ctor_kind() {
19481948
Some(CtorKind::Const) => {}
19491949
Some(CtorKind::Fn) => {
@@ -1979,7 +1979,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
19791979
}
19801980
(_, ty::FnDef(def_id, args)) => {
19811981
// Never allowed today, but we still encounter them in invalid const args.
1982-
self.print_value_path(def_id, args)?;
1982+
self.pretty_print_value_path(def_id, args)?;
19831983
return Ok(());
19841984
}
19851985
// FIXME(oli-obk): also pretty print arrays and other aggregate constants by reading
@@ -2000,7 +2000,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
20002000
Ok(())
20012001
}
20022002

2003-
fn pretty_closure_as_impl(
2003+
fn pretty_print_closure_as_impl(
20042004
&mut self,
20052005
closure: ty::ClosureArgs<TyCtxt<'tcx>>,
20062006
) -> Result<(), PrintError> {
@@ -2335,7 +2335,7 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> {
23352335
self_ty: Ty<'tcx>,
23362336
trait_ref: Option<ty::TraitRef<'tcx>>,
23372337
) -> Result<(), PrintError> {
2338-
self.pretty_path_qualified(self_ty, trait_ref)?;
2338+
self.pretty_print_path_with_qualified(self_ty, trait_ref)?;
23392339
self.empty_path = false;
23402340
Ok(())
23412341
}
@@ -2346,7 +2346,7 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> {
23462346
self_ty: Ty<'tcx>,
23472347
trait_ref: Option<ty::TraitRef<'tcx>>,
23482348
) -> Result<(), PrintError> {
2349-
self.pretty_path_append_impl(
2349+
self.pretty_print_path_with_impl(
23502350
|p| {
23512351
print_prefix(p)?;
23522352
if !p.empty_path {
@@ -2424,7 +2424,7 @@ impl<'tcx> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx> {
24242424
self.0.const_infer_name_resolver.as_ref().and_then(|func| func(id))
24252425
}
24262426

2427-
fn print_value_path(
2427+
fn pretty_print_value_path(
24282428
&mut self,
24292429
def_id: DefId,
24302430
args: &'tcx [GenericArg<'tcx>],
@@ -2436,7 +2436,7 @@ impl<'tcx> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx> {
24362436
Ok(())
24372437
}
24382438

2439-
fn print_in_binder<T>(&mut self, value: &ty::Binder<'tcx, T>) -> Result<(), PrintError>
2439+
fn pretty_print_in_binder<T>(&mut self, value: &ty::Binder<'tcx, T>) -> Result<(), PrintError>
24402440
where
24412441
T: Print<'tcx, Self> + TypeFoldable<TyCtxt<'tcx>>,
24422442
{
@@ -2899,7 +2899,7 @@ where
28992899
T: Print<'tcx, P> + TypeFoldable<TyCtxt<'tcx>>,
29002900
{
29012901
fn print(&self, p: &mut P) -> Result<(), PrintError> {
2902-
p.print_in_binder(self)
2902+
p.pretty_print_in_binder(self)
29032903
}
29042904
}
29052905

@@ -3097,7 +3097,7 @@ define_print! {
30973097
}
30983098

30993099
write!(p, "fn")?;
3100-
p.pretty_fn_sig(self.inputs(), self.c_variadic, self.output())?;
3100+
p.pretty_print_fn_sig(self.inputs(), self.c_variadic, self.output())?;
31013101
}
31023102

31033103
ty::TraitRef<'tcx> {
@@ -3321,7 +3321,7 @@ define_print_and_forward_display! {
33213321
}
33223322

33233323
PrintClosureAsImpl<'tcx> {
3324-
p.pretty_closure_as_impl(self.closure)?;
3324+
p.pretty_print_closure_as_impl(self.closure)?;
33253325
}
33263326

33273327
ty::ParamTy {

compiler/rustc_symbol_mangling/src/legacy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ impl<'tcx> Printer<'tcx> for LegacySymbolMangler<'tcx> {
313313
self_ty: Ty<'tcx>,
314314
trait_ref: Option<ty::TraitRef<'tcx>>,
315315
) -> Result<(), PrintError> {
316-
// Similar to `pretty_path_qualified`, but for the other
316+
// Similar to `pretty_print_path_with_qualified`, but for the other
317317
// types that are printed as paths (see `print_type` above).
318318
match self_ty.kind() {
319319
ty::FnDef(..)
@@ -326,7 +326,7 @@ impl<'tcx> Printer<'tcx> for LegacySymbolMangler<'tcx> {
326326
self.print_type(self_ty)
327327
}
328328

329-
_ => self.pretty_path_qualified(self_ty, trait_ref),
329+
_ => self.pretty_print_path_with_qualified(self_ty, trait_ref),
330330
}
331331
}
332332

@@ -336,7 +336,7 @@ impl<'tcx> Printer<'tcx> for LegacySymbolMangler<'tcx> {
336336
self_ty: Ty<'tcx>,
337337
trait_ref: Option<ty::TraitRef<'tcx>>,
338338
) -> Result<(), PrintError> {
339-
self.pretty_path_append_impl(
339+
self.pretty_print_path_with_impl(
340340
|cx| {
341341
print_prefix(cx)?;
342342

0 commit comments

Comments
 (0)