diff options
| author | Sarthak Singh <ss269@uw.edu> | 2022-10-30 17:38:49 +0530 |
|---|---|---|
| committer | Sarthak Singh <ss269@uw.edu> | 2022-10-30 20:37:43 +0530 |
| commit | 8609364480a7fb95edbecd202ecc511348ddbd25 (patch) | |
| tree | 57f47ed5e68b333067a351a128f253c1d753020d /compiler/rustc_const_eval/src | |
| parent | b03502b35d111bef0399a66ab3cc765f0802e8ba (diff) | |
| download | rust-8609364480a7fb95edbecd202ecc511348ddbd25.tar.gz rust-8609364480a7fb95edbecd202ecc511348ddbd25.zip | |
All verbosity checks in `PrettyPrinter` now go through `PrettyPrinter::should_print_verbose`
Diffstat (limited to 'compiler/rustc_const_eval/src')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/intrinsics/type_name.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics/type_name.rs b/compiler/rustc_const_eval/src/interpret/intrinsics/type_name.rs index ffdb8de5b6c..b15606baee5 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics/type_name.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics/type_name.rs @@ -4,7 +4,7 @@ use rustc_hir::definitions::DisambiguatedDefPathData; use rustc_middle::mir::interpret::{Allocation, ConstAllocation}; use rustc_middle::ty::{ self, - print::{with_no_verbose_constants, PrettyPrinter, Print, Printer}, + print::{PrettyPrinter, Print, Printer}, subst::{GenericArg, GenericArgKind}, Ty, TyCtxt, }; @@ -179,6 +179,11 @@ impl<'tcx> PrettyPrinter<'tcx> for AbsolutePathPrinter<'tcx> { Ok(self) } + + fn should_print_verbose(&self) -> bool { + // `std::any::type_name` should never print verbose type names + false + } } impl Write for AbsolutePathPrinter<'_> { @@ -190,9 +195,7 @@ impl Write for AbsolutePathPrinter<'_> { /// Directly returns an `Allocation` containing an absolute path representation of the given type. pub(crate) fn alloc_type_name<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> ConstAllocation<'tcx> { - let path = with_no_verbose_constants!( - AbsolutePathPrinter { tcx, path: String::new() }.print_type(ty).unwrap().path - ); + let path = AbsolutePathPrinter { tcx, path: String::new() }.print_type(ty).unwrap().path; let alloc = Allocation::from_bytes_byte_aligned_immutable(path.into_bytes()); tcx.intern_const_alloc(alloc) } |
