mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-24 12:54:00 +00:00
Rollup merge of #97188 - carbotaniuman:remove-null-assert, r=RalfJung
Remove unneeded null pointer asserts in ptr2int casts This removes an assert that a pointer with address 0 has no provenance. This change is needed to support permissive provenance work in Miri, and seems justified by `ptr.with_addr(0)` working and a discussion on Zulip regarding LLVM semantics. r? `@RalfJung`
This commit is contained in:
commit
9098f05b26
@ -225,9 +225,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
let addr = u64::try_from(size.truncate(v)).unwrap();
|
||||
|
||||
let ptr = M::ptr_from_addr_cast(&self, addr);
|
||||
if addr == 0 {
|
||||
assert!(ptr.provenance.is_none(), "null pointer can never have an AllocId");
|
||||
}
|
||||
Scalar::from_maybe_pointer(ptr, self)
|
||||
}
|
||||
|
||||
|
@ -1149,11 +1149,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
Err(ptr) => ptr.into(),
|
||||
Ok(bits) => {
|
||||
let addr = u64::try_from(bits).unwrap();
|
||||
let ptr = M::ptr_from_addr_transmute(&self, addr);
|
||||
if addr == 0 {
|
||||
assert!(ptr.provenance.is_none(), "null pointer can never have an AllocId");
|
||||
}
|
||||
ptr
|
||||
M::ptr_from_addr_transmute(&self, addr)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user