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

serde_derive fails in latest nightly #621

Closed
lambda-fairy opened this issue Nov 16, 2016 · 2 comments
Closed

serde_derive fails in latest nightly #621

lambda-fairy opened this issue Nov 16, 2016 · 2 comments

Comments

@lambda-fairy
Copy link

Using this code:

#![feature(proc_macro)]

extern crate serde;
#[macro_use]
extern crate serde_derive;

#[derive(Deserialize)]
pub struct Foo;

fails with this error:

error[E0428]: a type named `Foo` has already been defined in this module
 --> src/lib.rs:8:1
  |
7 | #[derive(Deserialize)]
  |          ----------- previous definition of `Foo` here
8 | pub struct Foo;
  | ^^^^^^^^^^^^^^^ already defined

I am using rustc 1.15.0-nightly (43006fcea 2016-11-15) on Arch Linux.

@lambda-fairy
Copy link
Author

Running rustc with --pretty=expanded yields the following:

#![feature(prelude_import)]
#![no_std]
#![feature(proc_macro)]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std as std;

extern crate serde;
#[macro_use]
extern crate serde_derive;

pub struct Foo;
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
const _IMPL_DESERIALIZE_FOR_Foo: () =
    {
        extern crate serde as _serde;
        #[automatically_derived]
        impl _serde::de::Deserialize for Foo {
            fn deserialize<__D>(deserializer: &mut __D)
             -> ::std::result::Result<Foo, __D::Error> where
             __D: _serde::de::Deserializer {
                struct __Visitor;
                impl _serde::de::Visitor for __Visitor {
                    type
                    Value
                    =
                    Foo;
                    #[inline]
                    fn visit_unit<__E>(&mut self)
                     -> ::std::result::Result<Foo, __E> where
                     __E: _serde::de::Error {
                        Ok(Foo)
                    }
                    #[inline]
                    fn visit_seq<__V>(&mut self, mut visitor: __V)
                     -> ::std::result::Result<Foo, __V::Error> where
                     __V: _serde::de::SeqVisitor {
                        match visitor.end() {
                            $crate::result::Result::Ok(val) => val,
                            $crate::result::Result::Err(err) => {
                                return $crate::result::Result::Err($crate::convert::From::from(err))
                            }
                        };
                        self.visit_unit()
                    }
                }
                deserializer.deserialize_unit_struct("Foo", __Visitor)
            }
        }
    };
pub struct Foo;

Note the duplicated pub struct Foo.

@lambda-fairy
Copy link
Author

Duplicate of #614

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