Don't print literal type suffixes if print_ty is false

This commit is contained in:
Oliver Scherer 2020-02-26 19:20:14 +01:00
parent fff2e0f806
commit cc9ca640c2
2 changed files with 10 additions and 3 deletions

View File

@ -973,7 +973,7 @@ pub trait PrettyPrinter<'tcx>:
if data == max {
p!(write("std::{}::MAX", ui_str))
} else {
p!(write("{}{}", data, ui_str))
if print_ty { p!(write("{}{}", data, ui_str)) } else { p!(write("{}", data)) }
};
}
(Scalar::Raw { data, .. }, ty::Int(i)) => {
@ -986,7 +986,14 @@ pub trait PrettyPrinter<'tcx>:
match data {
d if d == min => p!(write("std::{}::MIN", i_str)),
d if d == max => p!(write("std::{}::MAX", i_str)),
_ => p!(write("{}{}", sign_extend(data, size) as i128, i_str)),
_ => {
let data = sign_extend(data, size) as i128;
if print_ty {
p!(write("{}{}", data, i_str))
} else {
p!(write("{}", data))
}
}
}
}
// Char

View File

@ -7,5 +7,5 @@
struct S<const N: usize>;
fn main() {
assert_eq!(std::any::type_name::<S<3>>(), "const_generic_type_name::S<3usize>");
assert_eq!(std::any::type_name::<S<3>>(), "const_generic_type_name::S<3>");
}