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
Invalid Cargo.toml
when using dep:
namespaced features
#171
Comments
You can either use `std::os::raw::c_int` or `libc::c_int`. Unfortunately, the feature name is awkward to work around dtolnay/trybuild#171.
You can either use `std::os::raw::c_int` or `libc::c_int`. Unfortunately, the feature name is awkward to work around dtolnay/trybuild#171.
I'd love it if this were fixed! I recently updated |
Well that was quick. Thank you @dtolnay! |
Actually, it looks like this does miss one case. If a feature has the same name as the namespaced feature, it fails with the same error. [features]
rand = ["dep:rand"]
[dependencies]
rand = { version = "0.8", optional = true }
|
That should work. Is it maybe if an optional dependency has the same name as a non-optional dev-dependency? |
Yeah, that is the case. I was typing that off-hand without thinking that it could be more complicated. Specifically I was testing the current head of time-rs/time (with Edit: Just tried 1.0.68, and it works. Thanks again! |
Below is an attempt at creating a minimal reproducible example of this bug.
In
rustc 1.60.0
, namespaced dependencies were added that made the followingCargo.toml
manifest possible:However, when adding a simple trybuild test, like the following:
tests/trybuild.rs
With tests/ui/test.rs simply containing:
Running the tests results in the following:
If you look at target/tests/foo/Cargo.toml, it is as follows:
It seems the problem is that
rayon = ["foo/rayon"]
causes cargo to not use an implicitrayon = ["dep:rayon"]
, which meansdep:rayon
is never included in any feature, hence the error. Changing the line torayon = ["foo/rayon", "dep:rayon"]
solves the problem and allows the crate to compile.I'm not exactly sure how to go about solving this generally. It seems all of the dependencies and features are included to allow the test crate to use them. I wonder if it would work to copy the list of additional features to enable for each feature into the new
Cargo.toml
file that is generated. This would retain thedep:
features, while also not enabling any extra features, since those same features are already being enabled by the original crate itself.The text was updated successfully, but these errors were encountered: