diff options
author | HampusM <hampus@hampusmat.com> | 2022-09-23 22:19:08 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-09-23 22:19:08 +0200 |
commit | 3ed020425bfd1fc5fedfa89a7ce20207bedcf5bc (patch) | |
tree | 7ac971df9005f82445a4d01e4c5dec2c938a63d9 /macros/src/lib.rs | |
parent | 145a257775f2397ceba0941ac2a2642cf3382dcb (diff) |
fix: prevent problems caused by non send + sync traits
Diffstat (limited to 'macros/src/lib.rs')
-rw-r--r-- | macros/src/lib.rs | 7 |
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 { |