Skip to content

Commit 655e122

Browse files
committed
Auto merge of #8773 - pickfire:patch-1, r=ehuss
Add actionable help message for --features Fix #8770
2 parents 40b7793 + fd5902c commit 655e122

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

crates/cargo-test-support/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,7 @@ fn substitute_macros(input: &str) -> String {
15211521
("[ERROR]", "error:"),
15221522
("[WARNING]", "warning:"),
15231523
("[NOTE]", "note:"),
1524+
("[HELP]", "help:"),
15241525
("[DOCUMENTING]", " Documenting"),
15251526
("[FRESH]", " Fresh"),
15261527
("[UPDATING]", " Updating"),

src/cargo/util/command_prelude.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ pub trait ArgMatchesExt {
308308
if self._is_present(flag) {
309309
bail!(
310310
"--{} is not allowed in the root of a virtual workspace\n\
311-
note: while this was previously accepted, it didn't actually do anything",
311+
note: while this was previously accepted, it didn't actually do anything\n\
312+
help: change the current directory to the package directory, or use the --manifest-path flag to the path of the package",
312313
flag
313314
);
314315
}

tests/testsuite/features.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,15 +1939,17 @@ fn virtual_ws_flags() {
19391939
p.cargo("build --features=f1")
19401940
.with_stderr(
19411941
"[ERROR] --features is not allowed in the root of a virtual workspace\n\
1942-
note: while this was previously accepted, it didn't actually do anything",
1942+
[NOTE] while this was previously accepted, it didn't actually do anything\n\
1943+
[HELP] change the current directory to the package directory, or use the --manifest-path flag to the path of the package",
19431944
)
19441945
.with_status(101)
19451946
.run();
19461947

19471948
p.cargo("build --no-default-features")
19481949
.with_stderr(
19491950
"[ERROR] --no-default-features is not allowed in the root of a virtual workspace\n\
1950-
note: while this was previously accepted, it didn't actually do anything",
1951+
[NOTE] while this was previously accepted, it didn't actually do anything\n\
1952+
[HELP] change the current directory to the package directory, or use the --manifest-path flag to the path of the package",
19511953
)
19521954
.with_status(101)
19531955
.run();

tests/testsuite/package_features.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ fn virtual_no_default_features() {
5757
"\
5858
[ERROR] --no-default-features is not allowed in the root of a virtual workspace
5959
[NOTE] while this was previously accepted, it didn't actually do anything
60+
[HELP] change the current directory to the package directory, or use the --manifest-path flag to the path of the package
6061
",
6162
)
6263
.run();
@@ -125,6 +126,7 @@ fn virtual_features() {
125126
"\
126127
[ERROR] --features is not allowed in the root of a virtual workspace
127128
[NOTE] while this was previously accepted, it didn't actually do anything
129+
[HELP] change the current directory to the package directory, or use the --manifest-path flag to the path of the package
128130
",
129131
)
130132
.run();
@@ -202,6 +204,7 @@ fn virtual_with_specific() {
202204
"\
203205
[ERROR] --features is not allowed in the root of a virtual workspace
204206
[NOTE] while this was previously accepted, it didn't actually do anything
207+
[HELP] change the current directory to the package directory, or use the --manifest-path flag to the path of the package
205208
",
206209
)
207210
.run();
@@ -371,6 +374,7 @@ fn virtual_member_slash() {
371374
"\
372375
[ERROR] --features is not allowed in the root of a virtual workspace
373376
[NOTE] while this was previously accepted, it didn't actually do anything
377+
[HELP] change the current directory to the package directory, or use the --manifest-path flag to the path of the package
374378
",
375379
)
376380
.run();

0 commit comments

Comments
 (0)