-
Notifications
You must be signed in to change notification settings - Fork 1.8k
#[path = "../XXXXXX"]
attribute on modules gives false unresolved-module
error
#9173
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
Comments
If I try the quick fix, I get this error in console:
|
This is a known limitation, I'm not sure if there's already an open issue for it. |
Not one that I could find - is there a reason for this limitation? I noticed there are tests which surprisingly pass with this exact scenario, from what I can gather. |
I'm not sure, but maybe we don't load the file. |
Yeah, it seems to work for files that are inside the project. It gets loaded by the VFS once you edit the file, but we still don't resolve the module for some reason. |
I believe that module files need to be part of the same source root at the moment |
I've also just run into this issue, I guess the more idiomatic way to handle this situation is to make the referenced module into a full blown library referenced by |
Hi! I'm also hitting this problem on both stable and nightly. Unfortunately, the solution suggested by @kellpossible won't work for me since I include autogenerated modules in such a way, so putting them all into Please let me know if I can provide any more info, and in the meantime - is there any way to silence this error locally? Thanks! |
@curldivergence my use case sounds similar, auto generated module, I still didn't implement this workaround for the same reason. |
I see that there is a test which appears to cover this case? rust-analyzer/crates/hir-def/src/nameres/tests/mod_resolution.rs Lines 322 to 347 in ba32991
|
To my knowledge this is a known shortcoming of our VFS, so this is "unactionable" in the sense that it needs design decisions on how to get around this shortcoming. |
Setting |
Yeah, I have this in my settings "rust-analyzer.diagnostics.disabled": [
"unlinked-file", // I guess for "normal" projects unlinked files are strange, for me they are common
"missing-match-arm", // https://github.com/rust-lang/rust-analyzer/issues/4896
"type-mismatch", // https://github.com/rust-lang/rust-analyzer/issues/1109
"unresolved-module", // https://github.com/rust-lang/rust-analyzer/issues/9173
"unresolved-extern-crate", // https://github.com/rust-lang/rust-analyzer/issues/12926
], |
Encoutered this same issue #[path = "../../shared/schema_generated.rs"]
mod schema_generated; for reference this file is at |
Maybe the error message could be improved? Currently it says "Cannot find module file", but if the user goes looking then the module file is right there, so that's quite confusing. FWIW the error that needs to be listed in |
by symlink the updir then use `#[path = "symlink/file.rs"]` rust-lang/rust-analyzer#9173
duplicate of #3898 |
Example: https://github.com/WilliamVenner/rust-analyzer-broken-example
Code:
./package/src/main.rs
./silly_mod/mod.rs
The text was updated successfully, but these errors were encountered: