From eeb7dc88f286df558d933214fff829205ffa5506 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Mon, 30 Sep 2024 11:15:40 -0700 Subject: [PATCH] 'Temporary' fix to avoid breakage from to_json and to_proto on crate_info() on some bazel versions. PiperOrigin-RevId: 680648840 --- rust/defs.bzl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/rust/defs.bzl b/rust/defs.bzl index 6e9117e349..14d7e70278 100644 --- a/rust/defs.bzl +++ b/rust/defs.bzl @@ -1,7 +1,4 @@ -"""This file implements an experimental, do-not-use-kind of rust_proto_library. - -Disclaimer: This project is experimental, under heavy development, and should not -be used yet.""" +"""This file implements rust_proto_library.""" load("@rules_rust//rust:defs.bzl", "rust_common") load("//bazel/common:proto_common.bzl", "proto_common") @@ -20,7 +17,6 @@ def rust_proto_library(name, deps, **args): Hopefully no user will ever need to read this code. - Args: name: name of the Rust protobuf target. deps: proto_library target for which to generate Rust gencode. @@ -102,6 +98,12 @@ def _rust_proto_library_impl(ctx): pkg, name = _user_visible_label(ctx).rsplit(":") label = struct(**{"name": name, "pkg": pkg}) fields["name"] = label_to_crate_name(ctx, label, toolchain) + + # These two fields present on the dir(crate_info) but break on some versions of Bazel when + # passed back in to crate_info. Strip them for now. + fields.pop("to_json") + fields.pop("to_proto") + crate_info_with_rust_proto_name = rust_common.crate_info(**fields) return [