Skip to content

Commit

Permalink
Auto merge of #14564 - epage:rustup, r=weihanglo
Browse files Browse the repository at this point in the history
fix(complete): Harden `--target` completions

### What does this PR try to resolve?

I found `--target` wasn't working with rustup as I expected, so this fixes it.  We generally only reference rustup if we are running under it but I think in UX code like this, with a fallback scheme, this should be reasonable enough.

### How should we test and review this PR?

### Additional information
  • Loading branch information
bors committed Sep 19, 2024
2 parents 9d5c149 + a5c25f3 commit eaee77d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/cargo/util/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1121,13 +1121,13 @@ fn get_targets_from_metadata() -> CargoResult<Vec<Target>> {
fn get_target_triples() -> Vec<clap_complete::CompletionCandidate> {
let mut candidates = Vec::new();

if is_rustup() {
if let Ok(targets) = get_target_triples_from_rustup() {
candidates.extend(targets);
}
} else {
if let Ok(targets) = get_target_triples_from_rustup() {
candidates = targets;
}

if candidates.is_empty() {
if let Ok(targets) = get_target_triples_from_rustc() {
candidates.extend(targets);
candidates = targets;
}
}

Expand Down

0 comments on commit eaee77d

Please sign in to comment.