branch: elpa/rust-mode
commit 85befb942a11c76caf2b7889ed79453fd4512198
Merge: 4d651ab f269c5e
Author: Niko Matsakis <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #201 from tromey/question-indentation
fix syntax of "<" appearing after "?"
---
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 9c9a4d6..98230de 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -1868,6 +1868,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 5b53277..2307cc0 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -866,6 +866,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)