Prevent error output on invocation of rustc completions

fish was indiscriminately calling `rustc -Z help` in the autocompletion
script for `rustc`, but `-Z` (and its `-Z help` output completions) is
only available when using the nightly compiler.

Note that this isn't a perfect fix since if you try to use those command
line options now added to the autocompletions list without using the
nightly toolchain, `rustc` will still throw an error. But at least this
way we don't cause random errors about `-Z` not being available to
appear any time someone tries to use `rustc` from the fish command prompt.
This commit is contained in:
Mahmoud Al-Qudsi 2017-10-18 11:47:21 -05:00
parent 5196354176
commit e1c90cac88

View file

@ -36,16 +36,19 @@ for line in $rust_docs
complete -c rustc -x -s C -l codegen -a "$flag" -d "$docs[2]" complete -c rustc -x -s C -l codegen -a "$flag" -d "$docs[2]"
end end
set -l rust_docs (rustc -Z help \ # rustc -Z is only available with the nightly toolchain, which may not be installed
| string replace -r -i '(\s+)-Z(.+)--(\s+)([^\n]+)' '$2 $4' \ if rustc +nightly >/dev/null 2>&1
| string trim \ set -l rust_docs (rustc +nightly -Z help \
| string match -r '^.*[^:]$') | string replace -r -i '(\s+)-Z(.+)--(\s+)([^\n]+)' '$2 $4' \
| string trim \
| string match -r '^.*[^:]$')
for line in $rust_docs for line in $rust_docs
set docs (string split -m 1 ' ' $line) set docs (string split -m 1 ' ' $line)
set flag (string replace -r '^([a-z\-]+\=|[a-z\-]+)(.*)' '$1' \ set flag (string replace -r '^([a-z\-]+\=|[a-z\-]+)(.*)' '$1' \
$docs[1]) $docs[1])
complete -c rustc -x -s Z -a "$flag" -d "$docs[2]" complete -c rustc -x -s Z -a "$flag" -d "$docs[2]"
end
end end
set -l rust_docs (rustc -W help \ set -l rust_docs (rustc -W help \