rust-lang / rust-lang/cargo

Allow specifying defaults for build target types

Open
#6,945 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-features A-manifest A-required-features C-feature-request S-needs-rfc
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

Request: allow a feature flag to be required by all benchmarks (whether this acts like dev-dependencies and affects tests too or only benchmarks does not matter).

From what I understand, currently:

  • Dev-dependencies cannot be optional. source
  • The required-features field can apply to specific targets (e.g. [[bin]] or [[bench]] for a single binary)

Workaround: it appears to be possible to enable the feature for each benchmark independently, as follows:

[[bench]]
name = "distributions"
path = "benches/distributions.rs"
required-features = ["small_rng"]

[[bench]]
name = "generators"
path = "benches/generators.rs"
required-features = ["small_rng"]

...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Cargo's manifest rules for dev-dependencies and the required-features field, then compare the repeated [[bench]] workaround in the issue. Decide whether the default applies to all benchmarks or to tests as well; done means one manifest-level setting can replace repeated required-features entries and its semantics are documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.