Skip to content

Panic on <- in macro invocation #2953

@dtolnay

Description

@dtolnay

I am trying to write a macro where the input syntax is $a:ident <- $b:expr (unrelated to the old placement expression syntax). Rustfmt sees this as placement, decides to format the macro input as a placement expression, and hits an unimplemented!().

macro_rules! demo {
    ($a:ident <- $b:expr) => {};
}

fn main() {
    demo!(i <- 0);
}
thread 'main' panicked at 'not yet implemented', tools/rustfmt/src/expr.rs:347:47
note: Run with `RUST_BACKTRACE=1` for a backtrace.

If we don't want to implement formatting for actual placement expressions (#2743), at least inside of macro input rustfmt should let them go and not treat them as expressions at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICE

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions