diff options
Diffstat (limited to 'rtic-macros/src/codegen/assertions.rs')
-rw-r--r-- | rtic-macros/src/codegen/assertions.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/rtic-macros/src/codegen/assertions.rs b/rtic-macros/src/codegen/assertions.rs new file mode 100644 index 00000000..2f5dd523 --- /dev/null +++ b/rtic-macros/src/codegen/assertions.rs @@ -0,0 +1,23 @@ +use proc_macro2::TokenStream as TokenStream2; +use quote::quote; + +use super::bindings::extra_assertions; +use crate::analyze::Analysis; +use crate::syntax::ast::App; + +/// Generates compile-time assertions that check that types implement the `Send` / `Sync` traits +pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> { + let mut stmts = vec![]; + + for ty in &analysis.send_types { + stmts.push(quote!(rtic::export::assert_send::<#ty>();)); + } + + for ty in &analysis.sync_types { + stmts.push(quote!(rtic::export::assert_sync::<#ty>();)); + } + + stmts.append(&mut extra_assertions(app, analysis)); + + stmts +} |