Skip to content
New issue

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

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

Already on GitHub? # to your account

Add warning for unused workspace dependency #13723

Open
legounix opened this issue Apr 8, 2024 · 2 comments
Open

Add warning for unused workspace dependency #13723

legounix opened this issue Apr 8, 2024 · 2 comments
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-bug Category: bug S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

Comments

@legounix
Copy link

legounix commented Apr 8, 2024

Problem

I have a workspace project with a database crate that uses diesel for sql stuff. All the dependencies are specified at workspace level. To make sure libsqlite3-sys is bundling sqlite3, i need to activate the "bundled" feature. Therefore I added it as transitive dependency in the workspace dependencies. The database crate didn't pick up this transitive dependency though, as long as i didn't add libsqlite3-sys.workspace = true to the database Cargo.toml.

Steps

  1. Create workspace
  2. Create database crate
  3. Add workspace dependency for diesel
  4. Use diesel in database crate
  5. cargo tree -e features
  6. Add libsqlite3-sys dependency with "bundled" feature to workspace
  7. cargo tree - features shows that database crate is not using transitive libsqlite3-sys dependency

Possible Solution(s)

I think it would be helpful if cargo would report this as a warning.

Notes

No response

Version

cargo 1.75.0 (1d8b05cdd 2023-11-20)
release: 1.75.0
commit-hash: 1d8b05cdd1287c64467306cf3ca2c8ac60c11eb0
commit-date: 2023-11-20
host: x86_64-unknown-linux-gnu
libgit2: 1.7.1 (sys:0.18.1 vendored)
libcurl: 8.4.0-DEV (sys:0.4.68+curl-8.4.0 vendored ssl:OpenSSL/1.1.1u)
ssl: OpenSSL 1.1.1u  30 May 2023
os: Red Hat Enterprise Linux 9.3.0 [64-bit]
@legounix legounix added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Apr 8, 2024
@epage epage changed the title Add warning for unused transitive dependency Add warning for unused workspace dependency Apr 8, 2024
@weihanglo
Copy link
Member

This was a rior discussion regarding this on Zulip: Workspace inheritance lints. While Cargo has got a basic (unstable) linting system since #13621, we still need to work with other team and set up some policies before adding more lints. See also "This Development-cycle in Cargo: 1.78 — Linter for Cargo".

@weihanglo weihanglo added A-diagnostics Area: Error and warning messages generated by Cargo itself. S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. and removed S-triage Status: This issue is waiting on initial triage. labels Apr 8, 2024
@epage
Copy link
Contributor

epage commented Apr 8, 2024

iirc that zulip thread is about enforcing the use of them, rather than unused workspace dependencies but a lot of the discussion is still relevant.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-bug Category: bug S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Projects
None yet
Development

No branches or pull requests

3 participants