Open
Description
Given a &Cell<T>
or &UnsafeCell<T>
, is it sound to produce a &Cell<F>
or &UnsafeCell<F>
to a field within the original (assuming that lifetimes are respected etc etc)? E.g.:
pub fn project(cell: &Cell<(u8, u16)>) -> &Cell<u16> {
let cell_raw: *const _ = cell;
let inner_raw: *const (u8, u16) = cell_raw.cast();
let field_raw = core::mem::addr_of!(inner_raw.1);
unsafe { &*field_raw }
}
Metadata
Metadata
Assignees
Labels
No labels