Updated repository rules to notify users about non-reproducible repos. (#2593)

This change updates rules_rust repository rules to report when the rules
are not guaranteed to be reproducible due to missing sha256 values when
fetching Rust artifacts. A common case for this is when users request
newer versions of Rust than the ones referenced in
[@rules_rust//rust:known_shas.bzl](https://github.com/bazelbuild/rules_rust/blob/0.41.0/rust/known_shas.bzl),
thus leading to unnecessary downloads or potential security issues.
After this PR, users will see warnings similar to when `integrity` is
omitted from `http_archive` definitions

```
DEBUG: Rule 'rust_analyzer_1.77.1_tools' indicated that a canonical reproducible form can be obtained by modifying arguments sha256s = {"rust-src-1.77.1.tar.xz": "ad2064aa4a444ae35d55b8b57bec837b90c4f10fe6d721f8fce86d7a1992f607", "rustc-1.77.1-aarch64-apple-darwin.tar.xz": "8da1814eb8358236e88ceb155e32f0f34bbe71cb19cd9700c7eb40e675738d77"}
DEBUG: Repository rust_analyzer_1.77.1_tools instantiated at:
  /Users/user/rules_rust/WORKSPACE.bazel:7:25: in <toplevel>
  /Users/user/rules_rust/rust/repositories.bzl:202:10: in rust_register_toolchains
  /private/var/tmp/_bazel_user/76282c66b0dfe3c5cb9a230bdc913a52/external/bazel_tools/tools/build_defs/repo/utils.bzl:240:18: in maybe
  /Users/user/rules_rust/rust/repositories.bzl:737:45: in rust_analyzer_toolchain_repository
Repository rule rust_analyzer_toolchain_tools_repository defined at:
  /Users/user/rules_rust/rust/repositories.bzl:705:59: in <toplevel>
DEBUG: Rule 'rust_darwin_aarch64__aarch64-apple-darwin__stable_tools' indicated that a canonical reproducible form can be obtained by modifying arguments sha256s = {"rustc-1.77.1-aarch64-apple-darwin.tar.xz": "8da1814eb8358236e88ceb155e32f0f34bbe71cb19cd9700c7eb40e675738d77", "clippy-1.77.1-aarch64-apple-darwin.tar.xz": "343f125b0c05dd756e71992c04fb5a4a29ce705c50a739d76eb7f38b088103ac", "cargo-1.77.1-aarch64-apple-darwin.tar.xz": "c0249b6c247953cbe3b01e276988b6ca600aeba4e91332cd2ddaa0b7eee4dfb7", "llvm-tools-1.77.1-aarch64-apple-darwin.tar.xz": "dfee0aaed6b24d34362f229f2926e6b1805f2a8ec4a090c7c28837b82a9bdfd1", "rust-std-1.77.1-aarch64-apple-darwin.tar.xz": "3b5b71e40d934de25dcb553b9df28289d38640e6fa2654b42410f4cc8d9bed2a"}
DEBUG: Repository rust_darwin_aarch64__aarch64-apple-darwin__stable_tools instantiated at:
  /Users/user/rules_rust/WORKSPACE.bazel:7:25: in <toplevel>
  /Users/user/rules_rust/rust/repositories.bzl:230:14: in rust_register_toolchains
  /private/var/tmp/_bazel_user/76282c66b0dfe3c5cb9a230bdc913a52/external/bazel_tools/tools/build_defs/repo/utils.bzl:240:18: in maybe
  /Users/user/rules_rust/rust/repositories.bzl:1043:61: in rust_repository_set
  /Users/user/rules_rust/rust/repositories.bzl:601:36: in rust_toolchain_repository
Repository rule rust_toolchain_tools_repository defined at:
  /Users/user/rules_rust/rust/repositories.bzl:475:50: in <toplevel>
```
The above was produced by running `bazel test //...` after applying the
following diff:
```diff
diff --git a/rust/private/common.bzl b/rust/private/common.bzl
index 52728fe7..c035ad5a 100644
--- a/rust/private/common.bzl
+++ b/rust/private/common.bzl
@@ -31,7 +31,7 @@ load(":providers.bzl", "CrateGroupInfo", "CrateInfo", "DepInfo", "DepVariantInfo
 #
 # Note: Code in `.github/workflows/crate_universe.yaml` looks for this line, if
 # you remove it or change its format, you will also need to update that code.
-DEFAULT_RUST_VERSION = "1.77.0"
+DEFAULT_RUST_VERSION = "1.77.1"

 DEFAULT_NIGHTLY_ISO_DATE = "2024-03-21"

```

closes https://github.com/bazelbuild/rules_rust/issues/1825
6 files changed
tree: 6cff3fbe4aa7dc4e2e873fea843a67e5b26e268a
  1. .bazelci/
  2. .bcr/
  3. .github/
  4. bindgen/
  5. cargo/
  6. crate_universe/
  7. docs/
  8. examples/
  9. ffi/
  10. nix/
  11. proto/
  12. rust/
  13. test/
  14. tools/
  15. util/
  16. wasm_bindgen/
  17. .bazelignore
  18. .bazelrc
  19. .clang-format
  20. .envrc
  21. .gitattributes
  22. .gitignore
  23. .prettierrc.toml
  24. .rustfmt.toml
  25. ARCHITECTURE.md
  26. AUTHORS
  27. BUILD.bazel
  28. CODEOWNERS
  29. COMPATIBILITY.md
  30. CONTRIBUTING.md
  31. CONTRIBUTORS
  32. LICENSE.txt
  33. MODULE.bazel
  34. README.md
  35. version.bzl
  36. WORKSPACE.bazel
README.md

Rust Rules

  • Postsubmit Build status

Overview

This repository provides rules for building Rust projects with Bazel.

Community

General discussions and announcements take place in the GitHub Discussions, but there are additional places where community members gather to discuss rules_rust.

Documentation

Please refer to the full documentation.