Skip to content

Commit 866df37

Browse files
committed
make rust-mode use lexical binding
Emacs 24 introduces lexical binding, which should be preferred for new code. This enables it for rust-mode. The code continues to work fine on pre-24 Emacs, and it won't be difficult for this to remain true. One concrete advantage of lexical binding is that it lets the byte-compiler generate better warnings in some cases; here it found a couple of unused variables.
1 parent 012537b commit 866df37

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

rust-mode.el

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
;;; rust-mode.el --- A major emacs mode for editing Rust source code
1+
;;; rust-mode.el --- A major emacs mode for editing Rust source code -*-lexical-binding: t-*-
22

33
;; Version: 0.2.0
44
;; Author: Mozilla
@@ -12,7 +12,8 @@
1212

1313
(eval-when-compile (require 'misc)
1414
(require 'rx)
15-
(require 'compile))
15+
(require 'compile)
16+
(require 'url-vars))
1617

1718
(defvar electric-pair-inhibit-predicate)
1819

@@ -1102,7 +1103,7 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
11021103
(progn
11031104
(goto-char (match-beginning 0))
11041105
;; Go to the closing brace
1105-
(condition-case err
1106+
(condition-case nil
11061107
(forward-sexp)
11071108
(scan-error
11081109
;; The parentheses are unbalanced; instead of being unable to fontify, just jump to the end of the buffer
@@ -1175,7 +1176,7 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
11751176
(error-or-warning "\\(?:[Ee]rror\\|\\([Ww]arning\\)\\)"))
11761177
(let ((re (concat "^" file ":" start-line ":" start-col
11771178
": " end-line ":" end-col
1178-
" \\(?:[Ee]rror\\|\\([Ww]arning\\)\\):")))
1179+
" " error-or-warning ":")))
11791180
(cons re '(1 (2 . 4) (3 . 5) (6)))))
11801181
"Specifications for matching errors in rustc invocations.
11811182
See `compilation-error-regexp-alist' for help on their format.")

0 commit comments

Comments
 (0)