@@ -8,7 +8,7 @@ use proc_macro2::{TokenStream as TokenStream2, TokenTree};
8
8
use quote:: { quote, quote_spanned, ToTokens , TokenStreamExt } ;
9
9
use syn:: spanned:: Spanned ;
10
10
use syn:: {
11
- parse_macro_input, parse_quote, Error , Fields , FnArg , Ident , ItemFn , ItemStruct , LitStr , Pat ,
11
+ parse_macro_input, parse_quote, Error , FnArg , Ident , ItemFn , ItemStruct , LitStr , Pat ,
12
12
Visibility ,
13
13
} ;
14
14
@@ -25,11 +25,9 @@ macro_rules! err {
25
25
///
26
26
/// The macro takes one argument, a GUID string.
27
27
///
28
- /// The macro can only be applied to a struct, and the struct must have
29
- /// named fields (i.e. not a unit or tuple struct). It implements the
28
+ /// The macro can only be applied to a struct. It implements the
30
29
/// [`Protocol`] trait and the `unsafe` [`Identify`] trait for the
31
- /// struct. It also adds a hidden field that causes the struct to be
32
- /// marked as [`!Send` and `!Sync`][send-and-sync].
30
+ /// struct.
33
31
///
34
32
/// # Safety
35
33
///
@@ -64,25 +62,16 @@ pub fn unsafe_protocol(args: TokenStream, input: TokenStream) -> TokenStream {
64
62
let item_struct = parse_macro_input ! ( input as ItemStruct ) ;
65
63
66
64
let ident = & item_struct. ident ;
67
- let struct_attrs = & item_struct. attrs ;
68
- let struct_vis = & item_struct. vis ;
69
- let struct_fields = if let Fields :: Named ( struct_fields) = & item_struct. fields {
70
- & struct_fields. named
71
- } else {
72
- return err ! ( item_struct, "Protocol struct must used named fields" ) . into ( ) ;
73
- } ;
74
- let struct_generics = & item_struct. generics ;
75
65
let ( impl_generics, ty_generics, where_clause) = item_struct. generics . split_for_impl ( ) ;
76
66
77
67
quote ! {
78
- #( #struct_attrs) *
79
- #struct_vis struct #ident #struct_generics {
80
- // Add a hidden field with `PhantomData` of a raw
81
- // pointer. This has the implicit side effect of making the
82
- // struct !Send and !Sync.
83
- _no_send_or_sync: :: core:: marker:: PhantomData <* const u8 >,
84
- #struct_fields
85
- }
68
+ // Disable this lint for now. It doesn't account for the fact that
69
+ // currently it doesn't work to `derive(Debug)` on structs that have
70
+ // `extern "efiapi" fn` fields, which most protocol structs have. The
71
+ // derive _does_ work in current nightly (1.70.0) though, so hopefully
72
+ // in a couple Rust releases we can drop this.
73
+ #[ allow( missing_debug_implementations) ]
74
+ #item_struct
86
75
87
76
unsafe impl #impl_generics :: uefi:: Identify for #ident #ty_generics #where_clause {
88
77
const GUID : :: uefi:: Guid = :: uefi:: Guid :: from_values(
0 commit comments