1
Fork 0

improve dangling/oob errors and make them more uniform

This commit is contained in:
Ralf Jung 2024-07-27 18:09:50 +02:00
parent 5b38b149dc
commit f8ebe8d783
75 changed files with 225 additions and 182 deletions

View file

@ -180,9 +180,12 @@ 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.
if ptr.offset.bytes() > 0 {
write!(f, "+{:#x}", ptr.offset.bytes())?;
// 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 immutable status.
if ptr.provenance.immutable() {