From f269c5ed312715fe862a32fae79f3e12131b1b7a Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 21 Mar 2017 21:36:05 -0600 Subject: 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) -- cgit v1.2.3