Skip to content

Incorrect truncated macro expansion #4777

@jonas-schievink

Description

@jonas-schievink

This code results in a wrong expansion of the macro, where the resulting enum only has the first specified variant:

macro_rules! enum_with_unknown {
    (
        enum $name:ident {
            $(
              $variant:ident $(,)*
            ),*
        }
    ) => {
        enum $name {
            $(
              $variant,
            )*
        }
    }
}

enum_with_unknown! {
    enum ControlOpcode {
        ConnectionUpdateReq,
        ChannelMapReq,
    }
}

Resulting code according to "Expand macro recursively":

enum ControlOpcode {
  ConnectionUpdateReq,
}

(EDIT: Reduced)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macromacro expansionE-hardS-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