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

Panic when formatting a macro usage with generics #5208

Closed
Samzyre opened this issue Jan 31, 2022 · 2 comments
Closed

Panic when formatting a macro usage with generics #5208

Samzyre opened this issue Jan 31, 2022 · 2 comments

Comments

@Samzyre
Copy link

Samzyre commented Jan 31, 2022

I get a formatter panic when running it on a file with macro usage.
No difference with rustfmt.toml settings all commented out.

rustfmt version:
rustfmt 1.4.38-nightly (5e57faa7 2022-01-19)

Error:

thread 'main' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler\rustc_errors\src\lib.rs:1188:13

Code that breaks it:

// #[rustfmt::skip] // Formatting breaks here without this
impl_widget_basic!(PairTable, 'a, 'b, L, R);

The macro in question (also using macro keyword feature on nightly):

macro impl_widget_basic($i:ident, $b:lifetime $(,$a:tt)*) {
    impl<$b$(,$a)*> WidgetBasic<$b> for $i<$b$(,$a)*> {
        fn block(mut self, block: Block<$b>) -> Self {
            self.block = Some(block);
            self
        }

        fn style(mut self, style: Style) -> Self {
            self.style = style;
            self
        }
    }
}

Other uses without generics seem to be fine, though

impl_widget_basic!(BigText, 'a, 'b); // No problems here
@ytmimi
Copy link
Contributor

ytmimi commented Jan 31, 2022

Thanks for submitting this report!

I don't think this is rustfmt panicking. I mostly think that because of the panic message you included:
compiler\rustc_errors\src\lib.rs:1188:13

rustfmt uses the parser defined in the compiler to parse your rust code into an AST, before trying to format it. It appears to me that the panic is actually happening in the compiler. It might be more appropriate to open up this issue in that repo?

@calebcartwright
Copy link
Member

Thanks for reaching out, but going to close as this is a duplicate report of an upstream issue within the compiler (rust-lang/rust#93282) which has already been resolved. You can update to a newer nightly to pull in the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants