How unsafe is allowed in unsafe code?

MIRI doesn't mind that example, I'm pretty sure it's fine because p is derived from r. Using r in the last line invalidates p, but you also don't use it again so that's also not an issue with this specific code.