rust-lang / rust-lang/cargo

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

Open
#16,166 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-new-lint S-needs-design
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

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" }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing Cargo's package manifest validation and dependency handling for the version field, especially when publish = false and a dependency uses git or path. Define the lint behavior from the examples: warn about the unused field in that case, while preserving valid use cases when publishing is intended.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.