rust-lang / rust-lang/rust-analyzer
Unresolved import error for crate after adding lib.rs
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
I have a lib.rs file, which has the pub async fn run() function, but when I try to import it, rust-analyzer shows unresolved import error.
But it doesn't show any errors in cargo check / clippy , and it also builds successfully!

Here is my Cargo.toml file:
[package]
name = "zero2prod"
version = "0.1.0"
..
[lib]
path = "src/lib.rs"
[[bin]]
path = "src/main.rs"
name = "zero2prod"
[dependencies]
..
rust-analyzer version: 4e72700e3 2022-02-28 stable
rustc version: rustc 1.59.0 (9d1b2106e 2022-02-23)
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
Reproduce the report using the provided Cargo.toml with src/lib.rs and src/main.rs, then compare rust-analyzer diagnostics with cargo check and clippy using the listed tool versions. Trace the unresolved import from the lib.rs setup and confirm the behavior against the successful build; done means the false diagnostic is explained and addressed with a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100