rust-lang / rust-lang/rust-analyzer
rusy-analyzer can't show definition for extern crate
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P) rust-analyzer version: 0.3.1435-standalone
rustc version: (eg. output of rustc -V)rustc 1.67.1 (d5a82bbd2 2023-02-07)
relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)
rust-src installed
rusy-analyzer performs well when no extern crate imported like below,it could remind me that unused import and jump to Add definition

however, when i use cargo new PRJ and add dependencies as follow
[dependencies]
libafl = {path="/home/aria/Desktop/LibAFL/libafl"}
rust-analyzer failed to find the source and definitions of all structures even defined in this scope like Cacher

cargo check cargo build works fine in this PRJ
cargo check
Updating `ustc` index
Checking baby_fuzzer v0.1.0 (/home/aria/Desktop/fuzzer/baby_fuzzer)
warning: unused import: `std::ops::Add`
--> src/main.rs:2:5
|
2 | use std::ops::Add;
| ^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: unused imports: `BytesInput`, `HasTargetBytes`, `bolts::AsSlice`, `executors::ExitKind`
--> src/main.rs:4:5
|
4 | bolts::AsSlice,
| ^^^^^^^^^^^^^^
5 | inputs::{BytesInput, HasTargetBytes},
| ^^^^^^^^^^ ^^^^^^^^^^^^^^
6 | executors::ExitKind,
| ^^^^^^^^^^^^^^^^^^^
warning: `baby_fuzzer` (bin "baby_fuzzer") generated 2 warnings
Finished dev [unoptimized + debuginfo] target(s) in 0.91s
I'm newbie to rust, so all setting is default.
I try to find any logs in OUTPUT window from RA Client or RA language server but nothing there.
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 problem with a cargo new project and the local libafl path dependency shown in the report. Run cargo check and cargo build, then investigate why rust-analyzer cannot resolve definitions for the dependency while those commands succeed. Done means navigation to definitions works for imported external-crate items, including locally defined structures such as Cacher.
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
- Mostly clear
- Newbie friendliness
- 35/100