Skip to content

Add actionable help message for --features #8773

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

Merged
merged 5 commits into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/cargo-test-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,7 @@ fn substitute_macros(input: &str) -> String {
("[ERROR]", "error:"),
("[WARNING]", "warning:"),
("[NOTE]", "note:"),
("[HELP]", "help:"),
("[DOCUMENTING]", " Documenting"),
("[FRESH]", " Fresh"),
("[UPDATING]", " Updating"),
Expand Down
3 changes: 2 additions & 1 deletion src/cargo/util/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ pub trait ArgMatchesExt {
if self._is_present(flag) {
bail!(
"--{} is not allowed in the root of a virtual workspace\n\
note: while this was previously accepted, it didn't actually do anything",
note: while this was previously accepted, it didn't actually do anything\n\
help: change the current directory to the package directory, or use the --manifest-path flag to the path of the package",
flag
);
}
Expand Down
6 changes: 4 additions & 2 deletions tests/testsuite/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1939,15 +1939,17 @@ fn virtual_ws_flags() {
p.cargo("build --features=f1")
.with_stderr(
"[ERROR] --features is not allowed in the root of a virtual workspace\n\
note: while this was previously accepted, it didn't actually do anything",
[NOTE] while this was previously accepted, it didn't actually do anything\n\
[HELP] change the current directory to the package directory, or use the --manifest-path flag to the path of the package",
)
.with_status(101)
.run();

p.cargo("build --no-default-features")
.with_stderr(
"[ERROR] --no-default-features is not allowed in the root of a virtual workspace\n\
note: while this was previously accepted, it didn't actually do anything",
[NOTE] while this was previously accepted, it didn't actually do anything\n\
[HELP] change the current directory to the package directory, or use the --manifest-path flag to the path of the package",
)
.with_status(101)
.run();
Expand Down
4 changes: 4 additions & 0 deletions tests/testsuite/package_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ fn virtual_no_default_features() {
"\
[ERROR] --no-default-features is not allowed in the root of a virtual workspace
[NOTE] while this was previously accepted, it didn't actually do anything
[HELP] change the current directory to the package directory, or use the --manifest-path flag to the path of the package
",
)
.run();
Expand Down Expand Up @@ -125,6 +126,7 @@ fn virtual_features() {
"\
[ERROR] --features is not allowed in the root of a virtual workspace
[NOTE] while this was previously accepted, it didn't actually do anything
[HELP] change the current directory to the package directory, or use the --manifest-path flag to the path of the package
",
)
.run();
Expand Down Expand Up @@ -202,6 +204,7 @@ fn virtual_with_specific() {
"\
[ERROR] --features is not allowed in the root of a virtual workspace
[NOTE] while this was previously accepted, it didn't actually do anything
[HELP] change the current directory to the package directory, or use the --manifest-path flag to the path of the package
",
)
.run();
Expand Down Expand Up @@ -371,6 +374,7 @@ fn virtual_member_slash() {
"\
[ERROR] --features is not allowed in the root of a virtual workspace
[NOTE] while this was previously accepted, it didn't actually do anything
[HELP] change the current directory to the package directory, or use the --manifest-path flag to the path of the package
",
)
.run();
Expand Down