Support bzlmod (#1528)
This makes rules_rust load dependencies via bzlmod. Currently only basic functionality is completed, such as registering rustc toolchains and compiling crates. Note that it cannot interact with cargo, wasm or load any other rust toolchains such as rustfmt.
There is one new module, `examples/bzlmod/hello_world`, that depends on the root `rules_rust` module. This example can be built and run using:
```
cd examples/bzlmod/hello_world
bazel run //:hello_world
```
To register toolchains in an ergonomic way, it defines a new "hub" repository that contains all the toolchain proxies, so they can all be registered like so:
```
register_toolchains("@rust_toolchains//:all")
```
closes https://github.com/bazelbuild/rules_rust/issues/1493
diff --git a/rust/private/extensions.bzl b/rust/private/extensions.bzl
new file mode 100644
index 0000000..05f9076
--- /dev/null
+++ b/rust/private/extensions.bzl
@@ -0,0 +1,12 @@
+"""Bzlmod module extensions that are only used internally"""
+
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+load("//rust/private:repository_utils.bzl", "TINYJSON_KWARGS")
+
+def _internal_deps_impl(_module_ctx):
+ http_archive(**TINYJSON_KWARGS)
+
+internal_deps = module_extension(
+ doc = "Dependencies for rules_rust",
+ implementation = _internal_deps_impl,
+)