From 2415a640af49666799bb4cd09a40f16853bdd687 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 2 Oct 2017 14:49:40 +0200 Subject: [PATCH] fix `idle::Resources::new` it assumed that all resources were "early" resources --- examples/late-resources.rs | 5 +++++ macros/src/trans.rs | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/examples/late-resources.rs b/examples/late-resources.rs index b5dba1467e..b60c7740f6 100644 --- a/examples/late-resources.rs +++ b/examples/late-resources.rs @@ -32,6 +32,11 @@ app! { static PORT: u16; }, + idle: { + // Test that late resources can be used in idle + resources: [IP_ADDRESS], + } + tasks: { SYS_TICK: { priority: 1, diff --git a/macros/src/trans.rs b/macros/src/trans.rs index 45841e7300..96ff770b64 100644 --- a/macros/src/trans.rs +++ b/macros/src/trans.rs @@ -74,8 +74,14 @@ fn idle( }); let _name = Ident::new(format!("_{}", name.as_ref())); - rexprs.push(quote! { - #name: &mut #super_::#_name, + rexprs.push(if resource.expr.is_some() { + quote! { + #name: &mut #super_::#_name, + } + } else { + quote! { + #name: #super_::#_name.as_mut(), + } }); } else { rfields.push(quote! {