Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jonas-schievink opened this issue Apr 16, 2021 · 0 comments · Fixed by #8550
Closed

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

jonas-schievink opened this issue Apr 16, 2021 · 0 comments · Fixed by #8550
Assignees
Labels
A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now

Comments

@jonas-schievink
Copy link
Contributor

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

@jonas-schievink jonas-schievink added A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now labels Apr 16, 2021
@edwin0cheng edwin0cheng self-assigned this Apr 17, 2021
@bors bors bot closed this as completed in c9ca6a1 Apr 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants