From 9098bb5c644f62e04dbcc11345d3ffa1d55b3662 Mon Sep 17 00:00:00 2001 From: Angelo Ross Date: Wed, 30 Aug 2023 16:17:01 -0300 Subject: [PATCH 1/2] Use rustc as fallback for --target completion --- src/etc/cargo.bashcomp.sh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/etc/cargo.bashcomp.sh b/src/etc/cargo.bashcomp.sh index 33f225ebf39..7c2ccfa3ad3 100644 --- a/src/etc/cargo.bashcomp.sh +++ b/src/etc/cargo.bashcomp.sh @@ -250,15 +250,11 @@ _get_examples(){ } _get_targets(){ - local result=() - local targets=$(rustup target list) - while read line - do - if [[ "$line" =~ default|installed ]]; then - result+=("${line%% *}") - fi - done <<< "$targets" - echo "${result[@]}" + if command -v rustup >/dev/null 2>/dev/null; then + rustup target list --installed + else + rustc --print target-list + fi } _toolchains(){ From b5c97d458113705e3639c36bd40021543f32cd49 Mon Sep 17 00:00:00 2001 From: Angelo Ross Date: Wed, 30 Aug 2023 17:25:23 -0300 Subject: [PATCH 2/2] Prefer rustup on --target completion --- src/etc/_cargo | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/etc/_cargo b/src/etc/_cargo index a017b51c552..a4c1949ae2a 100644 --- a/src/etc/_cargo +++ b/src/etc/_cargo @@ -407,9 +407,15 @@ _cargo_cmds() { } _cargo_target_triple() { - local -a targets - targets=( ${(f)"$(rustc --print target-list)"} ) - _describe 'target triple' targets + local -a result + + if (( $+commands[rustup] )); then + result=( ${(f)"$(rustup target list --installed)"} ) + else + result=( ${(f)"$(rustc --print target-list)"} ) + fi + + _describe 'target triple' result } #FIXME: Disabled until fixed