From c6bf89a31874839f22f9de823f874133b9746ce3 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Fri, 14 Apr 2017 00:33:07 -0500 Subject: [PATCH] remove unnecessary trait bounds --- build.rs | 2 +- src/lib.rs | 37 +++++++++++---------------------- tests/cfail/tasks-wrong-init.rs | 4 ++-- 3 files changed, 15 insertions(+), 28 deletions(-) diff --git a/build.rs b/build.rs index d31301f5af..aae9f89863 100644 --- a/build.rs +++ b/build.rs @@ -40,7 +40,7 @@ fn main() { ); // Ceilings - for i in 1..(1 << bits) + 1 { + for i in 0..(1 << bits) + 1 { let c = Ident::new(format!("C{}", i)); let u = Ident::new(format!("U{}", i)); diff --git a/src/lib.rs b/src/lib.rs index 39144740a7..07f1e6c8a0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,6 @@ +//! Stack Resource Policy + +#![deny(missing_docs)] #![deny(warnings)] #![feature(asm)] #![feature(const_fn)] @@ -52,10 +55,7 @@ impl Resource { } } -impl Resource> -where - C: Ceiling, -{ +impl Resource> { /// Borrows the resource for the duration of another resource's critical /// section /// @@ -68,7 +68,6 @@ where where SCEILING: GreaterThanOrEqual, CEILING: GreaterThanOrEqual, - P: Priority, { unsafe { &*self.data.get() } } @@ -82,7 +81,6 @@ where ) -> &'task T where CEILING: Cmp, - P: Priority, { unsafe { &*self.data.get() } } @@ -95,7 +93,6 @@ where ) -> &'task mut T where CEILING: Cmp, - P: Priority, { unsafe { &mut *self.data.get() } } @@ -117,10 +114,8 @@ where ) -> R where F: FnOnce(&T, C) -> R, - C: Ceiling, CEILING: Cmp + Cmp + Level, - P: Priority, { unsafe { let old_basepri = basepri::read(); @@ -147,10 +142,8 @@ where ) -> R where F: FnOnce(&mut T) -> R, - C: Ceiling, CEILING: Cmp + Cmp + Level, - P: Priority, { unsafe { let old_basepri = basepri::read(); @@ -164,9 +157,9 @@ where } } -unsafe impl Sync for Resource +unsafe impl Sync for Resource where - CEILING: Ceiling, + C: Ceiling, { } @@ -197,10 +190,7 @@ where } } -impl Peripheral> -where - C: Ceiling, -{ +impl Peripheral> { /// See [Resource.borrow](./struct.Resource.html#method.borrow) pub fn borrow<'cs, PRIORITY, SCEILING>( &'static self, @@ -221,7 +211,6 @@ where ) -> &'task Periph where CEILING: Cmp, - P: Priority, { unsafe { &*self.peripheral.get() } } @@ -235,10 +224,8 @@ where ) -> R where F: FnOnce(&Periph, C) -> R, - C: Ceiling, CEILING: Cmp + Cmp + Level, - P: Priority, { unsafe { let old_basepri = basepri::read(); @@ -279,7 +266,7 @@ where r } -/// Requests the execution of the task `task` +/// Requests the execution of a `task` pub fn request(_task: fn(T, P)) where T: Context + Nr, @@ -320,12 +307,13 @@ impl P where T: Level, { + #[doc(hidden)] pub fn hw() -> u8 { T::hw() } } -/// A valid ceiling +/// A valid resource ceiling /// /// DO NOT IMPLEMENT THIS TRAIT YOURSELF pub unsafe trait Ceiling {} @@ -339,10 +327,11 @@ pub unsafe trait GreaterThanOrEqual {} /// /// DO NOT IMPLEMENT THIS TRAIT YOURSELF pub unsafe trait Level { + /// Interrupt hardware level fn hw() -> u8; } -/// A valid priority level +/// A valid task priority /// /// DO NOT IMPLEMENT THIS TRAIT YOURSELF pub unsafe trait Priority {} @@ -354,8 +343,6 @@ fn logical2hw(logical: u8) -> u8 { /// Priority 0, the lowest priority pub type P0 = P<::typenum::U0>; -unsafe impl Priority for P0 {} - /// Declares tasks #[macro_export] macro_rules! tasks { diff --git a/tests/cfail/tasks-wrong-init.rs b/tests/cfail/tasks-wrong-init.rs index 73c472241a..368772fd17 100644 --- a/tests/cfail/tasks-wrong-init.rs +++ b/tests/cfail/tasks-wrong-init.rs @@ -14,8 +14,8 @@ tasks!(device, { j1: (Exti0, P1), }); -// WRONG. `init` must have signature `fn(C16)` -fn init(_: C1) {} +// WRONG. `init` must have signature `fn(P0, C16)` +fn init(_: P0, _: C1) {} fn idle(_: P0) {}