andersk / enum_primitive-rs

Macro to generate num::FromPrimitive instances for enum that works in Rust 1.0

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fails to parse attributes on enum variants

andersk opened this issue · comments

Due to rust-lang/rust#24189, we can’t match attributes on enum variants:

#[macro_use] extern crate enum_primitive;

enum_from_primitive! {
enum FooBar {
    Foo = 17,
    #[doc = "bar"]
    Bar = 42,
}
}
r.rs:6:5: 6:6 error: local ambiguity: multiple parsing options: built-in NTs ident ('variant') or 1 other options.
r.rs:6     #[doc = "bar"]
           ^
commented

Same happens for simple doc comments

#[macro_use] extern crate enum_primitive;

enum_from_primitive! {
enum FooBar {
    Foo = 17,
    /// bar
    Bar = 42,
}
}

I too am running into the same problem as nwin

This was fixed in Rust 1.20.