on a signed deref check, mention the right pointer in the error

This commit is contained in:
Ralf Jung 2024-07-29 16:40:21 +02:00
parent 70591dc15d
commit de78cb56b2
34 changed files with 192 additions and 141 deletions

View file

@ -181,12 +181,9 @@ impl Provenance for CtfeProvenance {
fn fmt(ptr: &Pointer<Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// Print AllocId.
fmt::Debug::fmt(&ptr.provenance.alloc_id(), f)?; // propagates `alternate` flag
// Print offset only if it is non-zero. Print it signed.
let signed_offset = ptr.offset.bytes() as i64;
if signed_offset > 0 {
write!(f, "+{:#x}", signed_offset)?;
} else if signed_offset < 0 {
write!(f, "-{:#x}", signed_offset.unsigned_abs())?;
// Print offset only if it is non-zero.
if ptr.offset.bytes() > 0 {
write!(f, "+{:#x}", ptr.offset.bytes())?;
}
// Print immutable status.
if ptr.provenance.immutable() {