rust-lang / rust-lang/rust-analyzer

Suggest a prelude glob import if you try to import an item inside of one

Open
#13,449 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I'd love to have the opportunity to import a full <crate>::prelude::* when importing an item that is inside of that prelude.

Example
foo.context(NotEnoughFrobnicationSnafu)?;
    ~~~~~~~ <context is the ResultExt::context trait fn from snafu, but the trait is not imported yet>

On opening the suggestions, currently it shows: "import snafu::ResultExt".
I'd like to have a second option "import snafu::prelude::*".

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

No files or tests are named. Start by tracing the code that produces the existing “import snafu::ResultExt” suggestion, then identify where an alternate prelude suggestion can be added; done means offering snafu::prelude::* alongside the item import when appropriate.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
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.