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

rusfmt hangs when using cfg-if macro #4442

Open
gliderkite opened this issue Sep 29, 2020 · 3 comments · May be fixed by #5341 or #6499
Open

rusfmt hangs when using cfg-if macro #4442

gliderkite opened this issue Sep 29, 2020 · 3 comments · May be fixed by #5341 or #6499
Labels
bug Panic, non-idempotency, invalid code, etc.

Comments

@gliderkite
Copy link

rusfmt hangs when using cfg-if macro

To reproduce run rustftm main.rs, where:

// main.rs
cfg_if::cfg_if! {
    if #[cfg(not(feature = "client"))] {
        if #[cfg(feature = "server")] {
        }
    }
}
rustfmt -V
rustfmt 1.4.18-stable (8157a3f 2020-07-15)

From the logs RUST_LOG=trace rustftm main.rs I can see it just keeps logging:

[2020-09-29T14:17:39Z DEBUG rustc_ap_rustc_parse::parser::attr] parse_outer_attributes: self.token=Token { kind: Ident("if", false), span: Span { lo: BytePos(67), hi: BytePos(69), ctxt: #0 } }
[2020-09-29T14:17:39Z DEBUG rustc_ap_rustc_parse::parser::attr] parse_outer_attributes: self.token=Token { kind: Ident("if", false), span: Span { lo: BytePos(67), hi: BytePos(69), ctxt: #0 } }
[2020-09-29T14:17:39Z DEBUG rustc_ap_rustc_parse::parser::attr] parse_outer_attributes: self.token=Token { kind: Ident("if", false), span: Span { lo: BytePos(67), hi: BytePos(69), ctxt: #0 } }
@gliderkite gliderkite added the bug Panic, non-idempotency, invalid code, etc. label Sep 29, 2020
@ytmimi ytmimi linked a pull request May 13, 2022 that will close this issue
@mpfaff
Copy link

mpfaff commented Jun 28, 2022

This is most minimal reproduction I've found:

cfg_if! {
    if #[_] { if }
}

Although I should note that it doesn't produce any debug messages when run with RUST_LOG=trace like yours does.

@youknowone
Copy link

current minimal reproduction

cfg_if! {
    if #[cfg()] { if }
}

@youknowone
Copy link

#6251 could fix this bug 6 months ago, but closed in favor of #5341.
#5341 doesn't look go well for months though.

@ytmimi for what? why don't you merge a simple fix and add a revert commit of that in front of your patch?

@youknowone youknowone linked a pull request Mar 11, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
3 participants