diff options
| author | est31 <MTest31@outlook.com> | 2016-11-04 22:37:51 +0100 |
|---|---|---|
| committer | est31 <MTest31@outlook.com> | 2016-11-04 23:52:20 +0100 |
| commit | ecd79a125b333e2e38fa1e0f6156438659c283db (patch) | |
| tree | 409e11cd92fa2c3bb58ebedd7de211e4358f1b41 /src/libsyntax_ext | |
| parent | ccfc38f034e3f53cb460936bd9744085d4a63b40 (diff) | |
| download | rust-ecd79a125b333e2e38fa1e0f6156438659c283db.tar.gz rust-ecd79a125b333e2e38fa1e0f6156438659c283db.zip | |
Add error when proc_macro_derive is used not on functions
Fixes #37590
Diffstat (limited to 'src/libsyntax_ext')
| -rw-r--r-- | src/libsyntax_ext/proc_macro_registrar.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libsyntax_ext/proc_macro_registrar.rs b/src/libsyntax_ext/proc_macro_registrar.rs index f49a5f0e070..a8accd63dcf 100644 --- a/src/libsyntax_ext/proc_macro_registrar.rs +++ b/src/libsyntax_ext/proc_macro_registrar.rs @@ -105,6 +105,17 @@ impl<'a> Visitor for CollectCustomDerives<'a> { 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) } |
