-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
include!
macro silently gives empty string if destination file is outside of the crate
#17040
Comments
Got some hint from #3767 and added some println, and it seems rust-analyzer/crates/hir-expand/src/builtin_fn_macro.rs Lines 668 to 670 in 5bf2f85
|
#15836 (comment) seems to apply here? |
So basically only the files that included in Maybe a fix can parse and load |
If parsing files requires a lot of changes, maybe at least allow adding some files in the list by environment variables? |
Yes, that's correct. I think that making source root resolution look outside the crate might be feasible, but I think you might be better off not |
Sure if the whole code is Rust, but if one needs to bind between other languages and Rust and the bindgen is not in Rust side (e.g. some Python code as in our case), the generated file ends up being outside of the crate graph. How are |
The corresponding out-dir is added correctly to the set of known files for a crate, so if your build script emits a file that the crate of that build script is then including that should work fine, it won't work cross crates though. This not working here is a known problem with our current VFS setup. |
Rust analyzer doesn't like `include!`s that reach outside of a crate's own OUT_DIR: rust-lang/rust-analyzer#17040 Fix this by requiring any crate that wants expanded output (in tests) to have a build script that sets a magic env var. Signed-off-by: Lann Martin <lann.martin@fermyon.com>
rust-analyzer version: 0.3.1916-standalone (7a8374c 2024-04-08)
rustc version: rustc 1.77.2 (25ef9e3d8 2024-04-09)
editor or extension: VSCode, rust-analyzer v0.3.1916
relevant settings: N/A?
repository link (if public, optional): https://github.com/saschanaz/rust-include-repro
code snippet to reproduce: (Please refer to the repo to see the exact file tree)
The issue is threefold:
in_workspace
does not autocomplete inmain()
in_workspace();
shows nothinginclude!("../../in-workspace.rs")
just deletes the lineThe build result works as expected, so this should be rust-analyzer specific.
See also: https://bugzilla.mozilla.org/show_bug.cgi?id=1890431
The text was updated successfully, but these errors were encountered: