Skip to content

Commit ed2bfde

Browse files
committed
fix(config): call warn_if_host_is_incompatible() in ensure_install()
1 parent 32e3338 commit ed2bfde

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/config.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ use tokio_stream::StreamExt;
1111
use tracing::trace;
1212

1313
use crate::{
14-
cli::self_update::SelfUpdateMode,
15-
dist::{self, download::DownloadCfg, temp, PartialToolchainDesc, Profile, ToolchainDesc},
14+
cli::{common, self_update::SelfUpdateMode},
15+
dist::{
16+
self, download::DownloadCfg, temp, PartialToolchainDesc, Profile, TargetTriple,
17+
ToolchainDesc,
18+
},
1619
errors::RustupError,
1720
fallback_settings::FallbackSettings,
1821
install::UpdateStatus,
@@ -788,6 +791,12 @@ impl<'a> Cfg<'a> {
788791
profile: Option<Profile>,
789792
verbose: bool,
790793
) -> Result<(UpdateStatus, Toolchain<'_>)> {
794+
common::warn_if_host_is_incompatible(
795+
toolchain,
796+
&TargetTriple::from_host_or_build(self.process),
797+
&toolchain.target,
798+
false,
799+
)?;
791800
if verbose {
792801
(self.notify_handler)(Notification::LookingForToolchain(toolchain));
793802
}

tests/suite/cli_rustup.rs

+13
Original file line numberDiff line numberDiff line change
@@ -2725,6 +2725,19 @@ warn: If you meant to build software to target that platform, perhaps try `rustu
27252725
).await;
27262726
}
27272727

2728+
#[tokio::test]
2729+
async fn warn_on_unmatch_build_default() {
2730+
let cx = CliTestContext::new(Scenario::MultiHost).await;
2731+
let arch = clitools::MULTI_ARCH1;
2732+
cx.config.expect_stderr_ok(
2733+
&["rustup", "default", &format!("nightly-{arch}")],
2734+
&format!(
2735+
r"warn: toolchain 'nightly-{arch}' may not be able to run on this system.
2736+
warn: If you meant to build software to target that platform, perhaps try `rustup target add {arch}` instead?",
2737+
),
2738+
).await;
2739+
}
2740+
27282741
#[tokio::test]
27292742
async fn dont_warn_on_partial_build() {
27302743
let cx = CliTestContext::new(Scenario::SimpleV2).await;

0 commit comments

Comments
 (0)