rust-lang / rust-lang/rust-analyzer

Prefer non-prelude paths when suggesting import

Open
#15,362 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-feature
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

As an example, Bevy's App struct can be found at both bevy::prelude::App and bevy::app::App. I feel that if I am importing App specifically (i.e. not using a glob import on Bevy's prelude), then I would rather use bevy::app::App. Yet rust-analyzer seems to only show me the bevy::prelude::App path. I'd like it to prefer showing me the bevy::app::App path (ideally it would list both, but the non-prelude path first).

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 reproducing the import suggestion for Bevy's App and trace rust-analyzer's import path selection and ranking. Done means a specific import prefers bevy::app::App over bevy::prelude::App, while considering whether both paths should be listed.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.