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

fix(codegen): Support extern crate serde not in toplevel module #298

Merged
merged 1 commit into from
May 3, 2016
Merged

fix(codegen): Support extern crate serde not in toplevel module #298

merged 1 commit into from
May 3, 2016

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented Apr 24, 2016

Addresses #159.

The generated code looks like:

#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
const _IMPL_DESERIALIZE_FOR_MyStruct: () = {
    extern crate serde as _serde;
    #[automatically_derived]
    impl _serde::de::Deserialize for MyStruct {
        // ...
    }
};

@@ -1,6 +1,4 @@
#![cfg_attr(feature = "nightly", feature(plugin))]
#![cfg_attr(feature = "nightly", plugin(clippy))]

extern crate serde;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this removed? Did it cause an error?

Copy link
Member Author

@dtolnay dtolnay Apr 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No error, just to demonstrate that things work even without "extern crate serde" at the top level. I kept the equivalent line in bench.rs so the build still uses both approaches.

@oli-obk
Copy link
Member

oli-obk commented Apr 24, 2016

Does this break any existing code? You changed quite a few tests' imports.

@dtolnay
Copy link
Member Author

dtolnay commented Apr 24, 2016

This does not break any existing code.

@dtolnay
Copy link
Member Author

dtolnay commented Apr 24, 2016

This makes extern crate serde optional unless you are using it explicitly in your own code, so I have removed it from the example in the readme.

@erickt
Copy link
Member

erickt commented Apr 25, 2016

@dtolnay: Once again, great work here. I'm working on merging this patch in by hand.

@dtolnay
Copy link
Member Author

dtolnay commented Apr 25, 2016

@erickt I fixed the merge conflict myself.

@dtolnay
Copy link
Member Author

dtolnay commented Apr 27, 2016

Ping @erickt - looks like you said this was ready to merge. Once you merge it, I will resolve the merge conflict in #293 (comment).

@erickt erickt merged commit 5716e8c into serde-rs:master May 3, 2016
@dtolnay dtolnay deleted the scope branch May 3, 2016 03:09
@erickt
Copy link
Member

erickt commented May 3, 2016

Thanks @dtolnay! I've been swamped with work recently, and unfortunately that's resulted in lots of my projects suffering. Thanks for keeping up with this.

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

Successfully merging this pull request may close these issues.

3 participants