Skip to content

book says $crate is a single identifier but it isn't #30217

Closed
@durka

Description

@durka

The macros chapter says:

To keep this system simple and correct, #[macro_use] extern crate ... may only appear at the root of your crate, not inside mod. This ensures that $crate is a single identifier.

However the second sentence isn't true. $crate is either nothing or a path with one :: and one identifier. That is, this pair of macros doesn't work, either when called from within the crate or from another one:

macro_rules! b { ($i:ident) => { stringify!($i); } }
macro_rules! a { () => (b!($crate)) }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions