diff options
| author | bors <bors@rust-lang.org> | 2016-11-19 13:28:50 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-19 13:28:50 -0600 |
| commit | bfa709a38a8c607e1c13ee5635fbfd1940eb18b1 (patch) | |
| tree | bab57c3dd07eec288d6cade2b14b6b4117367b86 /src/libsyntax_ext | |
| parent | b1da18fe9be180ecfcfb1691c4eb669c496996f5 (diff) | |
| parent | 3254fabf8e4a81a595579fa19abd5ec49bff270d (diff) | |
| download | rust-bfa709a38a8c607e1c13ee5635fbfd1940eb18b1.tar.gz rust-bfa709a38a8c607e1c13ee5635fbfd1940eb18b1.zip | |
Auto merge of #37826 - keeperofdakeys:proc-macro-test, r=alexcrichton
Show a better error when using --test with #[proc_macro_derive] Fixes https://github.com/rust-lang/rust/issues/37480 Currently using `--test` with a crate that contains a `#[proc_macro_derive]` attribute causes an error. This PR doesn't attempt to fix the issue itself, or determine what tesing of a proc_macro_derive crate should be - just to provide a better error message.
Diffstat (limited to 'src/libsyntax_ext')
| -rw-r--r-- | src/libsyntax_ext/proc_macro_registrar.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libsyntax_ext/proc_macro_registrar.rs b/src/libsyntax_ext/proc_macro_registrar.rs index d6d31200a99..36fd6408b4f 100644 --- a/src/libsyntax_ext/proc_macro_registrar.rs +++ b/src/libsyntax_ext/proc_macro_registrar.rs @@ -38,12 +38,14 @@ struct CollectCustomDerives<'a> { in_root: bool, handler: &'a errors::Handler, is_proc_macro_crate: bool, + is_test_crate: bool, } pub fn modify(sess: &ParseSess, resolver: &mut ::syntax::ext::base::Resolver, mut krate: ast::Crate, is_proc_macro_crate: bool, + is_test_crate: bool, num_crate_types: usize, handler: &errors::Handler, features: &Features) -> ast::Crate { @@ -55,6 +57,7 @@ pub fn modify(sess: &ParseSess, in_root: true, handler: handler, is_proc_macro_crate: is_proc_macro_crate, + is_test_crate: is_test_crate, }; visit::walk_crate(&mut collect, &krate); @@ -137,6 +140,12 @@ impl<'a> Visitor for CollectCustomDerives<'a> { attributes found"); } + if self.is_test_crate { + self.handler.span_err(attr.span(), + "`--test` cannot be used with proc-macro crates"); + return; + } + if !self.is_proc_macro_crate { self.handler.span_err(attr.span(), "the `#[proc_macro_derive]` attribute is \ |
