Skip to content

Commit 85befb9

Browse files
authored
Merge pull request #201 from tromey/question-indentation
fix syntax of "<" appearing after "?"
2 parents 4d651ab + f269c5e commit 85befb9

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
@@ -1868,6 +1868,13 @@ fn main() {
18681868
"))
18691869
(test-indent text text)))
18701870

1871+
(ert-deftest indent-question-mark-operator ()
1872+
(test-indent "fn foo() {
1873+
if bar()? < 1 {
1874+
}
1875+
baz();
1876+
}"))
1877+
18711878
(defun rust-test-matching-parens (content pairs &optional nonparen-positions)
18721879
"Assert that in rust-mode, given a buffer with the given `content',
18731880
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
@@ -866,6 +866,9 @@ the desired identifiers), but does not match type annotations \"foo::<\"."
866866
((rust-looking-back-symbols rust-mode-keywords)
867867
(rust-looking-back-symbols '("self" "true" "false")))
868868

869+
((rust-looking-back-str "?")
870+
(rust-is-in-expression-context 'ambiguous-operator))
871+
869872
;; If we're looking back at an identifier, this depends on whether
870873
;; the identifier is part of an expression or a type
871874
((rust-looking-back-ident)

0 commit comments

Comments
 (0)