Skip to content

Commit c1c865b

Browse files
krasimirggcopybara-github
authored andcommitted
cleanup: use Label() to construct the user-visible label
PiperOrigin-RevId: 782892594
1 parent 158312d commit c1c865b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

rust/defs.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ def _rust_proto_library_impl(ctx):
114114
# we have to create a shallow copy.
115115
toolchain = ctx.toolchains["@rules_rust//rust:toolchain_type"]
116116
fields = {field: getattr(crate_info, field) for field in dir(crate_info)}
117-
pkg, name = _user_visible_label(ctx).rsplit(":")
118117

119118
# Construct a label and compute the crate name.
120-
# Package and workspace root are only relevant when 1P crate renaming is enabled.
119+
# The label's package and workspace root are only relevant when 1P crate renaming is enabled.
121120
# The current implementation of crate renaming supports only monorepos which
122-
# means that it will only rename wen label.workspace_root is empty.
123-
label = struct(**{"name": name, "package": pkg, "workspace_root": ""})
121+
# means that it will only rename when label.workspace_root is empty.
122+
label_str = _user_visible_label(ctx)
123+
label = Label(label_str)
124124
fields["name"] = label_to_crate_name(ctx, label, toolchain)
125125

126126
# These two fields present on the dir(crate_info) but break on some versions of Bazel when

0 commit comments

Comments
 (0)