Skip to content
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

Remove _rustc_env_attr from CrateInfo #2189

Merged
merged 18 commits into from
Oct 18, 2023
Merged
3 changes: 1 addition & 2 deletions docs/flatten.md
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,7 @@ A toolchain for [rustfmt](https://rust-lang.github.io/rustfmt/)
<pre>
CrateInfo(<a href="#CrateInfo-aliases">aliases</a>, <a href="#CrateInfo-compile_data">compile_data</a>, <a href="#CrateInfo-compile_data_targets">compile_data_targets</a>, <a href="#CrateInfo-data">data</a>, <a href="#CrateInfo-deps">deps</a>, <a href="#CrateInfo-edition">edition</a>, <a href="#CrateInfo-is_test">is_test</a>, <a href="#CrateInfo-metadata">metadata</a>, <a href="#CrateInfo-name">name</a>,
<a href="#CrateInfo-output">output</a>, <a href="#CrateInfo-owner">owner</a>, <a href="#CrateInfo-proc_macro_deps">proc_macro_deps</a>, <a href="#CrateInfo-root">root</a>, <a href="#CrateInfo-rustc_env">rustc_env</a>, <a href="#CrateInfo-rustc_env_files">rustc_env_files</a>, <a href="#CrateInfo-srcs">srcs</a>, <a href="#CrateInfo-type">type</a>,
<a href="#CrateInfo-wrapped_crate_type">wrapped_crate_type</a>, <a href="#CrateInfo-_rustc_env_attr">_rustc_env_attr</a>)
<a href="#CrateInfo-wrapped_crate_type">wrapped_crate_type</a>)
</pre>

A provider containing general Crate information.
Expand Down Expand Up @@ -1478,7 +1478,6 @@ A provider containing general Crate information.
| <a id="CrateInfo-srcs"></a>srcs | depset[File]: All source Files that are part of the crate. |
| <a id="CrateInfo-type"></a>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)). |
| <a id="CrateInfo-wrapped_crate_type"></a>wrapped_crate_type | str, optional: The original crate type for targets generated using a previously defined crate (typically tests using the <code>rust_test::crate</code> attribute) |
| <a id="CrateInfo-_rustc_env_attr"></a>_rustc_env_attr | Dict[String, String]: Additional <code>"key": "value"</code> environment variables to set for rustc. |


<a id="DepInfo"></a>
Expand Down
3 changes: 1 addition & 2 deletions docs/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<pre>
CrateInfo(<a href="#CrateInfo-aliases">aliases</a>, <a href="#CrateInfo-compile_data">compile_data</a>, <a href="#CrateInfo-compile_data_targets">compile_data_targets</a>, <a href="#CrateInfo-data">data</a>, <a href="#CrateInfo-deps">deps</a>, <a href="#CrateInfo-edition">edition</a>, <a href="#CrateInfo-is_test">is_test</a>, <a href="#CrateInfo-metadata">metadata</a>, <a href="#CrateInfo-name">name</a>,
<a href="#CrateInfo-output">output</a>, <a href="#CrateInfo-owner">owner</a>, <a href="#CrateInfo-proc_macro_deps">proc_macro_deps</a>, <a href="#CrateInfo-root">root</a>, <a href="#CrateInfo-rustc_env">rustc_env</a>, <a href="#CrateInfo-rustc_env_files">rustc_env_files</a>, <a href="#CrateInfo-srcs">srcs</a>, <a href="#CrateInfo-type">type</a>,
<a href="#CrateInfo-wrapped_crate_type">wrapped_crate_type</a>, <a href="#CrateInfo-_rustc_env_attr">_rustc_env_attr</a>)
<a href="#CrateInfo-wrapped_crate_type">wrapped_crate_type</a>)
</pre>

A provider containing general Crate information.
Expand Down Expand Up @@ -40,7 +40,6 @@ A provider containing general Crate information.
| <a id="CrateInfo-srcs"></a>srcs | depset[File]: All source Files that are part of the crate. |
| <a id="CrateInfo-type"></a>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)). |
| <a id="CrateInfo-wrapped_crate_type"></a>wrapped_crate_type | str, optional: The original crate type for targets generated using a previously defined crate (typically tests using the <code>rust_test::crate</code> attribute) |
| <a id="CrateInfo-_rustc_env_attr"></a>_rustc_env_attr | Dict[String, String]: Additional <code>"key": "value"</code> environment variables to set for rustc. |


<a id="DepInfo"></a>
Expand Down
1 change: 0 additions & 1 deletion proto/prost/private/prost.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion proto/protobuf/proto.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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", [])),
Expand Down
2 changes: 0 additions & 2 deletions rust/private/providers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
},
)

Expand Down
7 changes: 1 addition & 6 deletions rust/private/rust.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
)

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
))

Expand Down
1 change: 0 additions & 1 deletion rust/private/rustdoc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion rust/private/rustdoc_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion test/unit/force_all_deps_direct/generator.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ EOF
compile_data = depset([]),
compile_data_targets = depset([]),
rustc_env = {},
_rustc_env_attr = {},
is_test = False,
),
output_hash = output_hash,
Expand Down
1 change: 0 additions & 1 deletion test/unit/pipelined_compilation/wrap.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ EOF
compile_data = depset([]),
compile_data_targets = depset([]),
rustc_env = {},
_rustc_env_attr = {},
is_test = False,
),
output_hash = output_hash,
Expand Down
Loading