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

Should warn on optional dep not used in any feature #9088

Closed
gdesmott opened this issue Jan 19, 2021 · 2 comments
Closed

Should warn on optional dep not used in any feature #9088

gdesmott opened this issue Jan 19, 2021 · 2 comments
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. A-features Area: features — conditional compilation C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@gdesmott
Copy link

Cargo could raise a warning when user defines an optional dependency which is not part of any feature.

I've been confused for a while trying to figure out why building my single feature project with --all-features was working while building it with --features=my-feature was not. Turned out I forgot to include one optional dep with the feature. Such warning would have prevent me from doing such stupid mistake. :)

@gdesmott gdesmott added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Jan 19, 2021
@jplatte
Copy link
Contributor

jplatte commented Jan 19, 2021

I think it was an intentional design choice to have optional crates exposed as features of their own. But maybe once the two namespaces are separated, that could be changed such that an optional dependency can only be activated through an explicitly declared feature.

In the current situation however, if you want a feature foo that (only) activates the dependency foo, there's no good way to express that other than making the dependency optional without creating an explicit feature. (you can rename the dependency and create a feature with the original dependency name that activates the dependency, but that's pretty ugly)

@ehuss ehuss added A-diagnostics Area: Error and warning messages generated by Cargo itself. A-features Area: features — conditional compilation A-namespaced-features Area: namespaced-features labels Feb 13, 2021
@ehuss ehuss removed the A-namespaced-features Area: namespaced-features label Feb 22, 2022
@epage
Copy link
Contributor

epage commented Jul 11, 2024

We are removing implicit features in Edition 2024 and warning the user that the dependency is unused.

Closing in favor of the tracking issue: #12826

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. A-features Area: features — conditional compilation C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

No branches or pull requests

4 participants