Open
Description
Hello, it is perfectly sound to move out of &'static mut T
and have that reference consumed, as no safe code can access T
under the reference after that point.
struct NotDefaultNotCopy([u8; 20]);
fn main() {
let foo: &'static mut NotDefaultNotCopy = Box::leak(Box::new(NotDefaultNotCopy([0; 20])));
let foo_taken = *foo;
println!("{:?}", foo_taken.0);
}
For example, miri is happy with that code if take
in unsafely written (but detects leak) playground
Here is code with more unsafe but with no miri leak warnings: playground