rustfmt
rustfmt copied to clipboard
rusfmt hangs when using cfg-if macro
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 } }
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.
current minimal reproduction
cfg_if! {
if #[cfg()] { if }
}
#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?