rust-lang / rust-lang/rust-analyzer
New files in `tests/` give "This file is not included in any crates"
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
When I open a new file in tests/ (e.g. tests/my_test.rs), rust-analyzer gives an unlinked file diagnostic:
This file is not included in any crates, so rust-analyzer can't offer IDE services.
If you're intentionally working on unowned files, you can silence this warning by adding "unlinked-file" to rust-analyzer.diagnostics.disabled in your settings. [unlinked-file]
Once I restart the rust-analyzer process, the file is loaded correctly. This may be related to #9910, but I only have this issue with files under the tests/ directory.
rust-analyzer version: rust-analyzer 2024-09-02
rustc version: rustc 1.81.0 (eeb90cda1 2024-09-04)
editor or extension: Neovim with native LSP
relevant settings: https://github.com/9999years/dotfiles/blob/205a5d1738c5520759512bf82454d04059b3b1b3/config/nvim/init.lua#L911-L949
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 issue by creating a new tests/my_test.rs file with rust-analyzer and observe the unlinked-file diagnostic before and after restarting the process. Trace how files under tests/ are discovered and included, then verify that a newly created test file is loaded without requiring a restart.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100