Skip to content

Unused patch with same dependency as a used patch isn't marked unused #12471

@alcolmenar

Description

@alcolmenar

Problem

A known unused patch isn't marked unused and doesn't emit a warning when there is another used patch using the same dependency.

e.g.

[patch.crates-io]
bar = { git = "test" }

[patch."foo"]
bar = { git = "test" }

if the crates-io patch is used and the foo patch is unused, foo will not be marked as unused.

Steps

# Cargo.toml

[workspace]
members = [ "my-member" ]

[patch.'https://github.com/foo/bar.git']
serde = { git = "https://github.com/serde-rs/serde.git" }

[patch.crates-io]
serde = { git = "https://github.com/serde-rs/serde.git" }
# my-member/Cargo.toml
[package]
name = "my-member"
version = "0.1.0"

[dependencies]
serde = "1"

Execute cargo update

Expectation

A warning of the foo/bar patch being unused is emitted and a section in the Cargo.lock file for it.

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.73.0-nightly (45782b6b8 2023-07-05)
release: 1.73.0-nightly
commit-hash: 45782b6b8afd1da042d45c2daeec9c0744f72cc7
commit-date: 2023-07-05
host: aarch64-apple-darwin
libgit2: 1.6.4 (sys:0.17.2 vendored)
libcurl: 7.79.1 (sys:0.4.63+curl-8.1.2 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1u  30 May 2023
os: Mac OS 12.5.1 [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Error and warning messages generated by Cargo itself.A-patchArea: [patch] table overrideC-bugCategory: bugS-needs-mentorStatus: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions