From 80c8dd52f1590767bcad106abf5144d0bc6aa2e7 Mon Sep 17 00:00:00 2001 From: Vinh Tran Date: Wed, 18 Oct 2023 10:59:08 -0400 Subject: [PATCH] Remove _rustc_env_attr from CrateInfo (#2189) #2188's follow-up PR to remove unused `_rustc_env_attr` field in `CrateInfo` provider. We can rely on `skip_expanding_rustc_env` to determine whether `rustc_env` is already expanded or not. --- docs/flatten.md | 3 +-- docs/providers.md | 3 +-- proto/prost/private/prost.bzl | 1 - proto/protobuf/proto.bzl | 1 - rust/private/providers.bzl | 2 -- rust/private/rust.bzl | 7 +------ rust/private/rustc.bzl | 2 +- rust/private/rustdoc.bzl | 1 - rust/private/rustdoc_test.bzl | 1 - .../consistent_crate_name/with_modified_crate_name.bzl | 1 - test/unit/force_all_deps_direct/generator.bzl | 1 - test/unit/pipelined_compilation/wrap.bzl | 1 - 12 files changed, 4 insertions(+), 20 deletions(-) diff --git a/docs/flatten.md b/docs/flatten.md index 49ed515574..03a23a9183 100644 --- a/docs/flatten.md +++ b/docs/flatten.md @@ -1450,7 +1450,7 @@ A toolchain for [rustfmt](https://rust-lang.github.io/rustfmt/)
 CrateInfo(aliases, compile_data, compile_data_targets, data, deps, edition, is_test, metadata, name,
           output, owner, proc_macro_deps, root, rustc_env, rustc_env_files, srcs, type,
-          wrapped_crate_type, _rustc_env_attr)
+          wrapped_crate_type)
 
A provider containing general Crate information. @@ -1478,7 +1478,6 @@ A provider containing general Crate information. | srcs | depset[File]: All source Files that are part of the crate. | | type | str: The type of this crate (see [rustc --crate-type](https://doc.rust-lang.org/rustc/command-line-arguments.html#--crate-type-a-list-of-types-of-crates-for-the-compiler-to-emit)). | | wrapped_crate_type | str, optional: The original crate type for targets generated using a previously defined crate (typically tests using the rust_test::crate attribute) | -| _rustc_env_attr | Dict[String, String]: Additional "key": "value" environment variables to set for rustc. | diff --git a/docs/providers.md b/docs/providers.md index e553ffb949..c97ad9bce9 100644 --- a/docs/providers.md +++ b/docs/providers.md @@ -12,7 +12,7 @@
 CrateInfo(aliases, compile_data, compile_data_targets, data, deps, edition, is_test, metadata, name,
           output, owner, proc_macro_deps, root, rustc_env, rustc_env_files, srcs, type,
-          wrapped_crate_type, _rustc_env_attr)
+          wrapped_crate_type)
 
A provider containing general Crate information. @@ -40,7 +40,6 @@ A provider containing general Crate information. | srcs | depset[File]: All source Files that are part of the crate. | | type | str: The type of this crate (see [rustc --crate-type](https://doc.rust-lang.org/rustc/command-line-arguments.html#--crate-type-a-list-of-types-of-crates-for-the-compiler-to-emit)). | | wrapped_crate_type | str, optional: The original crate type for targets generated using a previously defined crate (typically tests using the rust_test::crate attribute) | -| _rustc_env_attr | Dict[String, String]: Additional "key": "value" environment variables to set for rustc. | diff --git a/proto/prost/private/prost.bzl b/proto/prost/private/prost.bzl index 1db20021a6..b070227b61 100644 --- a/proto/prost/private/prost.bzl +++ b/proto/prost/private/prost.bzl @@ -173,7 +173,6 @@ def _compile_rust(ctx, attr, crate_name, src, deps, edition): edition = edition, is_test = False, rustc_env = {}, - _rustc_env_attr = {}, compile_data = depset([]), compile_data_targets = depset([]), owner = ctx.label, diff --git a/proto/protobuf/proto.bzl b/proto/protobuf/proto.bzl index 6ff45cc2a8..a45b3f20a9 100644 --- a/proto/protobuf/proto.bzl +++ b/proto/protobuf/proto.bzl @@ -225,7 +225,6 @@ def _rust_proto_compile(protos, descriptor_sets, imports, crate_name, ctx, is_gr metadata = rust_metadata, edition = proto_toolchain.edition, rustc_env = {}, - _rustc_env_attr = {}, is_test = False, compile_data = depset([target.files for target in getattr(ctx.attr, "compile_data", [])]), compile_data_targets = depset(getattr(ctx.attr, "compile_data", [])), diff --git a/rust/private/providers.bzl b/rust/private/providers.bzl index b2fced7442..e4db9c9f9d 100644 --- a/rust/private/providers.bzl +++ b/rust/private/providers.bzl @@ -41,8 +41,6 @@ CrateInfo = provider( "str, optional: The original crate type for targets generated using a previously defined " + "crate (typically tests using the `rust_test::crate` attribute)" ), - # TODO: Remove `_rustc_env_attr` after refactoring rust_test to only rely on rustc_env - "_rustc_env_attr": "Dict[String, String]: Additional `\"key\": \"value\"` environment variables to set for rustc.", }, ) diff --git a/rust/private/rust.bzl b/rust/private/rust.bzl index 2914f4cc3d..6f375defb7 100644 --- a/rust/private/rust.bzl +++ b/rust/private/rust.bzl @@ -200,7 +200,6 @@ def _rust_library_common(ctx, crate_type): compile_data = depset(ctx.files.compile_data), compile_data_targets = depset(ctx.attr.compile_data), owner = ctx.label, - _rustc_env_attr = ctx.attr.rustc_env, ), ) @@ -241,7 +240,6 @@ def _rust_binary_impl(ctx): aliases = ctx.attr.aliases, output = output, edition = get_edition(ctx.attr, toolchain, ctx.label), - _rustc_env_attr = ctx.attr.rustc_env, rustc_env = ctx.attr.rustc_env, rustc_env_files = ctx.files.rustc_env_files, is_test = False, @@ -295,9 +293,8 @@ def _rust_test_impl(ctx): compile_data_targets = depset(ctx.attr.compile_data) rustc_env_files = ctx.files.rustc_env_files + crate.rustc_env_files - rustc_env = dict(crate._rustc_env_attr) - # crate.rustc_env is already expanded upstream in rust_library rule implementation + rustc_env = dict(crate.rustc_env) data_paths = depset(direct = getattr(ctx.attr, "data", [])).to_list() rustc_env.update(expand_dict_value_locations( ctx, @@ -317,7 +314,6 @@ def _rust_test_impl(ctx): output = output, edition = crate.edition, rustc_env = rustc_env, - _rustc_env_attr = ctx.attr.rustc_env, rustc_env_files = rustc_env_files, is_test = True, compile_data = compile_data, @@ -361,7 +357,6 @@ def _rust_test_impl(ctx): output = output, edition = get_edition(ctx.attr, toolchain, ctx.label), rustc_env = rustc_env, - _rustc_env_attr = ctx.attr.rustc_env, rustc_env_files = ctx.files.rustc_env_files, is_test = True, compile_data = depset(ctx.files.compile_data), diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl index c972e4783e..9ba3115e76 100644 --- a/rust/private/rustc.bzl +++ b/rust/private/rustc.bzl @@ -1034,7 +1034,7 @@ def construct_arguments( else: env.update(expand_dict_value_locations( ctx, - crate_info._rustc_env_attr, + crate_info.rustc_env, data_paths, )) diff --git a/rust/private/rustdoc.bzl b/rust/private/rustdoc.bzl index dac24b3e74..1859c4aa3a 100644 --- a/rust/private/rustdoc.bzl +++ b/rust/private/rustdoc.bzl @@ -39,7 +39,6 @@ def _strip_crate_info_output(crate_info): output = None, metadata = None, edition = crate_info.edition, - _rustc_env_attr = crate_info._rustc_env_attr, rustc_env = crate_info.rustc_env, rustc_env_files = crate_info.rustc_env_files, is_test = crate_info.is_test, diff --git a/rust/private/rustdoc_test.bzl b/rust/private/rustdoc_test.bzl index f580c27aec..79b0f4dd84 100644 --- a/rust/private/rustdoc_test.bzl +++ b/rust/private/rustdoc_test.bzl @@ -122,7 +122,6 @@ def _rust_doc_test_impl(ctx): output = crate.output, edition = crate.edition, rustc_env = crate.rustc_env, - _rustc_env_attr = crate._rustc_env_attr, rustc_env_files = crate.rustc_env_files, is_test = True, compile_data = crate.compile_data, diff --git a/test/unit/consistent_crate_name/with_modified_crate_name.bzl b/test/unit/consistent_crate_name/with_modified_crate_name.bzl index 7a3bca6012..cd02617500 100644 --- a/test/unit/consistent_crate_name/with_modified_crate_name.bzl +++ b/test/unit/consistent_crate_name/with_modified_crate_name.bzl @@ -47,7 +47,6 @@ def _with_modified_crate_name_impl(ctx): compile_data = depset([]), compile_data_targets = depset([]), rustc_env = {}, - _rustc_env_attr = {}, is_test = False, ), output_hash = output_hash, diff --git a/test/unit/force_all_deps_direct/generator.bzl b/test/unit/force_all_deps_direct/generator.bzl index 959687c6b6..6501b36215 100644 --- a/test/unit/force_all_deps_direct/generator.bzl +++ b/test/unit/force_all_deps_direct/generator.bzl @@ -63,7 +63,6 @@ EOF compile_data = depset([]), compile_data_targets = depset([]), rustc_env = {}, - _rustc_env_attr = {}, is_test = False, ), output_hash = output_hash, diff --git a/test/unit/pipelined_compilation/wrap.bzl b/test/unit/pipelined_compilation/wrap.bzl index 7ceef1c021..9a7a2d2157 100644 --- a/test/unit/pipelined_compilation/wrap.bzl +++ b/test/unit/pipelined_compilation/wrap.bzl @@ -73,7 +73,6 @@ EOF compile_data = depset([]), compile_data_targets = depset([]), rustc_env = {}, - _rustc_env_attr = {}, is_test = False, ), output_hash = output_hash,