Skip to content

Panic when formatting a macro usage with generics #5208

Closed
@Samzyre

Description

@Samzyre

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions