rust-analyzer: Rust analyzer incorrectly analyzes file as "Does not belong to any crate"
rust-analyzer version: (eg. output of “Rust Analyzer: Show RA Version” command) rust-analyzer version: 5d5bbec9b 2022-05-08 nightly
rustc version: (eg. output of rustc -V)
rustc 1.62.0-nightly (52ca603da 2022-04-12)
relevant settings: (eg. client settings, or environment variables like CARGO, RUSTUP_HOME or CARGO_HOME)
Unknown.
In my project here: https://github.com/spacestation13/BYONDDiffBots
Rust Analyzer won’t load crates/mapdiffbot2/src/github_processor.rs as part of the mapdiffbot2 crate. Instead, it just reports “File info: Does not belong to any crate”, as seen below.

This doesn’t happen with any other files in the repository. crates/mapdiffbot2/src/rendering.rs loads fine:

Furthermore, on the idb2 branch, crates/icondiffbot2/src/github_processor.rs does not have the issue, while crates/mapdiffbot2/src/github_processor.rs does, despite having the same file name, and being included with the same mod statement in the respective main.rs.

Please let me know if there is any more information I can provide, I’m not familiar with how to debug rust-analyzer.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (5 by maintainers)
Keeps happening to me too… I noticed its most often when I create a new file and copy paste some code. Can’t tell which part does that exactly, but either way very annoying.
EDIT : use
"rust-analyzer.showUnlinkedFileNotification": false,in your settings JSON to make this issue go byebyeMake sure to check your vscode workspace settings don’t have any
linkedProjectssettings configured. Other than that, please open a new issue ideally with a repo that reproduces this.Can confirm that what @nngeorgiy noticed it true. There is an issue here, please reopen.
I’m being bombarded by the same
file does not belong toprompts, but my circumstances are different. First, there’s an additional error right after starting VS Code:The difference is, unlike posters above, I use multiple root folders in my workspace, and the
notesfolder is just a bunch of.mdfiles. The only Rust code is in thehellofolder, and it’s just an empty project courtesy of cargo. When I reorder the two folders in VS Code so that thehellofolder is first, all the errors vanish. When I reorder them back, they reappear. It looks to me that the VS Code extension just grabs the first root folder in the workspace and ignores the rest?I use
rust-analyzer v0.3.1481withrustc 1.68.2. The issue reproduces with all extensions other thanrust-analyzerdisabled and VS Code restarted.Also keeps happening to me for some reason. whenever I open Cargo.toml. This didn’t happen a few months ago.