Open dtolnay opened 1 month ago
This currently affects syn
as of https://github.com/dtolnay/syn/tree/2.0.66. Running cargo fmt
in that repo produces the incorrect diff seen in https://github.com/dtolnay/syn/pull/1672.
The oldest version of rustfmt that exhibits this issue is the one that shipped with Rust 1.38; rustfmt in older Rust releases leaves the original code unmodified.
According to bisect, this regressed between nightly-2019-07-25 and nightly-2019-07-31 (the dates in between are missing the rustfmt component). The only PR touching rust-lang/rust's src/tools/rustfmt in that range is https://github.com/rust-lang/rust/pull/62805, so the relevant rustfmt commit range is https://github.com/rust-lang/rustfmt/compare/66c27c9161b2aa70c2902807be12952bd4a0a62b...9e960e7d6a0c6b7c46c195acbd6f92ade6eec3ba.
https://github.com/rust-lang/rustfmt/pull/3691 looks suspiciously relevant based on these changes it causes to some of the tests.
Running rustfmt on this file turns it into:
Observations:
#[path = "/dev/null"]
attribute is not necessary for the repro. It is just to make this reproducible with a single input file.#[rustfmt::skip]
are necessary for the repro. Without either one, the problem does not occur.;
are necessary for the repro. If either module uses{
}
instead of;
, the problem does not occur.