about summary refs log tree commit diff
path: root/src/libsyntax_ext/deriving/generic
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-03-16 20:48:40 +0000
committerbors <bors@rust-lang.org>2019-03-16 20:48:40 +0000
commit7cf074a1e655ac07d04d045667278fa1a9970b93 (patch)
treed2509e198c34af3e41cce2dbde186635384a418a /src/libsyntax_ext/deriving/generic
parent2c8bbf50db0ef90a33f986ba8fc2e1fe129197ff (diff)
parent2fd4cbb3f283b903f55444bb585d38a2539f4e8d (diff)
Auto merge of #58899 - petrochenkov:derval2, r=estebank
Do not accidentally treat multi-segment meta-items as single-segment

Fixes https://github.com/rust-lang/rust/issues/55168 and many other regressions from https://github.com/rust-lang/rust/pull/50030

Basically, attributes like `#[any::prefix::foo]` were commonly interpreted as `#[foo]` due to `name()` successfully returning the last segment (this applies to nested things as well `#[attr(any::prefix::foo)]`).
Diffstat (limited to 'src/libsyntax_ext/deriving/generic')
-rw-r--r--src/libsyntax_ext/deriving/generic/mod.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs
index b8f96c5bc0e..2bb98c1bf62 100644
--- a/src/libsyntax_ext/deriving/generic/mod.rs
+++ b/src/libsyntax_ext/deriving/generic/mod.rs
@@ -463,12 +463,9 @@ impl<'a> TraitDef<'a> {
                 let mut attrs = newitem.attrs.clone();
                 attrs.extend(item.attrs
                     .iter()
-                    .filter(|a| {
-                        match &*a.name().as_str() {
-                            "allow" | "warn" | "deny" | "forbid" | "stable" | "unstable" => true,
-                            _ => false,
-                        }
-                    })
+                    .filter(|a| a.ident_str().map_or(false, |name| {
+                        ["allow", "warn", "deny", "forbid", "stable", "unstable"].contains(&name)
+                    }))
                     .cloned());
                 push(Annotatable::Item(P(ast::Item { attrs: attrs, ..(*newitem).clone() })))
             }