Skip to content

Explicitly specify the serde/derive dev-dependency - #1032

Merged
Keats merged 2 commits into
Keats:masterfrom
musicinmybrain:serde-derive
Sep 1, 2026
Merged

Keats merged 2 commits into
Keats:masterfrom
musicinmybrain:serde-derive

Conversation

@musicinmybrain

Copy link
Copy Markdown
Contributor

In downstream packaging for Fedora, we routinely patch out dev-dependencies on criterion because they are unnecessary (we run tests, but not benchmarks) and bring in a large tree of otherwise-unnecessary dependencies.

It turns out that dropping the criterion dev-dependency by removing this line from Cargo.toml

criterion = "0.8"

breaks compiling the tests and examples, with many errors like:

error: cannot find derive macro `Serialize` in this scope
 --> examples/teams.rs:5:10
  |
5 | #[derive(Serialize)]
  |          ^^^^^^^^^
  |
note: `Serialize` is imported here, but it is only a trait, without a derive macro
 --> examples/teams.rs:1:5
  |
1 | use serde::Serialize;
  |     ^^^^^^^^^^^^^^^^
help: consider importing this derive macro
  |
1 + use serde_derive::Serialize;
  |

This is because tests and examples rely on the derive feature of the serde crate (not just having serde_derive in the dependency tree, although the explicit dependency on it is correct since serde_derive::Serialize is used directly), but there’s no (dev-)dependency on serde with the derive feature. Instead, criterion happens to depend on serde/derive, so it gets enabled due to feature unification.

To be more explicit about this requirement, to guard against possible changes in the features used by criterion or perhaps a future switch to a different benchmarking library, and to make downstream packaging easier, this PR adds an explicit dev-dependency on serde/derive.

@musicinmybrain

musicinmybrain commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor Author

@decathorpe pointed out that with the serde/derive dev-dependency properly specified, it’s no longer necessary to use and depend on serde_derive directly, and that this would eliminate the need to update serde and serde_derive in lockstep. I pushed a follow-up commit implementing that suggestion.

@Keats
Keats merged commit 2ed8ef4 into Keats:master Sep 1, 2026
5 checks passed
@Keats

Keats commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Thanks!

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