Renamed `_build_script_run` rule to `cargo_build_script` (#1612)

* Renamed `_build_script_run` rule to `cargo_build_script`

* Regenerate documentation
diff --git a/cargo/defs.bzl b/cargo/defs.bzl
index 0ca086b..2801805 100644
--- a/cargo/defs.bzl
+++ b/cargo/defs.bzl
@@ -1,9 +1,21 @@
 """Common definitions for the `@rules_rust//cargo` package"""
 
-load(":cargo_bootstrap.bzl", _cargo_bootstrap_repository = "cargo_bootstrap_repository", _cargo_env = "cargo_env")
-load(":cargo_build_script.bzl", _cargo_build_script = "cargo_build_script")
+load(
+    "//cargo/private:cargo_build_script.bzl",
+    _cargo_dep_env = "cargo_dep_env",
+)
+load(
+    "//cargo/private:cargo_build_script_wrapper.bzl",
+    _cargo_build_script = "cargo_build_script",
+)
+load(
+    ":cargo_bootstrap.bzl",
+    _cargo_bootstrap_repository = "cargo_bootstrap_repository",
+    _cargo_env = "cargo_env",
+)
 
 cargo_bootstrap_repository = _cargo_bootstrap_repository
 cargo_env = _cargo_env
 
 cargo_build_script = _cargo_build_script
+cargo_dep_env = _cargo_dep_env
diff --git a/cargo/cargo_build_script.bzl b/cargo/private/cargo_build_script.bzl
similarity index 76%
rename from cargo/cargo_build_script.bzl
rename to cargo/private/cargo_build_script.bzl
index fcab6ad..c0d9c17 100644
--- a/cargo/cargo_build_script.bzl
+++ b/cargo/private/cargo_build_script.bzl
@@ -1,8 +1,9 @@
-# buildifier: disable=module-docstring
+"""Rules for Cargo build scripts (`build.rs` files)"""
+
 load("@bazel_skylib//lib:paths.bzl", "paths")
 load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "CPP_COMPILE_ACTION_NAME", "C_COMPILE_ACTION_NAME")
 load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
-load("//rust:defs.bzl", "rust_binary", "rust_common")
+load("//rust:defs.bzl", "rust_common")
 
 # buildifier: disable=bzl-visibility
 load("//rust/private:providers.bzl", _DepInfo = "DepInfo")
@@ -11,7 +12,10 @@
 load("//rust/private:rustc.bzl", "BuildInfo", "get_compilation_mode_opts", "get_linker_and_args")
 
 # buildifier: disable=bzl-visibility
-load("//rust/private:utils.bzl", "dedent", "expand_dict_value_locations", "find_cc_toolchain", "find_toolchain", "name_to_crate_name")
+load("//rust/private:utils.bzl", "dedent", "expand_dict_value_locations", "find_cc_toolchain", "find_toolchain", _name_to_crate_name = "name_to_crate_name")
+
+# Reexport for cargo_build_script_wrapper.bzl
+name_to_crate_name = _name_to_crate_name
 
 def strip_target(elems):
     """Remove '-target xxx' from C(XX)FLAGS.
@@ -90,8 +94,8 @@
             res.append(arg)
     return res
 
-def _build_script_impl(ctx):
-    """The implementation for the `_build_script_run` rule.
+def _cargo_build_script_impl(ctx):
+    """The implementation for the `cargo_build_script` rule.
 
     Args:
         ctx (ctx): The rules context object
@@ -115,7 +119,7 @@
         stderr = ctx.actions.declare_file(ctx.label.name + ".stderr.log"),
     )
 
-    pkg_name = _name_to_pkg_name(ctx.label.name)
+    pkg_name = name_to_pkg_name(ctx.label.name)
 
     toolchain_tools = [toolchain.all_files]
 
@@ -261,15 +265,18 @@
             link_flags = link_flags,
             link_search_paths = link_search_paths,
         ),
-        OutputGroupInfo(streams = depset([streams.stdout, streams.stderr]), out_dir = depset([out_dir])),
+        OutputGroupInfo(
+            streams = depset([streams.stdout, streams.stderr]),
+            out_dir = depset([out_dir]),
+        ),
     ]
 
-_build_script_run = rule(
+cargo_build_script = rule(
     doc = (
         "A rule for running a crate's `build.rs` files to generate build information " +
         "which is then used to determine how to compile said crate."
     ),
-    implementation = _build_script_impl,
+    implementation = _cargo_build_script_impl,
     attrs = {
         "build_script_env": attr.string_dict(
             doc = "Environment variables for build scripts.",
@@ -333,133 +340,15 @@
     incompatible_use_toolchain_transition = True,
 )
 
-def cargo_build_script(
-        name,
-        crate_features = [],
-        version = None,
-        deps = [],
-        build_script_env = {},
-        data = [],
-        tools = [],
-        links = None,
-        rustc_env = {},
-        rustc_flags = [],
-        visibility = None,
-        tags = None,
-        **kwargs):
-    """Compile and execute a rust build script to generate build attributes
-
-    This rules take the same arguments as rust_binary.
-
-    Example:
-
-    Suppose you have a crate with a cargo build script `build.rs`:
-
-    ```output
-    [workspace]/
-        hello_lib/
-            BUILD
-            build.rs
-            src/
-                lib.rs
-    ```
-
-    Then you want to use the build script in the following:
-
-    `hello_lib/BUILD`:
-    ```python
-    package(default_visibility = ["//visibility:public"])
-
-    load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library")
-    load("@rules_rust//cargo:cargo_build_script.bzl", "cargo_build_script")
-
-    # This will run the build script from the root of the workspace, and
-    # collect the outputs.
-    cargo_build_script(
-        name = "build_script",
-        srcs = ["build.rs"],
-        # Optional environment variables passed during build.rs compilation
-        rustc_env = {
-           "CARGO_PKG_VERSION": "0.1.2",
-        },
-        # Optional environment variables passed during build.rs execution.
-        # Note that as the build script's working directory is not execroot,
-        # execpath/location will return an absolute path, instead of a relative
-        # one.
-        build_script_env = {
-            "SOME_TOOL_OR_FILE": "$(execpath @tool//:binary)"
-        }
-        # Optional data/tool dependencies
-        data = ["@tool//:binary"],
-    )
-
-    rust_library(
-        name = "hello_lib",
-        srcs = [
-            "src/lib.rs",
-        ],
-        deps = [":build_script"],
-    )
-    ```
-
-    The `hello_lib` target will be build with the flags and the environment variables declared by the \
-    build script in addition to the file generated by it.
+def name_to_pkg_name(name):
+    """Sanitize the name of cargo_build_script targets.
 
     Args:
-        name (str): The name for the underlying rule. This should be the name of the package being compiled, optionally with a suffix of _build_script.
-        crate_features (list, optional): A list of features to enable for the build script.
-        version (str, optional): The semantic version (semver) of the crate.
-        deps (list, optional): The dependencies of the crate.
-        build_script_env (dict, optional): Environment variables for build scripts.
-        data (list, optional): Files needed by the build script.
-        tools (list, optional): Tools (executables) needed by the build script.
-        links (str, optional): Name of the native library this crate links against.
-        rustc_env (dict, optional): Environment variables to set in rustc when compiling the build script.
-        rustc_flags (list, optional): List of compiler flags passed to `rustc`.
-        visibility (list of label, optional): Visibility to apply to the generated build script output.
-        tags: (list of str, optional): Tags to apply to the generated build script output.
-        **kwargs: Forwards to the underlying `rust_binary` rule.
+        name (str): The name value pass to the `cargo_build_script` wrapper.
+
+    Returns:
+        str: A cleaned up name for a build script target.
     """
-
-    # This duplicates the code in _build_script_impl because we need to make these available both when we invoke rustc (this code) and when we run the compiled build script (_build_script_impl).
-    # https://github.com/bazelbuild/rules_rust/issues/661 will hopefully remove this duplication.
-    rustc_env = dict(rustc_env)
-    if "CARGO_PKG_NAME" not in rustc_env:
-        rustc_env["CARGO_PKG_NAME"] = _name_to_pkg_name(name)
-    if "CARGO_CRATE_NAME" not in rustc_env:
-        rustc_env["CARGO_CRATE_NAME"] = name_to_crate_name(_name_to_pkg_name(name))
-
-    binary_tags = [tag for tag in tags or []]
-    if "manual" not in binary_tags:
-        binary_tags.append("manual")
-
-    rust_binary(
-        name = name + "_",
-        crate_features = crate_features,
-        version = version,
-        deps = deps,
-        data = data,
-        rustc_env = rustc_env,
-        rustc_flags = rustc_flags,
-        tags = binary_tags,
-        **kwargs
-    )
-    _build_script_run(
-        name = name,
-        script = ":{}_".format(name),
-        crate_features = crate_features,
-        version = version,
-        build_script_env = build_script_env,
-        links = links,
-        deps = deps,
-        data = data,
-        tools = tools,
-        rustc_flags = rustc_flags,
-        visibility = visibility,
-        tags = tags,
-    )
-
-def _name_to_pkg_name(name):
     if name.endswith("_build_script"):
         return name[:-len("_build_script")]
     return name
diff --git a/cargo/private/cargo_build_script_wrapper.bzl b/cargo/private/cargo_build_script_wrapper.bzl
new file mode 100644
index 0000000..b0e0b60
--- /dev/null
+++ b/cargo/private/cargo_build_script_wrapper.bzl
@@ -0,0 +1,138 @@
+"""Rules for Cargo build scripts (`build.rs` files)"""
+
+load(
+    "//cargo/private:cargo_build_script.bzl",
+    "name_to_crate_name",
+    "name_to_pkg_name",
+    _build_script_run = "cargo_build_script",
+)
+load("//rust:defs.bzl", "rust_binary")
+
+def cargo_build_script(
+        name,
+        crate_features = [],
+        version = None,
+        deps = [],
+        build_script_env = {},
+        data = [],
+        tools = [],
+        links = None,
+        rustc_env = {},
+        rustc_flags = [],
+        visibility = None,
+        tags = None,
+        **kwargs):
+    """Compile and execute a rust build script to generate build attributes
+
+    This rules take the same arguments as rust_binary.
+
+    Example:
+
+    Suppose you have a crate with a cargo build script `build.rs`:
+
+    ```output
+    [workspace]/
+        hello_lib/
+            BUILD
+            build.rs
+            src/
+                lib.rs
+    ```
+
+    Then you want to use the build script in the following:
+
+    `hello_lib/BUILD`:
+    ```python
+    package(default_visibility = ["//visibility:public"])
+
+    load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library")
+    load("@rules_rust//cargo:defs.bzl", "cargo_build_script")
+
+    # This will run the build script from the root of the workspace, and
+    # collect the outputs.
+    cargo_build_script(
+        name = "build_script",
+        srcs = ["build.rs"],
+        # Optional environment variables passed during build.rs compilation
+        rustc_env = {
+           "CARGO_PKG_VERSION": "0.1.2",
+        },
+        # Optional environment variables passed during build.rs execution.
+        # Note that as the build script's working directory is not execroot,
+        # execpath/location will return an absolute path, instead of a relative
+        # one.
+        build_script_env = {
+            "SOME_TOOL_OR_FILE": "$(execpath @tool//:binary)"
+        }
+        # Optional data/tool dependencies
+        data = ["@tool//:binary"],
+    )
+
+    rust_library(
+        name = "hello_lib",
+        srcs = [
+            "src/lib.rs",
+        ],
+        deps = [":build_script"],
+    )
+    ```
+
+    The `hello_lib` target will be build with the flags and the environment variables declared by the \
+    build script in addition to the file generated by it.
+
+    Args:
+        name (str): The name for the underlying rule. This should be the name of the package
+            being compiled, optionally with a suffix of `_build_script`.
+        crate_features (list, optional): A list of features to enable for the build script.
+        version (str, optional): The semantic version (semver) of the crate.
+        deps (list, optional): The dependencies of the crate.
+        build_script_env (dict, optional): Environment variables for build scripts.
+        data (list, optional): Files needed by the build script.
+        tools (list, optional): Tools (executables) needed by the build script.
+        links (str, optional): Name of the native library this crate links against.
+        rustc_env (dict, optional): Environment variables to set in rustc when compiling the build script.
+        rustc_flags (list, optional): List of compiler flags passed to `rustc`.
+        visibility (list of label, optional): Visibility to apply to the generated build script output.
+        tags: (list of str, optional): Tags to apply to the generated build script output.
+        **kwargs: Forwards to the underlying `rust_binary` rule.
+    """
+
+    # This duplicates the code in _cargo_build_script_impl because we need to make these
+    # available both when we invoke rustc (this code) and when we run the compiled build
+    # script (_cargo_build_script_impl). https://github.com/bazelbuild/rules_rust/issues/661
+    # will hopefully remove this duplication.
+    rustc_env = dict(rustc_env)
+    if "CARGO_PKG_NAME" not in rustc_env:
+        rustc_env["CARGO_PKG_NAME"] = name_to_pkg_name(name)
+    if "CARGO_CRATE_NAME" not in rustc_env:
+        rustc_env["CARGO_CRATE_NAME"] = name_to_crate_name(name_to_pkg_name(name))
+
+    binary_tags = [tag for tag in tags or []]
+    if "manual" not in binary_tags:
+        binary_tags.append("manual")
+
+    rust_binary(
+        name = name + "_",
+        crate_features = crate_features,
+        version = version,
+        deps = deps,
+        data = data,
+        rustc_env = rustc_env,
+        rustc_flags = rustc_flags,
+        tags = binary_tags,
+        **kwargs
+    )
+    _build_script_run(
+        name = name,
+        script = ":{}_".format(name),
+        crate_features = crate_features,
+        version = version,
+        build_script_env = build_script_env,
+        links = links,
+        deps = deps,
+        data = data,
+        tools = tools,
+        rustc_flags = rustc_flags,
+        visibility = visibility,
+        tags = tags,
+    )
diff --git a/docs/BUILD.bazel b/docs/BUILD.bazel
index ebca2dc..41fbf1f 100644
--- a/docs/BUILD.bazel
+++ b/docs/BUILD.bazel
@@ -40,6 +40,7 @@
         symbols = [
             "cargo_bootstrap_repository",
             "cargo_build_script",
+            "cargo_dep_env",
             "cargo_env",
         ],
     ),
diff --git a/docs/cargo.md b/docs/cargo.md
index 400fd7e..af56443 100644
--- a/docs/cargo.md
+++ b/docs/cargo.md
@@ -3,6 +3,7 @@
 
 * [cargo_bootstrap_repository](#cargo_bootstrap_repository)
 * [cargo_build_script](#cargo_build_script)
+* [cargo_dep_env](#cargo_dep_env)
 * [cargo_env](#cargo_env)
 
 <a id="cargo_bootstrap_repository"></a>
@@ -40,6 +41,26 @@
 | <a id="cargo_bootstrap_repository-version"></a>version |  The version of cargo the resolver should use   | String | optional | "1.64.0" |
 
 
+<a id="cargo_dep_env"></a>
+
+## cargo_dep_env
+
+<pre>
+cargo_dep_env(<a href="#cargo_dep_env-name">name</a>, <a href="#cargo_dep_env-out_dir">out_dir</a>, <a href="#cargo_dep_env-src">src</a>)
+</pre>
+
+A rule for generating variables for dependent `cargo_build_script`s without a build script. This is useful for using Bazel rules instead of a build script, while also generating configuration information for build scripts which depend on this crate.
+
+**ATTRIBUTES**
+
+
+| Name  | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| <a id="cargo_dep_env-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required |  |
+| <a id="cargo_dep_env-out_dir"></a>out_dir |  Folder containing additional inputs when building all direct dependencies.<br><br>This has the same effect as a <code>cargo_build_script</code> which prints puts files into <code>$OUT_DIR</code>, but without requiring a build script.   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="cargo_dep_env-src"></a>src |  File containing additional environment variables to set for build scripts of direct dependencies.<br><br>This has the same effect as a <code>cargo_build_script</code> which prints <code>cargo:VAR=VALUE</code> lines, but without requiring a build script.<br><br>This files should  contain a single variable per line, of format <code>NAME=value</code>, and newlines may be included in a value by ending a line with a trailing back-slash (<code>\\</code>).   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required |  |
+
+
 <a id="cargo_build_script"></a>
 
 ## cargo_build_script
@@ -73,7 +94,7 @@
 package(default_visibility = ["//visibility:public"])
 
 load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library")
-load("@rules_rust//cargo:cargo_build_script.bzl", "cargo_build_script")
+load("@rules_rust//cargo:defs.bzl", "cargo_build_script")
 
 # This will run the build script from the root of the workspace, and
 # collect the outputs.
@@ -112,7 +133,7 @@
 
 | Name  | Description | Default Value |
 | :------------- | :------------- | :------------- |
-| <a id="cargo_build_script-name"></a>name |  The name for the underlying rule. This should be the name of the package being compiled, optionally with a suffix of _build_script.   |  none |
+| <a id="cargo_build_script-name"></a>name |  The name for the underlying rule. This should be the name of the package being compiled, optionally with a suffix of <code>_build_script</code>.   |  none |
 | <a id="cargo_build_script-crate_features"></a>crate_features |  A list of features to enable for the build script.   |  <code>[]</code> |
 | <a id="cargo_build_script-version"></a>version |  The semantic version (semver) of the crate.   |  <code>None</code> |
 | <a id="cargo_build_script-deps"></a>deps |  The dependencies of the crate.   |  <code>[]</code> |
diff --git a/docs/flatten.md b/docs/flatten.md
index 2f34051..0051df3 100644
--- a/docs/flatten.md
+++ b/docs/flatten.md
@@ -6,6 +6,7 @@
 * [capture_clippy_output](#capture_clippy_output)
 * [cargo_bootstrap_repository](#cargo_bootstrap_repository)
 * [cargo_build_script](#cargo_build_script)
+* [cargo_dep_env](#cargo_dep_env)
 * [cargo_env](#cargo_env)
 * [error_format](#error_format)
 * [extra_rustc_flag](#extra_rustc_flag)
@@ -105,6 +106,26 @@
 | <a id="cargo_bootstrap_repository-version"></a>version |  The version of cargo the resolver should use   | String | optional | "1.64.0" |
 
 
+<a id="cargo_dep_env"></a>
+
+## cargo_dep_env
+
+<pre>
+cargo_dep_env(<a href="#cargo_dep_env-name">name</a>, <a href="#cargo_dep_env-out_dir">out_dir</a>, <a href="#cargo_dep_env-src">src</a>)
+</pre>
+
+A rule for generating variables for dependent `cargo_build_script`s without a build script. This is useful for using Bazel rules instead of a build script, while also generating configuration information for build scripts which depend on this crate.
+
+**ATTRIBUTES**
+
+
+| Name  | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| <a id="cargo_dep_env-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required |  |
+| <a id="cargo_dep_env-out_dir"></a>out_dir |  Folder containing additional inputs when building all direct dependencies.<br><br>This has the same effect as a <code>cargo_build_script</code> which prints puts files into <code>$OUT_DIR</code>, but without requiring a build script.   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="cargo_dep_env-src"></a>src |  File containing additional environment variables to set for build scripts of direct dependencies.<br><br>This has the same effect as a <code>cargo_build_script</code> which prints <code>cargo:VAR=VALUE</code> lines, but without requiring a build script.<br><br>This files should  contain a single variable per line, of format <code>NAME=value</code>, and newlines may be included in a value by ending a line with a trailing back-slash (<code>\\</code>).   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required |  |
+
+
 <a id="error_format"></a>
 
 ## error_format
@@ -1475,7 +1496,7 @@
 package(default_visibility = ["//visibility:public"])
 
 load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library")
-load("@rules_rust//cargo:cargo_build_script.bzl", "cargo_build_script")
+load("@rules_rust//cargo:defs.bzl", "cargo_build_script")
 
 # This will run the build script from the root of the workspace, and
 # collect the outputs.
@@ -1514,7 +1535,7 @@
 
 | Name  | Description | Default Value |
 | :------------- | :------------- | :------------- |
-| <a id="cargo_build_script-name"></a>name |  The name for the underlying rule. This should be the name of the package being compiled, optionally with a suffix of _build_script.   |  none |
+| <a id="cargo_build_script-name"></a>name |  The name for the underlying rule. This should be the name of the package being compiled, optionally with a suffix of <code>_build_script</code>.   |  none |
 | <a id="cargo_build_script-crate_features"></a>crate_features |  A list of features to enable for the build script.   |  <code>[]</code> |
 | <a id="cargo_build_script-version"></a>version |  The semantic version (semver) of the crate.   |  <code>None</code> |
 | <a id="cargo_build_script-deps"></a>deps |  The dependencies of the crate.   |  <code>[]</code> |
diff --git a/docs/symbols.bzl b/docs/symbols.bzl
index 42e2f20..8d68e9e 100644
--- a/docs/symbols.bzl
+++ b/docs/symbols.bzl
@@ -18,6 +18,7 @@
     "@rules_rust//cargo:defs.bzl",
     _cargo_bootstrap_repository = "cargo_bootstrap_repository",
     _cargo_build_script = "cargo_build_script",
+    _cargo_dep_env = "cargo_dep_env",
     _cargo_env = "cargo_env",
 )
 load(
@@ -130,8 +131,9 @@
 rust_stdlib_filegroup = _rust_stdlib_filegroup
 rust_proto_transitive_repositories = _rust_proto_transitive_repositories
 
-cargo_build_script = _cargo_build_script
 cargo_bootstrap_repository = _cargo_bootstrap_repository
+cargo_build_script = _cargo_build_script
+cargo_dep_env = _cargo_dep_env
 cargo_env = _cargo_env
 
 rust_wasm_bindgen = _rust_wasm_bindgen
diff --git a/examples/cargo/BUILD.bazel b/examples/cargo/BUILD.bazel
index 463841f..909416c 100644
--- a/examples/cargo/BUILD.bazel
+++ b/examples/cargo/BUILD.bazel
@@ -1,5 +1,5 @@
 load(
-    "@rules_rust//cargo:cargo_build_script.bzl",
+    "@rules_rust//cargo:defs.bzl",
     "cargo_build_script",
 )
 load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
diff --git a/examples/env_locations/BUILD.bazel b/examples/env_locations/BUILD.bazel
index 82161bb..7dd3a4a 100644
--- a/examples/env_locations/BUILD.bazel
+++ b/examples/env_locations/BUILD.bazel
@@ -1,4 +1,4 @@
-load("@rules_rust//cargo:cargo_build_script.bzl", "cargo_build_script")
+load("@rules_rust//cargo:defs.bzl", "cargo_build_script")
 load("@rules_rust//rust:defs.bzl", "rust_test")
 
 # generate a file
diff --git a/test/build_env/BUILD.bazel b/test/build_env/BUILD.bazel
index b4e1a92..43de1ff 100644
--- a/test/build_env/BUILD.bazel
+++ b/test/build_env/BUILD.bazel
@@ -1,5 +1,5 @@
 load(
-    "//cargo:cargo_build_script.bzl",
+    "//cargo:defs.bzl",
     "cargo_build_script",
 )
 load("//rust:defs.bzl", "rust_library", "rust_test")
diff --git a/test/cargo_build_script/BUILD.bazel b/test/cargo_build_script/BUILD.bazel
index 31bff6c..9923a2f 100644
--- a/test/cargo_build_script/BUILD.bazel
+++ b/test/cargo_build_script/BUILD.bazel
@@ -1,7 +1,7 @@
 """Tests for the cargo_build_script rule"""
 
 load("@bazel_skylib//rules:write_file.bzl", "write_file")
-load("//cargo:cargo_build_script.bzl", "cargo_build_script")
+load("//cargo:defs.bzl", "cargo_build_script")
 load("//rust:defs.bzl", "rust_test")
 
 # Test that tools are built in the exec configuration.
diff --git a/test/dep_env/BUILD.bazel b/test/dep_env/BUILD.bazel
index 0296917..4126125 100644
--- a/test/dep_env/BUILD.bazel
+++ b/test/dep_env/BUILD.bazel
@@ -1,6 +1,6 @@
 """Tests for passing configuration to cargo_build_script rules"""
 
-load("//cargo:cargo_build_script.bzl", "cargo_build_script", "cargo_dep_env")
+load("//cargo:defs.bzl", "cargo_build_script", "cargo_dep_env")
 load("//rust:defs.bzl", "rust_library", "rust_test")
 load(":dep_env.bzl", "create_dep_dir")
 
diff --git a/test/out_dir_in_tests/BUILD.bazel b/test/out_dir_in_tests/BUILD.bazel
index c3d8d99..0e063e2 100644
--- a/test/out_dir_in_tests/BUILD.bazel
+++ b/test/out_dir_in_tests/BUILD.bazel
@@ -1,4 +1,4 @@
-load("//cargo:cargo_build_script.bzl", "cargo_build_script")
+load("//cargo:defs.bzl", "cargo_build_script")
 load("//rust:defs.bzl", "rust_library", "rust_test", "rust_test_suite")
 
 cargo_build_script(
diff --git a/test/transitive_lib/BUILD.bazel b/test/transitive_lib/BUILD.bazel
index b745248..dc4dfe9 100644
--- a/test/transitive_lib/BUILD.bazel
+++ b/test/transitive_lib/BUILD.bazel
@@ -1,4 +1,4 @@
-load("//cargo:cargo_build_script.bzl", "cargo_build_script")
+load("//cargo:defs.bzl", "cargo_build_script")
 load("//rust:defs.bzl", "rust_binary", "rust_library")
 
 # sets link alias