For instance,
pub fn g(r: &'static u32) -> *const u32 {
let p = r as *const _;
p
}
is converted to the following in MIR
fn g(_1: &u32) -> *const u32 {
debug r => _1;
let mut _0: *const u32;
scope 1 {
debug p => _0;
}
bb0: {
_0 = &raw const (*_1);
return;
}
}
Why is the reference _1
reborrowed but directly assigned to a pointer type? I understand implicit reborrowing in the context of mutable references but I am not aware of this happening with shared references.