Skip to content

$crate in macros is accepted in any identifier position #42898

Closed
@petrochenkov

Description

@petrochenkov

E.g. this compiles on rustc 1.20.0-nightly (c9bb93576 2017-06-24)

macro_rules! m {
    () => {
        struct $crate {}
    }
}

m!();

fn main() {}

This is a regression from Rust 1.14.0.

$crate should be accepted only as a first segment in a path, so it would be reasonable to turn it from an "arbitrary identifier" into a "path segment keyword" like Self/self/super.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-parserArea: The lexing & parsing of Rust source code to an ASTregression-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

    Issue actions