Skip to content

Commit adea3d1

Browse files
committed
fix(cli): Help people find possible --target values
1 parent fe37a36 commit adea3d1

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/cargo/util/command_prelude.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::core::{Edition, Workspace};
44
use crate::ops::{CompileFilter, CompileOptions, NewOptions, Packages, VersionControl};
55
use crate::util::important_paths::find_root_manifest_for_wd;
66
use crate::util::interning::InternedString;
7+
use crate::util::is_rustup;
78
use crate::util::restricted_names::is_glob_pattern;
89
use crate::util::toml::{StringOrVec, TomlProfile};
910
use crate::util::validate_package_name;
@@ -445,7 +446,16 @@ pub trait ArgMatchesExt {
445446

446447
fn targets(&self) -> CargoResult<Vec<String>> {
447448
if self.is_present_with_zero_values("target") {
448-
bail!("\"--target\" takes an argument.");
449+
let cmd = if is_rustup() {
450+
"rustup target list"
451+
} else {
452+
"rustc --print target-list"
453+
};
454+
bail!(
455+
"\"--target\" takes an argument.
456+
457+
Run `{cmd}` to see possible targets."
458+
);
449459
}
450460
Ok(self._values_of("target"))
451461
}

tests/testsuite/list_availables.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ No tests available.
167167
.with_stderr(
168168
"\
169169
error: \"--target\" takes an argument.
170+
171+
Run `[..]` to see possible targets.
170172
",
171173
)
172174
.with_status(101)

0 commit comments

Comments
 (0)