You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a Cargo.toml of a package within a workspace is using the same crate in dependencies and dev-dependencies but with additional feature in dev-dependency that feature-flag will be used even when running in regular build (not a test) .
This seems pretty similar to #1796 but it only happens in a workspace.
Steps
If you prefer you can just clone and run this repository
create a workspace with two packages. one package should be a binary (core in my example) and the other a lib (get_str).
There are different feature resolver behaviors selected with the resolver setting. With a single package, the 2021 edition implicitly selects version "2". With a virtual workspace, there is no edition to select, so it defaults to the original version "1". You have to set the resolver field in the workspace. More can be found here.
Problem
If a Cargo.toml of a package within a workspace is using the same crate in dependencies and dev-dependencies but with additional feature in dev-dependency that feature-flag will be used even when running in regular build (not a test) .
This seems pretty similar to #1796 but it only happens in a workspace.
Steps
create a workspace with two packages. one package should be a binary (
core
in my example) and the other a lib (get_str)../Cargo.toml
core/Cargo.toml
core/src/main
get_str/Cargo.toml
get_str/src/lib.rs
Now just run
cargo run
. it should printThis is ... not a test
but it printsThis is ... a test
.I reproduced it on cargo 1.58 and 1.61) .
Possible Solution(s)
No response
Notes
In the provided example the dependent crate is part of the workspace but it gets reproduced even if the crate is downloaded from crates.io .
Version
The text was updated successfully, but these errors were encountered: