Skip to content

Commit

Permalink
tests/target: Add failing test for rustdoc in enum
Browse files Browse the repository at this point in the history
Test case as reported in #6280.
This test case used to fail, but the code in the previous commit fixes
it.

We followed instructions on Contributing.md [1] to create a test case.

`tests/target/rust-doc-in-enum/vertical-no-doc.rs` is being left unformatted
(expected behavior), while `tests/target/rust-doc-in-enum/vertical-with-doc.rs`
is formatted to `C { a: usize }` (unexpected behavior).

The only different between the two samples is the `/// C` rustdoc added
in `with-doc.rs`.
This reproducing example is minimal: for example, after removing `d: usize`
we do not reproduce the reported behavior.

We found this issue while adding rustdocs to an existing project.
We would expect that adding a line of documentation should not cause the
formatting of the code to change.

[1] https://github.com/rust-lang/rustfmt/blob/40f507526993651ad3b92eda89d5b1cebd0ed374/Contributing.md#L33
  • Loading branch information
malikolivier committed Aug 18, 2024
1 parent ce990c8 commit 6f204cd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/target/rust-doc-in-enum/vertical-no-doc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
enum A {
B {
a: usize,
b: usize,
c: usize,
d: usize,
},

C {
a: usize,
},
}
13 changes: 13 additions & 0 deletions tests/target/rust-doc-in-enum/vertical-with-doc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
enum A {
B {
a: usize,
b: usize,
c: usize,
d: usize,
},

/// C
C {
a: usize,
},
}

0 comments on commit 6f204cd

Please sign in to comment.