Rollup merge of #37596 - est31:master, r=alexcrichton
Add error when proc_macro_derive is used not on functions Fixes #37590
This commit is contained in:
commit
9847bd3d68
@ -105,6 +105,17 @@ fn visit_item(&mut self, item: &ast::Item) {
|
||||
match item.node {
|
||||
ast::ItemKind::Fn(..) => {}
|
||||
_ => {
|
||||
// Check for invalid use of proc_macro_derive
|
||||
let attr = item.attrs.iter()
|
||||
.filter(|a| a.check_name("proc_macro_derive"))
|
||||
.next();
|
||||
if let Some(attr) = attr {
|
||||
self.handler.span_err(attr.span(),
|
||||
"the `#[proc_macro_derive]` \
|
||||
attribute may only be used \
|
||||
on bare functions");
|
||||
return;
|
||||
}
|
||||
self.check_not_pub_in_root(&item.vis, item.span);
|
||||
return visit::walk_item(self, item)
|
||||
}
|
||||
|
@ -18,4 +18,10 @@ pub fn foo(a: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
||||
a
|
||||
}
|
||||
|
||||
// Issue #37590
|
||||
#[proc_macro_derive(Foo)]
|
||||
//~^ ERROR: the `#[proc_macro_derive]` attribute may only be used on bare functions
|
||||
pub struct Foo {
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user