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

macro fragment names are no longer idents #42019

Closed
durka opened this issue May 15, 2017 · 13 comments
Closed

macro fragment names are no longer idents #42019

durka opened this issue May 15, 2017 · 13 comments
Assignees
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@durka
Copy link
Contributor

durka commented May 15, 2017

This is a stable-to-beta regression, but it's such a weird thing to do that I don't know if it counts.

Consider the following code (playpen):

macro_rules! gen {
    ($name:ident ($($dol:tt $var:ident)*) $($body:tt)*) => {
        macro_rules! $name {
            ($($dol $var:ident)*) => {
                $($body)*
            }
        }
    }
}

The gen macro parses a macro argument spec by matching a dollar sign with $dol and the fragment name with $var. Then (in this toy example) it just regurgitates that adding :ident as the type of each fragment.

This works in 1.17, but fails when invoked in 1.18 and nightly with the message "expected identifier, found [the ident passed in for $var]", pointing at $var on line 4. All three channels work if $var:ident is changed to $var:tt on line 2.

@durka
Copy link
Contributor Author

durka commented May 15, 2017

cc @jseyfried

@bstrie bstrie added regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 15, 2017
@jseyfried jseyfried self-assigned this May 15, 2017
@jseyfried
Copy link
Contributor

I believe this is a duplicate of #41803; it should be fixed once #42005 lands.

@nagisa
Copy link
Member

nagisa commented May 18, 2017

Now that #42005 has landed, this should be re-reproduced.

@nagisa nagisa added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) P-high High priority labels May 18, 2017
@durka
Copy link
Contributor Author

durka commented May 18, 2017

It landed, but why is there no nightly?

@durka
Copy link
Contributor Author

durka commented May 19, 2017

This was not fixed by #42005. It is still broken with rustc 1.19.0-nightly (0ed1ec9 2017-05-18).

@brson
Copy link
Contributor

brson commented May 25, 2017

Still broken on beta too I guess?

@durka
Copy link
Contributor Author

durka commented May 25, 2017

Yes, the code in the playpen still fails to compile on beta and nightly.

@nikomatsakis
Copy link
Contributor

cc @Mark-Simulacrum -- it'd be great to know just what caused this problem. @jseyfried, are you going to have time to investigate?

@Mark-Simulacrum
Copy link
Member

If I have a chance I'll run bisect-rust, also cc @est31 -- they have it working locally as well.

@Mark-Simulacrum
Copy link
Member

Ran bisect: fe15119 - #40597.

@brson brson added the I-wrong label Jun 1, 2017
@nikomatsakis
Copy link
Contributor

@jseyfried any progress?

@brson brson added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. and removed regression-from-stable-to-beta Performance or correctness regression from stable to beta. labels Jun 15, 2017
@brson
Copy link
Contributor

brson commented Jul 13, 2017

This is a P-high bug and it is inactive cc @rust-lang/compiler

@jseyfried
Copy link
Contributor

Fixed in #43224.

bors added a commit that referenced this issue Jul 15, 2017
macros: fix regression involving identifiers in `macro_rules!` patterns.

Fixes #42019.
r? @nrc
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, ..) P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants