-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating a new source file results in an unhelpful "This rust file does not belong to a loaded cargo project" notification #14523
Comments
The prompt seems to come from #14366, which is trying to be helpful, but in this particular (very common) case it ends up being misguided. |
I was facing this same issue since today and this affected auto-completion too. Also, clicking the pop-up options doesn't solve the problem and makes it more confusing. I fixed it adding |
fix: Fix project linking popup appearing for modules that can be linked to a crate should fix #14523
Was this resolved? I am experiencing the same issue and not seeing a fix. |
It should be fixed, what is your rust-analyzer version? |
FWIW, it seems to be fixed for me: rust-analyzer version: 0.3.1481-standalone (bab80da 2023-04-16) |
still ran into this issue today, seems to be tied to a specific file name for some reason |
same issue today, |
same issue today |
Well seems to be caused by creating a subfolder to hold a module, and not having defined the |
Problem still remains. Large project sure, but only one sub-crate seems to be the one that it complains about. There are other sub-crates that it doesn't complain about, can't understand why this one specifically. |
Same issue on mac 12.6.5 today. Tried installing multiple versions, but as long as I'm not in main.rs, I get no intellisense :/ |
Would be nice to know if this being addressed after all this time. |
FWIW, in a recently created toy project the total content of /.vscode/settings.json is: {
"rust-analyzer.linkedProjects": [
"./Cargo.toml",
"./Cargo.toml",
"./Cargo.toml",
"./Cargo.toml",
"./Cargo.toml",
"./Cargo.toml"
]
} |
I'm still encountering this issue. rust-analyzer: v0.3.1722 I know someone said it could be fixed by adding a I know this isn't really a high-priority thing but given it is such a common occurrence, it'd be nice to see progress. |
I think I fix it. The reason why it pop up is analyzer can't find the file. It look like the compile always to like files from So you can pase If you don't like wirte in Resume it, compile may first open |
Just to remind: you might see this if some of your code is behind a condition compilation Conditional compilation I just saw this pop-up when I open Hyper source and realized some mod was not compiled because feature was not enabled. So I just go to toml file and update default to be "full" feature.
then cargo build and reload my vs code solved the issue. |
Still getting this. Same workflow as #14523 (comment) ...and using the method of structuring mods without the mod.rs file. rust-analyser: v0.3.1815 Test 1:
Note: Open src/bar/systems.rs in Code, RA pops up "This rust file....". Confirming adds multiple lines to .vscode/settings.json:
But, (test 2):
Then:
Open src/foo/systems.rs in VSCode, no popup from RA. While RA's warnings about unlinked files are welcome, it isn't clear what the resolution should be in the message, and adding entries to its stanza in settings.json is distinctly odd. |
Same here. v0.3.1868 |
With v0.3.1896 it started to pop up when I open a recent VSCode folder with opened files (i.e. you open a project, you open a few files, close the project, open it again - now the popup appears). |
After adding #[cfg(featrue = "xxx")] to xxx pub mod in lib.rs, still encountering this issue. rust-analyzer: v0.3.1916 |
Had the same problem when hiding a module behind conditional compilation (feature flag). "rust-analyzer.cargo.features": "all" |
rust-analyzer version: 0.3.1463-standalone (2365762 2023-04-02)
Steps to reproduce:
foo.rs
)Actual behaviour:
When the file is opened, a popup immediately appears warning that:
This is pretty confusing, since I'm about to add the file to my project with the “Insert
mod foo;
” quick-fix, and none of the options provided seem to have anything to do with that.Also, the
Cargo.toml
file mentioned in the popup is the one that RA has already loaded, so trying to load it more isn't going to help.The text was updated successfully, but these errors were encountered: