diff options
Diffstat (limited to 'macros/src/codegen/init.rs')
-rw-r--r-- | macros/src/codegen/init.rs | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/macros/src/codegen/init.rs b/macros/src/codegen/init.rs index 465a927d..922e43b5 100644 --- a/macros/src/codegen/init.rs +++ b/macros/src/codegen/init.rs @@ -1,5 +1,5 @@ use proc_macro2::TokenStream as TokenStream2; -use quote::{format_ident, quote}; +use quote::quote; use rtic_syntax::{ast::App, Context}; use crate::{ @@ -24,8 +24,6 @@ pub fn codegen( Vec<TokenStream2>, // user_init -- the `#[init]` function written by the user Option<TokenStream2>, - // user_init_imports -- the imports for `#[init]` functio written by the user - Vec<TokenStream2>, // call_init -- the call to the user `#[init]` if there's one Option<TokenStream2>, ) { @@ -52,7 +50,6 @@ pub fn codegen( }) .collect::<Vec<_>>(); - let mut user_init_imports = vec![]; let late_resources = util::late_resources_ident(&name); root_init.push(quote!( @@ -63,12 +60,6 @@ pub fn codegen( } )); - let name_late = format_ident!("{}LateResources", name); - user_init_imports.push(quote!( - #[allow(non_snake_case)] - use super::#name_late; - )); - let mut locals_pat = None; let mut locals_new = None; if !init.locals.is_empty() { @@ -90,11 +81,6 @@ pub fn codegen( #(#stmts)* } )); - user_init_imports.push(quote!( - #(#attrs)* - #[allow(non_snake_case)] - use super::#name; - )); let mut mod_app = None; if !init.args.resources.is_empty() { @@ -103,17 +89,13 @@ pub fn codegen( root_init.push(item); mod_app = Some(constructor); - - let name_late = format_ident!("{}Resources", name); - user_init_imports.push(quote!( - #[allow(non_snake_case)] - use super::#name_late; - )); } + let app_name = &app.name; + let app_path = quote! {crate::#app_name}; let locals_new = locals_new.iter(); let call_init = Some( - quote!(let late = crate::#name(#(#locals_new,)* #name::Context::new(core.into()));), + quote!(let late = #app_path::#name(#(#locals_new,)* #name::Context::new(core.into()));), ); root_init.push(module::codegen( @@ -124,8 +106,8 @@ pub fn codegen( extra, )); - (mod_app, root_init, user_init, user_init_imports, call_init) + (mod_app, root_init, user_init, call_init) } else { - (None, vec![], None, vec![], None) + (None, vec![], None, None) } } |