|
| 1 | +#compdef rustc |
| 2 | + |
| 3 | +local -a _rustc_opts_switches _rustc_opts_lint _rustc_opts_debug |
| 4 | + |
| 5 | +typeset -A opt_args |
| 6 | + |
| 7 | +_rustc_opts_switches=( |
| 8 | + --bin'[Compile an executable crate (default)]' |
| 9 | + -c'[Compile and assemble, but do not link]' |
| 10 | + --cfg'[Configure the compilation environment]' |
| 11 | + --emit-llvm'[Produce an LLVM bitcode file]' |
| 12 | + {-h,--help}'[Display this message]' |
| 13 | + -L'[Add a directory to the library search path]' |
| 14 | + --lib'[Compile a library crate]' |
| 15 | + --linker'[Program to use for linking instead of the default.]' |
| 16 | + --link-args'[FLAGS is a space-separated list of flags passed to the linker]' |
| 17 | + --ls'[List the symbols defined by a library crate]' |
| 18 | + --no-trans'[Run all passes except translation; no output]' |
| 19 | + -O'[Equivalent to --opt-level=2]' |
| 20 | + -o'[Write output to <filename>]' |
| 21 | + --opt-level'[Optimize with possible levels 0-3]' |
| 22 | + --out-dir'[Write output to compiler-chosen filename in <dir>]' |
| 23 | + --parse-only'[Parse only; do not compile, assemble, or link]' |
| 24 | + --pretty'[Pretty-print the input instead of compiling]' |
| 25 | + -S'[Compile only; do not assemble or link]' |
| 26 | + --save-temps'[Write intermediate files (.bc, .opt.bc, .o) in addition to normal output]' |
| 27 | + --sysroot'[Override the system root]' |
| 28 | + --test'[Build a test harness]' |
| 29 | + --target'[Target triple cpu-manufacturer-kernel\[-os\] to compile]' |
| 30 | + --target-feature'[Target specific attributes (llc -mattr=help for detail)]' |
| 31 | + --android-cross-path'[The path to the Android NDK]' |
| 32 | + {-W,--warn}'[Set lint warnings]' |
| 33 | + {-A,--allow}'[Set lint allowed]' |
| 34 | + {-D,--deny}'[Set lint denied]' |
| 35 | + {-F,--forbid}'[Set lint forbidden]' |
| 36 | + -Z'[Set internal debugging options]' |
| 37 | + {-v,--version}'[Print version info and exit]' |
| 38 | +) |
| 39 | + |
| 40 | +_rustc_opts_lint=( |
| 41 | + 'path-statement:path statements with no effect' |
| 42 | + 'deprecated-pattern:warn about deprecated uses of pattern bindings' |
| 43 | + 'non-implicitly-copyable-typarams:passing non implicitly copyable types as copy type params' |
| 44 | + 'missing-trait-doc:detects missing documentation for traits' |
| 45 | + 'missing-struct-doc:detects missing documentation for structs' |
| 46 | + 'ctypes:proper use of core::libc types in foreign modules' |
| 47 | + 'implicit-copies:implicit copies of non implicitly copyable data' |
| 48 | + "unused-mut:detect mut variables which don't need to be mutable" |
| 49 | + 'unused-imports:imports that are never used' |
| 50 | + 'heap-memory:use of any (~ type or @ type) heap memory' |
| 51 | + 'default-methods:allow default methods' |
| 52 | + 'unused-variable:detect variables which are not used in any way' |
| 53 | + 'dead-assignment:detect assignments that will never be read' |
| 54 | + 'unrecognized-lint:unrecognized lint attribute' |
| 55 | + 'type-limits:comparisons made useless by limits of the types involved' |
| 56 | + 'unused-unsafe:unnecessary use of an `unsafe` block' |
| 57 | + 'while-true:suggest using loop { } instead of while(true) { }' |
| 58 | + 'non-camel-case-types:types, variants and traits should have camel case names' |
| 59 | + 'managed-heap-memory:use of managed (@ type) heap memory' |
| 60 | + 'unnecessary-allocation:detects unnecessary allocations that can be eliminated' |
| 61 | + 'owned-heap-memory:use of owned (~ type) heap memory' |
| 62 | +) |
| 63 | + |
| 64 | +_rustc_opts_debug=( |
| 65 | + 'verbose:in general, enable more debug printouts' |
| 66 | + 'time-passes:measure time of each rustc pass' |
| 67 | + 'count-llvm-insns:count where LLVM instrs originate' |
| 68 | + 'time-llvm-passes:measure time of each LLVM pass' |
| 69 | + 'trans-stats:gather trans statistics' |
| 70 | + 'asm-comments:generate comments into the assembly (may change behavior)' |
| 71 | + 'no-verify:skip LLVM verification' |
| 72 | + 'trace:emit trace logs' |
| 73 | + 'coherence:perform coherence checking' |
| 74 | + 'borrowck-stats:gather borrowck statistics' |
| 75 | + "borrowck-note-pure:note where purity is req'd" |
| 76 | + "borrowck-note-loan:note where loans are req'd" |
| 77 | + 'no-landing-pads:omit landing pads for unwinding' |
| 78 | + 'debug-llvm:enable debug output from LLVM' |
| 79 | + 'count-type-sizes:count the sizes of aggregate types' |
| 80 | + 'meta-stats:gather metadata statistics' |
| 81 | + 'no-opt:do not optimize, even if -O is passed' |
| 82 | + 'no-monomorphic-collapse:do not collapse template instantiations' |
| 83 | + 'print-link-args:Print the arguments passed to the linker' |
| 84 | + 'gc:Garbage collect shared data (experimental)' |
| 85 | + 'jit:Execute using JIT (experimental)' |
| 86 | + 'extra-debug-info:Extra debugging info (experimental)' |
| 87 | + 'debug-info:Produce debug info (experimental)' |
| 88 | + 'static:Use or produce static libraries or binaries (experimental)' |
| 89 | + 'no-debug-borrows:do not show where borrow checks fail' |
| 90 | + 'lint-llvm:Run the LLVM lint pass on the pre-optimization IR' |
| 91 | +) |
| 92 | + |
| 93 | +_rustc() { |
| 94 | + case $words[2] in |
| 95 | + -[WADF]) _describe 'options' _rustc_opts_lint ;; |
| 96 | + -Z) _describe 'options' _rustc_opts_debug ;; |
| 97 | + -) _arguments -s -w : "$_rustc_opts_switches[@]" ;; |
| 98 | + *) _files -g "*.rs" ;; |
| 99 | + esac |
| 100 | +} |
| 101 | + |
| 102 | +_rustc "$@" |
0 commit comments