emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/rust-mode f269c5e 292/486: fix syntax of "<" appearing aft


From: ELPA Syncer
Subject: [nongnu] elpa/rust-mode f269c5e 292/486: fix syntax of "<" appearing after "?"
Date: Sat, 7 Aug 2021 09:25:38 -0400 (EDT)

branch: elpa/rust-mode
commit f269c5ed312715fe862a32fae79f3e12131b1b7a
Author: Tom Tromey <tom@tromey.com>
Commit: Tom Tromey <tom@tromey.com>

    fix syntax of "<" appearing after "?"
    
    The "<" syntax-setting code could be confused after a "?".  This patch
    changes the code to treat "?" as an "ambiguous operator" and adjust
    according to further context.
    Fixes #200
---
 rust-mode-tests.el | 7 +++++++
 rust-mode.el       | 3 +++
 2 files changed, 10 insertions(+)

diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index f7c2a91..dc561e1 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -1891,6 +1891,13 @@ fn main() {
 "))
     (test-indent text text)))
 
+(ert-deftest indent-question-mark-operator ()
+  (test-indent "fn foo() {
+    if bar()? < 1 {
+    }
+    baz();
+}"))
+
 (defun rust-test-matching-parens (content pairs &optional nonparen-positions)
   "Assert that in rust-mode, given a buffer with the given `content',
   emacs's paren matching will find all of the pairs of positions
diff --git a/rust-mode.el b/rust-mode.el
index 4fadd81..00714a9 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -1012,6 +1012,9 @@ the desired identifiers), but does not match type 
annotations \"foo::<\"."
        ((rust-looking-back-symbols rust-mode-keywords)
         (rust-looking-back-symbols '("self" "true" "false")))
 
+       ((rust-looking-back-str "?")
+       (rust-is-in-expression-context 'ambiguous-operator))
+
        ;; If we're looking back at an identifier, this depends on whether
        ;; the identifier is part of an expression or a type
        ((rust-looking-back-ident)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]