rust-lang / rust-lang/rust-analyzer

Unresolved import error for crate after adding lib.rs

Open
#11,604 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

C-support
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!

image

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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.