Remove unnecessary `crate_name` usage in `rust_test_suite`. (#1345)

This usage of `crate_name` is not needed, and should be removed, so that the underlying `rust_test` targets participate in the same naming scheme as is used by normal invocations of `rust_test`.

Proof that `crate_name` is not needed here:
First, note that `name_to_crate_name` just replaces "/" and "-" characters in the provided string with underscores. So, we can immediately replace `name_to_crate_name(test_name.replace("/", "_"))` with just `name_to_crate_name(test_name)`. Next, we trace through the call to `rust_test`: since this target does not use the `crate` attribute, it will go through the call to `compute_crate_name(...)` on line 381. Assuming we have removed the `crate_name` attribute, that function will skip the first if statement on utils.bzl:303, and compute the crate name as usual: `crate_name = name_to_crate_name(label.name)`. Since the `rust_test` was created with `name = test_name,`, this means `compute_crate_name` will end up returning the same string that is currently assigned to the target's `crate_name` attribute, which makes the attribute unnecessary.

Co-authored-by: cfredric <cfredric@chromium.org>
1 file changed
tree: 342fdf77f096764386d4fc857dd88ae427293602
  1. .bazelci/
  2. .github/
  3. bindgen/
  4. cargo/
  5. crate_universe/
  6. distro/
  7. docs/
  8. examples/
  9. proto/
  10. rust/
  11. test/
  12. tools/
  13. util/
  14. wasm_bindgen/
  15. .bazelignore
  16. .bazelrc
  17. .gitignore
  18. ARCHITECTURE.md
  19. AUTHORS
  20. BUILD.bazel
  21. CODEOWNERS
  22. COMPATIBILITY.md
  23. CONTRIBUTING.md
  24. CONTRIBUTORS
  25. LICENSE.txt
  26. README.md
  27. version.bzl
  28. WORKSPACE.bazel
  29. workspace.bzl
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.