diff --git a/rust/private/rust.bzl b/rust/private/rust.bzl index 4ade35aaed..f77098e1ae 100644 --- a/rust/private/rust.bzl +++ b/rust/private/rust.bzl @@ -528,10 +528,6 @@ RUSTC_ATTRS = { "_extra_rustc_flags": attr.label( default = Label("//:extra_rustc_flags"), ), - "_import_macro_dep": attr.label( - default = Label("//util/import"), - cfg = "exec", - ), "_is_proc_macro_dep": attr.label( default = Label("//rust/private:is_proc_macro_dep"), ), diff --git a/rust/private/utils.bzl b/rust/private/utils.bzl index 06a3d3340c..57a3fe7a7e 100644 --- a/rust/private/utils.bzl +++ b/rust/private/utils.bzl @@ -493,6 +493,9 @@ def get_import_macro_deps(ctx): list of Targets. Either empty (if the fake import macro implementation is being used), or a singleton list with the real implementation. """ + if not hasattr(ctx.attr, "_import_macro_dep"): + return [] + if ctx.attr._import_macro_dep.label.name == "fake_import_macro_impl": return [] diff --git a/test/genquery/BUILD.bazel b/test/genquery/BUILD.bazel new file mode 100644 index 0000000000..53a033fcec --- /dev/null +++ b/test/genquery/BUILD.bazel @@ -0,0 +1,26 @@ +load("//rust:defs.bzl", "rust_binary", "rust_library") + +rust_library( + name = "bar", + srcs = ["bar.rs"], + edition = "2021", +) + +genquery( + name = "bar_deps", + expression = "deps(//test/genquery:bar)", + scope = [":bar"], +) + +rust_binary( + name = "foo", + srcs = ["foo.rs"], + edition = "2021", + deps = [":bar"], +) + +genquery( + name = "foo_deps", + expression = "deps(//test/genquery:foo)", + scope = [":foo"], +) diff --git a/test/genquery/bar.rs b/test/genquery/bar.rs new file mode 100644 index 0000000000..811f1120ef --- /dev/null +++ b/test/genquery/bar.rs @@ -0,0 +1,3 @@ +pub fn bar() { + println!("Bar"); +} diff --git a/test/genquery/foo.rs b/test/genquery/foo.rs new file mode 100644 index 0000000000..3ca6ac6d10 --- /dev/null +++ b/test/genquery/foo.rs @@ -0,0 +1,4 @@ +fn main() { + println!("foo"); + bar::bar(); +}