Skip to content

Commit 98fab85

Browse files
authored
Fixed genquery for rust targets (#2559)
relates to #2522
1 parent 00a4bfb commit 98fab85

File tree

5 files changed

+36
-4
lines changed

5 files changed

+36
-4
lines changed

rust/private/rust.bzl

-4
Original file line numberDiff line numberDiff line change
@@ -528,10 +528,6 @@ RUSTC_ATTRS = {
528528
"_extra_rustc_flags": attr.label(
529529
default = Label("//:extra_rustc_flags"),
530530
),
531-
"_import_macro_dep": attr.label(
532-
default = Label("//util/import"),
533-
cfg = "exec",
534-
),
535531
"_is_proc_macro_dep": attr.label(
536532
default = Label("//rust/private:is_proc_macro_dep"),
537533
),

rust/private/utils.bzl

+3
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,9 @@ def get_import_macro_deps(ctx):
493493
list of Targets. Either empty (if the fake import macro implementation
494494
is being used), or a singleton list with the real implementation.
495495
"""
496+
if not hasattr(ctx.attr, "_import_macro_dep"):
497+
return []
498+
496499
if ctx.attr._import_macro_dep.label.name == "fake_import_macro_impl":
497500
return []
498501

test/genquery/BUILD.bazel

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
load("//rust:defs.bzl", "rust_binary", "rust_library")
2+
3+
rust_library(
4+
name = "bar",
5+
srcs = ["bar.rs"],
6+
edition = "2021",
7+
)
8+
9+
genquery(
10+
name = "bar_deps",
11+
expression = "deps(//test/genquery:bar)",
12+
scope = [":bar"],
13+
)
14+
15+
rust_binary(
16+
name = "foo",
17+
srcs = ["foo.rs"],
18+
edition = "2021",
19+
deps = [":bar"],
20+
)
21+
22+
genquery(
23+
name = "foo_deps",
24+
expression = "deps(//test/genquery:foo)",
25+
scope = [":foo"],
26+
)

test/genquery/bar.rs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub fn bar() {
2+
println!("Bar");
3+
}

test/genquery/foo.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
println!("foo");
3+
bar::bar();
4+
}

0 commit comments

Comments
 (0)