mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update to syn 2 where possible (#30387)
* Update to syn 2 where possible * Cleanups * Better no_trace comment Co-authored-by: Martin Robinson <mrobinson@igalia.com> --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
7caac9790d
commit
8b30d1a4b2
8 changed files with 57 additions and 54 deletions
|
@ -149,21 +149,15 @@ fn js_traceable_derive(s: synstructure::Structure) -> proc_macro2::TokenStream {
|
|||
let mut asserts = quote!();
|
||||
let match_body = s.each(|binding| {
|
||||
for attr in binding.ast().attrs.iter() {
|
||||
match attr.parse_meta().unwrap() {
|
||||
syn::Meta::Path(ref path) | syn::Meta::List(syn::MetaList { ref path, .. }) => {
|
||||
if path.is_ident("no_trace") {
|
||||
asserts.extend(assert_not_impl_traceable(&binding.ast().ty));
|
||||
return None;
|
||||
} else if path.is_ident("custom_trace") {
|
||||
return Some(quote!(<crate::dom::bindings::trace::CustomTraceable>::trace(#binding, tracer);));
|
||||
}
|
||||
},
|
||||
syn::Meta::NameValue(syn::MetaNameValue { ref path, .. }) => {
|
||||
// if reason provided we can skip JSTraceable check
|
||||
if path.is_ident("no_trace") {
|
||||
return None;
|
||||
}
|
||||
},
|
||||
if attr.path().is_ident("no_trace") {
|
||||
// If no reason argument is provided to `no_trace` (ie `#[no_trace="This types does not need..."]`),
|
||||
// assert that the type in this bound field does not implement traceable.
|
||||
if !matches!(attr.meta, syn::Meta::NameValue(_)) {
|
||||
asserts.extend(assert_not_impl_traceable(&binding.ast().ty));
|
||||
}
|
||||
return None;
|
||||
} else if attr.path().is_ident("custom_trace") {
|
||||
return Some(quote!(<crate::dom::bindings::trace::CustomTraceable>::trace(#binding, tracer);));
|
||||
}
|
||||
}
|
||||
Some(quote!(#binding.trace(tracer);))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue