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:
Samson 2023-09-19 17:57:37 +02:00 committed by GitHub
parent 7caac9790d
commit 8b30d1a4b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 57 additions and 54 deletions

View file

@ -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);))