Skip to content

Commit c500e62

Browse files
committed
fix: improve message for inactive weak optional feature with edition2024
1 parent 3410354 commit c500e62

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/cargo/core/summary.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,13 @@ fn build_feature_map(
304304

305305
// Validation of the feature name will be performed in the resolver.
306306
if !is_any_dep {
307+
// editon2024 stops expose implicit features, which will strip weak optional dependencies from `dependencies`
308+
if *weak {
309+
bail!(
310+
"feature `{feature}` includes `{fv}`, activate it in a feature with `dep:{dep_name}` if `{dep_name}` is an enabled dependency"
311+
);
312+
}
313+
307314
bail!(
308315
"feature `{}` includes `{}`, but `{}` is not a dependency",
309316
feature,

tests/testsuite/lints/unused_optional_dependencies.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ fn inactive_weak_optional_dep() {
188188
error: failed to parse manifest at `[ROOT]/foo/Cargo.toml`
189189
190190
Caused by:
191-
feature `feat` includes `dep?/feat`, but `dep` is not a dependency
191+
feature `feat` includes `dep?/feat`, activate it in a feature with `dep:dep` if `dep` is an enabled dependency
192192
",
193193
)
194194
.run();
@@ -221,7 +221,7 @@ Caused by:
221221
error: failed to parse manifest at `[ROOT]/foo/Cargo.toml`
222222
223223
Caused by:
224-
feature `feat` includes `dep?/feat`, but `dep` is not a dependency
224+
feature `feat` includes `dep?/feat`, activate it in a feature with `dep:dep` if `dep` is an enabled dependency
225225
",
226226
)
227227
.run();

0 commit comments

Comments
 (0)