Skip to content

macro fragment names are no longer idents #42019

Closed
@durka

Description

@durka
Contributor

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.

Activity

durka

durka commented on May 15, 2017

@durka
ContributorAuthor
added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on May 15, 2017
self-assigned this
on May 15, 2017
jseyfried

jseyfried commented on May 15, 2017

@jseyfried
Contributor

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

nagisa

nagisa commented on May 18, 2017

@nagisa
Member

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

added
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
P-highHigh priority
on May 18, 2017
durka

durka commented on May 18, 2017

@durka
ContributorAuthor

It landed, but why is there no nightly?

durka

durka commented on May 19, 2017

@durka
ContributorAuthor

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

brson

brson commented on May 25, 2017

@brson
Contributor

Still broken on beta too I guess?

durka

durka commented on May 25, 2017

@durka
ContributorAuthor

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

nikomatsakis

nikomatsakis commented on May 25, 2017

@nikomatsakis
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

Mark-Simulacrum commented on May 25, 2017

@Mark-Simulacrum
Member

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

Mark-Simulacrum

Mark-Simulacrum commented on May 25, 2017

@Mark-Simulacrum
Member

Ran bisect: fe15119 - #40597.

11 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @durka@brson@nikomatsakis@nagisa@bstrie

      Issue actions

        macro fragment names are no longer idents · Issue #42019 · rust-lang/rust