Skip to content

Infinite loop in recursive macro expansion #4054

@powerboat9

Description

@powerboat9

Summary

It seems like recursive macros aren't being expanded correctly. Notably, the issue seems to go away if the metavariable isn't an ident.

Reproducer

I tried this code:

#![allow(path_statements)]

macro_rules! array_impl_default {
    {$t:ident} => {
        $t;
        array_impl_default!{}
    };
    {} => {};
}

pub fn foo() {
    let x = 12;
    array_impl_default! {x}
}

Does the code make use of any (1.49) nightly feature ?

  • Nightly

Godbolt link

https://godbolt.org/z/Mbd1cdYhb

Actual behavior

An infinite loop

Expected behavior

Compiles

GCC Version

85ec714

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions