Skip to content

Extended key-value attributes result in broken macro expansion #8544

Closed
@jonas-schievink

Description

@jonas-schievink

cc #8092

macro_rules! enum_from_u32 {
    (pub enum $name:ident {
        $($(#[$var_attr:meta])* $variant:ident,)*
    }) => {
        pub enum $name {
            $($variant,)*
        }

        impl $name {}
    }
}

macro_rules! language_item_table {
    (
        $( $variant:ident )*
    ) => {
        enum_from_u32! {
            pub enum LangItem {
                $(
                    #[doc = concat!("The `", "bla", "` lang item.")]
                    ///
                    $variant,
                )*
            }
        }
    }
}

language_item_table! {
    Bool
}

Results in:

pub enum$name{}
impl$name{}

...which is parsed as a name! macro invocation, causing spurious "unresolved macro call" diagnostics

Metadata

Metadata

Assignees

Labels

A-macromacro expansionS-actionableSomeone could pick this issue up and work on it right now

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions