VSCode with the rust-analyzer plugin: Rust project, 2 levels counting the open folder [Solved]

Hi there all, I am just starting to learn Rust and I think I stumbled upon a bug with the rurt-analyzer for VS Code. I'm going through The Rust Programming Language book and just finished Chapter 8.3. When I tried to make a project to solve the three exercises at the end of the chapter, I happened upon a problem where the rust-analyzer stopped working suddenly. Restarting it does not solve it; no suggestions, no linting, nothing. I have seen this problem before but only on some projects (I assumed it was due to me being on Windows instead of Linux or another UNIX system). Although this time I decided to try to find what caused it. I searched on the web but no one seemed to have the same exact problem as me or at least I did not find it.

Anyhow, I think it is caused due to an extra parent directory of the cargo project. My file hierarchy is as follows:


The issue with the rust-analyzer only occurred for the "problematic_project" and the other project (working_project) worked fine (you might need to reload VSCode tho).

For reference, the version of the rust-analyzer I use is:
rust-analyzer version: 0.3.1369-standalone (ff4d55e48 2023-01-15)
and VS code version:

The problem is that you have a Cargo.toml more than 1 level deep nested. For performance reasons rust-anlayzer only searches it up to 1 level deep. You can use the rust-analyzer.linkedProjects config to point to all the Cargo.toml files of the crates you are working on. Alternatively you could create cargo workspace at the top level and include all packages as members. This will also share the target dir and thus share compiled dependencies.


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.