Skip to content

Provide a way for a crate to ask not to be used twice in the dependency graph #5920

Open

Description

I'm writing a crate that uses thread_local! and lazy_static! variables. If this crate is duplicated in the dependency graph, functions risk being called with non-up-to-date global variables, and Bad Things™ (though hopefully no unsafe, but panics for almost certain) will ensue.

As a consequence, I wonder if there could a way for a crate to ask cargo not to allow to pull it twice in the dependency tree. Maybe a do-not-pull-twice attribute on the crate that could be overridden by a --yes-pull-this-twice… something to at least error against the common case of unwillingly pulling a dependency that's brittle in this regard? :)

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

Metadata

Assignees

No one assigned

    Labels

    A-dependency-resolutionArea: dependency resolution and the resolverArea: dependency resolution and the resolverC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-rfcStatus: Needs an RFC to make progress.Status: Needs an RFC to make progress.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions