diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc index c64a42dc94..983ebef172 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc @@ -3961,7 +3961,8 @@ void FieldDescriptor::DebugString( // Label is omitted for maps, oneof, and plain proto3 fields. if (is_map() || real_containing_oneof() || - (!is_required() && !is_repeated() && !has_optional_keyword())) { + (!is_required() && !is_repeated() && !proto3_optional_ && + file()->edition() == Edition::EDITION_PROTO3)) { label.clear(); } // Label is omitted for optional and required fields under editions. @@ -4283,12 +4284,6 @@ bool FieldDescriptor::legacy_enum_field_treated_as_closed() const { enum_type()->is_closed()); } -bool FieldDescriptor::has_optional_keyword() const { - return proto3_optional_ || - (file()->edition() == Edition::EDITION_PROTO2 && !is_required() && - !is_repeated() && !containing_oneof()); -} - FieldDescriptor::CppStringType FieldDescriptor::CalculateCppStringType() const { ABSL_DCHECK(cpp_type() == FieldDescriptor::CPPTYPE_STRING); diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h index 6a361f6c4c..cac13c7d74 100644 --- a/src/google/protobuf/descriptor.h +++ b/src/google/protobuf/descriptor.h @@ -1137,11 +1137,6 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase, int legacy_proto_ctype() const { return legacy_proto_ctype_; } bool has_legacy_proto_ctype() const; - // Returns true if this field was syntactically written with "optional" in the - // .proto file. Excludes singular proto3 fields that do not have a label. - ABSL_DEPRECATED("Use has_presence() instead.") - bool has_optional_keyword() const; - // Get the merged features that apply to this field. These are specified in // the .proto file through the feature options in the message definition. // Allowed features are defined by Features in descriptor.proto, along with