Skip to content

Cargo should allow features/optional-dependencies to be private or public, private by default #7769

Closed
@infinity0

Description

@infinity0

A feature of a crate is part of its public API, but many crate authors don't realise this and constantly re-arrange their features. This in fact breaks semver, because someone depending on e.g. cc/rayon (present in version 1.0.37) will have this broken by cc version 1.0.47 which does not have this feature. What one should actually be depending on is the parallel feature which points to rayon in version 1.0.37, but points instead to num_cpus, jobserver in version 1.0.47 thereby retaining semver compatibility.

However the fact that the "public/private"-ness of features is not even typically discussed, means that many crate authors are unaware of this, and freely add and remove features/optional-dependencies from their crates without thinking about semver compatibility.

Not sure if this is related to #6129 or not - that issue seems more to be about the --extern flag to rustc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-featuresArea: features — conditional compilationC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions