diff options
| author | Tom Tromey <tom@tromey.com> | 2017-03-18 21:55:18 +0100 |
|---|---|---|
| committer | Tom Tromey <tom@tromey.com> | 2017-04-11 09:46:52 -0600 |
| commit | 5469d9bc3a13c75a8e98a86b6005d3540eb92524 (patch) | |
| tree | e4093fdd2e16cc8b003d4b971b556b0d52d059fa /rust-mode-tests.el | |
| parent | 85befb942a11c76caf2b7889ed79453fd4512198 (diff) | |
| download | rust-mode-5469d9bc3a13c75a8e98a86b6005d3540eb92524.tar.gz | |
fix rust indentation bug
This patch fixes a bug I found where rust-mode would misindent code
like:
fn each_split_within<'a, F>(ss: &'a str, lim: usize, mut it: F)
-> bool where F: FnMut(&'a str) -> bool {
}
fn test_split_within() {
}
In particular the second "fn" would be indented a level.
On the "fn" line, rust-mode-indent-line was calling
rust-beginning-of-defun, which would go to the previous defun. Fixing
this required moving the definition of rust-top-item-beg-re higher in
the file, before its first use (recent versions of Emacs insist on
this). And, this required removing the "^" from this regexp, which is
ok because the sole use is already adding a "^". Additionally, I moved
the "\\_>" into the regexp, rather than have it added at the point of
use, so that the new use would also benefit.
This patch includes two new test cases.
Diffstat (limited to 'rust-mode-tests.el')
| -rw-r--r-- | rust-mode-tests.el | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/rust-mode-tests.el b/rust-mode-tests.el index 98230de..5abd4a7 100644 --- a/rust-mode-tests.el +++ b/rust-mode-tests.el @@ -1628,6 +1628,34 @@ fn main() { " ))) +(ert-deftest indent-function-after-where () + (let ((rust-indent-method-chain t)) (test-indent + " +fn each_split_within<'a, F>(ss: &'a str, lim: usize, mut it: F) + -> bool where F: FnMut(&'a str) -> bool { +} + +#[test] +fn test_split_within() { +} +" + ))) + +(ert-deftest indent-function-after-where-nested () + (let ((rust-indent-method-chain t)) (test-indent + " +fn outer() { + fn each_split_within<'a, F>(ss: &'a str, lim: usize, mut it: F) + -> bool where F: FnMut(&'a str) -> bool { + } + #[test] + fn test_split_within() { + } + fn bar() { + } +} +" + ))) (ert-deftest test-for-issue-36-syntax-corrupted-state () "This is a test for a issue #36, which involved emacs's |
