Skip to content
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

Infinite loop when using expr attributes inside macro expansion #5896

Closed
Swatinem opened this issue Aug 27, 2020 · 1 comment · Fixed by #7060
Closed

Infinite loop when using expr attributes inside macro expansion #5896

Swatinem opened this issue Aug 27, 2020 · 1 comment · Fixed by #7060
Assignees
Labels
A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now

Comments

@Swatinem
Copy link
Contributor

Reproduction using lazy_static:

lazy_static::lazy_static! {
    static ref FOO: () = #[allow(missing_docs)]
    ();
}

I’m trying to further minimize the testcase.

I get the following with RA_LOG:

[WARN hir_expand::db] fail on macro_parse: (reason: BindingError("expected subtree") macro_call: __lazy_static_internal!(@MAKETY, ,(), $N);) parents: __lazy_static_internal!(@TAIL, $N: : = =);
__lazy_static_internal!(@TAIL, $N:()= $);
__lazy_static_internal!(@MAKETY, ,(), $N);
__lazy_static_internal!(@MAKETY, ,(), $N);
__lazy_static_internal!(@TAIL, $N:()= $);
__lazy_static_internal!(@MAKETY, ,(), $N);
__lazy_static_internal!(@MAKETY, ,(), $N);
__lazy_static_internal!(@TAIL, $N:()= $);
__lazy_static_internal!(@MAKETY, ,(), $N);
__lazy_static_internal!(@MAKETY, ,(), $N);
__lazy_static_internal!(@MAKETY, ,(), $N);
__lazy_static_internal!(()staticref$N: $T= $e;);
lazy_static!((););
__lazy_static_internal!(()staticrefFOO:()= # ;(););
lazy_static::lazy_static! {
    static ref FOO: () = #[allow(missing_docs)]
    ();
}

the log message changes a bit, but its just looping there.

@Swatinem
Copy link
Contributor Author

This can be easily worked around by wrapping both the attribute and the expression in braces. We hit this problem here btw: getsentry/relay#734

@jonas-schievink jonas-schievink added the A-macro macro expansion label Aug 27, 2020
@lnicola lnicola added the S-actionable Someone could pick this issue up and work on it right now label Oct 15, 2020
@edwin0cheng edwin0cheng self-assigned this Dec 27, 2020
@bors bors bot closed this as completed in 77ad203 Dec 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants