cargo icon indicating copy to clipboard operation
cargo copied to clipboard

Lint on unused `version` field with git/path dependencies

Open epage opened this issue 2 months ago • 0 comments

What it does

Users may add the version field, thinking its relevant for git/path dependencies when it is instead adding a fallback registry source when published. While we can't tell if the user intended it when publish = true, we can when publish = false. Granted, publish = false being the default (#6153) would make this more likely to be beneficial

Inspired by #16161

Advantage

  • Help users better understand what the version field does

Drawbacks

  • Not enough people benefit because publish = true (intentional publish)
  • Not enough people benefit because of the publish = true default (not published but haven't told cargo)

Example

[package]
name = "foo"
publish = false

[dependencies]
serde = { git = "https://github.com/serde-rs/serde.git", version = "1" }

Could be written as:

[package]
name = "foo"
publish = false

[dependencies]
serde = { git = "https://github.com/serde-rs/serde.git" }

epage avatar Oct 28 '25 15:10 epage