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

Bug: workspace-duplicate triggers on renamed dependencies #707

Open
Nemo157 opened this issue Oct 11, 2024 · 0 comments
Open

Bug: workspace-duplicate triggers on renamed dependencies #707

Nemo157 opened this issue Oct 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Nemo157
Copy link

Nemo157 commented Oct 11, 2024

Describe the bug

When using a renamed dependency in one crate of a workspace (e.g. as is useful for testing macro hygienity) the workspace-duplicate lint triggers with no way to suppress it.

To reproduce

> cat >>Cargo.toml <<-END
[workspace]
resolver = "2"
END

> cargo new foo --lib && cargo new bar && cargo new baz
    Creating library `foo` package
      Adding `foo` as member of workspace at `/tmp/scratch.rust.2024-10-11T15-00.ay4VzE`
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
    Creating binary (application) `bar` package
      Adding `bar` as member of workspace at `/tmp/scratch.rust.2024-10-11T15-00.ay4VzE`
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
    Creating binary (application) `baz` package
      Adding `baz` as member of workspace at `/tmp/scratch.rust.2024-10-11T15-00.ay4VzE`
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

> cat >>bar/Cargo.toml <<-END
my-foo = { package = "foo", path = "../foo" }
END

> cat >>baz/Cargo.toml <<-END
foo.workspace = true
END

> cat >>Cargo.toml <<-END
[workspace.dependencies]
foo.path = "foo"
END

> cat >>deny.toml <<-END
[bans.workspace-dependencies]
duplicates = "warn"
include-path-dependencies = true
END

> cargo deny check bans
warning[workspace-duplicate]: crate foo = 0.1.0 is used 2 times in the workspace, but not all declarations use the shared workspace dependency
  ┌─ /tmp/scratch.rust.2024-10-11T15-00.ay4VzE/Cargo.toml:4:1

4 │ foo.path = "foo"
  │ ─── workspace dependency

  ┌─ /tmp/scratch.rust.2024-10-11T15-00.ay4VzE/bar/Cargo.toml:7:1

7 │ my-foo = { package = "foo", path = "../foo" }
  │ ━━━━━━                ─── note the dependency is renamed

  ├ foo v0.1.0
    ├── bar v0.1.0
    └── baz v0.1.0

bans ok

cargo-deny version

cargo-deny 0.16.1

What OS were you running cargo-deny on?

Linux

Additional context

If I could use the workspace dependency with renaming I would, but this is not something cargo supports.

@Nemo157 Nemo157 added the bug Something isn't working label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant