aboutsummaryrefslogtreecommitdiff
path: root/macros/src/lib.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-09-23 22:19:08 +0200
committerHampusM <hampus@hampusmat.com>2022-09-23 22:19:08 +0200
commit3ed020425bfd1fc5fedfa89a7ce20207bedcf5bc (patch)
tree7ac971df9005f82445a4d01e4c5dec2c938a63d9 /macros/src/lib.rs
parent145a257775f2397ceba0941ac2a2642cf3382dcb (diff)
fix: prevent problems caused by non send + sync traits
Diffstat (limited to 'macros/src/lib.rs')
-rw-r--r--macros/src/lib.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/macros/src/lib.rs b/macros/src/lib.rs
index 2cd57f0..b0ccc86 100644
--- a/macros/src/lib.rs
+++ b/macros/src/lib.rs
@@ -6,7 +6,7 @@
use proc_macro::TokenStream;
use quote::quote;
-use syn::{parse, parse_macro_input};
+use syn::{parse, parse_macro_input, parse_str};
mod decl_def_factory_args;
mod declare_interface_args;
@@ -236,6 +236,11 @@ pub fn factory(args_stream: TokenStream, type_alias_stream: TokenStream) -> Toke
)
.unwrap();
+ if is_threadsafe {
+ factory_interface.add_trait_bound(parse_str("Send").unwrap());
+ factory_interface.add_trait_bound(parse_str("Sync").unwrap());
+ }
+
type_alias.ty = Box::new(Type::Verbatim(factory_interface.to_token_stream()));
let decl_interfaces = if is_threadsafe {