Skip to content

Commit 3fd3656

Browse files
committed
fix(resolver): Have errors follow rustc's casing convention
1 parent 93c734b commit 3fd3656

File tree

4 files changed

+31
-16
lines changed

4 files changed

+31
-16
lines changed

src/cargo/core/resolver/dep_cache.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ impl RequirementError {
524524
"feature",
525525
);
526526
ActivateError::Fatal(anyhow::format_err!(
527-
"Package `{}` does not have the feature `{}`{}",
527+
"package `{}` does not have the feature `{}`{}",
528528
summary.package_id(),
529529
feat,
530530
closest
@@ -555,9 +555,11 @@ impl RequirementError {
555555
}
556556
ActivateError::Fatal(anyhow::format_err!(
557557
"\
558-
Package `{}` does not have feature `{}`. It has an optional dependency \
559-
with that name, but that dependency uses the \"dep:\" \
560-
syntax in the features table, so it does not have an implicit feature with that name.{}",
558+
package `{}` does not have feature `{}`
559+
560+
help: an optional dependency \
561+
with that name exists, but the `features` table includes it with the \"dep:\" \
562+
syntax so it does not have an implicit feature with that name{}",
561563
summary.package_id(),
562564
feat,
563565
suggestion
@@ -571,8 +573,9 @@ syntax in the features table, so it does not have an implicit feature with that
571573
} else {
572574
match parent {
573575
None => ActivateError::Fatal(anyhow::format_err!(
574-
"Package `{}` does not have feature `{}`. It has a required dependency \
575-
with that name, but only optional dependencies can be used as features.",
576+
"package `{}` does not have feature `{}`
577+
578+
help: a depednency with that name exists but it is required dependency and only optional dependencies can be used as features.",
576579
summary.package_id(),
577580
feat,
578581
)),

tests/testsuite/features.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ failed to select a version for `bar` which could resolve this conflict
232232
p.cargo("check --features test")
233233
.with_status(101)
234234
.with_stderr_data(str![[r#"
235-
[ERROR] Package `foo v0.0.1 ([ROOT]/foo)` does not have the feature `test`
235+
[ERROR] package `foo v0.0.1 ([ROOT]/foo)` does not have the feature `test`
236236
237237
"#]])
238238
.run();
@@ -448,7 +448,9 @@ fn cli_activates_required_dependency() {
448448
p.cargo("check --features bar")
449449
.with_stderr_data(str![[r#"
450450
[LOCKING] 1 package to latest compatible version
451-
[ERROR] Package `foo v0.0.1 ([ROOT]/foo)` does not have feature `bar`. It has a required dependency with that name, but only optional dependencies can be used as features.
451+
[ERROR] package `foo v0.0.1 ([ROOT]/foo)` does not have feature `bar`
452+
453+
[HELP] a depednency with that name exists but it is required dependency and only optional dependencies can be used as features.
452454
453455
"#]])
454456
.with_status(101)

tests/testsuite/features_namespaced.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,9 @@ regex
419419

420420
p.cargo("run --features lazy_static")
421421
.with_stderr_data(str![[r#"
422-
[ERROR] Package `foo v0.1.0 ([ROOT]/foo)` does not have feature `lazy_static`. It has an optional dependency with that name, but that dependency uses the "dep:" syntax in the features table, so it does not have an implicit feature with that name.
422+
[ERROR] package `foo v0.1.0 ([ROOT]/foo)` does not have feature `lazy_static`
423+
424+
[HELP] an optional dependency with that name exists, but the `features` table includes it with the "dep:" syntax so it does not have an implicit feature with that name
423425
Dependency `lazy_static` would be enabled by these features:
424426
- `regex`
425427

tests/testsuite/package_features.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ f3f4
338338
p.cargo("run -p bar --features f1,f2")
339339
.with_status(101)
340340
.with_stderr_data(str![[r#"
341-
[ERROR] Package `foo v0.1.0 ([ROOT]/foo)` does not have the feature `f2`
341+
[ERROR] package `foo v0.1.0 ([ROOT]/foo)` does not have the feature `f2`
342342
343343
[HELP] a feature with a similar name exists: `f1`
344344
@@ -406,7 +406,7 @@ fn feature_default_resolver() {
406406
p.cargo("check --features testt")
407407
.with_status(101)
408408
.with_stderr_data(str![[r#"
409-
[ERROR] Package `a v0.1.0 ([ROOT]/foo)` does not have the feature `testt`
409+
[ERROR] package `a v0.1.0 ([ROOT]/foo)` does not have the feature `testt`
410410
411411
[HELP] a feature with a similar name exists: `test`
412412
@@ -458,7 +458,9 @@ fn command_line_optional_dep() {
458458
.with_stderr_data(str![[r#"
459459
[UPDATING] `dummy-registry` index
460460
[LOCKING] 1 package to latest compatible version
461-
[ERROR] Package `a v0.1.0 ([ROOT]/foo)` does not have feature `bar`. It has an optional dependency with that name, but that dependency uses the "dep:" syntax in the features table, so it does not have an implicit feature with that name.
461+
[ERROR] package `a v0.1.0 ([ROOT]/foo)` does not have feature `bar`
462+
463+
[HELP] an optional dependency with that name exists, but the `features` table includes it with the "dep:" syntax so it does not have an implicit feature with that name
462464
Dependency `bar` would be enabled by these features:
463465
- `foo`
464466
@@ -496,7 +498,9 @@ fn command_line_optional_dep_three_options() {
496498
.with_stderr_data(str![[r#"
497499
[UPDATING] `dummy-registry` index
498500
[LOCKING] 1 package to latest compatible version
499-
[ERROR] Package `a v0.1.0 ([ROOT]/foo)` does not have feature `bar`. It has an optional dependency with that name, but that dependency uses the "dep:" syntax in the features table, so it does not have an implicit feature with that name.
501+
[ERROR] package `a v0.1.0 ([ROOT]/foo)` does not have feature `bar`
502+
503+
[HELP] an optional dependency with that name exists, but the `features` table includes it with the "dep:" syntax so it does not have an implicit feature with that name
500504
Dependency `bar` would be enabled by these features:
501505
- `f1`
502506
- `f2`
@@ -537,7 +541,9 @@ fn command_line_optional_dep_many_options() {
537541
.with_stderr_data(str![[r#"
538542
[UPDATING] `dummy-registry` index
539543
[LOCKING] 1 package to latest compatible version
540-
[ERROR] Package `a v0.1.0 ([ROOT]/foo)` does not have feature `bar`. It has an optional dependency with that name, but that dependency uses the "dep:" syntax in the features table, so it does not have an implicit feature with that name.
544+
[ERROR] package `a v0.1.0 ([ROOT]/foo)` does not have feature `bar`
545+
546+
[HELP] an optional dependency with that name exists, but the `features` table includes it with the "dep:" syntax so it does not have an implicit feature with that name
541547
Dependency `bar` would be enabled by these features:
542548
- `f1`
543549
- `f2`
@@ -583,7 +589,9 @@ fn command_line_optional_dep_many_paths() {
583589
.with_stderr_data(str![[r#"
584590
[UPDATING] `dummy-registry` index
585591
[LOCKING] 1 package to latest compatible version
586-
[ERROR] Package `a v0.1.0 ([ROOT]/foo)` does not have feature `bar`. It has an optional dependency with that name, but that dependency uses the "dep:" syntax in the features table, so it does not have an implicit feature with that name.
592+
[ERROR] package `a v0.1.0 ([ROOT]/foo)` does not have feature `bar`
593+
594+
[HELP] an optional dependency with that name exists, but the `features` table includes it with the "dep:" syntax so it does not have an implicit feature with that name
587595
Dependency `bar` would be enabled by these features:
588596
- `f1`
589597
- `f2`
@@ -820,7 +828,7 @@ m1-feature set
820828
.cwd("member2")
821829
.with_status(101)
822830
.with_stderr_data(str![[r#"
823-
[ERROR] Package `member1 v0.1.0 ([ROOT]/foo/member1)` does not have the feature `m2-feature`
831+
[ERROR] package `member1 v0.1.0 ([ROOT]/foo/member1)` does not have the feature `m2-feature`
824832
825833
[HELP] a feature with a similar name exists: `m1-feature`
826834

0 commit comments

Comments
 (0)