Account for proc macro helpers when parsing attr
This commit is contained in:
parent
44587d1bfc
commit
8ab7696acd
2 changed files with 9 additions and 1 deletions
|
@ -1229,9 +1229,10 @@ impl ModCollector<'_, '_> {
|
|||
} else {
|
||||
let derive = attrs.by_key("proc_macro_derive");
|
||||
if let Some(arg) = derive.tt_values().next() {
|
||||
if let [TokenTree::Leaf(Leaf::Ident(trait_name))] = &*arg.token_trees {
|
||||
if let [TokenTree::Leaf(Leaf::Ident(trait_name)), ..] = &*arg.token_trees {
|
||||
trait_name.as_name()
|
||||
} else {
|
||||
log::trace!("malformed `#[proc_macro_derive]`: {}", arg);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -688,13 +688,20 @@ fn resolves_proc_macros() {
|
|||
pub fn derive_macro(_item: TokenStream) -> TokenStream {
|
||||
TokenStream
|
||||
}
|
||||
|
||||
#[proc_macro_derive(AnotherTrait, attributes(helper_attr))]
|
||||
pub fn derive_macro_2(_item: TokenStream) -> TokenStream {
|
||||
TokenStream
|
||||
}
|
||||
",
|
||||
expect![[r#"
|
||||
crate
|
||||
AnotherTrait: m
|
||||
DummyTrait: m
|
||||
TokenStream: t v
|
||||
attribute_macro: v m
|
||||
derive_macro: v
|
||||
derive_macro_2: v
|
||||
function_like_macro: v m
|
||||
"#]],
|
||||
);
|
||||
|
|
Loading…
Add table
Reference in a new issue