From d8c9476372e25799224d0225bb12c9a9fe043743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Tue, 1 Sep 2020 16:12:42 +0000 Subject: [PATCH] Since there only will be one init/idle use .first().unwrap(), matching rtic-syntax --- macros/src/codegen/idle.rs | 3 +-- macros/src/codegen/init.rs | 3 +-- macros/src/codegen/module.rs | 2 +- macros/src/codegen/resources_struct.rs | 4 ++-- macros/src/codegen/util.rs | 15 ++++----------- 5 files changed, 9 insertions(+), 18 deletions(-) diff --git a/macros/src/codegen/idle.rs b/macros/src/codegen/idle.rs index 853372db1d..cd97764e2a 100644 --- a/macros/src/codegen/idle.rs +++ b/macros/src/codegen/idle.rs @@ -26,9 +26,8 @@ pub fn codegen( // call_idle TokenStream2, ) { - //if let Some(idle) = app.idles.get(&core) { if app.idles.len() > 0 { - let idle = &app.idles[0]; + let idle = &app.idles.first().unwrap(); let mut needs_lt = false; let mut const_app = None; let mut root_idle = vec![]; diff --git a/macros/src/codegen/init.rs b/macros/src/codegen/init.rs index 01074db675..94f57afb36 100644 --- a/macros/src/codegen/init.rs +++ b/macros/src/codegen/init.rs @@ -27,9 +27,8 @@ pub fn codegen( // call_init -- the call to the user `#[init]` if there's one Option, ) { - //if let Some(init) = app.inits.get(&core) { if app.inits.len() > 0 { - let init = &app.inits[0]; + let init = &app.inits.first().unwrap(); let mut needs_lt = false; let name = &init.name; diff --git a/macros/src/codegen/module.rs b/macros/src/codegen/module.rs index ad20f1393e..4b3d0cf71e 100644 --- a/macros/src/codegen/module.rs +++ b/macros/src/codegen/module.rs @@ -253,7 +253,7 @@ pub fn codegen(ctxt: Context, resources_tick: bool, app: &App, extra: &Extra) -> } if let Context::Init = ctxt { - let init = &app.inits[0]; + let init = &app.inits.first().unwrap(); if init.returns_late_resources { let late_resources = util::late_resources_ident(&init.name); diff --git a/macros/src/codegen/resources_struct.rs b/macros/src/codegen/resources_struct.rs index bd92a59916..0c5efd3a10 100644 --- a/macros/src/codegen/resources_struct.rs +++ b/macros/src/codegen/resources_struct.rs @@ -14,8 +14,8 @@ pub fn codegen( let mut lt = None; let resources = match ctxt { - Context::Init => &app.inits[0].args.resources, - Context::Idle => &app.idles[0].args.resources, + Context::Init => &app.inits.first().unwrap().args.resources, + Context::Idle => &app.idles.first().unwrap().args.resources, Context::HardwareTask(name) => &app.hardware_tasks[name].args.resources, Context::SoftwareTask(name) => &app.software_tasks[name].args.resources, }; diff --git a/macros/src/codegen/util.rs b/macros/src/codegen/util.rs index 369025f3f0..f4dbca3978 100644 --- a/macros/src/codegen/util.rs +++ b/macros/src/codegen/util.rs @@ -165,8 +165,8 @@ pub fn link_section_uninit(empty_expr: bool) -> Option { /// Generates a pre-reexport identifier for the "locals" struct pub fn locals_ident(ctxt: Context, app: &App) -> Ident { let mut s = match ctxt { - Context::Init => app.inits[0].name.to_string(), - Context::Idle => app.idles[0].name.to_string(), + Context::Init => app.inits.first().unwrap().name.to_string(), + Context::Idle => app.idles.first().unwrap().name.to_string(), Context::HardwareTask(ident) | Context::SoftwareTask(ident) => ident.to_string(), }; @@ -234,8 +234,8 @@ pub fn regroup_inputs( /// Generates a pre-reexport identifier for the "resources" struct pub fn resources_ident(ctxt: Context, app: &App) -> Ident { let mut s = match ctxt { - Context::Init => app.inits[0].name.to_string(), - Context::Idle => app.idles[0].name.to_string(), + Context::Init => app.inits.first().unwrap().name.to_string(), + Context::Idle => app.idles.first().unwrap().name.to_string(), Context::HardwareTask(ident) | Context::SoftwareTask(ident) => ident.to_string(), }; @@ -266,13 +266,6 @@ pub fn schedule_t_ident() -> Ident { Ident::new(&format!("T"), Span::call_site()) } -/* -/// Generates an identifier for a cross-spawn barrier -pub fn spawn_barrier() -> Ident { - Ident::new(&format!("SB"), Span::call_site()) -} -*/ - /// Generates an identifier for a "spawn" function /// /// The methods of the `Spawn` structs invoke these functions. As one task may be `spawn`-ed by