rust-lang / rust-lang/rust-clippy

Allow `absolute_paths` to be configured based on occurrence

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

Nobody has claimed this yet.

C-enhancement
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

Description

I like the idea of absolute_paths but my heuristic I generally use is if something is used once or twice can remain as an absolute path.

Namely, support impls that are gated by #[cfg(feature = "")] impl MyCrateTrait for some::foreign::Type {}. Especially with a large workspace, specifying the allowed crate prefixes means that all occurrences of this type workspace-wide will now get excluded by the rule, or I have to do an #[expect()] attribute on all of them.

What I'd really like is to specify absolute-paths-max-occurrences = 2 in my clippy.toml to say "if this absolute path is used more than twice in a given file, it should trigger an absolute_paths warning".

Version
rustc 1.95.0-nightly (d940e5684 2026-01-19)
binary: rustc
commit-hash: d940e56841ddcc05671ead99290e35ff2e98369f
commit-date: 2026-01-19
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 21.1.8
Additional Labels

@rustbot label +C-enhancement

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 locating the absolute_paths lint and the clippy.toml configuration handling. Trace how lint occurrences are evaluated per file, then add coverage for a maximum of two occurrences and verify that repeated absolute paths warn while one or two uses do not.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 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.