Compiling the following code:
#![feature(rustc_macro)]
extern crate serde;
#[macro_use] extern crate serde_derive;
macro_rules! event {
( #[$attr:meta]
pub struct $name:ident($content_type:ty);
) => {
#[$attr]
#[derive(Debug, Deserialize, Serialize)]
pub struct $name {
/// The event's content.
content: $content_type,
}
}
}
event! {
/// A custom basic event not covered by the Matrix specification.
pub struct CustomEvent(String);
}
Results in:
Compiling serde_derive_error v0.1.0 (file:///Users/jimmy/Code/serde_derive_error)
error: custom derive attribute panicked
--> src/lib.rs:12:25
|
12 | #[derive(Debug, Deserialize, Serialize)]
| ^^^^^^^^^^^
...
20 | event! {
| - in this macro invocation
|
= help: message: called `Result::unwrap()` on an `Err` value: "failed to parse macro input: \"#[derive(Deserialize)]\\n#[doc = r\\\" A custom basic event not covered by the Matrix specification.\\\"]\\n#[derive(Debug, Serialize)]\\npub struct CustomEvent {\\n /// The event\\\'s content.\\n content: String,\\n}\\n\""
error: Could not compile `serde_derive_error`.
I'm using:
Raw string literals r"..." were not implemented in syn. I released syn 0.8.4 with a fix, confirmed that your snippet expands successfully, and added CustomEvent as a test case.
Most helpful comment
Raw string literals
r"..."were not implemented insyn. I released syn 0.8.4 with a fix, confirmed that your snippet expands successfully, and added CustomEvent as a test case.