diff --git a/prelude/rust/build.bzl b/prelude/rust/build.bzl index bba19e6e61073..ab7ce0bbbe2d7 100644 --- a/prelude/rust/build.bzl +++ b/prelude/rust/build.bzl @@ -187,7 +187,7 @@ def generate_rustdoc( subdir = common_args.subdir + "-rustdoc" output = ctx.actions.declare_output(subdir) - plain_env, path_env = process_env(compile_ctx, ctx.attrs.env, exec_is_windows) + plain_env, path_env = process_env(compile_ctx, toolchain_info.rustdoc_env | ctx.attrs.env, exec_is_windows) plain_env["RUSTDOC_BUCK_TARGET"] = cmd_args(str(ctx.label.raw_target())) rustdoc_cmd = cmd_args( diff --git a/prelude/rust/rust_toolchain.bzl b/prelude/rust/rust_toolchain.bzl index b921a5d5c1a85..a69e40d69ae4d 100644 --- a/prelude/rust/rust_toolchain.bzl +++ b/prelude/rust/rust_toolchain.bzl @@ -53,6 +53,8 @@ rust_toolchain_attrs = { # FIXME(JakobDegen): Can't use `list[str]` here, because then the default is wrong, but can't # use a non-empty list as the default because lists are mutable "rustc_coverage_flags": provider_field(typing.Any, default = ("-Cinstrument-coverage",)), + # Extra env variables that should be made available to the rustdoc executable. + "rustdoc_env": provider_field(dict[str, typing.Any], default = {}), # Extra flags for rustdoc invocations "rustdoc_flags": provider_field(list[typing.Any], default = []), # When you `buck test` a library, also compile and run example code in its