diff options
| author | homunkulus <homunkulus@gmx.com> | 2017-12-23 10:36:08 +0000 |
|---|---|---|
| committer | homunkulus <homunkulus@gmx.com> | 2017-12-23 10:36:08 +0000 |
| commit | 8a396c51f2caaeca7ee0f81ef2f3c4f2f73d8df1 (patch) | |
| tree | fa6538343f2d524be574285c2bb68057edc11420 /tests/cfail/lock.rs | |
| parent | 0f5784c2401d4b12004f34345e721598fa21219a (diff) | |
| parent | a238fd5dc783f57f8fa61795690e6069b1becd32 (diff) | |
Auto merge of #58 - japaric:init-resources, r=japaric
safe `&'static mut` references via init.resources
see RFC #59 for details
Diffstat (limited to 'tests/cfail/lock.rs')
| -rw-r--r-- | tests/cfail/lock.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/tests/cfail/lock.rs b/tests/cfail/lock.rs index 5630649..eb03b7d 100644 --- a/tests/cfail/lock.rs +++ b/tests/cfail/lock.rs @@ -45,22 +45,24 @@ fn idle() -> ! { } fn exti0(mut t: &mut Threshold, mut r: EXTI0::Resources) { + // ERROR need to lock to access the resource because priority < ceiling + if *r.ON { + //~^ error type `EXTI0::ON` cannot be dereferenced + } + // OK need to lock to access the resource - if r.ON.claim(&mut t, |on, _| **on) {} + if r.ON.claim(&mut t, |on, _| *on) {} // OK can claim a resource with maximum ceiling - r.MAX.claim_mut(&mut t, |max, _| **max += 1); + r.MAX.claim_mut(&mut t, |max, _| *max += 1); } fn exti1(mut t: &mut Threshold, r: EXTI1::Resources) { - // ERROR no need to lock. Has direct access because priority == ceiling - if (**r.ON).claim(&mut t, |on, _| **on) { - //~^ error no method named `claim` found for type - } + // OK to directly access the resource because priority == ceiling + if *r.ON {} - if **r.ON { - // OK - } + // though the resource can still be claimed -- the claim is a no-op + if r.ON.claim(&mut t, |on, _| *on) {} } fn exti2(_t: &mut Threshold, _r: EXTI2::Resources) {} |
