Skip to content

Have cargo add --optional <dep> create a <dep> = "dep:<dep> feature #11010

@epage

Description

@epage

Problem

This is inspired by my running cargo add and seeing a lot of features that might be there only because people have not updated to the new dep: syntax to disable unintended implicit features. For my crates, I'm aware of the syntax and plan to transition my crates. For others, they might not be aware the feature exists and by us cargo add turning it explicit, it would help raise visibility on these features to help lead more people to using it.

In addition, #10556 mentions the idea of cargo fix doing

possibly define a feature named "package" if it doesn't already exist and dep:package isn't already used

ie by convention moving away from implicit feature declarations.

Proposed Solution

cargo add --optional <dep> would create a <dep> = "dep:<dep> feature iff

  • rust-version is unset or is new enough for the syntax
  • dep:<dep> doesn't already exist

Metadata

Metadata

Assignees

Labels

C-enhancementCategory: enhancementCommand-addS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions