Skip to content

Instantly share code, notes, and snippets.

@orthecreedence
Last active July 10, 2016 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orthecreedence/599897d7ae38b6b271ac077239c00ab9 to your computer and use it in GitHub Desktop.
Save orthecreedence/599897d7ae38b6b271ac077239c00ab9 to your computer and use it in GitHub Desktop.
Rust macro error
macro_rules! serializable {
(
$(#[$struct_meta:meta])*
pub struct $name:ident {
$(
$(#[$field_meta:meta]) *
$field:ident: $type_:ty
),* ,
}
) => {
$(#[$struct_meta])*
pub struct $name {
$(
$(#[$field_meta]) *
$field: $type_
),* ,
}
}
}
serializable! {
#[allow(dead_code)]
/// This is a test
pub struct Tester {
#[allow(dead_code)]
name: String,
}
}
@orthecreedence
Copy link
Author

Gives the error:

error: local ambiguity: multiple parsing options: built-in NTs ident ('field') or 1 other option.
src\util\serialization.rs:180             #[allow(dead_code)]

@orthecreedence
Copy link
Author

removing the #[allow(dead_code)] above name: String works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment