rust-lang / rust-lang/rust-clippy

Cargo.toml dependencies: avoid caret requirements

Open
#13,307 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-lint T-cargo
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

What it does

Hello,
It would be nice to have a lint that highlights the presence of dependencies having the version specified with a ^ (caret) in the Cargo.toml. For example foo="^1.2.3".
As for Cargo docs:

Leaving off the caret is a simplified equivalent syntax to using caret requirements. While caret requirements are the default, it is recommended to use the simplified syntax when possible.

Advantage

This lint helps in having a uniform Cargo.toml where simplified syntax and explicit carets are not mixed, following Cargo docs suggestion.

Drawbacks

None I am aware of

Example
[dependencies]
foo="^1.2.3"
bar="9.8.7"

Could be written as:

[dependencies]
foo="1.2.3"
bar="9.8.7"

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

The requested lint concerns caret-version dependencies in Cargo.toml, with the Cargo caret-requirements documentation as the reference. Start by locating Clippy's existing dependency or version-related lint entry points and tests; done means caret requirements are flagged while equivalent simplified versions remain valid.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.