Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions src/toolchain/distributable.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[cfg(windows)]
use std::fs;
use std::{convert::Infallible, env::consts::EXE_SUFFIX, ffi::OsStr, process::Command};
use std::{convert::Infallible, env::consts::EXE_SUFFIX, ffi::OsStr, ops::Deref, process::Command};

#[cfg(windows)]
use anyhow::Context;
Expand Down Expand Up @@ -336,15 +336,12 @@ impl<'a> DistributableToolchain<'a> {
}

// Check if the target is installed.
if !config
.components
.iter()
.any(|c| c.target() == component.target())
if let Some(target) = component.target.as_ref()
&& !config
.components
.iter()
.any(|c| c.target() == target.deref())
{
let target = component
.target
.as_ref()
.expect("component target should be known");
let suggestion = TargetSuggestion::from_target(
&self.desc,
target,
Expand Down
17 changes: 17 additions & 0 deletions tests/suite/cli_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2361,6 +2361,23 @@ help: did you mean 'rustc'?
.is_err();
}

#[tokio::test]
async fn remove_targetless_component_not_installed() {
let cx = CliTestContext::new(Scenario::SimpleV2).await;
cx.config
.expect(["rustup", "default", "stable"])
.await
.is_ok();
cx.config
.expect(["rustup", "component", "remove", "rust-src"])
.await
.with_stderr(snapbox::str![[r#"
error: toolchain 'stable-[HOST_TUPLE]' does not contain component 'rust-src'

"#]])
.is_err();
}

#[tokio::test]
async fn add_target_suggest_best_match() {
let cx = CliTestContext::new(Scenario::SimpleV2).await;
Expand Down
Loading