#5974·rustfmt

Non-idempotent repeatedly growing indentation in doc attribute containing multi-line concat

Author: dtolnayCreated Dec 6, 2023Updated Sep 8, 2026
LabelsC-bugA-macrosI-non-idempotencyA-doc-comments

Minimized from https://github.com/rust-lang/rust/blob/1.74.0/library/core/src/num/nonzero.rs#L341-L342.

rust
macro_rules! repro {
    () => {
        #[doc = concat!("let var = ",
                        "false;")]
        fn f() {}
    };
}

As of current master, rustfmt applies the following diff. This is from cargo run --bin rustfmt -- /path/to/repro.rs.

diff
-                        "false;")]
+                                "false;")]

If you run rustfmt again, it keeps going for 16 levels of indentation before reaching an idempotent state.

diff
-                        "false;")]
+                                        "false;")]
diff
-                        "false;")]
+                                                "false;")]
diff
-                        "false;")]
+                                                        "false;")]
diff
-                        "false;")]
+                                                                "false;")]
diff
-                        "false;")]
+                                                                        "false;")]
diff
-                        "false;")]
+                                                                                "false;")]
diff
-                        "false;")]
+                                                                                        "false;")]
diff
-                        "false;")]
+                                                                                        "false;")]