From a452700628e352e6ac01da9e16223a47752ca860 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sun, 21 Apr 2019 20:02:59 +0200 Subject: implement RFCs 147 and 155, etc. This commit: - Implements RFC 147: "all functions must be safe" - Implements RFC 155: "explicit Context parameter" - Implements the pending breaking change #141: reject assign syntax in `init` (which was used to initialize late resources) - Refactors code generation to make it more readable -- there are no more random identifiers in the output -- and align it with the book description of RTFM internals. - Makes the framework hard depend on `core::mem::MaybeUninit` and thus will require nightly until that API is stabilized. - Fixes a ceiling analysis bug where the priority of the system timer was not considered in the analysis. - Shrinks the size of all the internal queues by turning `AtomicUsize` indices into `AtomicU8`s. - Removes the integration with `owned_singleton`. --- macros/src/check.rs | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'macros/src/check.rs') diff --git a/macros/src/check.rs b/macros/src/check.rs index 4adc2c1..6ba7d37 100644 --- a/macros/src/check.rs +++ b/macros/src/check.rs @@ -35,21 +35,12 @@ pub fn app(app: &App) -> parse::Result<()> { } } - // Check that all late resources have been initialized in `#[init]` if `init` has signature - // `fn()` - if !app.init.returns_late_resources { - for res in - app.resources - .iter() - .filter_map(|(name, res)| if res.expr.is_none() { Some(name) } else { None }) - { - if app.init.assigns.iter().all(|assign| assign.left != *res) { - return Err(parse::Error::new( - res.span(), - "late resources MUST be initialized at the end of `init`", - )); - } - } + // Check that `init` returns `LateResources` if there's any declared late resource + if !app.init.returns_late_resources && app.resources.iter().any(|(_, res)| res.expr.is_none()) { + return Err(parse::Error::new( + app.init.span, + "late resources have been specified so `init` must return `init::LateResources`", + )); } // Check that all referenced tasks have been declared -- cgit v1.2.3