Skip to content

Commit 89def67

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 13f4d9a commit 89def67

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

rust-mode.el

Lines changed: 5 additions & 4 deletions
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
;; for GNU Emacs < 24.3
1819
(eval-when-compile
@@ -647,7 +648,7 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
647648
(progn
648649
(goto-char (match-beginning 0))
649650
;; Go to the closing brace
650-
(condition-case err
651+
(condition-case nil
651652
(forward-sexp)
652653
(scan-error
653654
;; The parentheses are unbalanced; instead of being unable to fontify, just jump to the end of the buffer
@@ -791,7 +792,7 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
791792
(error-or-warning "\\(?:[Ee]rror\\|\\([Ww]arning\\)\\)"))
792793
(let ((re (concat "^" file ":" start-line ":" start-col
793794
": " end-line ":" end-col
794-
" \\(?:[Ee]rror\\|\\([Ww]arning\\)\\):")))
795+
" " error-or-warning ":")))
795796
(cons re '(1 (2 . 4) (3 . 5) (6)))))
796797
"Specifications for matching errors in rustc invocations.
797798
See `compilation-error-regexp-alist for help on their format.")

0 commit comments

Comments
 (0)