diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2016-11-04 16:49:33 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2016-11-05 10:50:25 -0700 |
| commit | 9847bd3d681ef9a80d1b0ff82cbffe70af5aab0b (patch) | |
| tree | b5b5af80daef4d2ef62d0c624b5af303528f9d30 /src/libsyntax_ext | |
| parent | 8e5c91a6fb842257b7ae38967da7073ff9a2f528 (diff) | |
| parent | ecd79a125b333e2e38fa1e0f6156438659c283db (diff) | |
| download | rust-9847bd3d681ef9a80d1b0ff82cbffe70af5aab0b.tar.gz rust-9847bd3d681ef9a80d1b0ff82cbffe70af5aab0b.zip | |
Rollup merge of #37596 - est31:master, r=alexcrichton
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) } |
