Could rust-analyzer resolve .rlib dependency?

I have a binary dependency dep.rlib, without any code sources. (I'm sure it's compiled with same rustc as mine, thus no abi problem.)

I write such code

extern crate dep;
fn main() {
    // do some stuff with dep::some_method.
}

Then compile it with RUSTFLAGS="--extern dep=path/to/the/rlib" cargo run and it works fine.

I learn that the exported items are written into rmeta and contained in rlib so it works. However rust-analyzer always report unresolved extern crate. Setting cargo.extraEnv, server.extraEnv, check.extraEnv all does not help.

How could rust-analyzer solves the dependency and enables completion?

Rust-analyzer does not support reading rlibs. It needs the crate source.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.