Skip to content

Commit

Permalink
fix(complete): Always check rustup for --target
Browse files Browse the repository at this point in the history
clap-rs/clap#5733 removed the rustup proxy so that
`CARGO_COMPLETE=bash cargo +nightly` works
(with a side benefit of removing the proxy overhead).

As a downside, cargo no longer knows it is running within rustup, so we
aren't reading `--target` candidates from rustup.

This changes the code to always try rustup.  It is likely a good enough
source, even if the user isn't currently using it.
The candidates should be about the same, just rustup hides some by
default.
Hiding just means it isn't shown by default but if only hidden
candidates match, then we show them.
  • Loading branch information
epage committed Sep 18, 2024
1 parent 397a180 commit a5c25f3
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/cargo/util/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1121,10 +1121,8 @@ 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 = targets;
}
if let Ok(targets) = get_target_triples_from_rustup() {
candidates = targets;
}

if candidates.is_empty() {
Expand Down

0 comments on commit a5c25f3

Please sign in to comment.