Commit d7490c8
Fix platform label context in rule transitions (#3997)
## Summary
Fix platform label resolution in rule transitions for `rust_binary`,
`rust_shared_library`, `rust_static_library`, and `rust_test`.
## Problem
When a platform label comes from the main repository (no repo name),
`str(label)` produces `//platforms:foo` instead of `@//platforms:foo`.
Bazel's `//command_line_option:platforms` setting requires the canonical
form with `@`, so the transition silently selects the wrong platform or
fails.
This affects anyone using the `platform` attribute on Rust rules with a
label defined in the main repository.
Note: as mentioned in
#3997 (comment),
this only affects builds that use
`--noincompatible_unambiguous_label_stringification`.
## Fix
Extract a `_resolve_platform` helper that adds the `@` prefix when
`attr.platform.repo_name` is empty, and apply it consistently to all
four rule transitions. The original patch only fixed `rust_binary`; this
PR fixes all four for completeness.
---
> **Note:** This PR was largely AI-generated using Claude Code, with
human review and guidance throughout.
---------
Co-authored-by: Tamas Vajk <tamas.vajk@databricks.com>
Co-authored-by: UebelAndre <github@uebelandre.com>1 parent 8e9f73f commit d7490c8
1 file changed
Lines changed: 24 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1006 | 1006 | | |
1007 | 1007 | | |
1008 | 1008 | | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
1009 | 1029 | | |
1010 | 1030 | | |
1011 | | - | |
| 1031 | + | |
1012 | 1032 | | |
1013 | 1033 | | |
1014 | 1034 | | |
| |||
1049 | 1069 | | |
1050 | 1070 | | |
1051 | 1071 | | |
1052 | | - | |
| 1072 | + | |
1053 | 1073 | | |
1054 | 1074 | | |
1055 | 1075 | | |
| |||
1171 | 1191 | | |
1172 | 1192 | | |
1173 | 1193 | | |
1174 | | - | |
| 1194 | + | |
1175 | 1195 | | |
1176 | 1196 | | |
1177 | 1197 | | |
| |||
1418 | 1438 | | |
1419 | 1439 | | |
1420 | 1440 | | |
1421 | | - | |
| 1441 | + | |
1422 | 1442 | | |
1423 | 1443 | | |
1424 | 1444 | | |
| |||
0 commit comments