-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'cargo test' with proc_macro_derive fails #37480
Comments
You can probably work around this by using |
Thanks for the report! I'm not sure what the best way to solve this would be. We could either tell the compiler that |
Would a simple fix for this be to add |
@keeperofdakeys I'd personally prefer for |
Show a better error when using --test with #[proc_macro_derive] Fixes #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.
I think it was wrong that this ticket was closed with #37826 since it states
|
@alexcrichton Actually fixing this appears simpler than I expected. I'm guessing a |
@keeperofdakeys of it works it works for me! |
Allow --test to be used on proc-macro crates Fixes #37480 This patch allows `--test` to work for proc-macro crates, removing the previous error.
@keeperofdakeys @alexcrichton this is failing again. It works correctly on nightly-2017-01-17 rustc 1.16.0-nightly (4ce7acc 2017-01-17) but fails on nightly-2017-01-18 rustc 1.16.0-nightly (c07a6ae 2017-01-17).
|
This could be related to recently enabling doc-testing of proc-macro crates in cargo rust-lang/cargo#3552. This rustc change should fix that #39136. If you look at the cargo output, does the error happen when running the normal tests, or after trying to run doc-tests? Edit: I've tested this in the latest nightly from rustup, and this is definitely what is happening. Hopefully it will be fixed soon. |
@keeperofdakeys thanks for staying on top of this! I've approved #39136 and p=1'd it to hopefully get it in soon. @dtolnay sorry for the breakage! |
I setup a crate using the example from http://www.ncameron.org/blog/macros-and-syntax-extensions-and-compiler-plugins-where-are-we-at/
There are no tests setup: no tests folder, no #[test] attributes.
cargo run
succeedscargo test
fails with:error: the
#[proc_macro_derive]attribute is only usable with crates of the
proc-macrocrate type
Naturally I expected this error not to occur.
cargo.toml
lib.rs
rust version
Run on the latest nightly via rustup:
rustc 1.14.0-nightly (3f4408347 2016-10-27) binary: rustc commit-hash: 3f4408347d2109803edbf53c89c8bce575de4b67 commit-date: 2016-10-27 host: x86_64-unknown-linux-gnu release: 1.14.0-nightly LLVM version: 3.9
The text was updated successfully, but these errors were encountered: