Skip to content

Fragment specifiers in macro are not taken into account #35650

Closed
@GuillaumeLestringant

Description

@GuillaumeLestringant

Here is a minimum example of the problem.

macro_rules! size    {
    ($ty:ty) => {
        std::mem::size_of::<$ty>()
    };
    ($size:tt) => {
        $size
    };
}

fn main()   {
    println!("{}", size!(u32));
    println!("{}", size!(4));
}

Compilation fails with following error.

temp.rs:12:26: 12:27 error: expected type, found 4
temp.rs:12 println!("{}", size!(4));

Which means that the fragment qualifier is not taken into account to choose which variant of the macro is to be used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions