cargo icon indicating copy to clipboard operation
cargo copied to clipboard

Feature named for private dependency

Open epage opened this issue 7 months ago • 0 comments

What it does

Identify any feature name that matches a dependency that it activates

This is easy to accidentally do from

  • Implicit features
  • cargo add --optional creating the explicit feature for you

Advantage

This is a semver hazard in case the dependency is swapped out for a different one

Drawbacks

For a generic enough dependency name, this could cause an annoyance

Example

[features]
strsim = ["dep:strsim"]

[dependencies]
strsim = { version = "*', optional = true }

Could be written as:

[features]
suggestions = ["dep:strsim"]

[dependencies]
strsim = { version = "*', optional = true }

epage avatar May 23 '25 15:05 epage