Skip to content

Commit 95d089c

Browse files
committed
Merge pull request #110 from mrBliss/fix-103
Fix #103
2 parents eaf95af + a33b684 commit 95d089c

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

rust-mode-tests.el

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,24 @@ fn foo() {
771771
"
772772
))
773773

774+
;; This is a test for #103: a comment after the last struct member that does
775+
;; not have a trailing comma. The comment used to be indented one stop too
776+
;; far.
777+
(ert-deftest indent-comment-after-last-struct-member ()
778+
(test-indent
779+
"
780+
struct A {
781+
x: u8
782+
// comment
783+
}
784+
785+
struct A {
786+
x: u8
787+
/* comment */
788+
}
789+
"
790+
))
791+
774792
(setq rust-test-motion-string
775793
"
776794
fn fn1(arg: int) -> bool {

rust-mode.el

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,9 @@ function or trait. When nil, where will be aligned with fn or trait."
440440
;; baseline as well (we are continuing an expression,
441441
;; but the "else" or "{" should align with the beginning
442442
;; of the expression it's in.)
443-
(looking-at "\\<else\\>\\|{")
443+
;; Or, if this line starts a comment, stay on the
444+
;; baseline as well.
445+
(looking-at "\\<else\\>\\|{\\|/[/*]")
444446

445447
(save-excursion
446448
(rust-rewind-irrelevant)

0 commit comments

Comments
 (0)