Skip to content

Commit 1366ad3

Browse files
authored
Rollup merge of rust-lang#113259 - MU001999:diag/add-std, r=Nilstrieb
Suggest `x build library` for a custom toolchain that fails to load `core` Fixes rust-lang#113222 r? `@jyn514`
2 parents 0aac35d + b913f55 commit 1366ad3

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

compiler/rustc_metadata/messages.ftl

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ metadata_conflicting_alloc_error_handler =
2525
metadata_conflicting_global_alloc =
2626
the `#[global_allocator]` in {$other_crate_name} conflicts with global allocator in: {$crate_name}
2727
28+
metadata_consider_adding_std =
29+
consider adding the standard library to the sysroot with `x build library --target {$locator_triple}`
30+
2831
metadata_consider_building_std =
2932
consider building the standard library from source with `cargo build -Zbuild-std`
3033

compiler/rustc_metadata/src/errors.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -646,12 +646,18 @@ impl IntoDiagnostic<'_> for CannotFindCrate {
646646
} else {
647647
diag.note(fluent::metadata_target_no_std_support);
648648
}
649-
// NOTE: this suggests using rustup, even though the user may not have it installed.
650-
// That's because they could choose to install it; or this may give them a hint which
651-
// target they need to install from their distro.
649+
652650
if self.missing_core {
653-
diag.help(fluent::metadata_consider_downloading_target);
651+
if env!("CFG_RELEASE_CHANNEL") == "dev" {
652+
diag.help(fluent::metadata_consider_adding_std);
653+
} else {
654+
// NOTE: this suggests using rustup, even though the user may not have it installed.
655+
// That's because they could choose to install it; or this may give them a hint which
656+
// target they need to install from their distro.
657+
diag.help(fluent::metadata_consider_downloading_target);
658+
}
654659
}
660+
655661
// Suggest using #![no_std]. #[no_core] is unstable and not really supported anyway.
656662
// NOTE: this is a dummy span if `extern crate std` was injected by the compiler.
657663
// If it's not a dummy, that means someone added `extern crate std` explicitly and

0 commit comments

Comments
 (0)