rust-lang / rust-lang/rust-analyzer
Never suggests importing anyhow::Result or anyhow::anyhow
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
For some reason Rust-analyzer never suggests importing anyhow::Result or anyhow::anyhow (a macro). I don't know if this is specific to anyhow but it's quite conspicuous because the import suggestion feature now works very reliably except for those imports (at least in my use).
As far as I remember they have never worked. It does work for anyhow::bail. At a guess Rust-analyzer doesn't suggest anything because anyhow is the name of the crate and it thinks you're going to type anyhow::, and Result is already available from the prelude. But I can't see any reason not to offer the import if there is one available. Especially if you type anyhow! because that's clearly not a crate name.
rust-analyzer version: rust-analyzer version: 0.3.2308-standalone (84b6936e08 2025-02-17)
rustc version: rustc 1.84.1 (e71f9a9a9 2025-01-27)
editor or extension: VSCode 0.3.2308
relevant settings: none
code snippet to reproduce:
fn foo() -> Result<()> {
}
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
No source file or test is named. Start by reproducing the issue with the provided Result<()> function and an anyhow! use, then trace rust-analyzer's import suggestions for anyhow::Result, anyhow::anyhow, and anyhow::bail. Done means the missing suggestions are offered and regression coverage verifies them.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100