rust-lang/rustfmt
Merge `.. .` tokens producing invalid syntax
Geschlossen
#7.011 geöffnet am 04.08.2026
A-closuresC-bugI-invalid-codegood first issue
Repository-Metriken
- Stars
- (4.893 Sterne)
- PR-Merge-Metriken
- (Durchschn. Merge 67T) (5 gemergte PRs in 30 T)
Beschreibung
Summary
Rustfmt produces syntactically valid, but not semantically equivalent to the original code, wrapping to parens.
There is two cases actually. In second case (field) rustfmt produces invalid syntax.
I tried to format this code:
See details in rust-analyzer/23004.
fn foo() {
|| 1.. .method();
|| 1.. .field;
}
From here on, this example is used without the function signature.
Expected behavior
I expected to see this happen, two possible options:
- no changes
- range wrappend in parens:
|| (1..).method(); || (1..).field;
Actual behavior
Instead, this happened:
(|| 1..).method(); // semantically defferent: `method()` should be "method of the range"
|| 1...field; // invalid token: `...`
Reproduction Steps
rustfmt ./file-with-foo-fn-from-summary.rs
Meta
rustfmt --version:
rustfmt 1.10.0-nightly (11177f2235 2026-08-02)