rust-lang / rust-lang/rust-analyzer
Spurious "does not belong to a cargo project" when files are cfg'd out
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
When a file is opened that belongs to a project but iscfg-disabled on the current configuration, RA shows a warning:
"This rust file does not belong to a loaded cargo project. It looks like it might belong to the workspace at /home/r/src/rust/compiler-builtins/Cargo.toml, do you want to add it to the linked Projects?"
However clicking the "yes" button does not help; it will add the project and then still show the same warning again next time. It will even show the warning when that exact project file has already been added, or when it is the "root" project file that is added by default when the list is empty.
This is easily reproduced for instance in the compiler-builtins crate, in files like src/mem/impls.rs or src/arm_linux.rs.
Maybe it would make sense to do a quick check whether the Cargo.toml file it suggests is already loaded, and only show the warning when it is not?
rust-analyzer version: rust-analyzer version: 0.3.1748-standalone
rustc version: rustc 1.76.0-nightly (b10cfcd65 2023-11-29)
relevant settings: -
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 warning with compiler-builtins files such as src/mem/impls.rs or src/arm_linux.rs under the reported rust-analyzer version and inspect the linked-project warning path. Verify the behavior with the suggested Cargo.toml both loaded and absent; done means cfg-disabled files no longer trigger the warning when their project is already loaded.
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
- 45/100