1515
1616; ;; Code:
1717
18- (eval-when-compile (require 'rx ))
18+ (eval-when-compile
19+ (require 'rx )
20+ (require 'subr-x ))
1921
2022(defvar rust-load-optional-libraries t
2123 " Whether loading `rust-mode' also loads optional libraries.
@@ -948,12 +950,11 @@ and end."
948950(defun rust-string-interpolation-matcher (limit )
949951 " Match next Rust interpolation marker before LIMIT and set match data if found.
950952Returns 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 ))
957958
958959(defun rust-syntax-class-before-point ()
959960 (when (> (point ) 1 )
@@ -976,19 +977,18 @@ Returns nil if not within a Rust string."
976977 ; ; We need to be able to back up past the Fn(args) -> RT form as well. If
977978 ; ; we're looking back at this, we want to end up just after "Fn".
978979 ((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 ))))))
992992 (goto-char dest))))))
993993
994994(defun rust-rewind-to-decl-name ()
@@ -1365,9 +1365,8 @@ whichever comes first."
13651365(defun rust-syntax-propertize (start end )
13661366 " A `syntax-propertize-function' to apply properties from START to END."
13671367 (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))
13711370 (funcall
13721371 (syntax-propertize-rules
13731372 ; ; Character literals.
0 commit comments