Skip to content

Commit f269c5e

Browse files
committed
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
1 parent 19e6f60 commit f269c5e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

rust-mode-tests.el

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,6 +1891,13 @@ fn main() {
18911891
"))
18921892
(test-indent text text)))
18931893

1894+
(ert-deftest indent-question-mark-operator ()
1895+
(test-indent "fn foo() {
1896+
if bar()? < 1 {
1897+
}
1898+
baz();
1899+
}"))
1900+
18941901
(defun rust-test-matching-parens (content pairs &optional nonparen-positions)
18951902
"Assert that in rust-mode, given a buffer with the given `content',
18961903
emacs's paren matching will find all of the pairs of positions

rust-mode.el

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,9 @@ the desired identifiers), but does not match type annotations \"foo::<\"."
10121012
((rust-looking-back-symbols rust-mode-keywords)
10131013
(rust-looking-back-symbols '("self" "true" "false")))
10141014

1015+
((rust-looking-back-str "?")
1016+
(rust-is-in-expression-context 'ambiguous-operator))
1017+
10151018
;; If we're looking back at an identifier, this depends on whether
10161019
;; the identifier is part of an expression or a type
10171020
((rust-looking-back-ident)

0 commit comments

Comments
 (0)