summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rust-mode-tests.el18
-rw-r--r--rust-mode.el4
2 files changed, 21 insertions, 1 deletions
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index cc76007..cbfde96 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -771,6 +771,24 @@ fn foo() {
"
))
+;; This is a test for #103: a comment after the last struct member that does
+;; not have a trailing comma. The comment used to be indented one stop too
+;; far.
+(ert-deftest indent-comment-after-last-struct-member ()
+ (test-indent
+ "
+struct A {
+ x: u8
+ // comment
+}
+
+struct A {
+ x: u8
+ /* comment */
+}
+"
+ ))
+
(setq rust-test-motion-string
"
fn fn1(arg: int) -> bool {
diff --git a/rust-mode.el b/rust-mode.el
index 6b09580..1d39a54 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -440,7 +440,9 @@ function or trait. When nil, where will be aligned with fn or trait."
;; baseline as well (we are continuing an expression,
;; but the "else" or "{" should align with the beginning
;; of the expression it's in.)
- (looking-at "\\<else\\>\\|{")
+ ;; Or, if this line starts a comment, stay on the
+ ;; baseline as well.
+ (looking-at "\\<else\\>\\|{\\|/[/*]")
(save-excursion
(rust-rewind-irrelevant)