Skip to content

Commit e381462

Browse files
authored
Rollup merge of #94246 - RalfJung:hex, r=oli-obk
ScalarMaybeUninit is explicitly hexadecimal in its formatting This makes `ScalarMaybeUninit` consistent with `Scalar` after the changes in #94189. r? ``@oli-obk``
2 parents 396910a + fb1ee87 commit e381462

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

compiler/rustc_const_eval/src/interpret/operand.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ impl<Tag: Provenance> std::fmt::Display for ImmTy<'_, Tag> {
142142
p(cx, s, ty)?;
143143
return Ok(());
144144
}
145-
write!(f, "{}: {}", s, self.layout.ty)
145+
write!(f, "{:x}: {}", s, self.layout.ty)
146146
}
147147
Immediate::ScalarPair(a, b) => {
148148
// FIXME(oli-obk): at least print tuples and slices nicely
149-
write!(f, "({}, {}): {}", a, b, self.layout.ty,)
149+
write!(f, "({:x}, {:x}): {}", a, b, self.layout.ty,)
150150
}
151151
}
152152
})

compiler/rustc_const_eval/src/interpret/validity.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
503503
value.to_bool(),
504504
self.path,
505505
err_ub!(InvalidBool(..)) | err_ub!(InvalidUninitBytes(None)) =>
506-
{ "{}", value } expected { "a boolean" },
506+
{ "{:x}", value } expected { "a boolean" },
507507
);
508508
Ok(true)
509509
}
@@ -513,7 +513,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
513513
value.to_char(),
514514
self.path,
515515
err_ub!(InvalidChar(..)) | err_ub!(InvalidUninitBytes(None)) =>
516-
{ "{}", value } expected { "a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`)" },
516+
{ "{:x}", value } expected { "a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`)" },
517517
);
518518
Ok(true)
519519
}
@@ -526,7 +526,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
526526
let is_bits = value.check_init().map_or(false, |v| v.try_to_int().is_ok());
527527
if !is_bits {
528528
throw_validation_failure!(self.path,
529-
{ "{}", value } expected { "initialized plain (non-pointer) bytes" }
529+
{ "{:x}", value } expected { "initialized plain (non-pointer) bytes" }
530530
)
531531
}
532532
}
@@ -580,7 +580,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
580580
err_ub!(DanglingIntPointer(..)) |
581581
err_ub!(InvalidFunctionPointer(..)) |
582582
err_ub!(InvalidUninitBytes(None)) =>
583-
{ "{}", value } expected { "a function pointer" },
583+
{ "{:x}", value } expected { "a function pointer" },
584584
);
585585
// FIXME: Check if the signature matches
586586
Ok(true)
@@ -632,7 +632,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
632632
let value = try_validation!(
633633
value.check_init(),
634634
self.path,
635-
err_ub!(InvalidUninitBytes(None)) => { "{}", value }
635+
err_ub!(InvalidUninitBytes(None)) => { "{:x}", value }
636636
expected { "something {}", wrapping_range_format(valid_range, max_value) },
637637
);
638638
let bits = match value.try_to_int() {

compiler/rustc_middle/src/mir/interpret/value.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ impl<Tag: Provenance> fmt::Debug for ScalarMaybeUninit<Tag> {
498498
}
499499
}
500500

501-
impl<Tag: Provenance> fmt::Display for ScalarMaybeUninit<Tag> {
501+
impl<Tag: Provenance> fmt::LowerHex for ScalarMaybeUninit<Tag> {
502502
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
503503
match self {
504504
ScalarMaybeUninit::Uninit => write!(f, "uninitialized bytes"),

0 commit comments

Comments
 (0)