Skip to content

Spurious local ambiguity error after empty $($ident),* #34030

Closed
@chris-morgan

Description

@chris-morgan
macro_rules! foo {
    ($($t:ident),*/) => {()};
}

fn main() {
    foo!(a, b/);  // works fine
    foo!(a/);     // works fine
    foo!(/);      // local ambiguity error ☹
}
error: local ambiguity: multiple parsing options: built-in NTs ident ('t') or 1 other option.
 --> <anon>:8:10
8 |>     foo!(/);
  |>          ^

In this case, it should be looking for an ident or a /, in which there is no ambiguity.

All channels are affected.

This is affecting my ability to write macros accepting generics using angle brackets, e.g. $ty:ident<$($x:ident),*>, with a supporting pattern to turn Foo into Foo<>.

May be related to #24827.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions