Skip to content

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

Open
@dtolnay

Description

@dtolnay

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

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.

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

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

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

Metadata

Metadata

Assignees

Labels

a-macrosbugPanic, non-idempotency, invalid code, etc.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions