]> git.lizzy.rs Git - rust.git/commitdiff
Correctly indent skipped-over code
authorAyaz Hafiz <ayaz.hafiz.1@gmail.com>
Wed, 26 Aug 2020 04:52:26 +0000 (23:52 -0500)
committerCaleb Cartwright <calebcartwright@users.noreply.github.com>
Sat, 24 Oct 2020 16:13:00 +0000 (11:13 -0500)
Closes #4398

src/missed_spans.rs
tests/source/issue-4398.rs [new file with mode: 0644]
tests/target/issue-4398.rs [new file with mode: 0644]

index e6889ae97865b690a9174126a74ea05704657038..17b11ed6cf49cd69c2d6afc62891048bd18a52bc 100644 (file)
@@ -353,6 +353,7 @@ fn process_missing_code(
 
         let remaining = snippet[status.line_start..subslice.len() + offset].trim();
         if !remaining.is_empty() {
+            self.push_str(&self.block_indent.to_string(self.config));
             self.push_str(remaining);
             status.line_start = subslice.len() + offset;
         }
diff --git a/tests/source/issue-4398.rs b/tests/source/issue-4398.rs
new file mode 100644 (file)
index 0000000..b0095aa
--- /dev/null
@@ -0,0 +1,19 @@
+impl Struct {
+    /// Documentation for `foo`
+    #[rustfmt::skip] // comment on why use a skip here
+    pub fn foo(&self) {}
+}
+
+impl Struct {
+    /// Documentation for `foo`
+       #[rustfmt::skip] // comment on why use a skip here
+    pub fn foo(&self) {}
+}
+
+/// Documentation for `Struct`
+#[rustfmt::skip] // comment
+impl Struct {
+    /// Documentation for `foo`
+       #[rustfmt::skip] // comment on why use a skip here
+    pub fn foo(&self) {}
+}
diff --git a/tests/target/issue-4398.rs b/tests/target/issue-4398.rs
new file mode 100644 (file)
index 0000000..2ca8945
--- /dev/null
@@ -0,0 +1,19 @@
+impl Struct {
+    /// Documentation for `foo`
+    #[rustfmt::skip] // comment on why use a skip here
+    pub fn foo(&self) {}
+}
+
+impl Struct {
+    /// Documentation for `foo`
+    #[rustfmt::skip] // comment on why use a skip here
+    pub fn foo(&self) {}
+}
+
+/// Documentation for `Struct`
+#[rustfmt::skip] // comment
+impl Struct {
+    /// Documentation for `foo`
+       #[rustfmt::skip] // comment on why use a skip here
+    pub fn foo(&self) {}
+}