Skip to content

Commit

Permalink
upstream: Add rust-indent-return-type-to-arguments variable
Browse files Browse the repository at this point in the history
  • Loading branch information
brotzeit committed Jan 31, 2019
1 parent 88bc339 commit cd46da9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
6 changes: 4 additions & 2 deletions rustic-interaction.el
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@
(back-to-indentation)
(current-column))))))

;; A function return type is indented to the corresponding function arguments
((looking-at "->")
;; A function return type is indented to the corresponding
;; function arguments, if -to-arguments is selected.
((and rust-indent-return-type-to-arguments
(looking-at "->"))
(save-excursion
(backward-list)
(or (rustic-align-to-expr-after-brace)
Expand Down
6 changes: 6 additions & 0 deletions rustic.el
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ function or trait. When nil, where will be aligned with fn or trait."
:type 'boolean
:group 'rustic)

(defcustom rust-indent-return-type-to-arguments t
"Indent a line starting with the `->' (RArrow) following a function, aligning
to the function arguments. When nil, `->' will be indented one level."
:type 'boolean
:group 'rust-mode
:safe #'booleanp)

;;;;;;;;;;;;;;;;;;
;; Faces
Expand Down
12 changes: 11 additions & 1 deletion test/rustic-rust-mode-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -1587,4 +1587,14 @@ extern \"rustic-intrinsic\" fn five() {
(test-electric-pair-insert "fn foo() -> Box" 16 ?< ?>))
)

;;; rustic-mode-tests.el ends here
(ert-deftest indent-return-type-non-visual ()
(let ((rust-indent-return-type-to-arguments nil))
(test-indent
"
fn imagine_long_enough_to_wrap_at_arrow(a:i32, b:char)
-> i32
{
let body;
}
")))

0 comments on commit cd46da9

Please sign in to comment.