From b1fb29b43209e90a108b493a9e0242e197a1b263 Mon Sep 17 00:00:00 2001 From: Matthew Hughes Date: Tue, 6 Oct 2026 19:58:53 +0100 Subject: [PATCH] Add regression test for issue 6300 It looks like this issue has been fixed, so add a test to ensure we never regress. You may ask _when_ this was fixed, the best I could do was bisect to a merge commit: d97c4fb3e2fa63e0a4cb4ba442bc8786a5ad4f24, via: # use --first-parent so we don't try and build commits that were # originally added in rust-lang/rust, since it's a pain to find the # correct toolchain to build those against $ git bisect start --term-new=fixed --term-old=broken --first-parent main 46cb7d322055625c07823dea8fdfad4c07f98754 $ git bisect run ./bisect.sh Where `bisect.sh` is: #!/usr/bin/env bash set -o errexit if ! cargo build --quiet --bin rustfmt then echo "failed to build" >&2 # exit: magic code that tells git-bisect to skip this commit (see # git-bisect(1)) exit 125 fi export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" # reverse the exit code: the basis of 'git bisect' is that the 'new' commit is # bad, the 'old' commit is good (e.g. there's a bug in HEAD but not HEAD~4, # which commit introduced that?). But we want the _opposite_ ! ./target/debug/rustfmt --check ./samples/bugs.rs >/dev/null References: rust-lang/rustfmt#6300 --- tests/target/issue_6300.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tests/target/issue_6300.rs diff --git a/tests/target/issue_6300.rs b/tests/target/issue_6300.rs new file mode 100644 index 00000000000..bb5a3673243 --- /dev/null +++ b/tests/target/issue_6300.rs @@ -0,0 +1,11 @@ +const B: b = b { + c: d, + /* block comment, has bug */ + .. +}; + +const C: c = c { + c: d, + // line comment has bug + .. +};