Fix unsoundness in Forever

This commit is contained in:
Dario Nieuwenhuis 2020-11-16 01:04:56 +01:00
parent 2e062f5627
commit 49d5121094

View file

@ -18,7 +18,7 @@ impl<T> Forever<T> {
}
}
pub fn put(&self, val: T) -> &'static mut T {
pub fn put(&'static self, val: T) -> &'static mut T {
if self.used.compare_and_swap(false, true, Ordering::SeqCst) {
panic!("Forever.put() called multiple times");
}
@ -31,7 +31,7 @@ impl<T> Forever<T> {
}
}
pub unsafe fn steal(&self) -> &'static mut T {
pub unsafe fn steal(&'static self) -> &'static mut T {
let p = self.t.get();
let p = (&mut *p).as_mut_ptr();
&mut *p