Using dep:
syntax in Cargo.toml makes it impossible to enable features for dependencies unless you also have a feature by that name #10788
Description
Any crate with this Cargo.toml, or any one like it:
[package]
name = 'whatever'
version = '0.1.0'
edition = '2021'
[features]
default = ['font', 'allsorts/flate2_rust']
font = ['dep:allsorts']
[dependencies]
allsorts = { version = '~0.10.0', optional = true, default-features = false }
fails to compile because of the allsorts/flate2_rust
, even though it shouldn't (allsorts
is a dependency, not a feature name).
Adding an allsorts
feature, even a completely empty one, fixes the error:
[package]
name = 'whatever'
version = '0.1.0'
edition = '2021'
[features]
default = ['font', 'allsorts/flate2_rust']
font = ['dep:allsorts']
allsorts = []
[dependencies]
allsorts = { version = '~0.10.0', optional = true, default-features = false }
so this is probably a misbehaving lint. I don't want an extra allsorts
feature (in my real crate, font
is more than just allsorts
, and enabling allsorts
on its own makes 0 sense).
If this lint exists for encapsulation purposes, I would like to be able to do dep:allsorts/flate2_rust
at least, if there is no outer-facing allsorts
feature (although I'd add one in that case so that downstream crates can configure which flate2 backend they want).
Active toolchain:
nightly-x86_64-unknown-linux-gnu (default)
rustc 1.63.0-nightly (dc80ca78b 2022-06-21)
I have made a minimum effort to search for duplicate issues, but "dep cargo feature" is such a generic search term that it gives thousands of results.