mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-19 14:25:18 +01:00
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);
});
});
});
}
```
This commit is contained in:
parent
e631d8513a
commit
759ac160db
1 changed files with 0 additions and 23 deletions
23
src/lib.rs
23
src/lib.rs
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue