Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

nested macros don't allow repetitions in binding patterns #35853

Copy link
Copy link
@colin-kiegel

Description

@colin-kiegel
Issue body actions

Example:

macro_rules! foo {
    () => {
        macro_rules! bar {
            ( $( $any:tt )* ) => { $( $any )* };
        }
    };
}

fn main() { foo!(); }

https://play.rust-lang.org/?gist=f7355a6828cc2af68cc17f280a982ad8&version=beta&backtrace=0

results in:

error: attempted to repeat an expression containing no syntax variables matched as repeating at this depth

 --> <anon>:4:15
  |
4 |             ( $( $any:tt )* ) => { $( $any )* };
  |               ^^^^^^^^^^^^

Note

If the repetition is removed, i.e. the offending part ( $( $any:tt )* ) => { $( $any )* }; is changed to ( $any:tt ) => { $any };, the error disappears on rustc 1.12+ due to the fix of #6994: macros should be parsed more lazily. I find it a bit inconsistent, that nested macros now support binding patterns, but no repetitions.

Meta

  • rustc 1.12.0-beta.1 (822166b 2016-08-16)
  • rustc 1.13.0-nightly (499484f 2016-08-18)
dtolnay, ids1024, JoeyAcc, exul, dginev and 34 more

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.