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

$a:tt $($b:tt)* is forbidden in macros #25436

Closed
nikomatsakis opened this issue May 15, 2015 · 7 comments · Fixed by #25444
Closed

$a:tt $($b:tt)* is forbidden in macros #25436

nikomatsakis opened this issue May 15, 2015 · 7 comments · Fixed by #25444
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority

Comments

@nikomatsakis
Copy link
Contributor

In an example like http://is.gd/TKfdKf:

macro_rules! foo {
  ( $a:tt $($b:tt)* ) => { }
}

fn main() { }

we report the following error:

<anon>:2:11: 2:19 error: `$a:tt` is followed by a sequence repetition, which is not allowed for `tt` fragments
<anon>:2   ( $a:tt $($b:tt)* ) => { }
                   ^~~~~~~~
error: aborting due to previous error
playpen: application terminated with error code 101

This is part of the macro future-proofing code but it is an unnecessary limitation. For fragments that represent at most one token tree (tt, block, ident, possibly others) there is no concern at all about being following by sequence repetition. This turns out to be a really big limitation in practice, since making macros that work over a generic sequence of token trees effectively allows for arbitrary parsing.

cc @pnkfelix

@nikomatsakis
Copy link
Contributor Author

triage: P-medium

@rust-highfive rust-highfive added the P-medium Medium priority label May 15, 2015
@nikomatsakis nikomatsakis added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. and removed P-medium Medium priority labels May 15, 2015
@nikomatsakis
Copy link
Contributor Author

I'd be happy to mentor this, if I don't fix it first.

@nikomatsakis
Copy link
Contributor Author

triage: P-medium

@rust-highfive rust-highfive added the P-medium Medium priority label May 15, 2015
@nikomatsakis
Copy link
Contributor Author

cc @cmr

@Stebalien
Copy link
Contributor

I-ICE?

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue May 15, 2015
bors added a commit that referenced this issue May 16, 2015
Permit token trees, identifiers, and blocks to be following by sequences.

Fixes #25436.

r? @pnkfelix
@bjadamson
Copy link
Contributor

Curious why this was closed, looks like it's blocking lispy-rust.

@jdm
Copy link
Contributor

jdm commented Sep 5, 2015

@bjadamson It was fixed by #25444; do you still see this issue present in nightly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants