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

Comments

Projects
None yet
7 participants
@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

This comment has been minimized.

Copy link
Contributor Author

durka commented May 15, 2017

@jseyfried

This comment has been minimized.

Copy link
Contributor

jseyfried commented May 15, 2017

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

@nagisa

This comment has been minimized.

Copy link
Contributor

nagisa commented May 18, 2017

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

@durka

This comment has been minimized.

Copy link
Contributor Author

durka commented May 18, 2017

It landed, but why is there no nightly?

@durka

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor

brson commented May 25, 2017

Still broken on beta too I guess?

@durka

This comment has been minimized.

Copy link
Contributor Author

durka commented May 25, 2017

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

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented May 25, 2017

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

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented May 25, 2017

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

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented May 25, 2017

Ran bisect: fe15119 - #40597.

@brson brson added the I-wrong label Jun 1, 2017

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Jun 8, 2017

@jseyfried any progress?

@brson

This comment has been minimized.

Copy link
Contributor

brson commented Jul 13, 2017

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

@jseyfried

This comment has been minimized.

Copy link
Contributor

jseyfried commented Jul 13, 2017

Fixed in #43224.

bors added a commit that referenced this issue Jul 15, 2017

Auto merge of #43224 - jseyfried:fix_macro_idents_regression, r=nrc
macros: fix regression involving identifiers in `macro_rules!` patterns.

Fixes #42019.
r? @nrc

bors added a commit that referenced this issue Jul 15, 2017

Auto merge of #43224 - jseyfried:fix_macro_idents_regression, r=nrc
macros: fix regression involving identifiers in `macro_rules!` patterns.

Fixes #42019.
r? @nrc

@bors bors closed this in #43224 Jul 15, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.