Skip to content

Commit 69bcd79

Browse files
committed
Move should_truncate from trait Printer to sub-trait PrettyPrinter.
It's not used in `Printer`.
1 parent dfd38f0 commit 69bcd79

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,6 @@ pub trait Printer<'tcx>: Sized {
126126
trait_ref: Option<ty::TraitRef<'tcx>>,
127127
) -> Result<(), PrintError>;
128128

129-
fn should_truncate(&mut self) -> bool {
130-
false
131-
}
132-
133129
// Defaults (should not be overridden):
134130

135131
#[instrument(skip(self), level = "debug")]

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,10 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
333333
f: impl FnOnce(&mut Self) -> Result<(), PrintError>,
334334
) -> Result<(), PrintError>;
335335

336+
fn should_truncate(&mut self) -> bool {
337+
false
338+
}
339+
336340
/// Returns `true` if the region should be printed in
337341
/// optional positions, e.g., `&'a T` or `dyn Tr + 'b`.
338342
/// This is typically the case for all non-`'_` regions.
@@ -2295,10 +2299,6 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> {
22952299
}
22962300
}
22972301

2298-
fn should_truncate(&mut self) -> bool {
2299-
!self.type_length_limit.value_within_limit(self.printed_type_count)
2300-
}
2301-
23022302
fn print_dyn_existential(
23032303
&mut self,
23042304
predicates: &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
@@ -2487,6 +2487,10 @@ impl<'tcx> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx> {
24872487
Ok(())
24882488
}
24892489

2490+
fn should_truncate(&mut self) -> bool {
2491+
!self.type_length_limit.value_within_limit(self.printed_type_count)
2492+
}
2493+
24902494
fn should_print_region(&self, region: ty::Region<'tcx>) -> bool {
24912495
let highlight = self.region_highlight_mode;
24922496
if highlight.region_highlighted(region).is_some() {

0 commit comments

Comments
 (0)