rust-lang / rust-lang/cargo

Allow arbitrary Horn clauses for inter-feature dependencies.

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

Nobody has claimed this yet.

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

Description

Sometimes it makes sense to enable feature Z if both features Y and feature Z are enabled. Simple example: #6658

[dependencies]
krate = { optional = true, version = "1.2.3" }

[features]
bar = []
foo = [ "krate" ]
"foo+bar" = [ "krate/bar" ]

Another example pops up in native library bindings:

name = "libB-sys"

[dependencies]
libA-sys = { optional = true, version = "4.5.6" } # libA is used by libB to do featX

[features]
vendored = [] # Build the bundled copy of the library instead of using the system one
featX = []
"vendored+featX" = "libA-sys"

It may also make sense to have clauses where resolution fails:

[features]
"do-it-this-way+do-it-that-way" = false

Note that this does not permit requirements of the form "featX or featY must be enabled". The naive algorithm that only enables a feature when all prerequisites are enabled still works (https://www.doc.ic.ac.uk/~rak/papers/kowalski-van_emden.pdf, the "model intersection property")

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

No implementation files, tests, or entry points are named. Start by tracing Cargo's feature and dependency-resolution logic, then define how conjunction clauses and clauses that fail resolution should be represented and evaluated; done means the TOML examples resolve as described without adding disjunctive requirements.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.