Skip to content

Commit 97656fb

Browse files
committed
Correct the helper name and the tip message
1 parent 817c2cb commit 97656fb

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

src/bin/cargo/commands/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub fn cli() -> Command {
3030
)
3131
.arg_features()
3232
.arg_release("Build artifacts in release mode, with optimizations")
33-
.arg_unsupported_mode("debug", "build", "release")
33+
.arg_redundant_default_mode("debug", "build", "release")
3434
.arg_profile("Build artifacts with the specified profile")
3535
.arg_parallel()
3636
.arg_target_triple("Build for the target triple")

src/bin/cargo/commands/install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub fn cli() -> Command {
8383
"debug",
8484
"Build in debug mode (with the 'dev' profile) instead of release mode",
8585
))
86-
.arg_unsupported_mode("release", "install", "debug")
86+
.arg_redundant_default_mode("release", "install", "debug")
8787
.arg_profile("Install artifacts with the specified profile")
8888
.arg_target_triple("Build for the target triple")
8989
.arg_target_dir()

src/cargo/util/command_prelude.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,15 @@ pub trait CommandExt: Sized {
112112
self._arg(flag("keep-going", "").value_parser(value_parser).hide(true))
113113
}
114114

115-
fn arg_unsupported_mode(
115+
fn arg_redundant_default_mode(
116116
self,
117-
want: &'static str,
117+
default_mode: &'static str,
118118
command: &'static str,
119-
actual: &'static str,
119+
supported_mode: &'static str,
120120
) -> Self {
121-
let msg = format!(
122-
"There is no `--{want}` for `cargo {command}`. Only `--{actual}` is supported."
123-
);
121+
let msg = format!("`--{default_mode}` is the default for `cargo {command}`; instead `--{supported_mode}` is supported");
124122
let value_parser = UnknownArgumentValueParser::suggest(msg);
125-
self._arg(flag(want, "").value_parser(value_parser).hide(true))
123+
self._arg(flag(default_mode, "").value_parser(value_parser).hide(true))
126124
}
127125

128126
fn arg_targets_all(

tests/testsuite/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ fn incremental_config() {
136136
}
137137

138138
#[cargo_test]
139-
fn cargo_compile_with_unsupported_mode() {
139+
fn cargo_compile_with_redundant_default_mode() {
140140
let p = project()
141141
.file("Cargo.toml", &basic_bin_manifest("foo"))
142142
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
@@ -147,7 +147,7 @@ fn cargo_compile_with_unsupported_mode() {
147147
"\
148148
error: unexpected argument '--debug' found
149149
150-
tip: There is no `--debug` for `cargo build`. Only `--release` is supported.
150+
tip: `--debug` is the default for `cargo build`; instead `--release` is supported
151151
152152
Usage: cargo[EXE] build [OPTIONS]
153153

tests/testsuite/install.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2445,15 +2445,15 @@ fn ambiguous_registry_vs_local_package() {
24452445
}
24462446

24472447
#[cargo_test]
2448-
fn install_with_unsupported_mode() {
2448+
fn install_with_redundant_default_mode() {
24492449
pkg("foo", "0.0.1");
24502450

24512451
cargo_process("install foo --release")
24522452
.with_stderr(
24532453
"\
24542454
error: unexpected argument '--release' found
24552455
2456-
tip: There is no `--release` for `cargo install`. Only `--debug` is supported.
2456+
tip: `--release` is the default for `cargo install`; instead `--debug` is supported
24572457
24582458
Usage: cargo[EXE] install [OPTIONS] [crate]...
24592459

0 commit comments

Comments
 (0)