Skip to content

Commit 2d75c09

Browse files
authored
Merge pull request #2732 from jyn514/platform
Give a better error when std is missing for a target
2 parents d6db55d + 495a682 commit 2d75c09

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/errors.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,16 @@ error_chain! {
355355
}
356356
UnknownComponent(t: String, c: String, s: Option<String>) {
357357
description("toolchain does not contain component")
358-
display("toolchain '{}' does not contain component {}{}", t, c, if let Some(suggestion) = s {
359-
format!("; did you mean '{}'?", suggestion)
360-
} else {
361-
"".to_string()
362-
})
358+
display("toolchain '{}' does not contain component {}{}{}", t, c, if let Some(suggestion) = s {
359+
format!("; did you mean '{}'?", suggestion)
360+
} else {
361+
"".to_string()
362+
}, if c.contains("rust-std") {
363+
format!("\nnote: not all platforms have the standard library pre-compiled: https://doc.rust-lang.org/nightly/rustc/platform-support.html{}",
364+
if t.contains("nightly") { "\nhelp: consider using `cargo build -Z build-std` instead" } else { "" }
365+
)
366+
} else { "".to_string() }
367+
)
363368
}
364369
UnknownProfile(p: String) {
365370
description("unknown profile name")

tests/cli-v2.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,9 @@ fn add_target_bogus() {
784784
expect_err(
785785
config,
786786
&["rustup", "target", "add", "bogus"],
787-
"does not contain component 'rust-std' for target 'bogus'",
787+
"does not contain component 'rust-std' for target 'bogus'\n\
788+
note: not all platforms have the standard library pre-compiled: https://doc.rust-lang.org/nightly/rustc/platform-support.html\n\
789+
help: consider using `cargo build -Z build-std` instead",
788790
);
789791
});
790792
}

0 commit comments

Comments
 (0)