- Immediate::Scalar(ScalarMaybeUndef::Scalar(s)) => match s.to_bits(self.layout.size) {
- Ok(s) => {
- match self.layout.ty.kind {
- ty::Int(_) => {
- return write!(
- fmt,
- "{}",
- super::sign_extend(s, self.layout.size) as i128,
- );
- }
- ty::Uint(_) => return write!(fmt, "{}", s),
- ty::Bool if s == 0 => return fmt.write_str("false"),
- ty::Bool if s == 1 => return fmt.write_str("true"),
- ty::Char => {
- if let Some(c) = u32::try_from(s).ok().and_then(std::char::from_u32) {
- return write!(fmt, "{}", c);
- }
+ // We cannot use `to_bits_or_ptr` as we do not have a `tcx`.
+ // So we use `is_bits` and circumvent a bunch of sanity checking -- but
+ // this is anyway only for printing.
+ Immediate::Scalar(ScalarMaybeUndef::Scalar(s)) if s.is_ptr() => {
+ fmt.write_str("{pointer}")
+ }
+ Immediate::Scalar(ScalarMaybeUndef::Scalar(s)) => {
+ let s = s.assert_bits(self.layout.size);
+ match self.layout.ty.kind {
+ ty::Int(_) => {
+ return write!(fmt, "{}", super::sign_extend(s, self.layout.size) as i128,);
+ }
+ ty::Uint(_) => return write!(fmt, "{}", s),
+ ty::Bool if s == 0 => return fmt.write_str("false"),
+ ty::Bool if s == 1 => return fmt.write_str("true"),
+ ty::Char => {
+ if let Some(c) = u32::try_from(s).ok().and_then(std::char::from_u32) {
+ return write!(fmt, "{}", c);