From d4dec0124b961bef1f36b7da986b5d47fc9cbe15 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sat, 8 Apr 2017 09:30:57 -0500 Subject: remove the Mutex.borrow_mut because it can be used to bypass Rust's borrow checker ``` rust static FOO: Mutex = Mutex::new(false); fn main() { cortex_m::interrupt::free(|mut cs1| { cortex_m::interrupt::free(|mut cs2| { let foo = FOO.borrow_mut(&mut cs1); let and_foo = FOO.borrow_mut(&mut cs2); }); }); } ``` --- src/interrupt.rs | 8 -------- 1 file changed, 8 deletions(-) (limited to 'src') diff --git a/src/interrupt.rs b/src/interrupt.rs index e11fdc3..a96b845 100644 --- a/src/interrupt.rs +++ b/src/interrupt.rs @@ -19,14 +19,6 @@ impl Mutex { pub fn borrow<'cs>(&self, _ctxt: &'cs CriticalSection) -> &'cs T { unsafe { &*self.inner.get() } } - - /// Mutably borrows the data for the duration of the critical section - pub fn borrow_mut<'cs>( - &self, - _ctxt: &'cs mut CriticalSection, - ) -> &'cs mut T { - unsafe { &mut *self.inner.get() } - } } /// Interrupt number -- cgit v1.2.3