rtic_macros/codegen/
assertions.rs

1use proc_macro2::TokenStream as TokenStream2;
2use quote::quote;
3
4use super::bindings::extra_assertions;
5use crate::analyze::Analysis;
6use crate::syntax::ast::App;
7
8/// Generates compile-time assertions that check that types implement the `Send` / `Sync` traits
9pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> {
10    let mut stmts = vec![];
11
12    for ty in &analysis.send_types {
13        stmts.push(quote!(rtic::export::assert_send::<#ty>();));
14    }
15
16    for ty in &analysis.sync_types {
17        stmts.push(quote!(rtic::export::assert_sync::<#ty>();));
18    }
19
20    stmts.append(&mut extra_assertions(app, analysis));
21
22    stmts
23}