15
15
16
16
; ;; Code:
17
17
18
- (eval-when-compile (require 'rx ))
18
+ (eval-when-compile
19
+ (require 'rx )
20
+ (require 'subr-x ))
19
21
20
22
(defvar rust-load-optional-libraries t
21
23
" Whether loading `rust-mode' also loads optional libraries.
@@ -948,12 +950,11 @@ and end."
948
950
(defun rust-string-interpolation-matcher (limit )
949
951
" Match next Rust interpolation marker before LIMIT and set match data if found.
950
952
Returns nil if not within a Rust string."
951
- (when (rust-in-str)
952
- (let ((match (rust-next-string-interpolation limit)))
953
- (when match
954
- (set-match-data match )
955
- (goto-char (cadr match ))
956
- match ))))
953
+ (when-let (((rust-in-str))
954
+ (match (rust-next-string-interpolation limit)))
955
+ (set-match-data match )
956
+ (goto-char (cadr match ))
957
+ match ))
957
958
958
959
(defun rust-syntax-class-before-point ()
959
960
(when (> (point ) 1 )
@@ -976,19 +977,18 @@ Returns nil if not within a Rust string."
976
977
; ; We need to be able to back up past the Fn(args) -> RT form as well. If
977
978
; ; we're looking back at this, we want to end up just after "Fn".
978
979
((member (char-before ) '(?\] ?\) ))
979
- (let* ((is-paren (rust-looking-back-str " )" ))
980
- (dest (save-excursion
981
- (backward-sexp )
982
- (rust-rewind-irrelevant)
983
- (or
984
- (when (rust-looking-back-str " ->" )
985
- (backward-char 2 )
986
- (rust-rewind-irrelevant)
987
- (when (rust-looking-back-str " )" )
988
- (backward-sexp )
989
- (point )))
990
- (and is-paren (point ))))))
991
- (when dest
980
+ (let ((is-paren (rust-looking-back-str " )" )))
981
+ (when-let ((dest (save-excursion
982
+ (backward-sexp )
983
+ (rust-rewind-irrelevant)
984
+ (or
985
+ (when (rust-looking-back-str " ->" )
986
+ (backward-char 2 )
987
+ (rust-rewind-irrelevant)
988
+ (when (rust-looking-back-str " )" )
989
+ (backward-sexp )
990
+ (point )))
991
+ (and is-paren (point ))))))
992
992
(goto-char dest))))))
993
993
994
994
(defun rust-rewind-to-decl-name ()
@@ -1365,9 +1365,8 @@ whichever comes first."
1365
1365
(defun rust-syntax-propertize (start end )
1366
1366
" A `syntax-propertize-function' to apply properties from START to END."
1367
1367
(goto-char start)
1368
- (let ((str-start (rust-in-str-or-cmnt)))
1369
- (when str-start
1370
- (rust--syntax-propertize-raw-string str-start end)))
1368
+ (when-let ((str-start (rust-in-str-or-cmnt)))
1369
+ (rust--syntax-propertize-raw-string str-start end))
1371
1370
(funcall
1372
1371
(syntax-propertize-rules
1373
1372
; ; Character literals.
0 commit comments