From dd539d114fe874c2793cef08360d078fec86813a Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 27 Jul 2017 12:29:52 -0500 Subject: [PATCH] don't generate empty modules --- macros/src/trans.rs | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/macros/src/trans.rs b/macros/src/trans.rs index 4f389d3028..468d96757e 100644 --- a/macros/src/trans.rs +++ b/macros/src/trans.rs @@ -153,12 +153,14 @@ fn idle( exprs.push(quote!(unsafe { idle::Resources::new() })); } - root.push(quote! { - #[allow(unsafe_code)] - mod idle { - #(#mod_items)* - } - }); + if !mod_items.is_empty() { + root.push(quote! { + #[allow(unsafe_code)] + mod idle { + #(#mod_items)* + } + }); + } let idle = &app.idle.path; main.push(quote! { @@ -486,12 +488,15 @@ fn resources(app: &App, ownerships: &Ownerships, root: &mut Vec) { } } + if !items.is_empty() { + root.push(quote! { + #[allow(unsafe_code)] + mod _resource { + #(#items)* + } + }) + } root.push(quote! { - #[allow(unsafe_code)] - mod _resource { - #(#items)* - } - #(#impls)* }); }