Files
emacsd/elpa/rust-mode-20191023.918/rust-mode.elc

318 lines
41 KiB
Plaintext
Raw Normal View History

2019-10-09 20:36:55 +02:00
;ELC
;;; Compiled
2019-10-27 19:05:34 +01:00
;;; in Emacs version 26.3
2019-10-09 20:36:55 +02:00
;;; with all optimizations.
;;; This file uses dynamic docstrings, first added in Emacs 19.29.
;;; This file does not contain utf-8 non-ASCII characters,
;;; and so can be loaded in Emacs versions earlier than 23.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(byte-code "\300\301!\210\302\303!\207" [require json make-variable-buffer-local rust-buffer-project] 2)
(defconst rust-re-ident "[[:word:][:multibyte:]_][[:word:][:multibyte:]_[:digit:]]*")
(defconst rust-re-lc-ident "[[:lower:][:multibyte:]_][[:word:][:multibyte:]_[:digit:]]*")
(defconst rust-re-uc-ident "[[:upper:]][[:word:][:multibyte:]_[:digit:]]*")
(defconst rust-re-vis "pub")
(defconst rust-re-unsafe "unsafe")
(defconst rust-re-extern "extern")
(defconst rust-re-generic (concat "<[[:space:]]*'" rust-re-ident "[[:space:]]*>"))
(defconst rust-re-union (byte-code "\301\302\303\304\305\306D\257!\207" [rust-re-ident rx-to-string seq (or space line-start) (group symbol-start "union" symbol-end) (+ space) regexp] 7))
(defvar rust-top-item-beg-re "\\s-*\\(?:priv\\|pub\\)?\\s-*\\(?:e\\(?:num\\|xtern\\)\\|fn\\|impl\\|mod\\|st\\(?:atic\\|ruct\\)\\|t\\(?:rait\\|ype\\)\\|u\\(?:nion\\|se\\)\\)\\_>")
#@169 Return non-nil if there's a match on the text before point and STR.
Like `looking-back' but for fixed strings rather than regexps (so that it's not so slow).
(fn STR)
(defalias 'rust-looking-back-str #[257 "\211G`V\205\300`Z`\"\232\207" [buffer-substring-no-properties] 6 (#$ . 1317)])
#@118 Return non-nil if the point is just after a complete symbol that is a member of the list of strings SYMS.
(fn SYMS)
(defalias 'rust-looking-back-symbols #[257 "\212`\300\301\302\"\210`\300\301\303\"\210`\211U\205\304\"\235\266\203)\207" [forward-thing symbol -1 1 buffer-substring-no-properties] 7 (#$ . 1616)])
#@65 Non-nil if we are looking backwards at a valid rust identifier.
(defalias 'rust-looking-back-ident #[0 "\212\301\302\303\"\210`)\304\"\207" [rust-re-ident forward-thing symbol -1 looking-back] 4 (#$ . 1941)])
#@53 Non-nil if looking back at an ident followed by a !
(defalias 'rust-looking-back-macro #[0 "`eZ\300V\205\212\301u\210\302f\303U\205\304 )\207" [1 -1 nil 33 rust-looking-back-ident] 2 (#$ . 2158)])
(defvar rust-mode-syntax-table (byte-code "\300 \301\211\203\211@\302\303#\210A\266\202\202\210\302\304\305#\210\302\306\307#\210\302\310\311#\210\302\312\313#\210\302\314\315#\210\302\316\317#\210\302\320\321#\210\302\322\321#\210\211\207" [make-syntax-table (43 45 42 47 37 38 124 94 33 60 62 126 64) modify-syntax-entry "." 34 "\"" 92 "\\" 60 "(>" 62 ")<" 47 ". 124b" 42 ". 23n" 10 "> b" 13] 7))
(byte-code "\300\301\302\303\304\305\306\307&\210\310\311\312\313\314DD\315\316\317\306\301\320\321& \210\310\322\312\313\323DD\324\316\325\306\301\320\326& \210\310\327\312\313\330DD\331\316\325\306\301\320\326& \210\310\332\312\313\333DD\334\316\325\306\301\320\326& \210\310\335\312\313\336DD\337\316\340\306\301&\210\310\341\312\313\342DD\343\316\340\306\301&\210\310\344\312\313\345DD\346\316\325\320\326\306\301& \210\310\347\312\313\350DD\351\316\325\320\326\306\301& \210\310\352\312\313\353DD\354\316\340\306\301&\210\310\355\312\313\356DD\357\316\340\306\301&\210\310\360\312\313\361DD\362\316\325\306\301&\210\363\364\365\366\306\301%\210\363\367\370\371\306\301%\210\363\372\373\374\306\301%\210\363\375\376\377\306\301%\207" [custom-declare-group rust-mode nil "Support for Rust code." :link (url-link "https://www.rust-lang.org/") :group languages custom-declare-variable rust-indent-offset funcall function #[0 "\300\207" [4] 1] "Indent Rust code by this number of spaces." :type integer :safe integerp rust-indent-method-chain #[0 "\300\207" [nil] 1] "Indent Rust method chains, aligned by the `.' operators." boolean booleanp rust-indent-where-clause #[0 "\300\207" [nil] 1] "Indent lines starting with the `where' keyword following a function or trait.\nWhen nil, `where' will be aligned with `fn' or `trait'." rust-indent-return-type-to-arguments #[0 "\300\207" [t] 1] "Indent a line starting with the `->' (RArrow) following a function, aligning\nto the function arguments. When nil, `->' will be indented one level." rust-playpen-url-format #[0 "\300\207" [#1="https://play.rust-lang.org/?code=%s"] 1 #1#] "Format string to use when submitting code to the playpen." string rust-shortener-url-format #[0 "\300\207" [#2="https://is.gd/create.php?format=simple&url=%s"] 1 #2#] "Format string to use for creating the shortened link of a playpen submission." rust-match-angle-brackets #[0 "\300\207" [t] 1] "Whether to attempt angle bracket matching (`<' and `>') where appropriate." rust-format-on-save #[0 "\300\207" [nil] 1] "Format future rust buffers before saving using rustfmt." rust-rustfmt-bin #[0 "\300\207" [#3="rustfmt"] 1 #3#] "Path to rustfmt executable." rust-cargo-bin #[0 "\300\207" [#4="cargo"] 1 #4#] "Path to cargo executable." rust-always-locate-project-on-open #[0 "\300\207" [nil] 1] "Whether to run `cargo locate-project' every time `rust-mode' is activated." custom-declare-face rust-unsafe-face ((t :inherit font-lock-warning-face)) "Face for the `unsafe' keyword." rust-question-mark-face ((t :weight bold :inherit font-lock-builtin-face)) "Face for the question mark operator." rust-builtin-formatting-macro-face ((t :inherit font-lock-builtin-face)) "Face for builtin formatting macros (print! &c.)." rust-string-interpolation-face ((t :slant italic :inherit font-lock-string-face)) "Face for interpolating braces in builtin formatting macro strings."] 10)
(defalias 'rust-paren-level #[0 "\300 @\207" [syntax-ppss] 1])
(defalias 'rust-in-str #[0 "\300\301 8\207" [3 syntax-ppss] 2])
(defalias 'rust-in-str-or-cmnt #[0 "\300\301 8\207" [8 syntax-ppss] 2])
(defalias 'rust-rewind-past-str-cmnt #[0 "\300\301 8b\207" [8 syntax-ppss] 2])
(defalias 'rust-rewind-irrelevant #[0 "\300\211\205$`\301\302x\210\303\304!\203\305u\210\306 \203\307 \210\211`U?\266\202\202\207" [t "[:space:]\n" nil rust-looking-back-str "*/" -1 rust-in-str-or-cmnt rust-rewind-past-str-cmnt] 4])
(defalias 'rust-in-macro #[0 "\212\300 \301V\205(\302 \210\303 \210\304 \206(\305 \203&\212\306 \210\303 \210\307\310!)\206(\311 )\207" [rust-paren-level 0 backward-up-list rust-rewind-irrelevant rust-looking-back-macro rust-looking-back-ident backward-sexp rust-looking-back-str "macro_rules!" rust-in-macro] 2])
#@47 Return T when looking at the "where" keyword.
(defalias 'rust-looking-at-where #[0 "\301\302\303!)\262\205\304 ?\207" [inhibit-changing-match-data "\\bwhere\\b" t looking-at rust-in-str-or-cmnt] 3 (#$ . 6524)])
#@223 Rewind the point to the closest occurrence of the "where" keyword.
Return T iff a where-clause was found. Does not rewind past
LIMIT when passed, otherwise only stops at the beginning of the
buffer.
(fn &optional LIMIT)
(defalias 'rust-rewind-to-where #[256 "\300\301\302#\205\303 \203\304!\207\302\207" [re-search-backward "\\bwhere\\b" t rust-in-str-or-cmnt rust-rewind-to-where] 5 (#$ . 6747)])
(defalias 'rust-align-to-expr-after-brace #[0 "\212\300u\210\301\302!?\205\301\303!\203\304v\210\305v\210i)\207" [nil looking-at "[[:blank:]]*\\(?://.*\\)?$" "[[:space:]]" 1 -1] 2])
(defalias 'rust-rewind-to-beginning-of-current-level-expr #[0 "\300 \301 \210\302\303!\203\304 \210\301 \210\300 V\203!\305 \210\301 \210\202\306\211\212\307 \210\301 \210`\262\300 \262)\310 \204E\212\311!)\205GU\205Gb\266\202\207" [rust-paren-level back-to-indentation looking-at "->" rust-rewind-irrelevant backward-up-list nil rust-beginning-of-defun rust-looking-at-where rust-rewind-to-where] 5])
(defalias 'rust-align-to-method-chain #[0 "\212\301\302P!\205E\303y\210\304\210\305 \306 \204\307\310\311 \"\203.\305 U\203.\303y\210\304\210\202\210\312\307\313`S\"\203A\314\315!\210\211 \202C\211 \262)\207" [rust-re-ident looking-at " *." -1 nil rust-paren-level rust-in-str-or-cmnt looking-back "^ *" point-at-bol #[0 "\301 \205\212\302\303\304\"\210`Sf\305U)\205\302\303\304\"\210\304u\210iZ\207" [rust-indent-offset rust-looking-back-ident forward-thing symbol -1 46] 3] "[)?]" backward-list 1] 4])
2019-10-27 19:05:34 +01:00
(defalias 'rust-mode-indent-line #[0 "\212\306 \210\307 \211\310U\203\310\202'\203\311 \206'\212\312 \210\313 \210\314 \210i \\)\315\316 8\203\206\317\316 8\320`e\"?\205=\321\310!f\322U?\205\201\211\205\201\211V\205\201\211\206T`Sf\323U\205\201\320\"\203x\211Z\324V\203t\212Tb\210i)\202\201\202\201\212\211b\210\306 \210i)\266\202\202X\n\203\240\325\326!\203\240\212\327 \210\330 \206\234\211 \\)\202X\325\331!\203\254\211 Z\202X\332\316 8\203\276\325\333!\203\276\211T\202X \204\313\334 \203\313\211\202X\310V\203\336\212\312 \210\313 \210\330 )\206X\212\335\211\212\335\210\336 \210\306 \210`\262\307 \262)\334 ?\205\325\f\337P!\205\340!\205\211U\205\341u\210l\203 \\\202\342\335w\210i\266\202)\206X\306 \210\325\343!\204Q\325 !\204Q\212\312 \210`\344U\206M\345\346`\324Z\"\206M\314 \210\325\347!)\203U\211\202X\211 \\\266\202)\211\205qi\350 X\203l\351!\202q\212\351!)\207" [rust-indent-method-chain rust-indent-offset rust-indent-return-type-to-arguments rust-indent-where-clause rust-re-ident rust-top-item-beg-re back-to-indentation rust-paren-level 0 rust-align-to-method-chain rust-rewind-irrelevant backward-up-list rust-rewind-to-beginning-of-current-level-expr 3 syntax-ppss 8 rust--same-line-p line-end-position 114 92 2 looking-at "->" backward-list rust-align-to-expr-after-brace "[]})]" 4 "*" rust-looking-at-where nil rust-beginning-of-defun ":" rust-rewind-to-where 5 "[:space:]" "\\<else\\>\\|{\\|/[/*]" 1 looking-back "[(,:;[{}]\\|[^|]|" "#" current-indentation indent-line-to] 7 nil nil])
#@71 Return non-nil if POS1 and POS2 are on the same line.
(fn POS1 POS2)
(defalias 'rust--same-line-p #[514 "\212b\210\300 b\210\300 U)\207" [line-end-position] 4 (#$ . 9864)])
2019-10-09 20:36:55 +02:00
(defconst rust-mode-keywords '("as" "async" "await" "box" "break" "const" "continue" "crate" "do" "dyn" "else" "enum" "extern" "false" "fn" "for" "if" "impl" "in" "let" "loop" "match" "mod" "move" "mut" "priv" "pub" "ref" "return" "self" "static" "struct" "super" "true" "trait" "type" "try" "use" "virtual" "where" "while" "yield"))
(defconst rust-special-types '("u8" "i8" "u16" "i16" "u32" "i32" "u64" "i64" "u128" "i128" "f32" "f64" "isize" "usize" "bool" "str" "char"))
(defconst rust-re-type-or-constructor "\\_<\\([[:upper:]][_[:digit:][:nonascii:][:word:]]*\\)\\_>")
(defconst rust-re-pre-expression-operators "[-=!%&*/:<>[{(|.^;}]")
#@14
(fn INNER)
2019-10-27 19:05:34 +01:00
(defalias 'rust-re-word #[257 "\300\301Q\207" ["\\<" "\\>"] 4 (#$ . 10688)])
2019-10-09 20:36:55 +02:00
#@14
(fn INNER)
2019-10-27 19:05:34 +01:00
(defalias 'rust-re-grab #[257 "\300\301Q\207" ["\\(" "\\)"] 4 (#$ . 10785)])
2019-10-09 20:36:55 +02:00
#@14
(fn INNER)
2019-10-27 19:05:34 +01:00
(defalias 'rust-re-shy #[257 "\300\301Q\207" ["\\(?:" "\\)"] 4 (#$ . 10882)])
2019-10-09 20:36:55 +02:00
#@14
(fn ITYPE)
2019-10-27 19:05:34 +01:00
(defalias 'rust-re-item-def #[257 "\302!\303!\304\305\306 !\260\207" [rust-re-generic rust-re-ident rust-re-word rust-re-shy "?" "[[:space:]]+" rust-re-grab] 7 (#$ . 10980)])
2019-10-09 20:36:55 +02:00
#@14
(fn ITYPE)
2019-10-27 19:05:34 +01:00
(defalias 'rust-re-item-def-imenu #[257 "\303\304\305!\306P!\307\304\305\310!\306P!\307\304\305 !\306P!\307\304\305\n!\306\304\311!\307R!\307\312\n!\260\n\207" [rust-re-vis rust-re-unsafe rust-re-extern "^[[:space:]]*" rust-re-shy rust-re-word "[[:space:]]+" "?" "default" "\"[^\"]+\"[[:space:]]+" rust-re-item-def] 13 (#$ . 11177)])
2019-10-09 20:36:55 +02:00
(defconst rust-re-special-types (regexp-opt rust-special-types 'symbols))
#@185 Match occurrences of RE-IDENT followed by a double-colon.
Examples include to match names like "foo::" or "Foo::".
Does not match type annotations of the form "foo::<".
(fn RE-IDENT)
2019-10-27 19:05:34 +01:00
(defalias 'rust-path-font-lock-matcher #[257 "\300\301\302\303\304\305\306\307\310\311\312\313\314 DD\315BBDDD\316B\317BBEEE\207" [lambda (limit) catch 'rust-path-font-lock-matcher while t let* symbol-then-colons rx-to-string quote seq group regexp ("::") ((match (re-search-forward symbol-then-colons limit t))) ((cond ((null match) (throw 'rust-path-font-lock-matcher nil)) ((not (looking-at (rx (0+ space) "<"))) (throw 'rust-path-font-lock-matcher match))))] 15 (#$ . 11607)])
2019-10-09 20:36:55 +02:00
#@174 Search forward from point for the next Rust interpolation marker before LIMIT.
Set point to the end of the occurrence found, and return match beginning
and end.
(fn LIMIT)
2019-10-27 19:05:34 +01:00
(defalias 'rust-next-string-interpolation #[257 "\3002B\301 \302\303\304\305\306!\307\"\310$\216\212\311\312\313#\205>\314`f\315\"\203)\316u\210\202\303\224\311\317\313#\203:\320\300`D\"\210\210\202*\2620\207" [match match-data make-byte-code 0 "\301\300\302\"\207" vconcat vector [set-match-data evaporate] 3 search-forward "{" t eql 123 nil "}" throw] 8 (#$ . 12280)])
2019-10-09 20:36:55 +02:00
#@147 Match the next Rust interpolation marker before LIMIT; set match data if found.
Returns nil if the point is not within a Rust string.
(fn LIMIT)
2019-10-27 19:05:34 +01:00
(defalias 'rust-string-interpolation-matcher #[257 "\300 \205\301!\211\205\302!\210\211A@b\210\211\262\207" [rust-in-str rust-next-string-interpolation set-match-data] 4 (#$ . 12844)])
2019-10-09 20:36:55 +02:00
#@124 List of builtin Rust macros for string formatting used by `rust-mode-font-lock-keywords' (`write!' is handled separately).
2019-10-27 19:05:34 +01:00
(defvar rust-builtin-formatting-macros '("eprint" "eprintln" "format" "print" "println") (#$ . 13189))
2019-10-09 20:36:55 +02:00
#@79 Regular expression to match the opening delimiter of a Rust formatting macro.
2019-10-27 19:05:34 +01:00
(defvar rust-formatting-macro-opening-re "[[:space:]\n]*[({[][[:space:]\n]*" (#$ . 13421))
2019-10-09 20:36:55 +02:00
#@61 Regular expression to match the start of a Rust raw string.
2019-10-27 19:05:34 +01:00
(defvar rust-start-of-string-re "\\(?:r#*\\)?\"" (#$ . 13596))
(defvar rust-mode-font-lock-keywords (byte-code "\306\307\310\"\311B\312 \313B\307\n\310\"\314B\315\316\317 \320Q!\321B\316\322\307\f!!\323P! \324,Q\325Q\326B\316\322\327!\323P! \330,QP\331B\316 \323P!\332P\333B\316 !\334P\335B-\336B\337\316 !\340Q\341B\342.!\343B\342/!\344B\345\316 !\346Q\347B\350BBBBBBBBBBBBBBB\351\352\353\"\"\207" [rust-mode-keywords rust-re-union rust-special-types rust-re-ident rust-builtin-formatting-macros rust-formatting-macro-opening-re append regexp-opt symbols font-lock-keyword-face ("\\_<\\(default\\)[[:space:]]+fn\\_>" 1 font-lock-keyword-face) (1 font-lock-keyword-face) font-lock-type-face ("\\_<unsafe\\_>" quote rust-unsafe-face) rust-re-grab "#\\!?\\[" "[^]]*\\]" (1 font-lock-preprocessor-face keep) rust-re-word "!" "\\(?:" "\\)?" ((1 'rust-builtin-formatting-macro-face) (rust-string-interpolation-matcher (rust-end-of-string) nil (0 'rust-string-interpolation-face t nil))) "write\\(ln\\)?" "[[:space:]]*[^\"]+,[[:space:]]*" ((1 'rust-builtin-formatting-macro-face) (rust-string-interpolation-matcher (rust-end-of-string) nil (0 'rust-string-interpolation-face t nil))) "[({[:space:][]" (1 font-lock-preprocessor-face) "[[:space:]]*:[^:]" (1 font-lock-variable-name-face) (1 font-lock-type-face) "\\_<\\(?:let\\s-+ref\\|let\\|ref\\|for\\)\\s-+\\(?:mut\\s-+\\)?" "\\_>" (1 font-lock-variable-name-face) rust-path-font-lock-matcher (1 font-lock-type-face) (1 font-lock-constant-face) "'" "[^']" (1 font-lock-variable-name-face) (("\\?" quote rust-question-mark-face)) mapcar #[257 "\300@!\301AE\207" [rust-re-item-def 1] 4 "\n\n(fn X)"] (("enum" . font-lock-type-face) ("struct" . font-lock-type-face) ("union" . font-lock-type-face) ("type" . font-lock-type-face) ("mod" . font-lock-constant-face) ("use" . font-lock-constant-face) ("fn" . font-lock-function-name-face)) rust-start-of-string-re rust-re-type-or-constructor rust-re-uc-ident rust-re-lc-ident] 18))
2019-10-09 20:36:55 +02:00
(defalias 'rust-syntax-class-before-point #[0 "`\300V\205\f\301\302`S!!\207" [1 syntax-class syntax-after] 3])
(defalias 'rust-rewind-qualified-ident #[0 "\300 \205\301 \210\212\302 \210\303\304!)\203\302 \210\305u\210\302 \210\202\207" [rust-looking-back-ident backward-sexp rust-rewind-irrelevant rust-looking-back-str "::" -2] 2])
(defalias 'rust-rewind-type-param-list #[0 "\300\301!\203\302 \303\232\203\304 \210\305 \207`Sf\306\235\205L\300\307!\212\304 \210\305 \210\300\310!\203>\311u\210\305 \210\300\307!\203>\304 \210`\206C\211\205C`)\211\205J\211b\266\202\207" [rust-looking-back-str ">" rust-syntax-class-before-point 5 backward-sexp rust-rewind-irrelevant (93 41) ")" "->" -2] 3])
#@276 Return the point at the beginning of the name in a declaration.
I.e. if we are before an ident that is part of a declaration that
can have a where clause, rewind back to just before the name of
the subject of that where clause and return the new point.
Otherwise return nil.
2019-10-27 19:05:34 +01:00
(defalias 'rust-rewind-to-decl-name #[0 "`\212\300 \210\301 \210\302\303!\203\211\202I\304 \305\232\203!\306 \210\307 \202I\310\311`S\"\2031\312u\210\307 \202I\313\314!\203?\315u\210\307 \202I\316 \205I\317 \210\307 )\211\203Q\211b\210\207" [rust-rewind-irrelevant rust-rewind-type-param-list rust-looking-back-symbols ("fn" "trait" "enum" "struct" "union" "impl" "type") rust-syntax-class-before-point 5 backward-sexp rust-rewind-to-decl-name looking-back "[:,'+=]" -1 rust-looking-back-str "->" -2 rust-looking-back-ident rust-rewind-qualified-ident] 4 (#$ . 16353)])
2019-10-09 20:36:55 +02:00
#@364 Return t if what comes right after the point is part of an
expression (as opposed to starting a type) by looking at what
comes before. Takes a symbol that roughly indicates what is
after the point.
This function is used as part of `rust-is-lt-char-operator' as
part of angle bracket matching, and is not intended to be used
outside of this context.
(fn TOKEN)
2019-10-27 19:05:34 +01:00
(defalias 'rust-is-in-expression-context #[257 "\212\301f\302 \210\303\235\203\304 \210\305\306!\203\307\202\347\305\310!\203#\301\202\347\311\232\2033\211\312\232\2033\301\202\347\311\232\203B\313 \203B\307\202\347\311=\203N\314\315!\206\347\316\232\203d\317 \320\232\203d\321 \210\322\311!\202\347\316\232\203~\305\323!\203~\321 \210\302 \210\324\325`S\"\202\347\326 \203[\327 \210\302 \210\311\232\203\260\211\330\235\203\233\322\316!\202\347\211\331\232\205\347\332 \205\254\302 \210\305\333!?\202\347\334\232\203!\211\335\232\203\300\307\202\347\211\336\232\203\340\324\337`\340Z\"\203\340\212\332 \205\333\302 \210\305\341!)?\206\347\211\336\232\203\360\305\342!\203\360\307\202\347\343 \344V\203\212\345 \210\302 \210\304 \210\326 \205\327 \210\302 \210\314\346!)\203\307\202\347\322\316!\205\347\307\202\347\347\232\205\347\343 \344X\2032\301\202\347\324\350`S\"\203W\345 \210\351\352!\205\347\302 \210\304 \210\326 \205\347\327 \210\322\316!\202\347\301\202\347\334\232\203l\317 \353\235\203l\307\202\347\347\232\203v\301\202\347\314\354!\203\200\301\202\347\314\355!\203\217\356u\210\322\347!\202\347\314\357!\203\231\301\202\347\317 \360\232\204\246\314\361!\203\271\3621\264\345 \210\322\311!0\202\347\210\301\202\347\314\363!\203\303\307\202\347\314\364!\203\315\307\202\347\324\365`S\"\203\336\356u\210\322\334!\202\347\324`S\"\205\347\307\262)\207" [rust-re-pre-expression-operators nil rust-rewind-irrelevant (ambiguous-operator open-brace) rust-rewind-type-param-list rust-looking-back-symbols ("if" "while" "match" "return" "box" "in") t ("as") open-brace 60 rust-looking-back-macro rust-looking-back-str "]" ident rust-syntax-class-before-point 5 backward-sexp rust-is-in-expression-context ("for") looking-back "[{;]" rust-looking-back-ident rust-rewind-qualified-ident (40 91) 123 rust-rewind-to-decl-name ("enum" "struct" "union" "trait" "type") ambiguous-operator 38 61 "[^:]:" 2 ("type") ("let" "const" "mut") rust-paren-level 0 backward-up-list "enum" colon "[{,]" looking-at "{" (5 7 15) "::" ":" -1 "->" 4 "," (scan-error) "=>" "==" "[-+=!?&*]"] 6 (#$ . 17216)])
2019-10-09 20:36:55 +02:00
#@134 Return t if the `<' after the point is the less-than operator.
Otherwise, for instance if it's an opening angle bracket, return nil.
2019-10-27 19:05:34 +01:00
(defalias 'rust-is-lt-char-operator #[0 "\304\212\305 \210\306\307!\203\310 \311\232\204\306\312!?\206Z\310 \313\235\203%\314\202Z\315 `S\"\2031\304\202Z\316\n!\203=\316\317!\202Z\306\320!\203I\321\322!\202Z\323 \205Z\324 \210\325 !\206Z\321\326!*\207" [case-fold-search rust-re-pre-expression-operators rust-mode-keywords rust-re-special-types nil rust-rewind-irrelevant rust-looking-back-str "<" rust-syntax-class-before-point 4 "<<" (5 7 15) t looking-back rust-looking-back-symbols ("self" "true" "false") "?" rust-is-in-expression-context ambiguous-operator rust-looking-back-ident backward-sexp looking-at ident] 3 (#$ . 19767)])
2019-10-09 20:36:55 +02:00
#@148 Prevent "matching" with a `>' when CHAR is the less-than operator.
This wraps the default defined by `electric-pair-inhibit-predicate'.
(fn CHAR)
2019-10-27 19:05:34 +01:00
(defalias 'rust-electric-pair-inhibit-predicate-wrap #[257 "\211\300U\203\212\301u\210\302 )\206\303\304!!\207" [60 -1 rust-is-lt-char-operator default-value electric-pair-inhibit-predicate] 3 (#$ . 20559)])
2019-10-09 20:36:55 +02:00
#@249 Test whether the `<' or `>' at point is an ordinary operator of some kind.
This returns t if the `<' or `>' is an ordinary operator (like
less-than) or part of one (like `->'); and nil if the character
should be considered a paired angle bracket.
2019-10-27 19:05:34 +01:00
(defalias 'rust-ordinary-lt-gt-p #[0 "\204\301\207\302 \203 \301\207\303 \203\301\207\304\305!\203\306 \207\304\307!\205C`\206(`Sf\310\235\2031\301\207\311\312 Y\203:\301\207\212\313 \210\304\305!)?\207" [rust-match-angle-brackets t rust-in-str-or-cmnt rust-in-macro looking-at "<" rust-is-lt-char-operator ">" (45 61) 0 rust-paren-level backward-up-list] 2 (#$ . 20926)])
2019-10-09 20:36:55 +02:00
#@96 Return face which distinguishes doc and normal comments in the given syntax STATE.
(fn STATE)
2019-10-27 19:05:34 +01:00
(defalias 'rust-mode-syntactic-face-function #[257 "\3008\203\301\207\212\3028b\210\303\304!\203\305\202\306)\207" [3 font-lock-string-face 8 looking-at "/\\([*][*!][^*!]\\|/[/!][^/!]\\)" font-lock-doc-face font-lock-comment-face] 3 (#$ . 21565)])
2019-10-09 20:36:55 +02:00
#@52 A regular expression matching a character literal.
2019-10-27 19:05:34 +01:00
(defconst rust--char-literal-rx "\\('\\)\\(?:\\\\\\(?:u{[[:xdigit:]]\\{1,6\\}}\\|x[[:xdigit:]]\\{2\\}\\|[\"'0\\nrt]\\)\\|[^'\\]\\)\\('\\)" (#$ . 21922))
2019-10-09 20:36:55 +02:00
#@208 A helper for rust-syntax-propertize.
This will apply the appropriate string syntax to the character
from the STR-START up to the end of the raw string, or to END,
whichever comes first.
(fn STR-START END)
2019-10-27 19:05:34 +01:00
(defalias 'rust--syntax-propertize-raw-string #[514 "\212b\210\300\301!)\2051\302\303!\304\305\306Q\307#\205/\310\303\224\303\225\311\312$\210\310\313\225S\313\225\311\314$\210\315\225b\262\207" [looking-at "r\\(#*\\)\\(\"\\)" match-string 1 re-search-forward "\\(\\\\*\\)\\(\"" "\\)" t put-text-property syntax-table (3) 2 (15) 0] 8 (#$ . 22133)])
2019-10-09 20:36:55 +02:00
#@87 A `syntax-propertize-function' to apply properties from START to END.
(fn START END)
2019-10-27 19:05:34 +01:00
(defalias 'rust-syntax-propertize #[514 "b\210\300 \211\203\301\"\210\210`b\210`W\205\277\302\303\304#\205\277\305\224\204,\306\224\203K\305\224\203:\307\305\224\305\225\310\311$\210\306\224\203\307\306\224\306\225\310\311$\210\202\312\224\203\200\313\314!\211A\315\233\241\210\316!\266\317\225b\210\212\315\320\317\224!8)\204\307\305\224\305\225\310\321$\210\301\317\224\"\210\202\322\224\203\313\314!\211A\323\233\241\210\316!\266\313 \324\317\325\326\327!\330\"\312$\216\212\317\224b\210\331 *\262\203\307\317\224\317\225\310\332$\210\317\225b\210\202\207" [rust-in-str-or-cmnt rust--syntax-propertize-raw-string re-search-forward "\\('\\)\\(?:\\\\\\(?:u{[[:xdigit:]]\\{1,6\\}}\\|x[[:xdigit:]]\\{2\\}\\|[\"'0\\nrt]\\)\\|[^'\\]\\)\\('\\)\\|\\(\\(r\\)#*\"\\)\\|\\([<>]\\)" t 1 2 put-text-property syntax-table (7) 3 match-data ints 8 set-match-data 0 syntax-ppss (15) 5 12 make-byte-code "\301\300\302\"\207" vconcat vector [set-match-data evaporate] rust-ordinary-lt-gt-p (1)] 11 (#$ . 22701)])
2019-10-09 20:36:55 +02:00
#@91 Determine what to use for `fill-prefix' based on the text at LINE-START.
(fn LINE-START)
2019-10-27 19:05:34 +01:00
(defalias 'rust-fill-prefix-for-comment-start #[257 "\300\301\302#\211GSH\303U\204\211\304P\262\211\207" [replace-regexp-in-string "\\(?:/\\*+?\\)[!*]?" #[257 "\300\301\302\211\211G\303ZG&\304=\203\305\202\303\306GZ\307\"\310P\207" [compare-strings "/*" nil 2 t 1 make-string 32 "*"] 8 "\n\n(fn S)"] 32 " "] 5 (#$ . 23828)])
2019-10-09 20:36:55 +02:00
#@13
(fn BODY)
2019-10-27 19:05:34 +01:00
(defalias 'rust-in-comment-paragraph #[257 "\212\302\303 8\204\304 \210\305\306P!\203\307\225b\210\310\311!\210\312\313!\212\314\210\310\311!\210\302\303 8\205C\212\304 \210\305 !)\205C\305\315!\205C\302\303!8)\203M\211b\210\202\210\310\311!\210\212\302\303\312\311!!8\205`\305\316!)\203i\317\307!b\210\211 )\207" [comment-start-skip paragraph-start 4 syntax-ppss beginning-of-line looking-at "[[:space:]\n]*" 0 syntax-ppss-flush-cache 1 line-beginning-position 2 nil "[[:space:]]*$" "[[:space:]]*\\*/" line-end-position] 5 (#$ . 24264)])
2019-10-09 20:36:55 +02:00
#@13
(fn BODY)
2019-10-27 19:05:34 +01:00
(defalias 'rust-with-comment-fill-prefix #[257 "\302\303 \304 \"\305\306 8\205*\307\310\"\203\311\312\"\202*\307\313P\"\205*\314\311\315\"!\211\206/  )\207" [comment-start-skip fill-prefix buffer-substring-no-properties line-beginning-position line-end-position 4 syntax-ppss string-match "^\\([[:space:]]*\\*+[[:space:]]*\\)" match-string 1 "[[:space:]]*" rust-fill-prefix-for-comment-start 0] 6 (#$ . 24836)])
2019-10-09 20:36:55 +02:00
(defalias 'rust-find-fill-prefix #[0 "\300\301!\207" [rust-in-comment-paragraph #[0 "\300\301!\207" [rust-with-comment-fill-prefix #[0 "\207" [fill-prefix] 1]] 2]] 2])
#@116 Special wrapping for `fill-paragraph' to handle multi-line comments with a * prefix on each line.
(fn &rest ARGS)
2019-10-27 19:05:34 +01:00
(defalias 'rust-fill-paragraph #[128 "\300\301\302\303\304\305!\306\"\307$!\207" [rust-in-comment-paragraph make-byte-code 0 "\301\302\303\304\305\306\300!\307\"\310$!\207" vconcat vector [rust-with-comment-fill-prefix make-byte-code 0 " \303=?\205 \304\305\306\300\"\210*\304\207" vconcat vector [fill-paragraph-function fill-paragraph-handle-comment rust-fill-paragraph t apply fill-paragraph] 3] 7] 8 (#$ . 25449)])
2019-10-09 20:36:55 +02:00
#@114 Special wrapping for `do-auto-fill' to handle multi-line comments with a * prefix on each line.
(fn &rest ARGS)
2019-10-27 19:05:34 +01:00
(defalias 'rust-do-auto-fill #[128 "\300\301\302\303\304\305!\306\"\307$!\207" [rust-with-comment-fill-prefix make-byte-code 0 "\301\302\300\"\210\303\207" vconcat vector [apply do-auto-fill t] 3] 8 (#$ . 25996)])
2019-10-09 20:36:55 +02:00
#@12
(fn ARG)
2019-10-27 19:05:34 +01:00
(defalias 'rust-fill-forward-paragraph #[257 "\301\302!)\207" [fill-prefix nil forward-paragraph] 3 (#$ . 26331)])
2019-10-09 20:36:55 +02:00
#@22
(fn &optional ARG)
2019-10-27 19:05:34 +01:00
(defalias 'rust-comment-indent-new-line #[256 "\300\301\302\303\304\305!\306\"\307$!\207" [rust-with-comment-fill-prefix make-byte-code 0 "\301\300!\207" vconcat vector [comment-indent-new-line] 2] 8 (#$ . 26465)])
2019-10-09 20:36:55 +02:00
#@246 Value for `imenu-generic-expression' in Rust mode.
Create a hierarchical index of the item definitions in a Rust file.
Imenu will show all the enums, structs, etc. in their own subheading.
Use idomenu (imenu with `ido-mode') for best mileage.
2019-10-27 19:05:34 +01:00
(defvar rust-imenu-generic-expression (byte-code "\300\301\302\303\"\304\305\306!\307BBC\"\207" [append mapcar #[257 "\300!\301!\302E\207" [capitalize rust-re-item-def-imenu 1] 4 "\n\n(fn X)"] ("enum" "struct" "union" "type" "mod" "fn" "trait" "impl") "Macro" rust-re-item-def-imenu "macro_rules!" (1)] 5) (#$ . 26710))
2019-10-09 20:36:55 +02:00
#@331 Move backward to the beginning of the current defun.
With ARG, move backward multiple defuns. Negative ARG means
move forward.
This is written mainly to be used as `beginning-of-defun-function' for Rust.
Don't move to the beginning of the line. `beginning-of-defun',
which calls this, does that afterwards.
(fn &optional ARG)
2019-10-27 19:05:34 +01:00
(defalias 'rust-beginning-of-defun #[256 "\211\206\301\302!\303W\203\304\202\301\211\303W\203\305\210\3062M\303\211W\205J\211\307\310\311Q\305\312$\203;\313 \202?\314\306\305\"\204)\210\211T\262\202\"\266\2020\210\315\207" [rust-top-item-beg-re 1 abs 0 -1 nil done re-search-backward "^\\(" "\\)" move rust-in-str-or-cmnt throw t] 12 (#$ . 27284) "p"])
2019-10-09 20:36:55 +02:00
#@324 Move forward to the next end of defun.
With argument, do it that many times.
Negative argument -N means move back to Nth preceding end of defun.
Assume that this is called after `beginning-of-defun'. So point is
at the beginning of the defun body.
This is written mainly to be used as `end-of-defun-function' for Rust.
2019-10-27 19:05:34 +01:00
(defalias 'rust-end-of-defun #[0 "\300\301\302\303#\203\304\224b\210\3051\306 0\207\210db\207db\207" [re-search-forward "[{]" nil t 0 (scan-error) forward-sexp] 4 (#$ . 27997) nil])
2019-10-09 20:36:55 +02:00
#@40 Skip to the end of the current string.
2019-10-27 19:05:34 +01:00
(defalias 'rust-end-of-string #[0 "\212\300\301!\210\300\302!\210`)\207" [skip-syntax-forward "^\"|" "\"|"] 2 (#$ . 28512)])
2019-10-09 20:36:55 +02:00
#@37 Format BUF using rustfmt.
(fn BUF)
2019-10-27 19:05:34 +01:00
(defalias 'rust--format-call #[257 "r\301\302!q\210\303 \210\304!\210\305\306!\307ed\310\211D\311&\312\216\211\313U\203=\314 rq\210\314 )\230\2047\315ed#\210\316 \210\202o\211\317U\203d\314 rq\210\314 )\230\204V\315ed#\210\303 \210\320!\210\321\322!\210\202o\303 \210\320!\210\321\323!\210)\324!\266\202)\207" [rust-rustfmt-bin get-buffer-create "*rustfmt*" erase-buffer insert-buffer-substring make-temp-file "rustfmt" call-process-region t nil #[0 "\300\207" [nil] 1] 0 buffer-string copy-to-buffer kill-buffer 3 insert-file-contents error "Rustfmt could not format some lines, see *rustfmt* buffer for details" "Rustfmt failed, see *rustfmt* buffer for details" delete-file] 9 (#$ . 28682)])
2019-10-09 20:36:55 +02:00
(defconst rust--format-word "\\b\\(else\\|enum\\|fn\\|for\\|if\\|let\\|loop\\|match\\|struct\\|union\\|unsafe\\|while\\)\\b")
(defconst rust--format-line "\\([\n]\\)")
#@28
(fn REGEX MAX-BEGINNING)
2019-10-27 19:05:34 +01:00
(defalias 'rust--format-count #[514 "\300\301\211`W\203\302\303#\203T\262\304\224\262\202`\262\302\301\303#\203=\304\224\211V\2035b\210\202<T\262\211\262\210\211\203D\211b\210\207" [0 nil re-search-forward t 1] 9 (#$ . 29605)])
2019-10-09 20:36:55 +02:00
#@29
(fn BUFFER &optional POS)
2019-10-27 19:05:34 +01:00
(defalias 'rust--format-get-loc #[513 "rq\210\212\211\206\n`\302\211\211eb\210\303\"\262\303 \"\262\304V\203:`U\203.\305\262\202C\306u\210b\210i\262\202Cib\210iZ\266\202E\266\204*\207" [rust--format-word rust--format-line nil rust--format-count 0 -1 1] 9 (#$ . 29890)])
2019-10-09 20:36:55 +02:00
#@28
(fn REGEX COUNT MAX-POS)
2019-10-27 19:05:34 +01:00
(defalias 'rust--format-forward #[771 "`W\2030`\300V\203S\262\301\302\303#\210\304\224\262\202\301\302\303#\203,\304\224^\262\211b\266\207" [0 re-search-forward nil t 1] 8 (#$ . 30215)])
2019-10-09 20:36:55 +02:00
#@19
(fn BUFFER LOC)
2019-10-27 19:05:34 +01:00
(defalias 'rust--format-get-pos #[514 "rq\210\212eb\210d\211A\262\242\211A\262\242\211A\262\242\302#\262\302 #\262\303V\2034\304u\210i`\305\304!\210i\\V\203H\211b\210u\210\266`^\266\204*\207" [rust--format-word rust--format-line rust--format-forward 0 nil move-end-of-line] 11 (#$ . 30451)])
2019-10-09 20:36:55 +02:00
#@72 Show diff to current buffer from rustfmt.
Return the created process.
2019-10-27 19:05:34 +01:00
(defalias 'rust-format-diff-buffer #[0 "\302!\204 \303\304\"\210\305\306r\307\310!q\210\311\312 \210)p)\313\314 %\315\316\"\210\211\207" [rust-rustfmt-bin inhibit-read-only executable-find error "Could not locate executable %s\"" start-process "rustfmt-diff" get-buffer-create "*rustfmt-diff*" t erase-buffer "--check" buffer-file-name set-process-sentinel rust-format-diff-buffer-sentinel] 6 (#$ . 30791) nil])
2019-10-09 20:36:55 +02:00
#@18
(fn PROCESS E)
2019-10-27 19:05:34 +01:00
(defalias 'rust-format-diff-buffer-sentinel #[514 "\301!\302=\205\"\303!\304V\203r\305q\210\306\307 \210)\310p!)\207\311\312!\207" [inhibit-read-only process-status exit process-exit-status 0 "*rustfmt-diff*" t diff-mode pop-to-buffer message "rustfmt check passed."] 4 (#$ . 31286)])
2019-10-09 20:36:55 +02:00
#@42 Format the current buffer using rustfmt.
2019-10-27 19:05:34 +01:00
(defalias 'rust-format-buffer #[0 "\301!\204 \302\303\"\210p\304!\206\211\305C\305C\306 \211\203@\211@\211=\204-\304!=\2039\307\305\"D\242B\240\210A\266\202\202\210\310 \211\203}\211@\311!\211=\204\\\304!=\203u\312!\313!\307\"\307\"E\242B\240\266\210A\266\202\202C\210\314\315\316\317\320#\321\"\322$\216\323p!\210)\266\324\325!\207" [rust-rustfmt-bin executable-find error "Could not locate executable \"%s\"" buffer-base-buffer nil buffer-list rust--format-get-loc window-list window-buffer window-start window-point make-byte-code 0 "\301\242\211\203(\211@\211A\262\242\303\211A\262\242\"rq\210\211b\210)\266A\266\202\202\210\302\242\211\205d\211@\211A\262\242\304!\303\211A\262\242\"\303\211A\262\242\"\300=\204W\305\"\210\306\"\266A\266\202\202+\207" vconcat vector [rust--format-get-pos window-buffer set-window-start set-window-point] 9 rust--format-call message "Formatted buffer with rustfmt."] 15 (#$ . 31600) nil])
2019-10-09 20:36:55 +02:00
#@53 Enable formatting using rustfmt when saving buffer.
2019-10-27 19:05:34 +01:00
(defalias 'rust-enable-format-on-save #[0 "\301\300!\210\302\211\207" [rust-format-on-save make-local-variable t] 2 (#$ . 32652) nil])
2019-10-09 20:36:55 +02:00
#@54 Disable formatting using rustfmt when saving buffer.
2019-10-27 19:05:34 +01:00
(defalias 'rust-disable-format-on-save #[0 "\301\300!\210\302\211\207" [rust-format-on-save make-local-variable nil] 2 (#$ . 32846) nil])
2019-10-09 20:36:55 +02:00
#@29 Compile using `cargo build`
2019-10-27 19:05:34 +01:00
(defalias 'rust-compile #[0 "\301\302\303\"!\207" [rust-cargo-bin compile format "%s build"] 4 (#$ . 33044) nil])
2019-10-09 20:36:55 +02:00
#@23 Run using `cargo run`
2019-10-27 19:05:34 +01:00
(defalias 'rust-run #[0 "\301\302\303\"!\207" [rust-cargo-bin compile format "%s run"] 4 (#$ . 33193) nil])
2019-10-09 20:36:55 +02:00
#@25 Test using `cargo test`
2019-10-27 19:05:34 +01:00
(defalias 'rust-test #[0 "\301\302\303\"!\207" [rust-cargo-bin compile format "%s test"] 4 (#$ . 33330) nil])
2019-10-09 20:36:55 +02:00
#@29 Keymap for Rust major mode.
2019-10-27 19:05:34 +01:00
(defvar rust-mode-map (byte-code "\300 \301\302\303#\210\211\207" [make-sparse-keymap define-key "" rust-format-buffer] 5) (#$ . 33471))
2019-10-09 20:36:55 +02:00
(defvar rust-mode-hook nil)
(byte-code "\300\301N\204\f\302\300\301\303#\210\304\305!\204\302\305\306\307#\210\300\207" [rust-mode-hook variable-documentation put "Hook run after entering Rust mode.\nNo problems result if this variable is not bound.\n`add-hook' automatically binds it. (This is true for all hook variables.)" boundp rust-mode-map definition-name rust-mode] 4)
(defvar rust-mode-map (make-sparse-keymap))
(byte-code "\301\302N\204\303\301\302\304\305!#\210\306\300!\204#\303\300\307\310#\210\311\312\300\313\"\210!\210\300\302N\2041\303\300\302\304\314!#\210\303\310\315\316#\210\303\310\317\310#\207" [rust-mode-abbrev-table rust-mode-map variable-documentation put purecopy "Keymap for `rust-mode'." boundp definition-name rust-mode (lambda (#1=#:def-tmp-var) (defvar rust-mode-abbrev-table #1#)) define-abbrev-table nil "Abbrev table for `rust-mode'." derived-mode-parent prog-mode custom-mode-group] 5)
#@213 Major mode for Rust code.
\{rust-mode-map}
In addition to any hooks its parent mode `prog-mode' might have run,
this mode runs the hook `rust-mode-hook', as the final or penultimate step
during initialization.
2019-10-27 19:05:34 +01:00
(defalias 'rust-mode #[0 "\306\300!\210\307\310 \210\311\312\310\313N\203\314\311\313\310\313N#\210\315 !\204'\316 \317 \"\210\320\f\321\"\204;\f =\204;\322\f\321 C#\210\323 !\210\324@!\210\f\306\325!\210\326\306\327!\210\330\306\331!\210\332\306\333!\210\334\306\335!\210\336\306\337!\210\340\306\341!\210\342\343\341!\205}!B!\306\344!\210\345$\306\346!\210\347$\350Q&\306\351!\210&)\306\352!\210\353*\306\354!\210\355,\306\356!\210\357.\306\360!\210\3610\306\362!\210\3362\306\363!\210\3073\306\364!\210\3654\306\366!\210A6\306\367!\210\3707\306\371!\210\3729\306\373!\210\374;\306\375!\210\307=\306\376!\210\377>\201D\201E\201F\340\307$\210\201D\201G\201H\340\307$\210\306\201B!\210\340BC\203#\201I \210)\201J\201K!\207" [delay-mode-hooks major-mode mode-name rust-mode-map rust-mode-abbrev-table local-abbrev-table make-local-variable t prog-mode rust-mode "Rust" mode-class put keymap-parent set-keymap-parent current-local-map abbrev-table-get :parents abbrev-table-put use-local-map set-syntax-table syntax-propertize-function rust-syntax-propertize indent-line-function rust-mode-indent-line font-lock-defaults (rust-mode-font-lock-keywords nil nil nil nil (font-lock-syntactic-face-function . rust-mode-syntactic-face-function)) comment-start "// " comment-end "" open-paren-in-column-0-is-defun-start nil electric-indent-chars 125 boundp comment-start-skip "\\(?://[/!]*\\|/\\*[*!]?\\)[[:space:]]*" paragraph-start "[[:space:]]*\\(?:" "\\|\\*/?[[:space:]]*\\|\\)$" paragraph-separate normal-auto-fill-function rust-do-auto-fill fill-paragraph-function rust-fill-paragraph fill-forward-paragraph-function rust-fill-forward-paragraph adaptive-fill-function rust-find-fill-prefix adaptive-fill-first-line-regexp comment-multi-line comment-line-break-function rust-comment-indent-new-line imenu-generic-expression imenu-syntax-alist ((33 . "w")) beginning-of-defun-function rust-beginning-of-defun end-of-defun-function rust-end-of-defun parse-sexp-lookup-properties electric-pair-inhibit-predicate rust-electric-pair-inhibit-predicate-wrap rust-mode-syntax-table rust-imenu-generic-expression rust-buffer-project rust-always-locate-project-on-open add-hook before-save-hook rust-before-save-hook after-save-hook rust-after-save-hook rust-update-buffer-project run-mode-hooks rust-mode-hook] 5 (#$ . 34578) nil])
2019-10-09 20:36:55 +02:00
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))
(defalias 'rust-mode-reload #[0 "\300\301!\210\302\301!\210\301 \207" [unload-feature rust-mode require] 2 nil nil])
(defalias 'rust-before-save-hook #[0 "\205\3011\f\302 0\207\210\303\207" [rust-format-on-save (error) rust-format-buffer nil] 1])
(defalias 'rust-after-save-hook #[0 "\205\302 !?\205\303\304 \"\207" [rust-format-on-save rust-rustfmt-bin executable-find error "Could not locate executable \"%s\""] 3])
#@121 Specifications for matching errors in rustc invocations.
See `compilation-error-regexp-alist' for help on their format.
2019-10-27 19:05:34 +01:00
(defvar rustc-compilation-regexps (byte-code "\300\301\211\302\303\303\304\260\211\305B\262\207" ["\\([^\n]+\\)" "\\([0-9]+\\)" "^\\(?:error\\|\\(warning\\)\\)[^]+?--> \\(" ":" "\\)" (3 4 5 (1) 2)] 10) (#$ . 37657))
2019-10-09 20:36:55 +02:00
#@126 Specifications for matching `:::` hints in rustc invocations.
See `compilation-error-regexp-alist' for help on their format.
2019-10-27 19:05:34 +01:00
(defvar rustc-colon-compilation-regexps (byte-code "\300\301\211\302\303\303\260\211\304B\262\207" ["\\([^\n]+\\)" "\\([0-9]+\\)" "^ *::: " ":" (1 2 3 0)] 9) (#$ . 38006))
2019-10-09 20:36:55 +02:00
#@126 Specifications for matching panics in cargo test invocations.
See `compilation-error-regexp-alist' for help on their format.
2019-10-27 19:05:34 +01:00
(defvar cargo-compilation-regexps '("^\\s-+thread '[^']+' panicked at \\('[^']+', \\([^:]+\\):\\([0-9]+\\)\\)" 2 3 nil nil 1) (#$ . 38315))
2019-10-09 20:36:55 +02:00
#@319 In the new style error messages, the regular expression
matches on the file name (which appears after `-->`), but the
start of the error appears a few lines earlier. This hook runs
after `next-error' (\[next-error]); it simply scrolls down a few lines in
the compilation window until the top of the error is visible.
2019-10-27 19:05:34 +01:00
(defalias 'rustc-scroll-down-after-next-error #[0 "\302 r\303\304\305\306\307!\310\"\311$\216\312=\205@\313\314 \315\"!\210\212\316 \210\317\320!)\205@\212\316 \210\317\321!\2047\322y\210\202+`)\323\324 \"\262*\207" [major-mode next-error-last-buffer internal--before-save-selected-window make-byte-code 0 "\301\300!\207" vconcat vector [internal--after-save-selected-window] 2 rust-mode select-window get-buffer-window visible beginning-of-line looking-at " *-->" "^[a-z]+:\\|^[a-z]+\\[E[0-9]+\\]:" -1 set-window-start selected-window] 7 (#$ . 38587)])
2019-10-09 20:36:55 +02:00
(eval-after-load 'compile #[0 "\303\304\305B\"\210\303\306\305\"\210\303\304\307 B\"\210\303\306\307\"\210\303\304\310\nB\"\210\303\306\310\"\210\311\312\313\"\207" [rustc-compilation-regexps rustc-colon-compilation-regexps cargo-compilation-regexps add-to-list compilation-error-regexp-alist-alist rustc compilation-error-regexp-alist rustc-colon cargo add-hook next-error-hook rustc-scroll-down-after-next-error] 4])
#@94 Create a shareable URL for the region from BEGIN to END on the Rust playpen.
(fn BEGIN END)
2019-10-27 19:05:34 +01:00
(defalias 'rust-playpen-region #[514 "{\303!\303\304\"!\211G\305V\203\306\307G\"\202(\304 \"\310\311\312\")\262\207" [rust-playpen-url-format rust-shortener-url-format url-request-method url-hexify-string format 5000 error "encoded playpen data exceeds 5000 character limit (length %s)" "POST" url-retrieve #[257 "db\210\300\301\302\"\303\304\"\305 \210\211\203\306\307\"\202\310\311\"\207" [thing-at-point line t plist-get :error kill-buffer error "failed to shorten playpen url: %s" message "%s"] 6 "\n\n(fn STATE)"]] 9 (#$ . 39893) "r"])
2019-10-09 20:36:55 +02:00
#@76 Create a shareable URL for the contents of the buffer on the Rust playpen.
2019-10-27 19:05:34 +01:00
(defalias 'rust-playpen-buffer #[0 "\300ed\"\207" [rust-playpen-region] 3 (#$ . 40553) nil])
2019-10-09 20:36:55 +02:00
#@290 Promote the module file visited by the current buffer into its own directory.
For example, if the current buffer is visiting the file `foo.rs',
then this function creates the directory `foo' and renames the
file to `foo/mod.rs'. The current buffer will be updated to
visit the new file.
2019-10-27 19:05:34 +01:00
(defalias 'rust-promote-module-into-dir #[0 "\300 \211\204\f\301\302!\2029\303!\304\230\203\301\305!\2029\306\303!!\307\310!P!\211\304P\311\312\"\210\313\314#\210\315!\266\203\207" [buffer-file-name message "Buffer is not visiting a file." file-name-nondirectory "mod.rs" "Won't promote a module file already named mod.rs." file-name-sans-extension file-name-as-directory file-name-directory mkdir t rename-file 1 set-visited-file-name] 8 (#$ . 40728) nil])
2019-10-09 20:36:55 +02:00
#@21 Run `cargo clippy'.
2019-10-27 19:05:34 +01:00
(defalias 'rust-run-clippy #[0 "\204\303 \210 \304\305PE\306\307\310#\311\n!)\207" [rust-buffer-project rust-cargo-bin compile-command rust-update-buffer-project "clippy" "--manifest-path=" mapconcat shell-quote-argument " " compile] 5 (#$ . 41494) nil])
2019-10-09 20:36:55 +02:00
(defalias 'rust-update-buffer-project #[0 "\301\300!\210\300 \211\207" [rust-buffer-project make-local-variable] 2])
#@31 Get project root if possible.
2019-10-27 19:05:34 +01:00
(defalias 'rust-buffer-project #[0 "\301\302!r\211q\210\303\304\305\306\307!\310\"\311$\216\312\313\314\313\315%\211\304U\204'\316\317\320 #\210\304b\210\321 \322\323\"A\262\262*\207" [rust-cargo-bin generate-new-buffer " *temp*" make-byte-code 0 "\301\300!\205 \302\300!\207" vconcat vector [buffer-name kill-buffer] 2 call-process nil t "locate-project" error "`cargo locate-project' returned %s status: %s" buffer-string json-read assoc-string "root"] 7 (#$ . 41899)])
2019-10-09 20:36:55 +02:00
(provide 'rust-mode)