Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cargo tree does not report a proc-macro duplicate in a workspace #10651

Open
ehuss opened this issue May 11, 2022 · 1 comment
Open

cargo tree does not report a proc-macro duplicate in a workspace #10651

ehuss opened this issue May 11, 2022 · 1 comment
Labels
A-features2 Area: issues specifically related to the v2 feature resolver C-bug Category: bug Command-tree S-triage Status: This issue is waiting on initial triage.

Comments

@ehuss
Copy link
Contributor

ehuss commented May 11, 2022

Problem

With resolver = "2", and a workspace with a proc-macro, duplicates of a shared dependency are not displayed in cargo tree in some situations.

Steps

The following cargo test demonstrates the problem.

#[cargo_test]
fn internal_default_features_twice() {
    // Test for new resolver where a shared dependency only differs in whether
    // or not it has the "default" feature enabled.
    // There was an issue where `cargo tree` was incorrectly merging it in the
    // output.
    let p = project()
        .file(
            "Cargo.toml",
            r#"
                [workspace]
                resolver = "2"
                members = ["foo", "foo_derive", "shared"]
            "#,
        )
        .file(
            "foo/Cargo.toml",
            r#"
                [package]
                name = "foo"
                version = "0.1.0"

                [dependencies]
                shared = {path="../shared", default-features=false}

                [features]
                default = ["std"]
                std = ["shared/std"]
            "#,
        )
        .file("foo/src/lib.rs", "")
        .file(
            "foo_derive/Cargo.toml",
            r#"
                [package]
                name = "foo_derive"
                version = "0.1.0"

                [lib]
                proc-macro = true

                [dependencies]
                foo = {path="../foo"}
            "#,
        )
        .file("foo_derive/src/lib.rs", "")
        .file(
            "shared/Cargo.toml",
            r#"
                [package]
                name = "shared"
                version = "0.1.0"

                [features]
                default = ["std"]
                std = []
            "#,
        )
        .file("shared/src/lib.rs", "")
        .build();

    p.cargo("tree -f")
        .arg("{p} ({f})")
        .with_stdout(
            "\
foo [..] (default,std)
└── shared [..] (default,std)

foo_derive (proc-macro) [..] ()
└── foo [..] (default,std)
    └── shared [..] (std)

shared [..] (default,std)
",
        )
        .run();
}

The problem is that cargo currently shows:

foo_derive v0.1.0 (proc-macro) ()
└── foo v0.1.0 (default,std) (*)

Indicating that the proc-macro is using the same foo. However it is not, foo is built twice. Once as a workspace root (with a dependency on shared with default,std features), and once as a proc-macro dependency (with a dependency on shared with only the std feature).

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.62.0-nightly (f63f23ff1 2022-04-28)
@ehuss ehuss added C-bug Category: bug A-features2 Area: issues specifically related to the v2 feature resolver Command-tree labels May 11, 2022
@Muscraft
Copy link
Member

This might be related to #10645

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-features2 Area: issues specifically related to the v2 feature resolver C-bug Category: bug Command-tree S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

3 participants