Auto merge of #14564 - epage:rustup, r=weihanglo

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
This commit is contained in:
bors 2024-09-19 21:10:23 +00:00
commit eaee77dc15

View File

@ -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;
}
}