-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Bad error message when a strong dep features's depedency is an unused optional dependency #14016
Copy link
Copy link
Open
Labels
A-editionsArea: edition-specific issuesArea: edition-specific issuesA-featuresArea: features — conditional compilationArea: features — conditional compilationC-bugCategory: bugCategory: bugS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Description
Problem
If nothing can activate an optional dependency, cargo acts as if the dependency doesn't exist which creates poor error messages.
Also, with how things are arranged, the unused optional dependency lint doesn't get reported which could at least reduce the burden on the error message.
Steps
Baseline Cargo.toml:
cargo-features = ["edition2024"]
[package]
name = "cargo-14010"
version = "0.1.0"
edition = "2024"
[dependencies]
serde = { version = "1.0.203", optional = true }$ 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.00sAdd the following to Cargo.toml:
[features]
serde = ["serde/derive"]$ cargo +nightly check -Zcargo-lints
error: failed to parse manifest at `/home/epage/src/personal/dump/cargo-14010-1/Cargo.toml`
Caused by:
feature `serde` includes `serde/derive`, but `serde` is not a dependencyPossible Solution(s)
- Improve the error message
- Implicitly create
dep:serdeifserde/deriveis used - Deprecate
serde/derivesyntax, removing it in a new edition (Transition out weak feature syntax in an edition #10556)
Notes
This was split out of #14015 assuming we'll go with a different solution than it
Version
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-editionsArea: edition-specific issuesArea: edition-specific issuesA-featuresArea: features — conditional compilationArea: features — conditional compilationC-bugCategory: bugCategory: bugS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Type
Fields
Give feedbackNo fields configured for issues without a type.