Skip to content

Commit f6b20f7

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 01fe7e2 commit f6b20f7

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
@@ -13,7 +13,8 @@
1313
(eval-when-compile (require 'misc)
1414
(require 'rx)
1515
(require 'compile)
16-
(require 'elec-pair))
16+
(require 'elec-pair)
17+
(require 'url-vars))
1718

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

0 commit comments

Comments
 (0)