Skip to content

RFC: Extend manifest dependencies with used#3920

Open
epage wants to merge 6 commits intorust-lang:masterfrom
epage:used-deps
Open

RFC: Extend manifest dependencies with used#3920
epage wants to merge 6 commits intorust-lang:masterfrom
epage:used-deps

Conversation

@epage
Copy link
Contributor

@epage epage commented Feb 13, 2026

Extend Cargo's dependency specifications so users can mark that a dependency is used, independent of what unused externs says.

Important

When responding to RFCs, try to use inline review comments (it is possible to leave an inline review comment for the entire file at the top) instead of direct comments for normal comments and keep normal comments for procedural matters like starting FCPs.

This keeps the discussion more organized.

Rendered

@epage epage added the T-cargo Relevant to the Cargo team, which will review and decide on the RFC. label Feb 13, 2026

However, not all dependencies exist for using their `extern` in the current package, including
- activating a feature on a transitive dependency
- pinning the version of a transitive dependency in `Cargo.toml` (however, normally this would be done via `Cargo.lock`)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could create a [peer-dependencies] section for that just like npm? This would also improve compile time by avoiding a need to block compilation of the current crate on said dependency. And cargo could get the option to warn if a peer-dependency is not used by any other crate (aka pinning a transitive dependency has no effect).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we could create a [peer-dependencies] section for that just like npm?

There is an ecosystem cost to adding new dependencies tables. We'd have to weigh the cost against the benefits.

This would also improve compile time by avoiding a need to block compilation of the current crate on said dependency.

For the two use cases we have, compilation will already be blocked on them. Do we know of any use cases where this would be a concern?

Copy link
Contributor Author

@epage epage Feb 13, 2026

Choose a reason for hiding this comment

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

Reading up on peerDependencies, they sounds like target."cfg(false)".dependencies which helps with version requirements but not with feature activation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-cargo Relevant to the Cargo team, which will review and decide on the RFC.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants