diff options
| author | Tom Tromey <tom@tromey.com> | 2017-03-21 21:36:05 -0600 |
|---|---|---|
| committer | Tom Tromey <tom@tromey.com> | 2017-04-05 09:26:39 -0600 |
| commit | f269c5ed312715fe862a32fae79f3e12131b1b7a (patch) | |
| tree | 8865b20ed91d02ffe3b24f97d62f2809acafdab1 | |
| parent | 19e6f604a0c9d838a1426604d70ce3af0960621d (diff) | |
| download | rust-mode-f269c5ed312715fe862a32fae79f3e12131b1b7a.tar.gz | |
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
| -rw-r--r-- | rust-mode-tests.el | 7 | ||||
| -rw-r--r-- | rust-mode.el | 3 |
2 files changed, 10 insertions, 0 deletions
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) |
