-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Description
This issue is part of the Strict Provenance Experiment - #95228
I left a few little FIXME(strict_provenance_magic)
comments around core::ptr to indicate places that might want to become a compiler intrinsic for... Reasons. Currently all of these operations function but it's possible they can function "better" or somehow power better checking/analysis with builtin support.
In particular you probably want with_addr as some kind of instrinsic because the naive impl does a bunch of faffing around when on most platforms it's usize as *mut T
and on CHERI this is literally cheri_address_set.
rust/library/core/src/ptr/mut_ptr.rs
Lines 197 to 205 in bb5c437
pub fn with_addr(self, addr: usize) -> Self | |
where | |
T: Sized, | |
{ | |
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic. | |
// | |
// In the mean-time, this operation is defined to be "as if" it was | |
// a wrapping_offset, so we can emulate it as such. This should properly | |
// restore pointer provenance even under today's compiler. |
This discussion is 100% "above my pay grade", I cannot provide any more insight.