diff options
| author | Josh Driver <keeperofdakeys@gmail.com> | 2016-11-17 22:06:36 +1030 |
|---|---|---|
| committer | Josh Driver <keeperofdakeys@gmail.com> | 2016-11-17 22:06:36 +1030 |
| commit | b9ed51c8f179da643bc7186c35d1beb3c5239723 (patch) | |
| tree | 3ceb45e92f48685a0a16a337ecc07e619173c144 /src/libsyntax_ext | |
| parent | 43006fcea0066a935b657fff9ccef56983cbf56c (diff) | |
| download | rust-b9ed51c8f179da643bc7186c35d1beb3c5239723.tar.gz rust-b9ed51c8f179da643bc7186c35d1beb3c5239723.zip | |
Show a better error when using --test with #[proc_macro_derive]
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 \ |
