Skip to content

Commit a0275e3

Browse files
committed
Only print integers in symbol path's constants
1 parent dd32795 commit a0275e3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/librustc_codegen_utils/symbol_names.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ use rustc::ty::print::{PrettyPrinter, Printer, Print};
9696
use rustc::ty::query::Providers;
9797
use rustc::ty::subst::{Kind, SubstsRef, UnpackedKind};
9898
use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
99+
use rustc::mir::interpret::{ConstValue, Scalar};
99100
use rustc::util::common::record_time;
100101
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
101102
use rustc_mir::monomorphize::item::{InstantiationMode, MonoItem, MonoItemExt};
@@ -438,10 +439,17 @@ impl Printer<'tcx, 'tcx> for SymbolPrinter<'_, 'tcx> {
438439
}
439440

440441
fn print_const(
441-
self,
442+
mut self,
442443
ct: &'tcx ty::Const<'tcx>,
443444
) -> Result<Self::Const, Self::Error> {
444-
self.pretty_print_const(ct)
445+
// only print integers
446+
if let ConstValue::Scalar(Scalar::Bits { .. }) = ct.val {
447+
if ct.ty.is_integral() {
448+
return self.pretty_print_const(ct);
449+
}
450+
}
451+
self.write_str("_")?;
452+
Ok(self)
445453
}
446454

447455
fn path_crate(

0 commit comments

Comments
 (0)