You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is the following sound? In particular, is it sound to synthesize a 'static reference to a local variable if we can prove that that variable will never go out of scope at runtime because the local scope will never finish executing?
fn with_static<T: 'static, F: FnOnce(&'static T)>(t: T, f: F) {
let tp: *const T = &t;
// SAFETY: The `loop {}` below ensures that `t` never goes
// out of scope.
let tr: &'static T = unsafe { &*tp };
f(tr);
loop {}
drop(t)
}