Skip to content

Relax requirement that [replace] overrides have the same version number #2649

@SimonSapin

Description

@SimonSapin

Top-level overrides with [replace] as implemented in #2385 require that the replacement has the exact same version number in its Cargo.toml as the package being replaced. As others have discussed in the PR I think this restriction gets in the way more than it helps.

Here is a workflow I just had. This happens more often than not when I use [replace].

  • I use some package maintained by someone else. In this case xml-rs.
  • I realize I need some functionality to be added in that package. Maybe it just belongs there better, or like here I can’t do it in my own crates because of privacy or trait coherence rules.
  • I write and send a pull request: Implement From<std::io::Error> for xml::reader::Error netvl/xml-rs#121 I include a version number increment in the PR to signal to the maintainer that I’d like them to publish this change on crates.io.
  • Back in my crate I add a [replace] override, which doesn’t work because versions don’t match. I have to revert the version number locally. If I want some else to use my override, I need to push a second branch of the dependency with the same changes but without the version number increment.
  • Cargo doesn’t let me "update" my dependency (not the replacement) to a version that isn’t published yet.

Maybe the requirement could be that the replacement’s version is SemVer-compatible with the thing being replaced, instead of exactly the same?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions