Skip to content

Suggest inheriting repository fields in explicit workspaces - #17541

Draft
darkraider01 wants to merge 3 commits into
rust-lang:masterfrom
darkraider01:repository-inheritance-lint
Draft

darkraider01 wants to merge 3 commits into
rust-lang:masterfrom
darkraider01:repository-inheritance-lint

Conversation

@darkraider01

@darkraider01 darkraider01 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

A workspace member can accidentally set package.repository to a URL for that crate’s page in a file browser. This adds cargo::repository_not_inherited to flag directly set repository fields in explicit workspaces and suggest inheritance where it applies.
The lint does not inspect or compare URLs. It is pedantic and allow by default for now because some workspaces intentionally span multiple repositories. I’d especially welcome feedback on that default level.
The commits first record the existing behavior, then add the lint and tests for inherited fields, implicit workspaces, and packages outside the workspace. The final commit updates the generated lint reference.
Related: rust-lang/cargo#15870.


pub static LINT: &Lint = &Lint {
name: "repository_not_inherited",
primary_group: &PEDANTIC,

@darkraider01 darkraider01 Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose pedantic for now because members can intentionally use different repositories. I’d appreciate guidance on whether this should warn by default

View changes since the review

}
primary = primary.element(Level::NOTE.message(LINT.emitted_source(level.level, level.source)));

let help = if workspace

@darkraider01 darkraider01 Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also fires when the workspace has no repository value yet. The help suggests defining one first, so the trigger stays based on the direct package declaration.

View changes since the review

@rustbot rustbot added the A-documenting-cargo-itself Area: Cargo's documentation label Sep 30, 2026

This branch has not been deployed

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

Labels

A-documenting-cargo-itself Area: Cargo's documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants