rust-lang / rust-lang/rust-analyzer
Sort import suggestions by frequency of use in crate
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
When something needs to be imported, but there are multiple possibilities of what could be imported (For example, the debug macro could be imported from tracing::debug or from tracing::field::debug), a list is shown to display all items with the same name that could be imported.
Currently, the list of options to choose from looks to be alphabetically ordered.
I would like to suggest this list to be sorted by the frequency of how often these items are already imported in the entire crate, because it's more likely one would import an item again instead of importing another one that is called the same, but wasn't used in the crate yet.
(Maybe the ordering could also be dependant on whether the item matches the expected type (macro, function, etc.), but that would be more difficult and is not my primary suggestion.)
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
The issue names no files, entry points, or tests. Locate the import-suggestion implementation and its current alphabetical ordering first, then inspect nearby tests for candidate ordering. Done means suggestions are ranked by how often each item is already imported in the crate, with existing behavior covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100