Rollup merge of #113259 - MU001999:diag/add-std, r=Nilstrieb

Suggest `x build library` for a custom toolchain that fails to load `core`

Fixes #113222

r? `@jyn514`
This commit is contained in:
Matthias Krüger 2023-07-02 23:30:47 +02:00 committed by GitHub
commit 1366ad36a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -25,6 +25,9 @@ metadata_conflicting_alloc_error_handler =
metadata_conflicting_global_alloc =
the `#[global_allocator]` in {$other_crate_name} conflicts with global allocator in: {$crate_name}
metadata_consider_adding_std =
consider adding the standard library to the sysroot with `x build library --target {$locator_triple}`
metadata_consider_building_std =
consider building the standard library from source with `cargo build -Zbuild-std`

View File

@ -646,12 +646,18 @@ impl IntoDiagnostic<'_> for CannotFindCrate {
} else {
diag.note(fluent::metadata_target_no_std_support);
}
if self.missing_core {
if env!("CFG_RELEASE_CHANNEL") == "dev" {
diag.help(fluent::metadata_consider_adding_std);
} else {
// NOTE: this suggests using rustup, even though the user may not have it installed.
// That's because they could choose to install it; or this may give them a hint which
// target they need to install from their distro.
if self.missing_core {
diag.help(fluent::metadata_consider_downloading_target);
}
}
// Suggest using #![no_std]. #[no_core] is unstable and not really supported anyway.
// NOTE: this is a dummy span if `extern crate std` was injected by the compiler.
// If it's not a dummy, that means someone added `extern crate std` explicitly and