Skip to content

new lint: workspace_dependencies - #15923

Draft
andrewgazelka wants to merge 1 commit into
rust-lang:masterfrom
andrewgazelka:workspace_dependencies
Draft

new lint: workspace_dependencies#15923
andrewgazelka wants to merge 1 commit into
rust-lang:masterfrom
andrewgazelka:workspace_dependencies

Conversation

@andrewgazelka

Copy link
Copy Markdown

Adds a new cargo lint that enforces using workspace = true for dependencies that are defined in [workspace.dependencies].

What it does

Checks that dependencies defined in [workspace.dependencies] are referenced with workspace = true in package dependency declarations instead of specifying version, git, or path information directly.

Why is this useful

When using workspace dependencies, all version information should be centralized in the workspace's Cargo.toml to ensure consistency across all crates in the workspace. Specifying version information in individual packages defeats this purpose and can lead to version mismatches.

Example

# In workspace Cargo.toml
[workspace.dependencies]
serde = "1.0"

# In package Cargo.toml (bad)
[dependencies]
serde = "1.0"

Use instead:

# In workspace Cargo.toml
[workspace.dependencies]
serde = "1.0"

# In package Cargo.toml (good)
[dependencies]
serde = { workspace = true }
# or with features
serde = { workspace = true, features = ["derive"] }

The lint checks [dependencies], [dev-dependencies], and [build-dependencies] sections.

@rustbot

rustbot commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (possibly #15979) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants