diff options
author | 2020-10-11 19:41:57 +0200 | |
---|---|---|
committer | 2020-10-11 20:35:50 +0200 | |
commit | 5b8e6a22ab68e316e11641dedf5b39e20878c7b7 (patch) | |
tree | 1bdc1812ca24203f3b99f381b1e9f8c89f60be24 /macros/src/codegen/module.rs | |
parent | 524273c96a978299b64e51a9cdcc007585a0f170 (diff) | |
download | rtic-5b8e6a22ab68e316e11641dedf5b39e20878c7b7.tar.gz rtic-5b8e6a22ab68e316e11641dedf5b39e20878c7b7.tar.zst rtic-5b8e6a22ab68e316e11641dedf5b39e20878c7b7.zip |
Fixing examples and tests, modules now import user imports correctly
Fmt
Correct syntax crate
UI test fix
Fix build script
Cleanup
More cleanup
Diffstat (limited to 'macros/src/codegen/module.rs')
-rw-r--r-- | macros/src/codegen/module.rs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/macros/src/codegen/module.rs b/macros/src/codegen/module.rs index 979c63ca..e3b0ed9b 100644 --- a/macros/src/codegen/module.rs +++ b/macros/src/codegen/module.rs @@ -21,9 +21,7 @@ pub fn codegen( let mut lt = None; match ctxt { Context::Init => { - if extra.monotonic.is_some() { - let m = extra.monotonic(); - + if let Some(m) = extra.monotonic { fields.push(quote!( /// System start time = `Instant(0 /* cycles */)` pub start: <#m as rtic::Monotonic>::Instant @@ -67,9 +65,7 @@ pub fn codegen( Context::Idle => {} Context::HardwareTask(..) => { - if extra.monotonic.is_some() { - let m = extra.monotonic(); - + if let Some(m) = extra.monotonic { fields.push(quote!( /// Time at which this handler started executing pub start: <#m as rtic::Monotonic>::Instant @@ -82,9 +78,7 @@ pub fn codegen( } Context::SoftwareTask(..) => { - if extra.monotonic.is_some() { - let m = extra.monotonic(); - + if let Some(m) = extra.monotonic { fields.push(quote!( /// The time at which this task was scheduled to run pub scheduled: <#m as rtic::Monotonic>::Instant @@ -242,11 +236,10 @@ pub fn codegen( })); // Schedule caller - if extra.monotonic.is_some() { + if let Some(m) = extra.monotonic { let instants = util::instants_ident(name); let tq = util::tq_ident(); - let m = extra.monotonic(); let t = util::schedule_t_ident(); items.push(quote!( @@ -288,10 +281,16 @@ pub fn codegen( } if !items.is_empty() { + let user_imports = &app.user_imports; + quote!( #[allow(non_snake_case)] #[doc = #doc] pub mod #name { + #( + #[allow(unused_imports)] + #user_imports + )* #(#items)* } ) |