Skip to content

Allow absolute_paths to be configured based on occurrence #16574

@Qix-

Description

@Qix-

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messages

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions