I'm getting an error when using cargo tarpaulin in the Rocket repository on the async branch. It turns out that they removed the extern crate proc_macro; from the ./contrib/codegen/ crate, which gave a warning in Rust 2018, since it's considered non-idiomatic.
It compiles fine with cargo build or cargo test, but it gives the following error when running the latest cargo tarpaulin:
[INFO tarpaulin] Running Tarpaulin
[INFO tarpaulin] Building project
error[E0432]: unresolved import `proc_macro`
--> contrib/codegen/src/lib.rs:39:5
|
39 | use proc_macro::TokenStream;
| ^^^^^^^^^^ help: a similar path exists: `quote::proc_macro`
error[E0432]: unresolved import `proc_macro`
--> contrib/codegen/src/database.rs:1:5
|
1 | use proc_macro::TokenStream;
| ^^^^^^^^^^ help: a similar path exists: `quote::proc_macro`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0432`.
error: could not compile `rocket_contrib_codegen`.
Error: "Failed to compile tests! Error: build failed"
If you give me some pointers I can try to fix it :)
I think this might be because proc-macro=true in a Cargo.toml allows certain extra nightly proc-macro features. I've had a brief look over the cargo source but can't find anything obvious I should be doing so raised this issue https://github.com/rust-lang/cargo/issues/7968
In the meantime I'll continue to look but it seems to be a cargo usage based issue
So I moved my cargo dependency to the latest on master and it seems to solve the issue. You can try it out by installing from https://github.com/xd009642/tarpaulin/tree/issue_339
So over this weekend I'm going to follow some advice of a cargo maintainer and move to using https://docs.rs/cargo_metadata/ to handle my interactions with cargo as this will keep tarpaulin more up-to-date with nightly features and stop issues like this in future. I'll close this issue when that's done, confirmed to work and released :smile:
This sounds great! Thanks for your work :) It really sounds promising, to be able to use the same binary that cargo test is using. It should also reduce tarpaulin compile times by removing the cargo dependency :)
Let me know if I can help with this!
So far I've mostly got it down, just two more tests need move from red to green (and that's ignoring nightly only tests)
This should be fixed in the 0.11.1 release since cargo was updated. I'm still working on removing cargo as a dependency though so I'll keep this issue open to track that (and slightly rename it)
Hi, so this particular issue is solved, cool!
How is the cargo dependency removal going?
There's a version without cargo as a dependency on the develop branch if you want to try it. It works exactly the same on all the projects I've tested with but could do with more testing!
This version is now released although it looks like there might be a regression with examples which is handled by another issue. So I'm going to close this
Great, thanks! Sorry I didn't have the time to check it.