Cleanup incompatible_make_rust_providers_target_independent (#1074)
Closes https://github.com/bazelbuild/rules_rust/issues/966
diff --git a/docs/flatten.md b/docs/flatten.md
index e579586..7dbaaf1 100644
--- a/docs/flatten.md
+++ b/docs/flatten.md
@@ -1360,13 +1360,13 @@
| :------------- | :------------- |
| <a id="CrateInfo-aliases"></a>aliases | Dict[Label, String]: Renamed and aliased crates |
| <a id="CrateInfo-compile_data"></a>compile_data | depset[File]: Compile data required by this crate. |
-| <a id="CrateInfo-deps"></a>deps | depset[DepVariantInfo|Target]: This crate's (rust or cc) dependencies' providers. |
+| <a id="CrateInfo-deps"></a>deps | depset[DepVariantInfo]: This crate's (rust or cc) dependencies' providers. |
| <a id="CrateInfo-edition"></a>edition | str: The edition of this crate. |
| <a id="CrateInfo-is_test"></a>is_test | bool: If the crate is being compiled in a test context |
| <a id="CrateInfo-name"></a>name | str: The name of this crate. |
| <a id="CrateInfo-output"></a>output | File: The output File that will be produced, depends on crate type. |
| <a id="CrateInfo-owner"></a>owner | Label: The label of the target that produced this CrateInfo |
-| <a id="CrateInfo-proc_macro_deps"></a>proc_macro_deps | depset[DepVariantInfo|Target]: This crate's rust proc_macro dependencies' providers. |
+| <a id="CrateInfo-proc_macro_deps"></a>proc_macro_deps | depset[DepVariantInfo]: This crate's rust proc_macro dependencies' providers. |
| <a id="CrateInfo-root"></a>root | File: The source File entrypoint to this crate, eg. lib.rs |
| <a id="CrateInfo-rustc_env"></a>rustc_env | Dict[String, String]: Additional <code>"key": "value"</code> environment variables to set for rustc. |
| <a id="CrateInfo-srcs"></a>srcs | depset[File]: All source Files that are part of the crate. |
diff --git a/docs/providers.md b/docs/providers.md
index 5408554..588b848 100644
--- a/docs/providers.md
+++ b/docs/providers.md
@@ -23,13 +23,13 @@
| :------------- | :------------- |
| <a id="CrateInfo-aliases"></a>aliases | Dict[Label, String]: Renamed and aliased crates |
| <a id="CrateInfo-compile_data"></a>compile_data | depset[File]: Compile data required by this crate. |
-| <a id="CrateInfo-deps"></a>deps | depset[DepVariantInfo|Target]: This crate's (rust or cc) dependencies' providers. |
+| <a id="CrateInfo-deps"></a>deps | depset[DepVariantInfo]: This crate's (rust or cc) dependencies' providers. |
| <a id="CrateInfo-edition"></a>edition | str: The edition of this crate. |
| <a id="CrateInfo-is_test"></a>is_test | bool: If the crate is being compiled in a test context |
| <a id="CrateInfo-name"></a>name | str: The name of this crate. |
| <a id="CrateInfo-output"></a>output | File: The output File that will be produced, depends on crate type. |
| <a id="CrateInfo-owner"></a>owner | Label: The label of the target that produced this CrateInfo |
-| <a id="CrateInfo-proc_macro_deps"></a>proc_macro_deps | depset[DepVariantInfo|Target]: This crate's rust proc_macro dependencies' providers. |
+| <a id="CrateInfo-proc_macro_deps"></a>proc_macro_deps | depset[DepVariantInfo]: This crate's rust proc_macro dependencies' providers. |
| <a id="CrateInfo-root"></a>root | File: The source File entrypoint to this crate, eg. lib.rs |
| <a id="CrateInfo-rustc_env"></a>rustc_env | Dict[String, String]: Additional <code>"key": "value"</code> environment variables to set for rustc. |
| <a id="CrateInfo-srcs"></a>srcs | depset[File]: All source Files that are part of the crate. |
diff --git a/proto/proto.bzl b/proto/proto.bzl
index 0805fdd..fee04e7 100644
--- a/proto/proto.bzl
+++ b/proto/proto.bzl
@@ -219,7 +219,6 @@
transform_deps(
compile_deps +
proto_toolchain.grpc_compile_deps if is_grpc else proto_toolchain.proto_compile_deps,
- toolchain._incompatible_make_rust_providers_target_independent,
),
)
diff --git a/rust/private/clippy.bzl b/rust/private/clippy.bzl
index 251398d..c090334 100644
--- a/rust/private/clippy.bzl
+++ b/rust/private/clippy.bzl
@@ -70,7 +70,6 @@
aliases = crate_info.aliases,
# Clippy doesn't need to invoke transitive linking, therefore doesn't need linkstamps.
are_linkstamps_supported = False,
- make_rust_providers_target_independent = toolchain._incompatible_make_rust_providers_target_independent,
remove_transitive_libs_from_dep_info = toolchain._incompatible_remove_transitive_libs_from_dep_info,
)
diff --git a/rust/private/providers.bzl b/rust/private/providers.bzl
index cf49c4d..b0f56f5 100644
--- a/rust/private/providers.bzl
+++ b/rust/private/providers.bzl
@@ -19,13 +19,13 @@
fields = {
"aliases": "Dict[Label, String]: Renamed and aliased crates",
"compile_data": "depset[File]: Compile data required by this crate.",
- "deps": "depset[DepVariantInfo|Target]: This crate's (rust or cc) dependencies' providers.",
+ "deps": "depset[DepVariantInfo]: This crate's (rust or cc) dependencies' providers.",
"edition": "str: The edition of this crate.",
"is_test": "bool: If the crate is being compiled in a test context",
"name": "str: The name of this crate.",
"output": "File: The output File that will be produced, depends on crate type.",
"owner": "Label: The label of the target that produced this CrateInfo",
- "proc_macro_deps": "depset[DepVariantInfo|Target]: This crate's rust proc_macro dependencies' providers.",
+ "proc_macro_deps": "depset[DepVariantInfo]: This crate's rust proc_macro dependencies' providers.",
"root": "File: The source File entrypoint to this crate, eg. lib.rs",
"rustc_env": "Dict[String, String]: Additional `\"key\": \"value\"` environment variables to set for rustc.",
"srcs": "depset[File]: All source Files that are part of the crate.",
diff --git a/rust/private/rust.bzl b/rust/private/rust.bzl
index f665325..b40de71 100644
--- a/rust/private/rust.bzl
+++ b/rust/private/rust.bzl
@@ -251,9 +251,8 @@
)
rust_lib = ctx.actions.declare_file(rust_lib_name)
- make_rust_providers_target_independent = toolchain._incompatible_make_rust_providers_target_independent
- deps = transform_deps(ctx.attr.deps, make_rust_providers_target_independent)
- proc_macro_deps = transform_deps(ctx.attr.proc_macro_deps, make_rust_providers_target_independent)
+ deps = transform_deps(ctx.attr.deps)
+ proc_macro_deps = transform_deps(ctx.attr.proc_macro_deps)
return rustc_compile_action(
ctx = ctx,
@@ -292,9 +291,8 @@
output = ctx.actions.declare_file(ctx.label.name + toolchain.binary_ext)
- make_rust_providers_target_independent = toolchain._incompatible_make_rust_providers_target_independent
- deps = transform_deps(ctx.attr.deps, make_rust_providers_target_independent)
- proc_macro_deps = transform_deps(ctx.attr.proc_macro_deps, make_rust_providers_target_independent)
+ deps = transform_deps(ctx.attr.deps)
+ proc_macro_deps = transform_deps(ctx.attr.proc_macro_deps)
return rustc_compile_action(
ctx = ctx,
@@ -426,9 +424,8 @@
crate_name = crate_name_from_attr(ctx.attr)
crate_type = "bin"
- make_rust_providers_target_independent = toolchain._incompatible_make_rust_providers_target_independent
- deps = transform_deps(ctx.attr.deps, make_rust_providers_target_independent)
- proc_macro_deps = transform_deps(ctx.attr.proc_macro_deps, make_rust_providers_target_independent)
+ deps = transform_deps(ctx.attr.deps)
+ proc_macro_deps = transform_deps(ctx.attr.proc_macro_deps)
if ctx.attr.crate:
# Target is building the crate in `test` config
diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl
index d0749c9..7a91746 100644
--- a/rust/private/rustc.bzl
+++ b/rust/private/rustc.bzl
@@ -118,7 +118,6 @@
proc_macro_deps,
aliases,
are_linkstamps_supported = False,
- make_rust_providers_target_independent = False,
remove_transitive_libs_from_dep_info = False):
"""Walks through dependencies and collects the transitive dependencies.
@@ -127,9 +126,7 @@
deps (list): The deps from ctx.attr.deps.
proc_macro_deps (list): The proc_macro deps from ctx.attr.proc_macro_deps.
aliases (dict): A dict mapping aliased targets to their actual Crate information.
- are_linkstamps_supported (bool): Whether the current rule and the toolchain support building linkstamps.
- make_rust_providers_target_independent (bool): Whether
- --incompatible_make_rust_providers_target_independent has been flipped.
+ are_linkstamps_supported (bool): Whether the current rule and the toolchain support building linkstamps..
remove_transitive_libs_from_dep_info (bool): Whether
--incompatible_remove_transitive_libs_from_dep_info has been flipped.
@@ -151,9 +148,6 @@
aliases = {k.label: v for k, v in aliases.items()}
for dep in depset(transitive = [deps, proc_macro_deps]).to_list():
- if type(dep) == "Target" and make_rust_providers_target_independent:
- fail("The `deps` parameter needs to be of type `depset[DepVariantInfo], got depset[Target]`")
-
(crate_info, dep_info) = _get_crate_and_dep_info(dep)
cc_info = _get_cc_info(dep)
dep_build_info = _get_build_info(dep)
@@ -164,9 +158,6 @@
if crate_info:
# This dependency is a rust_library
- if not getattr(crate_info, "owner", None) and make_rust_providers_target_independent:
- fail("Missing mandatory CrateInfo field: owner")
-
# When crate_info.owner is set, we use it. When the dep type is Target we get the
# label from dep.label
owner = getattr(crate_info, "owner", dep.label if type(dep) == "Target" else None)
@@ -731,7 +722,6 @@
"""
cc_toolchain, feature_configuration = find_cc_toolchain(ctx)
- make_rust_providers_target_independent = toolchain._incompatible_make_rust_providers_target_independent
remove_transitive_libs_from_dep_info = toolchain._incompatible_remove_transitive_libs_from_dep_info
dep_info, build_info, linkstamps = collect_deps(
@@ -743,7 +733,6 @@
feature_configuration = feature_configuration,
has_grep_includes = hasattr(ctx.attr, "_grep_includes"),
),
- make_rust_providers_target_independent = make_rust_providers_target_independent,
remove_transitive_libs_from_dep_info = remove_transitive_libs_from_dep_info,
)
diff --git a/rust/private/utils.bzl b/rust/private/utils.bzl
index bc00e69..08d2fa0 100644
--- a/rust/private/utils.bzl
+++ b/rust/private/utils.bzl
@@ -361,7 +361,7 @@
# TODO(djmarcin): Is there any better way to determine cfg=exec?
return ctx.genfiles_dir.path.find("-exec-") == -1
-def transform_deps(deps, make_rust_providers_target_independent):
+def transform_deps(deps):
"""Conditionally transform a [Target] into [DepVariantInfo].
This helper function is used to transform ctx.attr.deps and ctx.attr.proc_macro_deps into
@@ -371,8 +371,6 @@
Args:
deps (list of Targets): Dependencies comming from ctx.attr.deps or ctx.attr.proc_macro_deps
- make_rust_providers_target_independent (bool): The value of
- --//rust/settings:incompatible_make_rust_providers_target_independent.
Returns:
list of DepVariantInfos if --//rust/settings:incompatible_make_rust_providers_target has
@@ -383,4 +381,4 @@
dep_info = dep[DepInfo] if DepInfo in dep else None,
build_info = dep[BuildInfo] if BuildInfo in dep else None,
cc_info = dep[CcInfo] if CcInfo in dep else None,
- ) for dep in deps] if make_rust_providers_target_independent else deps
+ ) for dep in deps]
diff --git a/rust/settings/BUILD.bazel b/rust/settings/BUILD.bazel
index e3c4a84..f83d1f1 100644
--- a/rust/settings/BUILD.bazel
+++ b/rust/settings/BUILD.bazel
@@ -4,12 +4,6 @@
package(default_visibility = ["//visibility:public"])
incompatible_flag(
- name = "incompatible_make_rust_providers_target_independent",
- build_setting_default = True,
- issue = "https://github.com/bazelbuild/rules_rust/issues/966",
-)
-
-incompatible_flag(
name = "incompatible_remove_transitive_libs_from_dep_info",
build_setting_default = True,
issue = "https://github.com/bazelbuild/rules_rust/issues/1051",
diff --git a/rust/toolchain.bzl b/rust/toolchain.bzl
index 4538b21..e81671d 100644
--- a/rust/toolchain.bzl
+++ b/rust/toolchain.bzl
@@ -231,7 +231,6 @@
if ctx.attr.target_triple and ctx.file.target_json:
fail("Do not specify both target_triple and target_json, either use a builtin triple or provide a custom specification file.")
- make_rust_providers_target_independent = ctx.attr._incompatible_make_rust_providers_target_independent[IncompatibleFlagInfo]
remove_transitive_libs_from_dep_info = ctx.attr._incompatible_remove_transitive_libs_from_dep_info[IncompatibleFlagInfo]
disable_custom_test_launcher = ctx.attr._incompatible_disable_custom_test_launcher[IncompatibleFlagInfo]
@@ -285,7 +284,6 @@
compilation_mode_opts = compilation_mode_opts,
crosstool_files = ctx.files._crosstool,
libstd_and_allocator_ccinfo = _make_libstd_and_allocator_ccinfo(ctx, ctx.attr.rust_lib, ctx.attr.allocator_library),
- _incompatible_make_rust_providers_target_independent = make_rust_providers_target_independent.enabled,
_incompatible_remove_transitive_libs_from_dep_info = remove_transitive_libs_from_dep_info.enabled,
_incompatible_disable_custom_test_launcher = disable_custom_test_launcher.enabled,
)
@@ -403,9 +401,6 @@
"_incompatible_disable_custom_test_launcher": attr.label(
default = Label("@rules_rust//rust/settings:incompatible_disable_custom_test_launcher"),
),
- "_incompatible_make_rust_providers_target_independent": attr.label(
- default = "@rules_rust//rust/settings:incompatible_make_rust_providers_target_independent",
- ),
"_incompatible_remove_transitive_libs_from_dep_info": attr.label(
default = "@rules_rust//rust/settings:incompatible_remove_transitive_libs_from_dep_info",
),