From 49d5121094fb7e2f4ddc3aead351769443515d55 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 16 Nov 2020 01:04:56 +0100 Subject: [PATCH] Fix unsoundness in Forever --- embassy/src/util/forever.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/embassy/src/util/forever.rs b/embassy/src/util/forever.rs index 4d3e158ab..80dc0edac 100644 --- a/embassy/src/util/forever.rs +++ b/embassy/src/util/forever.rs @@ -18,7 +18,7 @@ impl Forever { } } - 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 Forever { } } - 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