Skip to content
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

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

Closed
epage opened this issue Aug 20, 2022 · 3 comments · Fixed by #13071
Closed

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

epage opened this issue Aug 20, 2022 · 3 comments · Fixed by #13071
Assignees
Labels
C-enhancement Category: enhancement Command-add S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review

Comments

@epage
Copy link
Contributor

epage commented Aug 20, 2022

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
@epage
Copy link
Contributor Author

epage commented Oct 17, 2023

This will be needed for #12826 once we no longer allow optional dependencies to be unreferenced. I'd propose we go ahead and implement it now to help raise awareness of dep: and prepare for that future.

@epage epage added the S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review label Oct 17, 2023
@epage
Copy link
Contributor Author

epage commented Oct 17, 2023

The contrib guide will soon have some guidance on how we should be handling formatting. See #12836

@LuuuXXX
Copy link
Contributor

LuuuXXX commented Nov 23, 2023

Looks like nobody's handling it. I'd like to try it. @rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: enhancement Command-add S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants