Skip to content

Hangs on derive macro invoked by format string macro #44692

Closed
@dtolnay

Description

@dtolnay

The compiler hangs when compiling the following code.

macro_rules! hang {
    () => {
        {
            #[derive(Clone)]
            struct S;

            ""
        }
    }
}

fn main() {
    format_args!(hang!());
}

This is a regression in 1.20.0. The same code terminates with an error "format argument must be a string literal" in 1.19.0, which is the correct behavior.

Metadata

Metadata

Labels

A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions