-
Notifications
You must be signed in to change notification settings - Fork 483
gen_rust_project
creates invalid entries if compile_data
is used
#3200
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
I'm confused, did this introduce an additional regression or not? If so I think we should revert it. |
Yes, it stopped working for bazel-lsp that is using compile_data. But I am not sure it worked even before if some generated data was used - or how it worked as in such case the sources also were transformed. I have not checked it for generated data though. |
Just confirmed, that generated data would trigger this issue even before the #3176 . Here is small patch on current bazel-lsp that triggers the same issue on rules_rust 0.56: diff --git a/BUILD b/BUILD
index a52b298..b57465d 100644
--- a/BUILD
+++ b/BUILD
@@ -2,7 +2,7 @@ load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_test")
rust_binary(
name = "bazel-lsp",
- srcs = glob(["src/**/*.rs"]),
+ srcs = glob(["src/**/*.rs"]) + ["src/empty.rs"],
compile_data = [
"//src/builtin:builtin.pb",
"//src/builtin:default_build_language.pb",
@@ -31,6 +31,12 @@ rust_binary(
],
)
+genrule(
+ name = "gen_empty_file",
+ cmd = "echo > $@",
+ outs = [ "src/empty.rs" ],
+)
+
genrule(
name = "generate_rustc_env_file",
srcs = [
diff --git a/MODULE.bazel b/MODULE.bazel
index 19049d3..f46ba5e 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -1,5 +1,5 @@
-bazel_dep(name = "rules_rust", version = "0.57.0")
-bazel_dep(name = "rules_rust_prost", version = "0.57.0")
+bazel_dep(name = "rules_rust", version = "0.56.0")
+bazel_dep(name = "rules_rust_prost", version = "0.56.0")
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain( |
There are a few general issues with generated sources/compile_data (especially when mixed with non-generated) in relation to rust-analyzer that is a bit unclear how to address, see #3126 for example. Afaict #3176 made builds work in more cases, but also exposed more cases where |
Uh oh!
There was an error while loading. Please reload this page.
Generated rust-project.json started to contain
include_dirs
which points to bin directory. Because of that rust_analyzer does not treat any file, other than root_module, as belonging to the crate.Workaround is to manually remove the source entry, or add appropriate include dir to rust-project.json ("src" in below example).
Bisect pointed to #3176, although reading through it possibly issue was present even before that if crate contained some generated data.
Example on https://github.com/cameron-martin/bazel-lsp after
bazel run @rules_rust//tools/rust_analyzer:gen_rust_project
The text was updated successfully, but these errors were encountered: