summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_macros/src/type_visitable.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_macros/src/type_visitable.rs')
-rw-r--r--compiler/rustc_macros/src/type_visitable.rs30
1 files changed, 16 insertions, 14 deletions
diff --git a/compiler/rustc_macros/src/type_visitable.rs b/compiler/rustc_macros/src/type_visitable.rs
index f6f4c4779..dcd505a10 100644
--- a/compiler/rustc_macros/src/type_visitable.rs
+++ b/compiler/rustc_macros/src/type_visitable.rs
@@ -1,5 +1,5 @@
use quote::quote;
-use syn::{parse_quote, Attribute, Meta, NestedMeta};
+use syn::parse_quote;
pub fn type_visitable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
if let syn::Data::Union(_) = s.ast().data {
@@ -8,19 +8,21 @@ pub fn type_visitable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:
// ignore fields with #[type_visitable(ignore)]
s.filter(|bi| {
- !bi.ast()
- .attrs
- .iter()
- .map(Attribute::parse_meta)
- .filter_map(Result::ok)
- .flat_map(|attr| match attr {
- Meta::List(list) if list.path.is_ident("type_visitable") => list.nested,
- _ => Default::default(),
- })
- .any(|nested| match nested {
- NestedMeta::Meta(Meta::Path(path)) => path.is_ident("ignore"),
- _ => false,
- })
+ let mut ignored = false;
+
+ bi.ast().attrs.iter().for_each(|attr| {
+ if !attr.path().is_ident("type_visitable") {
+ return;
+ }
+ let _ = attr.parse_nested_meta(|nested| {
+ if nested.path.is_ident("ignore") {
+ ignored = true;
+ }
+ Ok(())
+ });
+ });
+
+ !ignored
});
if !s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {