commit | 421d30e4ff5788c32f9e144f2ed8e6771c2a8809 | [log] [tgz] |
---|---|---|
author | Chris Fredrickson <cfredric@users.noreply.github.com> | Fri May 20 05:11:44 2022 -0400 |
committer | GitHub <noreply@github.com> | Fri May 20 11:11:44 2022 +0200 |
tree | 342fdf77f096764386d4fc857dd88ae427293602 | |
parent | 10185339ddd5db93a7ca4b10e2255e97c81f99cb [diff] |
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>
This repository provides rules for building Rust projects with Bazel.
General discussions and announcements take place in the GitHub Discussions, but there are additional places where community members gather to discuss rules_rust
.
Please refer to the full documentation.