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 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(){