rust-lang / rust-lang/rust-clippy
How to generate "correct" paths for types in replacement snippets
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
I'm writing a new lint (and have written one before, too), where the suggested replacement code needs to reference a type where it's non-obvious how the type has been imported into scope.
Is there a handy helper somewhere for "Given this type, give me the best way this code could reference it"? i.e. if the type is imported into scope, use its bare name, or if the module which defines it is in scope, reference it as module::Type, or if not, use ::fully::qualified::Type?
If not, are there any pointers for how I might go about implementing such a thing?
Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by examining the existing Clippy lint infrastructure for suggested replacement code and how types are represented in scope. The issue names no files, tests, or entry points; done would require determining whether a helper exists or defining and validating an approach for choosing imported, module-qualified, or fully qualified type paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100