diff options
Diffstat (limited to 'macros/src/check.rs')
-rw-r--r-- | macros/src/check.rs | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/macros/src/check.rs b/macros/src/check.rs index 4adc2c17..4471e96a 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 @@ -128,7 +119,7 @@ pub fn app(app: &App) -> parse::Result<()> { } else if app.init.returns_late_resources { return Err(parse::Error::new( Span::call_site(), - "`init` signature must be `[unsafe] fn()` if there are no late resources", + "`init` signature must be `fn(init::Context)` if there are no late resources", )); } |