Closed
Description
I'm trying to update ruma-events to Rust 2018 and the code generated by serde_derive seems to be using old-style paths that are resulting in compiler errors.
My crate has code like this (snippet from inside a decl macro expansion):
#[derive(Clone, Debug, serde_derive::Deserialize, serde_derive::Serialize)]
pub struct $name {
/// The event's content.
pub content: $content_type,
/// The type of the event.
#[serde(rename="type")]
pub event_type: $crate::EventType,
But compiling results in errors like this:
error[E0412]: cannot find type `EventType` in the crate root
--> src/macros.rs:81:32
|
81 | #[derive(Clone, Debug, serde_derive::Deserialize, serde_derive::Serialize)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ not found in the crate root
help: possible candidate is found in another module, you can import it into scope
|
3 | use crate::EventType;
|
I see this in the output of cargo expand
:
let __field2 = match match _serde::de::SeqAccess::next_element::<
::EventType,
>(&mut __seq)
My understanding is that this should be:
let __field2 = match match _serde::de::SeqAccess::next_element::<
crate::EventType,
>(&mut __seq)
Is this something that needs to be fixed within serde or is there something I'm doing wrong here?
I'm using rustc 1.32.0-nightly (14997d56a 2018-12-05), serde v1.0.81, serde_derive v1.0.81.
Thanks!