Skip to content

declarative macro results in rustc entering infinite loop #68228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
carllerche opened this issue Jan 14, 2020 · 1 comment
Open

declarative macro results in rustc entering infinite loop #68228

carllerche opened this issue Jan 14, 2020 · 1 comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. I-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@carllerche
Copy link
Member

Rustc: rustc 1.40.0 (73528e339 2019-12-16)

uname -a: Darwin Carls-MacBook-Pro-2.local 18.7.0 Darwin Kernel Version 18.7.0: Sun Dec 1 18:59:03 PST 2019; root:xnu-4903.278.19~1/RELEASE_X86_64 x86_64

I have crafted a declarative macro that results in rustc entering an infinite loop and never completing.

Repro:

#[macro_export]
macro_rules! lock {
    // Done normalizing
    (@ { $($t:tt)* }) => {
    };
    (@ { $($t:tt)* } $a:pat, $b:expr, $c:block $($r:tt)* ) => {
        $crate:lock!(@{ $($t)* $a,$b, $c, } $($r)*)

    };
    ( $($t:tt)* ) => {
        $crate::lock!(@{} $($t:tt)*)
    }
}

fn main() {
    lock! {
        foo, bar(), {
            println!("WAT!");
        }
    }
}
@carllerche
Copy link
Member Author

Perhaps a dup of #51754

@varkor varkor added the I-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. label Jan 14, 2020
@JohnTitor JohnTitor added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. I-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants