Repository: sharkdp/bat (language: rust)

Issue:
diff mode doesn't display content
<!-- Hey there, thank you for creating an issue! -->

**Describe the bug you encountered:**

After installing `bat` for the first time, I wanted to test it out in my git repository. Running `bat -d <filename>` with a file that has been stored in my git repository's index and has a local modification does not output any of the content, modification or not.

```
➜ git d -- dotfiles/git/.config/git/config
diff --git a/dotfiles/git/.config/git/config b/dotfiles/git/.config/git/config
index 3eb29fd..75bdf05 100644
--- a/dotfiles/git/.config/git/config
+++ b/dotfiles/git/.config/git/config
@@ -23,6 +23,8 @@
   default = simple
 [pull]
   rebase = true
+[log]
+  mailmap = true
 [merge]
   ff = false
   tool = vimdiff


➜ bat -d dotfiles/git/.config/git/config
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: dotfiles/git/.config/git/config
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
```

I am able to replicate this erroneous behavior in a new repository:

```
➜ mkdir /tmp/bat-diff-issue && cd /tmp/bat-diff-issue


➜ git init
Initialized empty Git repository in /tmp/bat-diff-issue/.git/


➜ echo "foo" > README


➜ git add -A && git commit -m 'initial commit'
[trunk (root-commit) 8e32fca] initial commit
 1 file changed, 1 insertion(+)
 create mode 100644 README


➜ echo "bar" > README


➜ git diff -- README
diff --git a/README b/README
index 257cc56..5716ca5 100644
--- a/README
+++ b/README
@@ -1 +1 @@
-foo
+bar


➜ bat -d README
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: README
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────
```

**What did you expect to happen instead?**

I expected to see the modified line(s) with proper highlighting.


**How did you install `bat`?**

Through my system package manager.

```
➜ pacman -Qi bat | head -n5
Name            : bat
Version         : 0.18.3-1
Description     : Cat clone with syntax highlighting and git integration
Architecture    : x86_64
URL             : https://github.com/sharkdp/bat
```

---

**bat version and environment**

#### Software version

bat 0.18.3 (b146958)

#### Operating system

Linux 5.14.8-arch1-1

#### Command-line

```bash
bat -d --diagnostic README
```

#### Environment variables

```bash
SHELL=/usr/bin/zsh
PAGER=<not set>
LESS=<not set>
BAT_PAGER=<not set>
BAT_CACHE_PATH=<not set>
BAT_CONFIG_PATH=<not set>
BAT_OPTS=<not set>
BAT_STYLE=<not set>
BAT_TABS=<not set>
BAT_THEME=<not set>
XDG_CONFIG_HOME=/home/sudoforge/.config
XDG_CACHE_HOME=<not set>
COLORTERM=truecolor
NO_COLOR=<not set>
MANPAGER='nvim +Man'\!''
```

#### Config file

```

```

#### Compile time information

- Profile: release
- Target triple: x86_64-unknown-linux-gnu
- Family: unix
- OS: linux
- Architecture: x86_64
- Pointer width: 64
- Endian: little
- CPU features: fxsr,sse,sse2
- Host: x86_64-unknown-linux-gnu

#### Less version

```
> less --version
less 590 (PCRE2 regular expressions)
Copyright (C) 1984-2021  Mark Nudelman

less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Home page: https://greenwoodsoftware.com/less
```


Discussion / hints:
What's curious here is that `LESS` is detected as "not set" when running `bat -d --diagnostic README`:

```
➜ echo $LESS
-XFRi
```

However, upon testing, unsetting this has no effect whatsoever.
Thanks for reporting this bug and providing instructions to reproduce it! It definitely looks like something's off with bat's output.

Some other bugged cases:

```console
$ printf "foo\nbar" > README && git add README && git commit -m 'commit'
$ printf "baz\nbar" > README
$ bat -d README
───────┬─────────────────────────────────────────────────────────────────────────────────────────
       │ File: README
───────┼─────────────────────────────────────────────────────────────────────────────────────────
───────┴────────────────────────────────────────────────────────────────────────────────────────
```

```console
$ printf "1\n2\n3" > README && git add README && git commit -m 'commit'
$ printf "0\n2\n3" > README
$ bat -d README
───────┬─────────────────────────────────────────────────────────────────────────────────────────
       │ File: README
───────┼─────────────────────────────────────────────────────────────────────────────────────────
───────┴────────────────────────────────────────────────────────────────────────────────────────
```

It looks like `bat` doesn't detect when the first line is changed.
> It looks like `bat` doesn't detect when the first line is changed.

Just to be explicit here, this issue is present even when lines other than the first are modified.
Thank you for reporting this.

> > It looks like `bat` doesn't detect when the first line is changed.
> 
> Just to be explicit here, this issue is present even when lines other than the first are modified.

I can only reproduce the bug for the first line modification:

`test.sh`
```sh
seq 5 > README
git commit -am "dummy commit" > /dev/null

for i in $(seq 5); do
    echo "=== $i"
    sed -i -e "s/^$i\$/this line has been modified/" README
    bat --diff README
    git checkout README > /dev/null
done
```

output:
```
▶ bash test.sh
=== 1
───────┬─────────────────────────────────────────────
       │ File: README
───────┼─────────────────────────────────────────────
───────┴─────────────────────────────────────────────
=== 2
───────┬─────────────────────────────────────────────
       │ File: README
───────┼─────────────────────────────────────────────
   1   │ 1
   2 ~ │ this line has been modified
   3   │ 3
   4   │ 4
───────┴─────────────────────────────────────────────
=== 3
───────┬─────────────────────────────────────────────
       │ File: README
───────┼─────────────────────────────────────────────
   1   │ 1
   2   │ 2
   3 ~ │ this line has been modified
   4   │ 4
   5   │ 5
───────┴─────────────────────────────────────────────
=== 4
───────┬─────────────────────────────────────────────
       │ File: README
───────┼─────────────────────────────────────────────
   2   │ 2
   3   │ 3
   4 ~ │ this line has been modified
   5   │ 5
───────┴─────────────────────────────────────────────
=== 5
───────┬─────────────────────────────────────────────
       │ File: README
───────┼─────────────────────────────────────────────
   3   │ 3
   4   │ 4
   5 ~ │ this line has been modified
───────┴─────────────────────────────────────────────
```
Interestingly, I copied a file that I experience the issue with into a temporary "test" repository, and cannot reproduce the error there. I'll dig into `bat --diff` when I get a chance over the next week and try to pinpoint why we'd be seeing different behavior.

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 364ad0d4bd..a8b38ee760 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@
 ## Bugfixes
 
 - Python syntax highlighting no longer suffers from abysmal performance in specific scenarios. See #1688 (@keith-hall)
+- First line not shown in diff context. See #1891 (@divagant-martian)
 
 ## Performance
 
diff --git a/src/controller.rs b/src/controller.rs
index a737f09b5a..d106d1f2e5 100644
--- a/src/controller.rs
+++ b/src/controller.rs
@@ -177,7 +177,8 @@ impl<'b> Controller<'b> {
                     if let Some(line_changes) = line_changes {
                         for &line in line_changes.keys() {
                             let line = line as usize;
-                            line_ranges.push(LineRange::new(line - context, line + context));
+                            line_ranges
+                                .push(LineRange::new(line.saturating_sub(context), line + context));
                         }
                     }
 


Test patch:
diff --git a/tests/snapshots/output/changes.snapshot.txt b/tests/snapshots/output/changes.snapshot.txt
index 28d87201f0..6f88351717 100644
--- a/tests/snapshots/output/changes.snapshot.txt
+++ b/tests/snapshots/output/changes.snapshot.txt
@@ -1,3 +1,4 @@
++ /// A rectangle. First line is changed to prevent a regression of #1869
   struct Rectangle {
       width: u32,
       height: u32,
diff --git a/tests/snapshots/output/changes_grid.snapshot.txt b/tests/snapshots/output/changes_grid.snapshot.txt
index 04767b8b3a..6de1f8f651 100644
--- a/tests/snapshots/output/changes_grid.snapshot.txt
+++ b/tests/snapshots/output/changes_grid.snapshot.txt
@@ -1,4 +1,5 @@
 ──┬─────────────────────────────────────────────────────────────────────────────
++ │ /// A rectangle. First line is changed to prevent a regression of #1869
   │ struct Rectangle {
   │     width: u32,
   │     height: u32,
diff --git a/tests/snapshots/output/changes_grid_header.snapshot.txt b/tests/snapshots/output/changes_grid_header.snapshot.txt
index 655b6e248f..98518e196e 100644
--- a/tests/snapshots/output/changes_grid_header.snapshot.txt
+++ b/tests/snapshots/output/changes_grid_header.snapshot.txt
@@ -1,6 +1,7 @@
 ──┬─────────────────────────────────────────────────────────────────────────────
   │ File: sample.rs
 ──┼─────────────────────────────────────────────────────────────────────────────
++ │ /// A rectangle. First line is changed to prevent a regression of #1869
   │ struct Rectangle {
   │     width: u32,
   │     height: u32,
diff --git a/tests/snapshots/output/changes_grid_header_numbers.snapshot.txt b/tests/snapshots/output/changes_grid_header_numbers.snapshot.txt
index cee4737f4d..f8ecaa32c3 100644
--- a/tests/snapshots/output/changes_grid_header_numbers.snapshot.txt
+++ b/tests/snapshots/output/changes_grid_header_numbers.snapshot.txt
@@ -1,26 +1,27 @@
 ───────┬────────────────────────────────────────────────────────────────────────
        │ File: sample.rs
 ───────┼────────────────────────────────────────────────────────────────────────
-   1   │ struct Rectangle {
-   2   │     width: u32,
-   3   │     height: u32,
-   4   │ }
-   5   │ 
-   6 _ │ fn main() {
-   7   │     let rect1 = Rectangle { width: 30, height: 50 };
-   8   │ 
-   9   │     println!(
-  10 ~ │         "The perimeter of the rectangle is {} pixels.",
-  11 ~ │         perimeter(&rect1)
-  12   │     );
-  13 + │     println!(r#"This line contains invalid utf8:  "�����"#;
-  14   │ }
-  15   │ 
-  16   │ fn area(rectangle: &Rectangle) -> u32 {
-  17   │     rectangle.width * rectangle.height
-  18   │ }
-  19 + │ 
-  20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
-  21 + │     (rectangle.width + rectangle.height) * 2
-  22 + │ }
+   1 + │ /// A rectangle. First line is changed to prevent a regression of #1869
+   2   │ struct Rectangle {
+   3   │     width: u32,
+   4   │     height: u32,
+   5   │ }
+   6   │ 
+   7 _ │ fn main() {
+   8   │     let rect1 = Rectangle { width: 30, height: 50 };
+   9   │ 
+  10   │     println!(
+  11 ~ │         "The perimeter of the rectangle is {} pixels.",
+  12 ~ │         perimeter(&rect1)
+  13   │     );
+  14 + │     println!(r#"This line contains invalid utf8:  "�����"#;
+  15   │ }
+  16   │ 
+  17   │ fn area(rectangle: &Rectangle) -> u32 {
+  18   │     rectangle.width * rectangle.height
+  19   │ }
+  20 + │ 
+  21 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
+  22 + │     (rectangle.width + rectangle.height) * 2
+  23 + │ }
 ───────┴────────────────────────────────────────────────────────────────────────
diff --git a/tests/snapshots/output/changes_grid_header_numbers_rule.snapshot.txt b/tests/snapshots/output/changes_grid_header_numbers_rule.snapshot.txt
index cee4737f4d..f8ecaa32c3 100644
--- a/tests/snapshots/output/changes_grid_header_numbers_rule.snapshot.txt
+++ b/tests/snapshots/output/changes_grid_header_numbers_rule.snapshot.txt
@@ -1,26 +1,27 @@
 ───────┬────────────────────────────────────────────────────────────────────────
        │ File: sample.rs
 ───────┼────────────────────────────────────────────────────────────────────────
-   1   │ struct Rectangle {
-   2   │     width: u32,
-   3   │     height: u32,
-   4   │ }
-   5   │ 
-   6 _ │ fn main() {
-   7   │     let rect1 = Rectangle { width: 30, height: 50 };
-   8   │ 
-   9   │     println!(
-  10 ~ │         "The perimeter of the rectangle is {} pixels.",
-  11 ~ │         perimeter(&rect1)
-  12   │     );
-  13 + │     println!(r#"This line contains invalid utf8:  "�����"#;
-  14   │ }
-  15   │ 
-  16   │ fn area(rectangle: &Rectangle) -> u32 {
-  17   │     rectangle.width * rectangle.height
-  18   │ }
-  19 + │ 
-  20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
-  21 + │     (rectangle.width + rectangle.height) * 2
-  22 + │ }
+   1 + │ /// A rectangle. First line is changed to prevent a regression of #1869
+   2   │ struct Rectangle {
+   3   │     width: u32,
+   4   │     height: u32,
+   5   │ }
+   6   │ 
+   7 _ │ fn main() {
+   8   │     let rect1 = Rectangle { width: 30, height: 50 };
+   9   │ 
+  10   │     println!(
+  11 ~ │         "The perimeter of the rectangle is {} pixels.",
+  12 ~ │         perimeter(&rect1)
+  13   │     );
+  14 + │     println!(r#"This line contains invalid utf8:  "�����"#;
+  15   │ }
+  16   │ 
+  17   │ fn area(rectangle: &Rectangle) -> u32 {
+  18   │     rectangle.width * rectangle.height
+  19   │ }
+  20 + │ 
+  21 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
+  22 + │     (rectangle.width + rectangle.height) * 2
+  23 + │ }
 ───────┴────────────────────────────────────────────────────────────────────────
diff --git a/tests/snapshots/output/changes_grid_header_rule.snapshot.txt b/tests/snapshots/output/changes_grid_header_rule.snapshot.txt
index 655b6e248f..98518e196e 100644
--- a/tests/snapshots/output/changes_grid_header_rule.snapshot.txt
+++ b/tests/snapshots/output/changes_grid_header_rule.snapshot.txt
@@ -1,6 +1,7 @@
 ──┬─────────────────────────────────────────────────────────────────────────────
   │ File: sample.rs
 ──┼─────────────────────────────────────────────────────────────────────────────
++ │ /// A rectangle. First line is changed to prevent a regression of #1869
   │ struct Rectangle {
   │     width: u32,
   │     height: u32,
diff --git a/tests/snapshots/output/changes_grid_numbers.snapshot.txt b/tests/snapshots/output/changes_grid_numbers.snapshot.txt
index 7fe7cccfdc..0154a2b092 100644
--- a/tests/snapshots/output/changes_grid_numbers.snapshot.txt
+++ b/tests/snapshots/output/changes_grid_numbers.snapshot.txt
@@ -1,24 +1,25 @@
 ───────┬────────────────────────────────────────────────────────────────────────
-   1   │ struct Rectangle {
-   2   │     width: u32,
-   3   │     height: u32,
-   4   │ }
-   5   │ 
-   6 _ │ fn main() {
-   7   │     let rect1 = Rectangle { width: 30, height: 50 };
-   8   │ 
-   9   │     println!(
-  10 ~ │         "The perimeter of the rectangle is {} pixels.",
-  11 ~ │         perimeter(&rect1)
-  12   │     );
-  13 + │     println!(r#"This line contains invalid utf8:  "�����"#;
-  14   │ }
-  15   │ 
-  16   │ fn area(rectangle: &Rectangle) -> u32 {
-  17   │     rectangle.width * rectangle.height
-  18   │ }
-  19 + │ 
-  20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
-  21 + │     (rectangle.width + rectangle.height) * 2
-  22 + │ }
+   1 + │ /// A rectangle. First line is changed to prevent a regression of #1869
+   2   │ struct Rectangle {
+   3   │     width: u32,
+   4   │     height: u32,
+   5   │ }
+   6   │ 
+   7 _ │ fn main() {
+   8   │     let rect1 = Rectangle { width: 30, height: 50 };
+   9   │ 
+  10   │     println!(
+  11 ~ │         "The perimeter of the rectangle is {} pixels.",
+  12 ~ │         perimeter(&rect1)
+  13   │     );
+  14 + │     println!(r#"This line contains invalid utf8:  "�����"#;
+  15   │ }
+  16   │ 
+  17   │ fn area(rectangle: &Rectangle) -> u32 {
+  18   │     rectangle.width * rectangle.height
+  19   │ }
+  20 + │ 
+  21 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
+  22 + │     (rectangle.width + rectangle.height) * 2
+  23 + │ }
 ───────┴────────────────────────────────────────────────────────────────────────
diff --git a/tests/snapshots/output/changes_grid_numbers_rule.snapshot.txt b/tests/snapshots/output/changes_grid_numbers_rule.snapshot.txt
index 7fe7cccfdc..0154a2b092 100644
--- a/tests/snapshots/output/changes_grid_numbers_rule.snapshot.txt
+++ b/tests/snapshots/output/changes_grid_numbers_rule.snapshot.txt
@@ -1,24 +1,25 @@
 ───────┬────────────────────────────────────────────────────────────────────────
-   1   │ struct Rectangle {
-   2   │     width: u32,
-   3   │     height: u32,
-   4   │ }
-   5   │ 
-   6 _ │ fn main() {
-   7   │     let rect1 = Rectangle { width: 30, height: 50 };
-   8   │ 
-   9   │     println!(
-  10 ~ │         "The perimeter of the rectangle is {} pixels.",
-  11 ~ │         perimeter(&rect1)
-  12   │     );
-  13 + │     println!(r#"This line contains invalid utf8:  "�����"#;
-  14   │ }
-  15   │ 
-  16   │ fn area(rectangle: &Rectangle) -> u32 {
-  17   │     rectangle.width * rectangle.height
-  18   │ }
-  19 + │ 
-  20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
-  21 + │     (rectangle.width + rectangle.height) * 2
-  22 + │ }
+   1 + │ /// A rectangle. First line is changed to prevent a regression of #1869
+   2   │ struct Rectangle {
+   3   │     width: u32,
+   4   │     height: u32,
+   5   │ }
+   6   │ 
+   7 _ │ fn main() {
+   8   │     let rect1 = Rectangle { width: 30, height: 50 };
+   9   │ 
+  10   │     println!(
+  11 ~ │         "The perimeter of the rectangle is {} pixels.",
+  12 ~ │         perimeter(&rect1)
+  13   │     );
+  14 + │     println!(r#"This line contains invalid utf8:  "�����"#;
+  15   │ }
+  16   │ 
+  17   │ fn area(rectangle: &Rectangle) -> u32 {
+  18   │     rectangle.width * rectangle.height
+  19   │ }
+  20 + │ 
+  21 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
+  22 + │     (rectangle.width + rectangle.height) * 2
+  23 + │ }
 ───────┴────────────────────────────────────────────────────────────────────────
diff --git a/tests/snapshots/output/changes_grid_rule.snapshot.txt b/tests/snapshots/output/changes_grid_rule.snapshot.txt
index 04767b8b3a..6de1f8f651 100644
--- a/tests/snapshots/output/changes_grid_rule.snapshot.txt
+++ b/tests/snapshots/output/changes_grid_rule.snapshot.txt
@@ -1,4 +1,5 @@
 ──┬─────────────────────────────────────────────────────────────────────────────
++ │ /// A rectangle. First line is changed to prevent a regression of #1869
   │ struct Rectangle {
   │     width: u32,
   │     height: u32,
diff --git a/tests/snapshots/output/changes_header.snapshot.txt b/tests/snapshots/output/changes_header.snapshot.txt
index 82fe8c47cb..d5c1afd920 100644
--- a/tests/snapshots/output/changes_header.snapshot.txt
+++ b/tests/snapshots/output/changes_header.snapshot.txt
@@ -1,4 +1,5 @@
   File: sample.rs
++ /// A rectangle. First line is changed to prevent a regression of #1869
   struct Rectangle {
       width: u32,
       height: u32,
diff --git a/tests/snapshots/output/changes_header_numbers.snapshot.txt b/tests/snapshots/output/changes_header_numbers.snapshot.txt
index 77145eb9b2..cc99df08b3 100644
--- a/tests/snapshots/output/changes_header_numbers.snapshot.txt
+++ b/tests/snapshots/output/changes_header_numbers.snapshot.txt
@@ -1,23 +1,24 @@
        File: sample.rs
-   1   struct Rectangle {
-   2       width: u32,
-   3       height: u32,
-   4   }
-   5   
-   6 _ fn main() {
-   7       let rect1 = Rectangle { width: 30, height: 50 };
-   8   
-   9       println!(
-  10 ~         "The perimeter of the rectangle is {} pixels.",
-  11 ~         perimeter(&rect1)
-  12       );
-  13 +     println!(r#"This line contains invalid utf8:  "�����"#;
-  14   }
-  15   
-  16   fn area(rectangle: &Rectangle) -> u32 {
-  17       rectangle.width * rectangle.height
-  18   }
-  19 + 
-  20 + fn perimeter(rectangle: &Rectangle) -> u32 {
-  21 +     (rectangle.width + rectangle.height) * 2
-  22 + }
+   1 + /// A rectangle. First line is changed to prevent a regression of #1869
+   2   struct Rectangle {
+   3       width: u32,
+   4       height: u32,
+   5   }
+   6   
+   7 _ fn main() {
+   8       let rect1 = Rectangle { width: 30, height: 50 };
+   9   
+  10       println!(
+  11 ~         "The perimeter of the rectangle is {} pixels.",
+  12 ~         perimeter(&rect1)
+  13       );
+  14 +     println!(r#"This line contains invalid utf8:  "�����"#;
+  15   }
+  16   
+  17   fn area(rectangle: &Rectangle) -> u32 {
+  18       rectangle.width * rectangle.height
+  19   }
+  20 + 
+  21 + fn perimeter(rectangle: &Rectangle) -> u32 {
+  22 +     (rectangle.width + rectangle.height) * 2
+  23 + }
diff --git a/tests/snapshots/output/changes_header_numbers_rule.snapshot.txt b/tests/snapshots/output/changes_header_numbers_rule.snapshot.txt
index 77145eb9b2..cc99df08b3 100644
--- a/tests/snapshots/output/changes_header_numbers_rule.snapshot.txt
+++ b/tests/snapshots/output/changes_header_numbers_rule.snapshot.txt
@@ -1,23 +1,24 @@
        File: sample.rs
-   1   struct Rectangle {
-   2       width: u32,
-   3       height: u32,
-   4   }
-   5   
-   6 _ fn main() {
-   7       let rect1 = Rectangle { width: 30, height: 50 };
-   8   
-   9       println!(
-  10 ~         "The perimeter of the rectangle is {} pixels.",
-  11 ~         perimeter(&rect1)
-  12       );
-  13 +     println!(r#"This line contains invalid utf8:  "�����"#;
-  14   }
-  15   
-  16   fn area(rectangle: &Rectangle) -> u32 {
-  17       rectangle.width * rectangle.height
-  18   }
-  19 + 
-  20 + fn perimeter(rectangle: &Rectangle) -> u32 {
-  21 +     (rectangle.width + rectangle.height) * 2
-  22 + }
+   1 + /// A rectangle. First line is changed to prevent a regression of #1869
+   2   struct Rectangle {
+   3       width: u32,
+   4       height: u32,
+   5   }
+   6   
+   7 _ fn main() {
+   8       let rect1 = Rectangle { width: 30, height: 50 };
+   9   
+  10       println!(
+  11 ~         "The perimeter of the rectangle is {} pixels.",
+  12 ~         perimeter(&rect1)
+  13       );
+  14 +     println!(r#"This line contains invalid utf8:  "�����"#;
+  15   }
+  16   
+  17   fn area(rectangle: &Rectangle) -> u32 {
+  18       rectangle.width * rectangle.height
+  19   }
+  20 + 
+  21 + fn perimeter(rectangle: &Rectangle) -> u32 {
+  22 +     (rectangle.width + rectangle.height) * 2
+  23 + }
diff --git a/tests/snapshots/output/changes_header_rule.snapshot.txt b/tests/snapshots/output/changes_header_rule.snapshot.txt
index 82fe8c47cb..d5c1afd920 100644
--- a/tests/snapshots/output/changes_header_rule.snapshot.txt
+++ b/tests/snapshots/output/changes_header_rule.snapshot.txt
@@ -1,4 +1,5 @@
   File: sample.rs
++ /// A rectangle. First line is changed to prevent a regression of #1869
   struct Rectangle {
       width: u32,
       height: u32,
diff --git a/tests/snapshots/output/changes_numbers.snapshot.txt b/tests/snapshots/output/changes_numbers.snapshot.txt
index bdfe745bff..5b4044110e 100644
--- a/tests/snapshots/output/changes_numbers.snapshot.txt
+++ b/tests/snapshots/output/changes_numbers.snapshot.txt
@@ -1,22 +1,23 @@
-   1   struct Rectangle {
-   2       width: u32,
-   3       height: u32,
-   4   }
-   5   
-   6 _ fn main() {
-   7       let rect1 = Rectangle { width: 30, height: 50 };
-   8   
-   9       println!(
-  10 ~         "The perimeter of the rectangle is {} pixels.",
-  11 ~         perimeter(&rect1)
-  12       );
-  13 +     println!(r#"This line contains invalid utf8:  "�����"#;
-  14   }
-  15   
-  16   fn area(rectangle: &Rectangle) -> u32 {
-  17       rectangle.width * rectangle.height
-  18   }
-  19 + 
-  20 + fn perimeter(rectangle: &Rectangle) -> u32 {
-  21 +     (rectangle.width + rectangle.height) * 2
-  22 + }
+   1 + /// A rectangle. First line is changed to prevent a regression of #1869
+   2   struct Rectangle {
+   3       width: u32,
+   4       height: u32,
+   5   }
+   6   
+   7 _ fn main() {
+   8       let rect1 = Rectangle { width: 30, height: 50 };
+   9   
+  10       println!(
+  11 ~         "The perimeter of the rectangle is {} pixels.",
+  12 ~         perimeter(&rect1)
+  13       );
+  14 +     println!(r#"This line contains invalid utf8:  "�����"#;
+  15   }
+  16   
+  17   fn area(rectangle: &Rectangle) -> u32 {
+  18       rectangle.width * rectangle.height
+  19   }
+  20 + 
+  21 + fn perimeter(rectangle: &Rectangle) -> u32 {
+  22 +     (rectangle.width + rectangle.height) * 2
+  23 + }
diff --git a/tests/snapshots/output/changes_numbers_rule.snapshot.txt b/tests/snapshots/output/changes_numbers_rule.snapshot.txt
index bdfe745bff..5b4044110e 100644
--- a/tests/snapshots/output/changes_numbers_rule.snapshot.txt
+++ b/tests/snapshots/output/changes_numbers_rule.snapshot.txt
@@ -1,22 +1,23 @@
-   1   struct Rectangle {
-   2       width: u32,
-   3       height: u32,
-   4   }
-   5   
-   6 _ fn main() {
-   7       let rect1 = Rectangle { width: 30, height: 50 };
-   8   
-   9       println!(
-  10 ~         "The perimeter of the rectangle is {} pixels.",
-  11 ~         perimeter(&rect1)
-  12       );
-  13 +     println!(r#"This line contains invalid utf8:  "�����"#;
-  14   }
-  15   
-  16   fn area(rectangle: &Rectangle) -> u32 {
-  17       rectangle.width * rectangle.height
-  18   }
-  19 + 
-  20 + fn perimeter(rectangle: &Rectangle) -> u32 {
-  21 +     (rectangle.width + rectangle.height) * 2
-  22 + }
+   1 + /// A rectangle. First line is changed to prevent a regression of #1869
+   2   struct Rectangle {
+   3       width: u32,
+   4       height: u32,
+   5   }
+   6   
+   7 _ fn main() {
+   8       let rect1 = Rectangle { width: 30, height: 50 };
+   9   
+  10       println!(
+  11 ~         "The perimeter of the rectangle is {} pixels.",
+  12 ~         perimeter(&rect1)
+  13       );
+  14 +     println!(r#"This line contains invalid utf8:  "�����"#;
+  15   }
+  16   
+  17   fn area(rectangle: &Rectangle) -> u32 {
+  18       rectangle.width * rectangle.height
+  19   }
+  20 + 
+  21 + fn perimeter(rectangle: &Rectangle) -> u32 {
+  22 +     (rectangle.width + rectangle.height) * 2
+  23 + }
diff --git a/tests/snapshots/output/changes_rule.snapshot.txt b/tests/snapshots/output/changes_rule.snapshot.txt
index 28d87201f0..6f88351717 100644
--- a/tests/snapshots/output/changes_rule.snapshot.txt
+++ b/tests/snapshots/output/changes_rule.snapshot.txt
@@ -1,3 +1,4 @@
++ /// A rectangle. First line is changed to prevent a regression of #1869
   struct Rectangle {
       width: u32,
       height: u32,
diff --git a/tests/snapshots/output/full.snapshot.txt b/tests/snapshots/output/full.snapshot.txt
index cee4737f4d..f8ecaa32c3 100644
--- a/tests/snapshots/output/full.snapshot.txt
+++ b/tests/snapshots/output/full.snapshot.txt
@@ -1,26 +1,27 @@
 ───────┬────────────────────────────────────────────────────────────────────────
        │ File: sample.rs
 ───────┼────────────────────────────────────────────────────────────────────────
-   1   │ struct Rectangle {
-   2   │     width: u32,
-   3   │     height: u32,
-   4   │ }
-   5   │ 
-   6 _ │ fn main() {
-   7   │     let rect1 = Rectangle { width: 30, height: 50 };
-   8   │ 
-   9   │     println!(
-  10 ~ │         "The perimeter of the rectangle is {} pixels.",
-  11 ~ │         perimeter(&rect1)
-  12   │     );
-  13 + │     println!(r#"This line contains invalid utf8:  "�����"#;
-  14   │ }
-  15   │ 
-  16   │ fn area(rectangle: &Rectangle) -> u32 {
-  17   │     rectangle.width * rectangle.height
-  18   │ }
-  19 + │ 
-  20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
-  21 + │     (rectangle.width + rectangle.height) * 2
-  22 + │ }
+   1 + │ /// A rectangle. First line is changed to prevent a regression of #1869
+   2   │ struct Rectangle {
+   3   │     width: u32,
+   4   │     height: u32,
+   5   │ }
+   6   │ 
+   7 _ │ fn main() {
+   8   │     let rect1 = Rectangle { width: 30, height: 50 };
+   9   │ 
+  10   │     println!(
+  11 ~ │         "The perimeter of the rectangle is {} pixels.",
+  12 ~ │         perimeter(&rect1)
+  13   │     );
+  14 + │     println!(r#"This line contains invalid utf8:  "�����"#;
+  15   │ }
+  16   │ 
+  17   │ fn area(rectangle: &Rectangle) -> u32 {
+  18   │     rectangle.width * rectangle.height
+  19   │ }
+  20 + │ 
+  21 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
+  22 + │     (rectangle.width + rectangle.height) * 2
+  23 + │ }
 ───────┴────────────────────────────────────────────────────────────────────────
diff --git a/tests/snapshots/output/grid.snapshot.txt b/tests/snapshots/output/grid.snapshot.txt
index 5b970581f5..7061949760 100644
--- a/tests/snapshots/output/grid.snapshot.txt
+++ b/tests/snapshots/output/grid.snapshot.txt
@@ -1,4 +1,5 @@
 ────────────────────────────────────────────────────────────────────────────────
+/// A rectangle. First line is changed to prevent a regression of #1869
 struct Rectangle {
     width: u32,
     height: u32,
diff --git a/tests/snapshots/output/grid_header.snapshot.txt b/tests/snapshots/output/grid_header.snapshot.txt
index 50c16941e9..010e3a8137 100644
--- a/tests/snapshots/output/grid_header.snapshot.txt
+++ b/tests/snapshots/output/grid_header.snapshot.txt
@@ -1,6 +1,7 @@
 ────────────────────────────────────────────────────────────────────────────────
 File: sample.rs
 ────────────────────────────────────────────────────────────────────────────────
+/// A rectangle. First line is changed to prevent a regression of #1869
 struct Rectangle {
     width: u32,
     height: u32,
diff --git a/tests/snapshots/output/grid_header_numbers.snapshot.txt b/tests/snapshots/output/grid_header_numbers.snapshot.txt
index e9f1a9cfe6..dfbb934bb7 100644
--- a/tests/snapshots/output/grid_header_numbers.snapshot.txt
+++ b/tests/snapshots/output/grid_header_numbers.snapshot.txt
@@ -1,26 +1,27 @@
 ─────┬──────────────────────────────────────────────────────────────────────────
      │ File: sample.rs
 ─────┼──────────────────────────────────────────────────────────────────────────
-   1 │ struct Rectangle {
-   2 │     width: u32,
-   3 │     height: u32,
-   4 │ }
-   5 │ 
-   6 │ fn main() {
-   7 │     let rect1 = Rectangle { width: 30, height: 50 };
-   8 │ 
-   9 │     println!(
-  10 │         "The perimeter of the rectangle is {} pixels.",
-  11 │         perimeter(&rect1)
-  12 │     );
-  13 │     println!(r#"This line contains invalid utf8:  "�����"#;
-  14 │ }
-  15 │ 
-  16 │ fn area(rectangle: &Rectangle) -> u32 {
-  17 │     rectangle.width * rectangle.height
-  18 │ }
-  19 │ 
-  20 │ fn perimeter(rectangle: &Rectangle) -> u32 {
-  21 │     (rectangle.width + rectangle.height) * 2
-  22 │ }
+   1 │ /// A rectangle. First line is changed to prevent a regression of #1869
+   2 │ struct Rectangle {
+   3 │     width: u32,
+   4 │     height: u32,
+   5 │ }
+   6 │ 
+   7 │ fn main() {
+   8 │     let rect1 = Rectangle { width: 30, height: 50 };
+   9 │ 
+  10 │     println!(
+  11 │         "The perimeter of the rectangle is {} pixels.",
+  12 │         perimeter(&rect1)
+  13 │     );
+  14 │     println!(r#"This line contains invalid utf8:  "�����"#;
+  15 │ }
+  16 │ 
+  17 │ fn area(rectangle: &Rectangle) -> u32 {
+  18 │     rectangle.width * rectangle.height
+  19 │ }
+  20 │ 
+  21 │ fn perimeter(rectangle: &Rectangle) -> u32 {
+  22 │     (rectangle.width + rectangle.height) * 2
+  23 │ }
 ─────┴──────────────────────────────────────────────────────────────────────────
diff --git a/tests/snapshots/output/grid_header_numbers_rule.snapshot.txt b/tests/snapshots/output/grid_header_numbers_rule.snapshot.txt
index e9f1a9cfe6..dfbb934bb7 100644
--- a/tests/snapshots/output/grid_header_numbers_rule.snapshot.txt
+++ b/tests/snapshots/output/grid_header_numbers_rule.snapshot.txt
@@ -1,26 +1,27 @@
 ─────┬──────────────────────────────────────────────────────────────────────────
      │ File: sample.rs
 ─────┼──────────────────────────────────────────────────────────────────────────
-   1 │ struct Rectangle {
-   2 │     width: u32,
-   3 │     height: u32,
-   4 │ }
-   5 │ 
-   6 │ fn main() {
-   7 │     let rect1 = Rectangle { width: 30, height: 50 };
-   8 │ 
-   9 │     println!(
-  10 │         "The perimeter of the rectangle is {} pixels.",
-  11 │         perimeter(&rect1)
-  12 │     );
-  13 │     println!(r#"This line contains invalid utf8:  "�����"#;
-  14 │ }
-  15 │ 
-  16 │ fn area(rectangle: &Rectangle) -> u32 {
-  17 │     rectangle.width * rectangle.height
-  18 │ }
-  19 │ 
-  20 │ fn perimeter(rectangle: &Rectangle) -> u32 {
-  21 │     (rectangle.width + rectangle.height) * 2
-  22 │ }
+   1 │ /// A rectangle. First line is changed to prevent a regression of #1869
+   2 │ struct Rectangle {
+   3 │     width: u32,
+   4 │     height: u32,
+   5 │ }
+   6 │ 
+   7 │ fn main() {
+   8 │     let rect1 = Rectangle { width: 30, height: 50 };
+   9 │ 
+  10 │     println!(
+  11 │         "The perimeter of the rectangle is {} pixels.",
+  12 │         perimeter(&rect1)
+  13 │     );
+  14 │     println!(r#"This line contains invalid utf8:  "�����"#;
+  15 │ }
+  16 │ 
+  17 │ fn area(rectangle: &Rectangle) -> u32 {
+  18 │     rectangle.width * rectangle.height
+  19 │ }
+  20 │ 
+  21 │ fn perimeter(rectangle: &Rectangle) -> u32 {
+  22 │     (rectangle.width + rectangle.height) * 2
+  23 │ }
 ─────┴──────────────────────────────────────────────────────────────────────────
diff --git a/tests/snapshots/output/grid_header_rule.snapshot.txt b/tests/snapshots/output/grid_header_rule.snapshot.txt
index 50c16941e9..010e3a8137 100644
--- a/tests/snapshots/output/grid_header_rule.snapshot.txt
+++ b/tests/snapshots/output/grid_header_rule.snapshot.txt
@@ -1,6 +1,7 @@
 ────────────────────────────────────────────────────────────────────────────────
 File: sample.rs
 ────────────────────────────────────────────────────────────────────────────────
+/// A rectangle. First line is changed to prevent a regression of #1869
 struct Rectangle {
     width: u32,
     height: u32,
diff --git a/tests/snapshots/output/grid_numbers.snapshot.txt b/tests/snapshots/output/grid_numbers.snapshot.txt
index 0961466704..83ee57cdca 100644
--- a/tests/snapshots/output/grid_numbers.snapshot.txt
+++ b/tests/snapshots/output/grid_numbers.snapshot.txt
@@ -1,24 +1,25 @@
 ─────┬──────────────────────────────────────────────────────────────────────────
-   1 │ struct Rectangle {
-   2 │     width: u32,
-   3 │     height: u32,
-   4 │ }
-   5 │ 
-   6 │ fn main() {
-   7 │     let rect1 = Rectangle { width: 30, height: 50 };
-   8 │ 
-   9 │     println!(
-  10 │         "The perimeter of the rectangle is {} pixels.",
-  11 │         perimeter(&rect1)
-  12 │     );
-  13 │     println!(r#"This line contains invalid utf8:  "�����"#;
-  14 │ }
-  15 │ 
-  16 │ fn area(rectangle: &Rectangle) -> u32 {
-  17 │     rectangle.width * rectangle.height
-  18 │ }
-  19 │ 
-  20 │ fn perimeter(rectangle: &Rectangle) -> u32 {
-  21 │     (rectangle.width + rectangle.height) * 2
-  22 │ }
+   1 │ /// A rectangle. First line is changed to prevent a regression of #1869
+   2 │ struct Rectangle {
+   3 │     width: u32,
+   4 │     height: u32,
+   5 │ }
+   6 │ 
+   7 │ fn main() {
+   8 │     let rect1 = Rectangle { width: 30, height: 50 };
+   9 │ 
+  10 │     println!(
+  11 │         "The perimeter of the rectangle is {} pixels.",
+  12 │         perimeter(&rect1)
+  13 │     );
+  14 │     println!(r#"This line contains invalid utf8:  "�����"#;
+  15 │ }
+  16 │ 
+  17 │ fn area(rectangle: &Rectangle) -> u32 {
+  18 │     rectangle.width * rectangle.height
+  19 │ }
+  20 │ 
+  21 │ fn perimeter(rectangle: &Rectangle) -> u32 {
+  22 │     (rectangle.width + rectangle.height) * 2
+  23 │ }
 ─────┴──────────────────────────────────────────────────────────────────────────
diff --git a/tests/snapshots/output/grid_numbers_rule.snapshot.txt b/tests/snapshots/output/grid_numbers_rule.snapshot.txt
index 0961466704..83ee57cdca 100644
--- a/tests/snapshots/output/grid_numbers_rule.snapshot.txt
+++ b/tests/snapshots/output/grid_numbers_rule.snapshot.txt
@@ -1,24 +1,25 @@
 ─────┬──────────────────────────────────────────────────────────────────────────
-   1 │ struct Rectangle {
-   2 │     width: u32,
-   3 │     height: u32,
-   4 │ }
-   5 │ 
-   6 │ fn main() {
-   7 │     let rect1 = Rectangle { width: 30, height: 50 };
-   8 │ 
-   9 │     println!(
-  10 │         "The perimeter of the rectangle is {} pixels.",
-  11 │         perimeter(&rect1)
-  12 │     );
-  13 │     println!(r#"This line contains invalid utf8:  "�����"#;
-  14 │ }
-  15 │ 
-  16 │ fn area(rectangle: &Rectangle) -> u32 {
-  17 │     rectangle.width * rectangle.height
-  18 │ }
-  19 │ 
-  20 │ fn perimeter(rectangle: &Rectangle) -> u32 {
-  21 │     (rectangle.width + rectangle.height) * 2
-  22 │ }
+   1 │ /// A rectangle. First line is changed to prevent a regression of #1869
+   2 │ struct Rectangle {
+   3 │     width: u32,
+   4 │     height: u32,
+   5 │ }
+   6 │ 
+   7 │ fn main() {
+   8 │     let rect1 = Rectangle { width: 30, height: 50 };
+   9 │ 
+  10 │     println!(
+  11 │         "The perimeter of the rectangle is {} pixels.",
+  12 │         perimeter(&rect1)
+  13 │     );
+  14 │     println!(r#"This line contains invalid utf8:  "�����"#;
+  15 │ }
+  16 │ 
+  17 │ fn area(rectangle: &Rectangle) -> u32 {
+  18 │     rectangle.width * rectangle.height
+  19 │ }
+  20 │ 
+  21 │ fn perimeter(rectangle: &Rectangle) -> u32 {
+  22 │     (rectangle.width + rectangle.height) * 2
+  23 │ }
 ─────┴──────────────────────────────────────────────────────────────────────────
diff --git a/tests/snapshots/output/grid_rule.snapshot.txt b/tests/snapshots/output/grid_rule.snapshot.txt
index 5b970581f5..7061949760 100644
--- a/tests/snapshots/output/grid_rule.snapshot.txt
+++ b/tests/snapshots/output/grid_rule.snapshot.txt
@@ -1,4 +1,5 @@
 ────────────────────────────────────────────────────────────────────────────────
+/// A rectangle. First line is changed to prevent a regression of #1869
 struct Rectangle {
     width: u32,
     height: u32,
diff --git a/tests/snapshots/output/header.snapshot.txt b/tests/snapshots/output/header.snapshot.txt
index 0889edfd32..3cbbad49d2 100644
--- a/tests/snapshots/output/header.snapshot.txt
+++ b/tests/snapshots/output/header.snapshot.txt
@@ -1,4 +1,5 @@
 File: sample.rs
+/// A rectangle. First line is changed to prevent a regression of #1869
 struct Rectangle {
     width: u32,
     height: u32,
diff --git a/tests/snapshots/output/header_numbers.snapshot.txt b/tests/snapshots/output/header_numbers.snapshot.txt
index a681e6b407..82fa9175a5 100644
--- a/tests/snapshots/output/header_numbers.snapshot.txt
+++ b/tests/snapshots/output/header_numbers.snapshot.txt
@@ -1,23 +1,24 @@
      File: sample.rs
-   1 struct Rectangle {
-   2     width: u32,
-   3     height: u32,
-   4 }
-   5 
-   6 fn main() {
-   7     let rect1 = Rectangle { width: 30, height: 50 };
-   8 
-   9     println!(
-  10         "The perimeter of the rectangle is {} pixels.",
-  11         perimeter(&rect1)
-  12     );
-  13     println!(r#"This line contains invalid utf8:  "�����"#;
-  14 }
-  15 
-  16 fn area(rectangle: &Rectangle) -> u32 {
-  17     rectangle.width * rectangle.height
-  18 }
-  19 
-  20 fn perimeter(rectangle: &Rectangle) -> u32 {
-  21     (rectangle.width + rectangle.height) * 2
-  22 }
+   1 /// A rectangle. First line is changed to prevent a regression of #1869
+   2 struct Rectangle {
+   3     width: u32,
+   4     height: u32,
+   5 }
+   6 
+   7 fn main() {
+   8     let rect1 = Rectangle { width: 30, height: 50 };
+   9 
+  10     println!(
+  11         "The perimeter of the rectangle is {} pixels.",
+  12         perimeter(&rect1)
+  13     );
+  14     println!(r#"This line contains invalid utf8:  "�����"#;
+  15 }
+  16 
+  17 fn area(rectangle: &Rectangle) -> u32 {
+  18     rectangle.width * rectangle.height
+  19 }
+  20 
+  21 fn perimeter(rectangle: &Rectangle) -> u32 {
+  22     (rectangle.width + rectangle.height) * 2
+  23 }
diff --git a/tests/snapshots/output/header_numbers_rule.snapshot.txt b/tests/snapshots/output/header_numbers_rule.snapshot.txt
index a681e6b407..82fa9175a5 100644
--- a/tests/snapshots/output/header_numbers_rule.snapshot.txt
+++ b/tests/snapshots/output/header_numbers_rule.snapshot.txt
@@ -1,23 +1,24 @@
      File: sample.rs
-   1 struct Rectangle {
-   2     width: u32,
-   3     height: u32,
-   4 }
-   5 
-   6 fn main() {
-   7     let rect1 = Rectangle { width: 30, height: 50 };
-   8 
-   9     println!(
-  10         "The perimeter of the rectangle is {} pixels.",
-  11         perimeter(&rect1)
-  12     );
-  13     println!(r#"This line contains invalid utf8:  "�����"#;
-  14 }
-  15 
-  16 fn area(rectangle: &Rectangle) -> u32 {
-  17     rectangle.width * rectangle.height
-  18 }
-  19 
-  20 fn perimeter(rectangle: &Rectangle) -> u32 {
-  21     (rectangle.width + rectangle.height) * 2
-  22 }
+   1 /// A rectangle. First line is changed to prevent a regression of #1869
+   2 struct Rectangle {
+   3     width: u32,
+   4     height: u32,
+   5 }
+   6 
+   7 fn main() {
+   8     let rect1 = Rectangle { width: 30, height: 50 };
+   9 
+  10     println!(
+  11         "The perimeter of the rectangle is {} pixels.",
+  12         perimeter(&rect1)
+  13     );
+  14     println!(r#"This line contains invalid utf8:  "�����"#;
+  15 }
+  16 
+  17 fn area(rectangle: &Rectangle) -> u32 {
+  18     rectangle.width * rectangle.height
+  19 }
+  20 
+  21 fn perimeter(rectangle: &Rectangle) -> u32 {
+  22     (rectangle.width + rectangle.height) * 2
+  23 }
diff --git a/tests/snapshots/output/header_rule.snapshot.txt b/tests/snapshots/output/header_rule.snapshot.txt
index 0889edfd32..3cbbad49d2 100644
--- a/tests/snapshots/output/header_rule.snapshot.txt
+++ b/tests/snapshots/output/header_rule.snapshot.txt
@@ -1,4 +1,5 @@
 File: sample.rs
+/// A rectangle. First line is changed to prevent a regression of #1869
 struct Rectangle {
     width: u32,
     height: u32,
diff --git a/tests/snapshots/output/numbers.snapshot.txt b/tests/snapshots/output/numbers.snapshot.txt
index c1341d29df..560e755702 100644
--- a/tests/snapshots/output/numbers.snapshot.txt
+++ b/tests/snapshots/output/numbers.snapshot.txt
@@ -1,22 +1,23 @@
-   1 struct Rectangle {
-   2     width: u32,
-   3     height: u32,
-   4 }
-   5 
-   6 fn main() {
-   7     let rect1 = Rectangle { width: 30, height: 50 };
-   8 
-   9     println!(
-  10         "The perimeter of the rectangle is {} pixels.",
-  11         perimeter(&rect1)
-  12     );
-  13     println!(r#"This line contains invalid utf8:  "�����"#;
-  14 }
-  15 
-  16 fn area(rectangle: &Rectangle) -> u32 {
-  17     rectangle.width * rectangle.height
-  18 }
-  19 
-  20 fn perimeter(rectangle: &Rectangle) -> u32 {
-  21     (rectangle.width + rectangle.height) * 2
-  22 }
+   1 /// A rectangle. First line is changed to prevent a regression of #1869
+   2 struct Rectangle {
+   3     width: u32,
+   4     height: u32,
+   5 }
+   6 
+   7 fn main() {
+   8     let rect1 = Rectangle { width: 30, height: 50 };
+   9 
+  10     println!(
+  11         "The perimeter of the rectangle is {} pixels.",
+  12         perimeter(&rect1)
+  13     );
+  14     println!(r#"This line contains invalid utf8:  "�����"#;
+  15 }
+  16 
+  17 fn area(rectangle: &Rectangle) -> u32 {
+  18     rectangle.width * rectangle.height
+  19 }
+  20 
+  21 fn perimeter(rectangle: &Rectangle) -> u32 {
+  22     (rectangle.width + rectangle.height) * 2
+  23 }
diff --git a/tests/snapshots/output/numbers_rule.snapshot.txt b/tests/snapshots/output/numbers_rule.snapshot.txt
index c1341d29df..560e755702 100644
--- a/tests/snapshots/output/numbers_rule.snapshot.txt
+++ b/tests/snapshots/output/numbers_rule.snapshot.txt
@@ -1,22 +1,23 @@
-   1 struct Rectangle {
-   2     width: u32,
-   3     height: u32,
-   4 }
-   5 
-   6 fn main() {
-   7     let rect1 = Rectangle { width: 30, height: 50 };
-   8 
-   9     println!(
-  10         "The perimeter of the rectangle is {} pixels.",
-  11         perimeter(&rect1)
-  12     );
-  13     println!(r#"This line contains invalid utf8:  "�����"#;
-  14 }
-  15 
-  16 fn area(rectangle: &Rectangle) -> u32 {
-  17     rectangle.width * rectangle.height
-  18 }
-  19 
-  20 fn perimeter(rectangle: &Rectangle) -> u32 {
-  21     (rectangle.width + rectangle.height) * 2
-  22 }
+   1 /// A rectangle. First line is changed to prevent a regression of #1869
+   2 struct Rectangle {
+   3     width: u32,
+   4     height: u32,
+   5 }
+   6 
+   7 fn main() {
+   8     let rect1 = Rectangle { width: 30, height: 50 };
+   9 
+  10     println!(
+  11         "The perimeter of the rectangle is {} pixels.",
+  12         perimeter(&rect1)
+  13     );
+  14     println!(r#"This line contains invalid utf8:  "�����"#;
+  15 }
+  16 
+  17 fn area(rectangle: &Rectangle) -> u32 {
+  18     rectangle.width * rectangle.height
+  19 }
+  20 
+  21 fn perimeter(rectangle: &Rectangle) -> u32 {
+  22     (rectangle.width + rectangle.height) * 2
+  23 }
diff --git a/tests/snapshots/output/plain.snapshot.txt b/tests/snapshots/output/plain.snapshot.txt
index dbc49f9fdd..b9da99a904 100644
--- a/tests/snapshots/output/plain.snapshot.txt
+++ b/tests/snapshots/output/plain.snapshot.txt
@@ -1,3 +1,4 @@
+/// A rectangle. First line is changed to prevent a regression of #1869
 struct Rectangle {
     width: u32,
     height: u32,
diff --git a/tests/snapshots/output/rule.snapshot.txt b/tests/snapshots/output/rule.snapshot.txt
index dbc49f9fdd..b9da99a904 100644
--- a/tests/snapshots/output/rule.snapshot.txt
+++ b/tests/snapshots/output/rule.snapshot.txt
@@ -1,3 +1,4 @@
+/// A rectangle. First line is changed to prevent a regression of #1869
 struct Rectangle {
     width: u32,
     height: u32,
diff --git a/tests/snapshots/sample.modified.rs b/tests/snapshots/sample.modified.rs
index bb1a794375..fff9f98213 100644
--- a/tests/snapshots/sample.modified.rs
+++ b/tests/snapshots/sample.modified.rs
@@ -1,3 +1,4 @@
+/// A rectangle. First line is changed to prevent a regression of #1869
 struct Rectangle {
     width: u32,
     height: u32,