Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with Rust 2018 paths #1440

Closed
jimmycuadra opened this issue Dec 8, 2018 · 1 comment
Closed

Compatibility with Rust 2018 paths #1440

jimmycuadra opened this issue Dec 8, 2018 · 1 comment

Comments

@jimmycuadra
Copy link
Contributor

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!

@dtolnay
Copy link
Member

dtolnay commented Dec 8, 2018

Thanks! Closing in favor of a compiler issue because I believe serde_derive is doing it correctly: rust-lang/rust#56622.

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

No branches or pull requests

2 participants