Skip to content

Commit e111f11

Browse files
committed
---
yaml --- r: 144870 b: refs/heads/try2 c: be4f19a h: refs/heads/master v: v3
1 parent 242041f commit e111f11

File tree

3 files changed

+37
-24
lines changed

3 files changed

+37
-24
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: fcf18786b4c37972d9220bfb8bbe6a4875433faf
8+
refs/heads/try2: be4f19ae7c8b72669f1201c5d009e34af2d49228
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/etc/emacs/rust-mode-tests.el

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,3 +378,15 @@ fn nexted_fns(a: fn(b:int,
378378
}
379379
"
380380
))
381+
382+
(ert-deftest indent-multi-line-expr ()
383+
(test-indent
384+
"
385+
fn foo()
386+
{
387+
x();
388+
let a =
389+
b();
390+
}
391+
"
392+
))

branches/try2/src/etc/emacs/rust-mode.el

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,12 @@
4848
(if (/= starting (point))
4949
(rust-rewind-irrelevant))))
5050

51-
(defun rust-first-indent-after-brace ()
51+
(defun rust-align-to-expr-after-brace ()
5252
(save-excursion
5353
(forward-char)
54-
(if (looking-at "[[:blank:]]*\\(?://.*\\)?$")
55-
;; We don't want to indent out to the open bracket if the
56-
;; open bracket ends the line
57-
(* rust-indent-offset (rust-paren-level))
54+
;; We don't want to indent out to the open bracket if the
55+
;; open bracket ends the line
56+
(when (not (looking-at "[[:blank:]]*\\(?://.*\\)?$"))
5857
(when (looking-at "[[:space:]]") (forward-to-word 1))
5958
(current-column))))
6059

@@ -69,7 +68,8 @@
6968
((looking-at "->")
7069
(save-excursion
7170
(backward-list)
72-
(rust-first-indent-after-brace)))
71+
(or (rust-align-to-expr-after-brace)
72+
(* rust-indent-offset (+ 1 level)))))
7373

7474
;; A closing brace is 1 level unindended
7575
((looking-at "}") (* rust-indent-offset (- level 1)))
@@ -91,24 +91,25 @@
9191
(let ((pt (point)))
9292
(rust-rewind-irrelevant)
9393
(backward-up-list)
94-
(if (looking-at "[[({]")
95-
(rust-first-indent-after-brace)
96-
(progn
97-
(goto-char pt)
98-
(back-to-indentation)
99-
(if (looking-at "\\<else\\>")
100-
(* rust-indent-offset (+ 1 level))
101-
(progn
102-
(goto-char pt)
103-
(beginning-of-line)
104-
(rust-rewind-irrelevant)
105-
(end-of-line)
106-
(if (looking-back "[[,;{}(][[:space:]]*\\(?://.*\\)?")
107-
(* rust-indent-offset level)
108-
(back-to-indentation)
109-
(if (looking-at "#")
94+
(or (and (looking-at "[[({]")
95+
(rust-align-to-expr-after-brace))
96+
(progn
97+
(goto-char pt)
98+
(back-to-indentation)
99+
(if (looking-at "\\<else\\>")
100+
(* rust-indent-offset (+ 1 level))
101+
(progn
102+
(goto-char pt)
103+
(beginning-of-line)
104+
(rust-rewind-irrelevant)
105+
(end-of-line)
106+
(if (looking-back
107+
"[[,;{}(][[:space:]]*\\(?://.*\\)?")
110108
(* rust-indent-offset level)
111-
(* rust-indent-offset (+ 1 level))))))))))
109+
(back-to-indentation)
110+
(if (looking-at "#")
111+
(* rust-indent-offset level)
112+
(* rust-indent-offset (+ 1 level))))))))))
112113

113114
;; Otherwise we're in a column-zero definition
114115
(t 0))))))

0 commit comments

Comments
 (0)