diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2017-04-07 16:38:39 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2017-04-07 16:38:39 -0500 |
| commit | 759ac160db3a02d23b1126c6875143b67f5c2e20 (patch) | |
| tree | 472c1eb500b751a99b30b7260645cf64b1c03d2d /src | |
| parent | e631d8513a83d5bf1d1e344977bdd3d84efdbc13 (diff) | |
remove the borrow_mut method from resources
it can be used to break references rules within nested locks
``` rust
static R1: Resource<bool, C1> = unsafe { Resource::new(false) };
static R2: Resource<bool, C2> = unsafe { Resource::new(false) };
static R3: Resource<bool, C3> = unsafe { Resource::new(false) };
// Priority = 1
extern "C" fn j1(task: interrupt::Exti0Irq) {
R1.lock(&task, |r1, c1| {
R2.lock(&task, |r2, c2| {
R3.lock(&task, |r3, mut c3| {
// BAD &- and &mut - that point to the same data
let r1_ref: &bool = R1.borrow(&c2);
let r1_ref_mut: &mut bool = R1.borrow_mut(&mut c3);
});
});
});
}
```
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 23 |
1 files changed, 0 insertions, 23 deletions
@@ -180,19 +180,6 @@ where unsafe { &*self.peripheral.get() } } - /// Mutably borrows the resource without locking - /// - /// NOTE The system ceiling must be higher than this resource ceiling - pub fn borrow_mut<'l, SC>( - &'static self, - _system_ceiling: &'l mut SC, - ) -> &'l mut P - where - SC: HigherThan<C>, - { - unsafe { &mut *self.peripheral.get() } - } - /// Returns an immutable reference to the inner data without locking /// /// # Safety @@ -327,16 +314,6 @@ where unsafe { &*self.data.get() } } - /// Mutably borrows the resource without locking - /// - /// NOTE The system ceiling must be higher than this resource ceiling - pub fn borrow_mut<'l, SC>(&'static self, _ctxt: &'l mut SC) -> &'l mut T - where - SC: HigherThan<C>, - { - unsafe { &mut *self.data.get() } - } - /// Returns an immutable reference to the inner data without locking /// /// # Safety |
