-
Notifications
You must be signed in to change notification settings - Fork 974
Open
Labels
A-stringsArea: string literalsArea: string literalsI-poor-formattingIssue: poor formattingIssue: poor formatting
Description
I tried this code:
struct Test;
impl Test {
fn callit<T, F: FnOnce() -> T>(&self, f: F) -> T {
f()
}
fn test(&self) {
self.callit(|| {
if true {
if true {
if true {
let r#type = 1;
println!(" {type:?} {} {} {:?}", 1,1,1);
}}}
});
}
}
fn main() {}I expected to see this happen: rustfmt should format the document
Instead, this happened: rustfmt did nothing and reported no error
Meta
rustc --version --verbose:
rustc 1.91.0-nightly (898aff704 2025-08-14)
binary: rustc
commit-hash: 898aff704d6f0d00343f21d31b8b9bfac8e43007
commit-date: 2025-08-14
host: x86_64-unknown-linux-gnu
release: 1.91.0-nightly
LLVM version: 21.1.0
Removing any single character from the println!() block allows it to format. Changing the name of r#type allows it to format. Removing one of the if true {} blocks or the closure allows it to format.
Link to playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=cee93ebcb8c17a2b8c989101d4a5f5fa
lmurri
Metadata
Metadata
Assignees
Labels
A-stringsArea: string literalsArea: string literalsI-poor-formattingIssue: poor formattingIssue: poor formatting