aboutsummaryrefslogtreecommitdiff
path: root/macros/src
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2017-07-27 12:29:52 -0500
committerGravatar Jorge Aparicio <jorge@japaric.io> 2017-07-27 12:29:52 -0500
commitdd539d114fe874c2793cef08360d078fec86813a (patch)
tree994ad7b0a6123995a72202865569928cc328dea3 /macros/src
parentb37c45ad2a295f067b6cacf9424ff9f68674f82b (diff)
downloadrtic-dd539d114fe874c2793cef08360d078fec86813a.tar.gz
rtic-dd539d114fe874c2793cef08360d078fec86813a.tar.zst
rtic-dd539d114fe874c2793cef08360d078fec86813a.zip
don't generate empty modules
Diffstat (limited to 'macros/src')
-rw-r--r--macros/src/trans.rs27
1 files changed, 16 insertions, 11 deletions
diff --git a/macros/src/trans.rs b/macros/src/trans.rs
index 4f389d30..468d9675 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<Tokens>) {
}
}
+ if !items.is_empty() {
+ root.push(quote! {
+ #[allow(unsafe_code)]
+ mod _resource {
+ #(#items)*
+ }
+ })
+ }
root.push(quote! {
- #[allow(unsafe_code)]
- mod _resource {
- #(#items)*
- }
-
#(#impls)*
});
}