From 0c1df427cdda14ab716edb0ba5eb6163efcfb2e8 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Wed, 14 Aug 2024 08:14:53 +0900 Subject: [PATCH] tests/target: Add failing test for docstring in enum Follow instructions on Contributing.md [1] to create a test case. [1] https://github.com/rust-lang/rustfmt/blob/40f507526993651ad3b92eda89d5b1cebd0ed374/Contributing.md#L33 `tests/target/rust-doc-in-enum/without-doc.rs` is being left unformatted (expected behavior), while ``tests/target/rust-doc-in-enum/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`. As far as I can tell, this reproducing example is minimal: for example, after removing `d: usize` we do not reproduce the reported behavior. I found this issue while adding rustdocs to an existing project. I would expect that adding a line of documentation should not cause the formatting of the code to change. --- tests/target/rust-doc-in-enum/with-doc.rs | 13 +++++++++++++ tests/target/rust-doc-in-enum/without-doc.rs | 12 ++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/target/rust-doc-in-enum/with-doc.rs create mode 100644 tests/target/rust-doc-in-enum/without-doc.rs diff --git a/tests/target/rust-doc-in-enum/with-doc.rs b/tests/target/rust-doc-in-enum/with-doc.rs new file mode 100644 index 00000000000..b61a018ac12 --- /dev/null +++ b/tests/target/rust-doc-in-enum/with-doc.rs @@ -0,0 +1,13 @@ +enum A { + B { + a: usize, + b: usize, + c: usize, + d: usize, + }, + + /// C + C { + a: usize, + }, +} diff --git a/tests/target/rust-doc-in-enum/without-doc.rs b/tests/target/rust-doc-in-enum/without-doc.rs new file mode 100644 index 00000000000..1148c03a008 --- /dev/null +++ b/tests/target/rust-doc-in-enum/without-doc.rs @@ -0,0 +1,12 @@ +enum A { + B { + a: usize, + b: usize, + c: usize, + d: usize, + }, + + C { + a: usize, + }, +}