Open UebelAndre opened 3 days ago
Trying to point the root back to the real source file can result in the generated modules not being located, despite using the include_dirs
directive:
--- rust-project.old.json 2024-06-27 09:04:25
+++ rust-project.new.json 2024-06-27 09:04:24
@@ -1,9 +1,15 @@
{
"display_name": "gen_src_in_different_cfg",
- "root_module": "/private/var/tmp/_bazel_user/76282c66b0dfe3c5cb9a230bdc913a52/execroot/rules_rust/bazel-out/darwin_arm64-fastbuild/bin/test/generated_inputs/root.rs",
+ "root_module": "test/generated_inputs/root.rs",
"edition": "2018",
"deps": [],
"is_workspace_member": true,
+ "source": {
+ "include_dirs": [
+ "/private/var/tmp/_bazel_user/76282c66b0dfe3c5cb9a230bdc913a52/execroot/rules_rust/bazel-out/darwin_arm64-fastbuild/bin/test/generated_inputs"
+ ],
+ "exclude_dirs": []
+ },
"cfg": [
"test",
"debug_assertions"
Oh, this might be due to the module being generated_in_different_cfg
which would probably not be in that directory!
Any target which has a single generated source will have all sources converted to generated sources so they live next to each other. This works fine for rustc but when using rust-analyzer on your repo, it is confusing as to why entire crates are getting completely ignored. The root cause is the source code in the repo is never referenced in the generated
rust-project.json
file and thus rust-analyzer does not know to process those files. An easy repro is to run the following in therules_rust
repo:From here, observe any of the targets in tests/generated_inputs package.
Despite
test/generated_inputs/root.rs
being a source file, the output path of/private/var/tmp/_bazel_user/76282c66b0dfe3c5cb9a230bdc913a52/execroot/rules_rust/bazel-out/darwin_arm64-fastbuild/bin/test/generated_inputs/root.rs
is used which does get processed by rust-analyzer but not the source file developers will be editing.This issue should be fixed such that sources within the repo get processed by rust-analyzer.