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

Migrate serde dependency to use derive feature #152

Merged
merged 1 commit into from
Feb 22, 2019

Conversation

veeg
Copy link
Contributor

@veeg veeg commented Feb 22, 2019

This is in line with best practices recommended by serde[1].
This will also resolve downstream crates depending on shiplift who enable the
serde derive feature, due to Cargos unification of features for each crate[2].

Example of the problem for downstream crates:

$ cargo new deptest
$ cd deptest
$ echo 'shiplift = "0.4"' >> Cargo.toml
$ echo 'serde = { version = "1.0", features = ["derive"] }' >> Cargo.toml
$ cargo build

This will result in the following error:

error[E0252]: the name `Serialize` is defined multiple times
 --> /home/veeg/.cargo/registry/src/github.com-1ecc6299db9ec823/shiplift-0.4.0/src/builder.rs:5:5
  |
4 | use serde::Serialize;
  |     ---------------- previous import of the macro `Serialize` here
5 | use serde_derive::Serialize;
  |     ^^^^^^^^^^^^^^^^^^^^^^^ `Serialize` reimported here
  |
  = note: `Serialize` must be defined only once in the macro namespace of this module
help: you can use `as` to change the binding name of the import
  |
5 | use serde_derive::Serialize as OtherSerialize;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

What did you implement:

Closes: #xxx

How did you verify your change:

cargo build && cargo test

What (if anything) would need to be called out in the CHANGELOG for the next release:

This is in line with best practices recommended
by serde[1]. This will also resolve downstream
crates depending on shiplift who enable the
serde derive feature, due to Cargos unification
of features for each crate[2].

[1]: serde-rs/serde#1441
[2]: rust-lang/cargo#4361 (comment)
@softprops
Copy link
Owner

Thanks for the patch. I've started noticing this pop up in other crates. Since serde is such a common crate it tends to have a ripple effect across the ecosystem :)

@softprops softprops merged commit ebb2938 into softprops:master Feb 22, 2019
@veeg
Copy link
Contributor Author

veeg commented Feb 22, 2019

I fell into this rabbit hole and had to figure out the cargo feature story. Hopefully they will make the huge refactoring work needed in cargo to split crate units by features enabled. I can image this issue with serde and how widespread it is will accelerate this process.

@softprops
Copy link
Owner

published a new release including this pr https://github.com/softprops/shiplift/blob/master/CHANGELOG.md#050

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

Successfully merging this pull request may close these issues.

2 participants