don't generate empty modules

This commit is contained in:
Jorge Aparicio 2017-07-27 12:29:52 -05:00
parent b37c45ad2a
commit dd539d114f

View file

@ -153,12 +153,14 @@ fn idle(
exprs.push(quote!(unsafe { idle::Resources::new() })); exprs.push(quote!(unsafe { idle::Resources::new() }));
} }
if !mod_items.is_empty() {
root.push(quote! { root.push(quote! {
#[allow(unsafe_code)] #[allow(unsafe_code)]
mod idle { mod idle {
#(#mod_items)* #(#mod_items)*
} }
}); });
}
let idle = &app.idle.path; let idle = &app.idle.path;
main.push(quote! { main.push(quote! {
@ -486,12 +488,15 @@ fn resources(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>) {
} }
} }
if !items.is_empty() {
root.push(quote! { root.push(quote! {
#[allow(unsafe_code)] #[allow(unsafe_code)]
mod _resource { mod _resource {
#(#items)* #(#items)*
} }
})
}
root.push(quote! {
#(#impls)* #(#impls)*
}); });
} }