Analyze crates in non-test mode (again)
asomers opened this issue · 3 comments
Issue #20 has regressed. cargo-modules is once again unconditionally enabling test mode. For example, with the following input:
use crate::a::X;
#[cfg(not(test))]
use crate::b::Y;
#[cfg(test)]
use crate::c::Z;
pub mod a {
pub struct X{}
}
pub mod b {
pub struct Y{}
}
pub mod c {
pub struct Z{}
}
I would expect the following uses edges:
crate -> a
crate -> b
But cargo-modules doesn't show crate -> b
. Instead it shows crate -> c
, indicating that cfg(test)
is set. It doesn't matter whether I use the --with-tests
option. Here are the complete uses edges:
"cfg_not_test" -> "cfg_not_test::a" [label="uses", color="#7f7f7f", style="Dashed"]; // "uses" edge
"cfg_not_test" -> "cfg_not_test::c" [label="uses", color="#7f7f7f", style="Dashed"]; // "uses" edge
Thanks for the bug report and test case @asomers!
It looks like this will require this issue on rust-analyzer to get resolved first.
Ouch, that's a doozy. Thanks for pointing me to it, regexident.
With rust-analyzer's CargoConfig
now accepting a …
/// crates to disable `#[cfg(test)]` on
pub unset_test_crates: Vec<String>,
we should hopefully be able to fix this regression sooner or later.
However, since unfortunately a recent change to rust-analyzer prevents cargo-modules from updating its dependency on rust-analyzer we will have to wait for this to be fixed first before we can make progress.