Skip generating oneof message fields referencing other crates

PiperOrigin-RevId: 597617683
pull/15389/head
Alyssa Haroldsen 11 months ago committed by Copybara-Service
parent 406fa60c9e
commit 7374e26fec
  1. 8
      src/google/protobuf/compiler/rust/oneof.cc

@ -99,6 +99,10 @@ std::string RsTypeNameView(Context& ctx, const FieldDescriptor& field) {
case FieldDescriptor::TYPE_STRING:
return "&'msg ::__pb::ProtoStr";
case FieldDescriptor::TYPE_MESSAGE:
// TODO: support messages which are defined in other crates.
if (!IsInCurrentlyGeneratingCrate(ctx, *field.message_type())) {
return "";
}
return absl::StrCat("::__pb::View<'msg, ", RsTypePath(ctx, field), ">");
case FieldDescriptor::TYPE_ENUM: // TODO: b/300257770 - Support enums.
case FieldDescriptor::TYPE_GROUP: // Not supported yet.
@ -135,6 +139,10 @@ std::string RsTypeNameMut(Context& ctx, const FieldDescriptor& field) {
case FieldDescriptor::TYPE_STRING:
return "::__pb::ProtoStrMut<'msg>";
case FieldDescriptor::TYPE_MESSAGE:
// TODO: support messages which are defined in other crates.
if (!IsInCurrentlyGeneratingCrate(ctx, *field.message_type())) {
return "";
}
return absl::StrCat("::__pb::Mut<'msg, ", RsTypePath(ctx, field), ">");
case FieldDescriptor::TYPE_ENUM: // TODO: b/300257770 - Support enums.
case FieldDescriptor::TYPE_GROUP: // Not supported yet.

Loading…
Cancel
Save