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

Suggested adding dep:foo to the foo feature if it exists for unused optional dependencies #14017

Closed
epage opened this issue Jun 5, 2024 · 2 comments
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. A-features Area: features — conditional compilation S-needs-team-input Status: Needs input from team on whether/how to proceed.

Comments

@epage
Copy link
Contributor

epage commented Jun 5, 2024

cargo-features = ["edition2024"]
[package]
name = "cargo-14010"
version = "0.1.0"
edition = "2024"

[dependencies]
serde = { version = "1.0.203", optional = true }

[features]
serde = []
$ cargo +nightly check -Zcargo-lints
warning: unused optional dependency
 --> Cargo.toml:8:1
  |
8 | serde = { version = "1.0.203", optional = true }
  | -----
  |
  = note: `cargo::unused_optional_dependency` is set to `warn` by default
  = help: remove the dependency or activate it in a feature with `dep:serde`
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.00s

Likely the user intended for dep:serde to be on the serde feature and it might be nice for us to call that out explicitly.

@epage epage added A-features Area: features — conditional compilation A-diagnostics Area: Error and warning messages generated by Cargo itself. S-needs-team-input Status: Needs input from team on whether/how to proceed. labels Jun 5, 2024
@epage
Copy link
Contributor Author

epage commented Jun 5, 2024

We'd likely get this "for free" if/when we show a code suggestion

@epage
Copy link
Contributor Author

epage commented Oct 29, 2024

As we don't have unused optional dependencies anymore, I'm going to close this but note it for when we bring it back

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Oct 29, 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 S-needs-team-input Status: Needs input from team on whether/how to proceed.
Projects
None yet
Development

No branches or pull requests

1 participant