aboutsummaryrefslogtreecommitdiff
path: root/macros/src/codegen/assertions.rs
blob: 4d9aae47259d5aa71ae43d4160eb734c84d11fbf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use proc_macro2::TokenStream as TokenStream2;
use quote::quote;

use crate::analyze::Analysis;

/// Generates compile-time assertions that check that types implement the `Send` / `Sync` traits
pub fn codegen(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
}