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

guarantee serde is in lockstep with serde_derive #2588

Merged

Conversation

soqb
Copy link
Contributor

@soqb soqb commented Aug 21, 2023

Objective

Solution

  • Implement the associated proc macro pattern, discovered by the excellent @matklad, to embed serde_derive in Cargo.lock files for projects that include serde without serde_derive being forced as a dependency, so users can do the following in their Cargo.toml:
[dependencies]
serde = "1"
serde_derive = "1" # these two crates are guaranteed to have the same version.
  • I also added a job to CI that verifies serde and serde_derive have the same version in a new dummy crate, though this does introduce some dev-dependencies which could be split out.

@soqb
Copy link
Contributor Author

soqb commented Aug 21, 2023

its going to take a better cargo wizard than me to figure out how to fix CI. i'm going to bed!

@soqb
Copy link
Contributor Author

soqb commented Aug 21, 2023

i don't seem to be able to get the "Outdated" check to pass, since the new CI check has to rely on an old version of cargo-lock, otherwise dependency resolution will fail on rust 1.36

@dtolnay dtolnay force-pushed the use-impossible-cfg-to-lockstep-serde-derive branch from 61998fc to 2ea7e13 Compare August 23, 2023 23:15
Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thanks!

@dtolnay dtolnay merged commit c0f7042 into serde-rs:master Aug 23, 2023
15 checks passed
@soqb soqb deleted the use-impossible-cfg-to-lockstep-serde-derive branch August 24, 2023 10:19
KamilaBorowska added a commit to KamilaBorowska/rust-url that referenced this pull request Aug 30, 2023
When serde's derive feature is used, serde_derive must be
compiled before serde can be, as serde with that feature has a
serde_derive dependency.

As of serde 1.0.186, this issue can be avoided by adding a separate
serde_derive dependency due to the fact that serde 1.0.186 has a
never-applicable dependency on serde_derive, which ensures that
there is no incompatible version of serde_derive in a program [1].

Because MSRV being set to 1.56, it's not possible to use the dep:
syntax in features, so serde crate needs to be renamed.

This should improve compilation times of programs that use url
with its serde feature, provided it doesn't have other crates that
use serde with its derive feature.

[1]: serde-rs/serde#2588
KamilaBorowska added a commit to KamilaBorowska/either that referenced this pull request Sep 2, 2023
When serde's derive feature is used, serde_derive must be
compiled before serde can be, as serde with that feature has a
serde_derive dependency.

As of serde 1.0.186, this issue can be avoided by adding a separate
serde_derive dependency due to the fact that serde 1.0.186 has a
never-applicable dependency on serde_derive, which ensures that
there is no incompatible version of serde_derive in a program [1].

Because MSRV being set to 1.36, it's not possible to use the dep:
syntax in features, so serde crate needs to be renamed.

This should improve compilation times of programs that use either
with its serde feature, provided it doesn't have other crates that
use serde with its derive feature.

[1]: serde-rs/serde#2588
KamilaBorowska added a commit to KamilaBorowska/either that referenced this pull request Sep 2, 2023
When serde's derive feature is used, serde_derive must be
compiled before serde can be, as serde with that feature has a
serde_derive dependency.

As of serde 1.0.186, this issue can be avoided by adding a separate
serde_derive dependency due to the fact that serde 1.0.186 has a
never-applicable dependency on serde_derive, which ensures that
there is no incompatible version of serde_derive in a program [1].

Because MSRV being set to 1.36, it's not possible to use the dep:
syntax in features, so serde crate needs to be renamed.

This should improve compilation times of programs that use either
with its serde feature, provided it doesn't have other crates that
use serde with its derive feature.

Fixes rayon-rs#86.

[1]: serde-rs/serde#2588
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.

None yet

2 participants