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() }));
} }
root.push(quote! { if !mod_items.is_empty() {
#[allow(unsafe_code)] root.push(quote! {
mod idle { #[allow(unsafe_code)]
#(#mod_items)* mod idle {
} #(#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! {
#[allow(unsafe_code)]
mod _resource {
#(#items)*
}
})
}
root.push(quote! { root.push(quote! {
#[allow(unsafe_code)]
mod _resource {
#(#items)*
}
#(#impls)* #(#impls)*
}); });
} }