From 6098c0227dc8b4416a9125875aecaa5bf197e3c1 Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Thu, 13 Jul 2023 18:02:26 -0700 Subject: [PATCH] Remove PROTOBUF_FUTURE_EDITIONS guards. This is just cruft used for selectively rolling out the editions changes. Since it's not tested, it would be dangerous to keep it in place. PiperOrigin-RevId: 547979600 --- src/google/protobuf/compiler/code_generator.h | 3 - .../compiler/command_line_interface.cc | 8 - .../compiler/command_line_interface.h | 2 - .../command_line_interface_unittest.cc | 4 - src/google/protobuf/compiler/cpp/generator.cc | 6 +- .../compiler/cpp/generator_unittest.cc | 6 - src/google/protobuf/compiler/cpp/helpers.cc | 2 - .../protobuf/compiler/objectivec/file.cc | 2 - src/google/protobuf/compiler/parser.cc | 14 -- src/google/protobuf/compiler/parser.h | 4 - .../protobuf/compiler/parser_unittest.cc | 2 - src/google/protobuf/descriptor.cc | 183 +----------------- src/google/protobuf/descriptor.h | 82 +------- src/google/protobuf/descriptor_legacy.h | 2 - src/google/protobuf/descriptor_unittest.cc | 33 ++-- src/google/protobuf/extension_set.h | 6 - src/google/protobuf/port_def.inc | 4 - 17 files changed, 25 insertions(+), 338 deletions(-) diff --git a/src/google/protobuf/compiler/code_generator.h b/src/google/protobuf/compiler/code_generator.h index 6350ed12c7..ded1872940 100644 --- a/src/google/protobuf/compiler/code_generator.h +++ b/src/google/protobuf/compiler/code_generator.h @@ -130,8 +130,6 @@ class PROTOC_EXPORT CodeGenerator { // method can be removed. virtual bool HasGenerateAll() const { return true; } -#ifdef PROTOBUF_FUTURE_EDITIONS - protected: // Retrieves the resolved source features for a given descriptor. These // should be used to make any feature-based decisions during code generation. @@ -157,7 +155,6 @@ class PROTOC_EXPORT CodeGenerator { StripSourceRetentionOptions(*file.pool(), proto); return proto; } -#endif // PROTOBUF_FUTURE_EDITIONS }; // CodeGenerators generate one or more files in a given directory. This diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index f9e966649d..174d721fb0 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -1554,7 +1554,6 @@ bool CommandLineInterface::ParseInputFiles( } parsed_files->push_back(parsed_file); -#ifdef PROTOBUF_FUTURE_EDITIONS if (!experimental_editions_ && !IsEarlyEditionsFile(parsed_file->name())) { if (FileDescriptorLegacy(parsed_file).syntax() == FileDescriptorLegacy::Syntax::SYNTAX_EDITIONS) { @@ -1568,7 +1567,6 @@ bool CommandLineInterface::ParseInputFiles( break; } } -#endif // PROTOBUF_FUTURE_EDITIONS // Enforce --disallow_services. if (disallow_services_ && parsed_file->service_count() > 0) { @@ -1619,9 +1617,7 @@ void CommandLineInterface::Clear() { descriptor_set_out_name_.clear(); dependency_out_name_.clear(); -#ifdef PROTOBUF_FUTURE_EDITIONS experimental_editions_ = false; -#endif // PROTOBUF_FUTURE_EDITIONS mode_ = MODE_COMPILE; print_mode_ = PRINT_NONE; @@ -1940,9 +1936,7 @@ bool CommandLineInterface::ParseArgument(const char* arg, std::string* name, *name == "--include_imports" || *name == "--include_source_info" || *name == "--retain_options" || *name == "--version" || *name == "--decode_raw" || -#ifdef PROTOBUF_FUTURE_EDITIONS *name == "--experimental_editions" || -#endif // PROTOBUF_FUTURE_EDITIONS *name == "--print_free_field_numbers" || *name == "--experimental_allow_proto3_optional" || *name == "--deterministic_output" || *name == "--fatal_warnings") { @@ -2269,14 +2263,12 @@ CommandLineInterface::InterpretArgument(const std::string& name, #else ::setenv(io::Printer::kProtocCodegenTrace.data(), "yes", 0); #endif -#ifdef PROTOBUF_FUTURE_EDITIONS } else if (name == "--experimental_editions") { // If you're reading this, you're probably wondering what // --experimental_editions is for and thinking of turning it on. This is an // experimental, undocumented, unsupported flag. Enable it at your own risk // (or, just don't!). experimental_editions_ = true; -#endif // PROTOBUF_FUTURE_EDITIONS } else { // Some other flag. Look it up in the generators list. const GeneratorInfo* generator_info = FindGeneratorByFlag(name); diff --git a/src/google/protobuf/compiler/command_line_interface.h b/src/google/protobuf/compiler/command_line_interface.h index c0a606d7c8..dbfb22ef0f 100644 --- a/src/google/protobuf/compiler/command_line_interface.h +++ b/src/google/protobuf/compiler/command_line_interface.h @@ -450,9 +450,7 @@ class PROTOC_EXPORT CommandLineInterface { // dependency file will be written. Otherwise, empty. std::string dependency_out_name_; -#ifdef PROTOBUF_FUTURE_EDITIONS bool experimental_editions_ = false; -#endif // PROTOBUF_FUTURE_EDITIONS // True if --include_imports was given, meaning that we should // write all transitive dependencies to the DescriptorSet. Otherwise, only diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index 4fe1211b7c..ad2fb0cc12 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc @@ -1346,8 +1346,6 @@ TEST_F(CommandLineInterfaceTest, AllowServicesHasService) { ExpectGenerated("test_generator", "", "foo.proto", "Foo"); } -#ifdef PROTOBUF_FUTURE_EDITIONS - TEST_F(CommandLineInterfaceTest, EditionsAreNotAllowed) { CreateTempFile("foo.proto", "edition = \"very-cool\";\n" @@ -1678,8 +1676,6 @@ TEST_F(CommandLineInterfaceTest, PluginNoEditionsSupport) { "code generator prefix-gen-plug hasn't been updated to support editions"); } -#endif // PROTOBUF_FUTURE_EDITIONS - TEST_F(CommandLineInterfaceTest, DirectDependencies_Missing_EmptyList) { CreateTempFile("foo.proto", diff --git a/src/google/protobuf/compiler/cpp/generator.cc b/src/google/protobuf/compiler/cpp/generator.cc index 73224ac0fd..5fdb9b15f6 100644 --- a/src/google/protobuf/compiler/cpp/generator.cc +++ b/src/google/protobuf/compiler/cpp/generator.cc @@ -46,12 +46,10 @@ #include "absl/strings/string_view.h" #include "google/protobuf/compiler/cpp/file.h" #include "google/protobuf/compiler/cpp/helpers.h" +#include "google/protobuf/cpp_features.pb.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/descriptor_visitor.h" -#ifdef PROTOBUF_FUTURE_EDITIONS -#include "google/protobuf/cpp_features.pb.h" -#endif // PROTOBUF_FUTURE_EDITIONS namespace google { namespace protobuf { @@ -367,7 +365,6 @@ bool CppGenerator::Generate(const FileDescriptor* file, absl::Status CppGenerator::ValidateFeatures(const FileDescriptor* file) const { absl::Status status = absl::OkStatus(); -#ifdef PROTOBUF_FUTURE_EDITIONS google::protobuf::internal::VisitDescriptors(*file, [&](const FieldDescriptor& field) { const FeatureSet& source_features = GetSourceFeatures(field); const FeatureSet& raw_features = GetSourceRawFeatures(field); @@ -385,7 +382,6 @@ absl::Status CppGenerator::ValidateFeatures(const FileDescriptor* file) const { " has a closed enum type with implicit presence.")); } }); -#endif // PROTOBUF_FUTURE_EDITIONS return status; } diff --git a/src/google/protobuf/compiler/cpp/generator_unittest.cc b/src/google/protobuf/compiler/cpp/generator_unittest.cc index 64efaea4db..0eabb094ce 100644 --- a/src/google/protobuf/compiler/cpp/generator_unittest.cc +++ b/src/google/protobuf/compiler/cpp/generator_unittest.cc @@ -35,9 +35,7 @@ #include "google/protobuf/descriptor.pb.h" #include #include "google/protobuf/compiler/command_line_interface_tester.h" -#ifdef PROTOBUF_FUTURE_EDITIONS #include "google/protobuf/cpp_features.pb.h" -#endif // PROTOBUF_FUTURE_EDITIONS namespace google { namespace protobuf { @@ -55,10 +53,8 @@ class CppGeneratorTest : public CommandLineInterfaceTester { CreateTempFile( "google/protobuf/descriptor.proto", google::protobuf::DescriptorProto::descriptor()->file()->DebugString()); -#ifdef PROTOBUF_FUTURE_EDITIONS CreateTempFile("google/protobuf/cpp_features.proto", pb::CppFeatures::descriptor()->file()->DebugString()); -#endif // PROTOBUF_FUTURE_EDITIONS } }; @@ -91,7 +87,6 @@ TEST_F(CppGeneratorTest, BasicError) { "foo.proto:4:7: Expected \"required\", \"optional\", or \"repeated\""); } -#ifdef PROTOBUF_FUTURE_EDITIONS TEST_F(CppGeneratorTest, LegacyClosedEnumOnNonEnumField) { CreateTempFile("foo.proto", @@ -176,7 +171,6 @@ TEST_F(CppGeneratorTest, LegacyClosedEnumImplicit) { ExpectErrorSubstring( "Field Foo.bar has a closed enum type with implicit presence."); } -#endif // PROTOBUF_FUTURE_EDITIONS } // namespace } // namespace cpp diff --git a/src/google/protobuf/compiler/cpp/helpers.cc b/src/google/protobuf/compiler/cpp/helpers.cc index 2b689b7d06..5cab1df912 100644 --- a/src/google/protobuf/compiler/cpp/helpers.cc +++ b/src/google/protobuf/compiler/cpp/helpers.cc @@ -1418,10 +1418,8 @@ bool GetBootstrapBasename(const Options& options, absl::string_view basename, new absl::flat_hash_map{ {"net/proto2/proto/descriptor", "third_party/protobuf/descriptor"}, -#ifdef PROTOBUF_FUTURE_EDITIONS {"third_party/protobuf/cpp_features", "third_party/protobuf/cpp_features"}, -#endif // PROTOBUF_FUTURE_EDITIONS {"third_party/protobuf/compiler/plugin", "third_party/protobuf/compiler/plugin"}, {"net/proto2/compiler/proto/profile", diff --git a/src/google/protobuf/compiler/objectivec/file.cc b/src/google/protobuf/compiler/objectivec/file.cc index e0b76069e2..28ef59445f 100644 --- a/src/google/protobuf/compiler/objectivec/file.cc +++ b/src/google/protobuf/compiler/objectivec/file.cc @@ -700,11 +700,9 @@ void FileGenerator::EmitFileDescription(io::Printer* p) const { case FileDescriptorLegacy::Syntax::SYNTAX_PROTO3: syntax = "GPBFileSyntaxProto3"; break; -#ifdef PROTOBUF_FUTURE_EDITIONS case FileDescriptorLegacy::Syntax::SYNTAX_EDITIONS: syntax = "GPBFileSyntaxProtoEditions"; break; -#endif // PROTOBUF_FUTURE_EDITIONS } p->Emit({{"file_description_name", file_description_name_}, diff --git a/src/google/protobuf/compiler/parser.cc b/src/google/protobuf/compiler/parser.cc index d0231a8da8..5d45741c67 100644 --- a/src/google/protobuf/compiler/parser.cc +++ b/src/google/protobuf/compiler/parser.cc @@ -662,9 +662,7 @@ bool Parser::Parse(io::Tokenizer* input, FileDescriptorProto* file) { DescriptorPool::ErrorCollector::OTHER); if (require_syntax_identifier_ || LookingAt("syntax") -#ifdef PROTOBUF_FUTURE_EDITIONS || LookingAt("edition") -#endif // PROTOBUF_FUTURE_EDITIONS ) { if (!ParseSyntaxIdentifier(file, root_location)) { // Don't attempt to parse the file if we didn't recognize the syntax @@ -674,11 +672,9 @@ bool Parser::Parse(io::Tokenizer* input, FileDescriptorProto* file) { // Store the syntax into the file. if (file != nullptr) { file->set_syntax(syntax_identifier_); -#ifdef PROTOBUF_FUTURE_EDITIONS if (syntax_identifier_ == "editions") { file->set_edition(edition_); } -#endif // PROTOBUF_FUTURE_EDITIONS } } else if (!stop_after_syntax_identifier_) { ABSL_LOG(WARNING) << "No syntax specified for the proto file: " @@ -718,20 +714,16 @@ bool Parser::ParseSyntaxIdentifier(const FileDescriptorProto* file, const LocationRecorder& parent) { LocationRecorder syntax_location(parent, FileDescriptorProto::kSyntaxFieldNumber); -#ifdef PROTOBUF_FUTURE_EDITIONS syntax_location.RecordLegacyLocation( file, DescriptorPool::ErrorCollector::EDITIONS); bool has_edition = false; if (TryConsume("edition")) { has_edition = true; } else { -#endif // PROTOBUF_FUTURE_EDITIONS DO(Consume("syntax", "File must begin with a syntax statement, e.g. 'syntax = " "\"proto2\";'.")); -#ifdef PROTOBUF_FUTURE_EDITIONS } -#endif // PROTOBUF_FUTURE_EDITIONS DO(Consume("=")); io::Tokenizer::Token syntax_token = input_->current(); @@ -739,7 +731,6 @@ bool Parser::ParseSyntaxIdentifier(const FileDescriptorProto* file, DO(ConsumeString(&syntax, "Expected syntax identifier.")); DO(ConsumeEndOfDeclaration(";", &syntax_location)); -#ifdef PROTOBUF_FUTURE_EDITIONS (has_edition ? edition_ : syntax_identifier_) = syntax; if (has_edition) { if (syntax.empty()) { @@ -751,7 +742,6 @@ bool Parser::ParseSyntaxIdentifier(const FileDescriptorProto* file, syntax_identifier_ = "editions"; return true; } -#endif // PROTOBUF_FUTURE_EDITIONS syntax_identifier_ = syntax; if (syntax != "proto2" && syntax != "proto3" && !stop_after_syntax_identifier_) { @@ -2343,7 +2333,6 @@ bool Parser::ParseLabel(FieldDescriptorProto::Label* label, !LookingAt("required")) { return false; } -#ifdef PROTOBUF_FUTURE_EDITIONS if (LookingAt("optional") && syntax_identifier_ == "editions") { RecordError( "Label \"optional\" is not supported in editions. By default, all " @@ -2354,7 +2343,6 @@ bool Parser::ParseLabel(FieldDescriptorProto::Label* label, "Label \"required\" is not supported in editions, use " "features.field_presence = LEGACY_REQUIRED."); } -#endif // PROTOBUF_FUTURE_EDITIONS LocationRecorder location(field_location, FieldDescriptorProto::kLabelFieldNumber); @@ -2374,7 +2362,6 @@ bool Parser::ParseType(FieldDescriptorProto::Type* type, const auto& type_names_table = GetTypeNameTable(); auto iter = type_names_table.find(input_->current().text); if (iter != type_names_table.end()) { -#ifdef PROTOBUF_FUTURE_EDITIONS if (syntax_identifier_ == "editions" && iter->second == FieldDescriptorProto::TYPE_GROUP) { RecordError( @@ -2382,7 +2369,6 @@ bool Parser::ParseType(FieldDescriptorProto::Type* type, "behavior you can specify features.message_encoding = DELIMITED on a " "message field."); } -#endif // PROTOBUF_FUTURE_EDITIONS *type = iter->second; input_->Next(); } else { diff --git a/src/google/protobuf/compiler/parser.h b/src/google/protobuf/compiler/parser.h index 8f8866267f..e68db1b9ea 100644 --- a/src/google/protobuf/compiler/parser.h +++ b/src/google/protobuf/compiler/parser.h @@ -530,9 +530,7 @@ class PROTOBUF_EXPORT Parser { // Whether fields without label default to optional fields. bool DefaultToOptionalFields() const { -#ifdef PROTOBUF_FUTURE_EDITIONS if (syntax_identifier_ == "editions") return true; -#endif // PROTOBUF_FUTURE_EDITIONS return syntax_identifier_ == "proto3"; } @@ -548,9 +546,7 @@ class PROTOBUF_EXPORT Parser { bool require_syntax_identifier_; bool stop_after_syntax_identifier_; std::string syntax_identifier_; -#ifdef PROTOBUF_FUTURE_EDITIONS std::string edition_; -#endif // PROTOBUF_FUTURE_EDITIONS // Leading doc comments for the next declaration. These are not complete // yet; use ConsumeEndOfDeclaration() to get the complete comments. diff --git a/src/google/protobuf/compiler/parser_unittest.cc b/src/google/protobuf/compiler/parser_unittest.cc index 0bf2dceb62..3c16aad4c8 100644 --- a/src/google/protobuf/compiler/parser_unittest.cc +++ b/src/google/protobuf/compiler/parser_unittest.cc @@ -3914,7 +3914,6 @@ TEST_F(SourceInfoTest, DocCommentsOneof) { // =================================================================== -#ifdef PROTOBUF_FUTURE_EDITIONS typedef ParserTest ParseEditionsTest; TEST_F(ParseEditionsTest, Editions) { @@ -4143,7 +4142,6 @@ TEST_F(ParseEditionsTest, FeaturesWithoutEditions) { "4:17: Features are only valid under editions.\n"); } -#endif // PROTOBUF_FUTURE_EDITIONS } // anonymous namespace diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc index fd5c0ba82f..91f093158a 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc @@ -71,15 +71,13 @@ #include "absl/synchronization/mutex.h" #include "absl/types/optional.h" #include "google/protobuf/any.h" +#include "google/protobuf/cpp_features.pb.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/descriptor_database.h" #include "google/protobuf/descriptor_legacy.h" #include "google/protobuf/descriptor_visitor.h" #include "google/protobuf/dynamic_message.h" -#ifdef PROTOBUF_FUTURE_EDITIONS -#include "google/protobuf/cpp_features.pb.h" #include "google/protobuf/feature_resolver.h" -#endif // PROTOBUF_FUTURE_EDITIONS #include "google/protobuf/generated_message_util.h" #include "google/protobuf/io/strtod.h" #include "google/protobuf/io/tokenizer.h" @@ -838,10 +836,8 @@ const char* FileDescriptor::SyntaxName(FileDescriptor::Syntax syntax) { return "proto2"; case SYNTAX_PROTO3: return "proto3"; -#ifdef PROTOBUF_FUTURE_EDITIONS case SYNTAX_EDITIONS: return "editions"; -#endif // !PROTOBUF_FUTURE_EDITIONS case SYNTAX_UNKNOWN: return "unknown"; } @@ -1114,8 +1110,6 @@ bool AllowedExtendeeInProto3(const std::string& name) { allowed_proto3_extendees->end(); } -#ifdef PROTOBUF_FUTURE_EDITIONS - // Create global defaults for proto2/proto3 compatibility. FeatureSet* CreateProto2DefaultFeatures() { FeatureSet* features = new FeatureSet(); @@ -1247,7 +1241,6 @@ const FeatureSet& GetParentFeatures(const ServiceDescriptor* service) { const FeatureSet& GetParentFeatures(const MethodDescriptor* method) { return internal::InternalFeatureHelper::GetFeatures(*method->service()); } -#endif // PROTOBUF_FUTURE_EDITIONS } // anonymous namespace // Contains tables specific to a particular file. These tables are not @@ -1363,15 +1356,11 @@ namespace internal { class FlatAllocator : public decltype(ApplyTypeList( SortByAlignment())) { -}; + ServiceOptions, MethodOptions, FileOptions>())) {}; } // namespace internal @@ -2009,10 +1998,8 @@ absl::string_view DescriptorPool::ErrorCollector::ErrorLocationName( return "OUTPUT_TYPE"; case IMPORT: return "IMPORT"; -#ifdef PROTOBUF_FUTURE_EDITIONS case EDITIONS: return "EDITIONS"; -#endif // PROTOBUF_FUTURE_EDITIONS case OTHER: return "OTHER"; } @@ -2125,9 +2112,7 @@ const DescriptorPool* DescriptorPool::generated_pool() { // ensure that the linker --gc-sections step can strip out the full runtime if // it is unused. DescriptorProto::descriptor(); -#ifdef PROTOBUF_FUTURE_EDITIONS pb::CppFeatures::descriptor(); -#endif // PROTOBUF_FUTURE_EDITIONS return pool; } @@ -2544,9 +2529,7 @@ void Descriptor::ExtensionRange::CopyTo( if (options_ != &ExtensionRangeOptions::default_instance()) { *proto->mutable_options() = *options_; } -#ifdef PROTOBUF_FUTURE_EDITIONS RestoreFeaturesToOptions(proto_features_, proto); -#endif // PROTOBUF_FUTURE_EDITIONS } const Descriptor::ExtensionRange* @@ -2759,7 +2742,6 @@ FileDescriptor::FileDescriptor() {} // CopyTo methods ==================================================== -#ifdef PROTOBUF_FUTURE_EDITIONS namespace internal { FileDescriptorProto InternalFeatureHelper::GetGeneratorProto( const FileDescriptor& file) { @@ -2780,7 +2762,6 @@ FileDescriptorProto InternalFeatureHelper::GetGeneratorProto( return file_proto; } } // namespace internal -#endif // PROTOBUF_FUTURE_EDITIONS void FileDescriptor::CopyTo(FileDescriptorProto* proto) const { CopyHeadingTo(proto); @@ -2819,25 +2800,18 @@ void FileDescriptor::CopyHeadingTo(FileDescriptorProto* proto) const { // TODO(liujisi): Also populate when syntax="proto2". FileDescriptorLegacy::Syntax syntax = FileDescriptorLegacy(this).syntax(); - if (syntax == FileDescriptorLegacy::Syntax::SYNTAX_PROTO3 -#ifdef PROTOBUF_FUTURE_EDITIONS - || syntax == FileDescriptorLegacy::Syntax::SYNTAX_EDITIONS -#endif // !PROTOBUF_FUTURE_EDITIONS - ) { + if (syntax == FileDescriptorLegacy::Syntax::SYNTAX_PROTO3 || + syntax == FileDescriptorLegacy::Syntax::SYNTAX_EDITIONS) { proto->set_syntax(FileDescriptorLegacy::SyntaxName(syntax)); } -#ifdef PROTOBUF_FUTURE_EDITIONS if (syntax == FileDescriptorLegacy::Syntax::SYNTAX_EDITIONS) { proto->set_edition(edition()); } -#endif // !PROTOBUF_FUTURE_EDITIONS if (&options() != &FileOptions::default_instance()) { *proto->mutable_options() = options(); } -#ifdef PROTOBUF_FUTURE_EDITIONS RestoreFeaturesToOptions(proto_features_, proto); -#endif // PROTOBUF_FUTURE_EDITIONS } void FileDescriptor::CopyJsonNameTo(FileDescriptorProto* proto) const { @@ -2895,9 +2869,7 @@ void Descriptor::CopyTo(DescriptorProto* proto) const { proto->mutable_options()->CopyFrom(options()); } -#ifdef PROTOBUF_FUTURE_EDITIONS RestoreFeaturesToOptions(proto_features_, proto); -#endif // PROTOBUF_FUTURE_EDITIONS } void Descriptor::CopyJsonNameTo(DescriptorProto* proto) const { @@ -2929,7 +2901,6 @@ void FieldDescriptor::CopyTo(FieldDescriptorProto* proto) const { } // Some compilers do not allow static_cast directly between two enum types, // so we must cast to int first. -#ifdef PROTOBUF_FUTURE_EDITIONS if (is_required() && FileDescriptorLegacy(file()).syntax() == FileDescriptorLegacy::Syntax::SYNTAX_EDITIONS) { // Editions files have no required keyword, and we only set this label @@ -2951,12 +2922,6 @@ void FieldDescriptor::CopyTo(FieldDescriptorProto* proto) const { proto->set_type(static_cast( absl::implicit_cast(type()))); } -#else // PROTOBUF_FUTURE_EDITIONS - proto->set_label(static_cast( - absl::implicit_cast(label()))); - proto->set_type(static_cast( - absl::implicit_cast(type()))); -#endif // PROTOBUF_FUTURE_EDITIONS if (is_extension()) { if (!containing_type()->is_unqualified_placeholder_) { @@ -2995,9 +2960,7 @@ void FieldDescriptor::CopyTo(FieldDescriptorProto* proto) const { proto->mutable_options()->CopyFrom(options()); } -#ifdef PROTOBUF_FUTURE_EDITIONS RestoreFeaturesToOptions(proto_features_, proto); -#endif // PROTOBUF_FUTURE_EDITIONS } void FieldDescriptor::CopyJsonNameTo(FieldDescriptorProto* proto) const { @@ -3009,9 +2972,7 @@ void OneofDescriptor::CopyTo(OneofDescriptorProto* proto) const { if (&options() != &OneofOptions::default_instance()) { proto->mutable_options()->CopyFrom(options()); } -#ifdef PROTOBUF_FUTURE_EDITIONS RestoreFeaturesToOptions(proto_features_, proto); -#endif // PROTOBUF_FUTURE_EDITIONS } void EnumDescriptor::CopyTo(EnumDescriptorProto* proto) const { @@ -3032,9 +2993,7 @@ void EnumDescriptor::CopyTo(EnumDescriptorProto* proto) const { if (&options() != &EnumOptions::default_instance()) { proto->mutable_options()->CopyFrom(options()); } -#ifdef PROTOBUF_FUTURE_EDITIONS RestoreFeaturesToOptions(proto_features_, proto); -#endif // PROTOBUF_FUTURE_EDITIONS } void EnumValueDescriptor::CopyTo(EnumValueDescriptorProto* proto) const { @@ -3044,9 +3003,7 @@ void EnumValueDescriptor::CopyTo(EnumValueDescriptorProto* proto) const { if (&options() != &EnumValueOptions::default_instance()) { proto->mutable_options()->CopyFrom(options()); } -#ifdef PROTOBUF_FUTURE_EDITIONS RestoreFeaturesToOptions(proto_features_, proto); -#endif // PROTOBUF_FUTURE_EDITIONS } void ServiceDescriptor::CopyTo(ServiceDescriptorProto* proto) const { @@ -3059,9 +3016,7 @@ void ServiceDescriptor::CopyTo(ServiceDescriptorProto* proto) const { if (&options() != &ServiceOptions::default_instance()) { proto->mutable_options()->CopyFrom(options()); } -#ifdef PROTOBUF_FUTURE_EDITIONS RestoreFeaturesToOptions(proto_features_, proto); -#endif // PROTOBUF_FUTURE_EDITIONS } void MethodDescriptor::CopyTo(MethodDescriptorProto* proto) const { @@ -3087,9 +3042,7 @@ void MethodDescriptor::CopyTo(MethodDescriptorProto* proto) const { if (server_streaming_) { proto->set_server_streaming(true); } -#ifdef PROTOBUF_FUTURE_EDITIONS RestoreFeaturesToOptions(proto_features_, proto); -#endif // PROTOBUF_FUTURE_EDITIONS } // DebugString methods =============================================== @@ -3097,23 +3050,19 @@ void MethodDescriptor::CopyTo(MethodDescriptorProto* proto) const { namespace { bool IsGroupSyntax(const FieldDescriptor* desc) { -#ifdef PROTOBUF_FUTURE_EDITIONS if (FileDescriptorLegacy(desc->file()).syntax() == FileDescriptorLegacy::SYNTAX_EDITIONS) { return false; } -#endif // PROTOBUF_FUTURE_EDITIONS return desc->type() == FieldDescriptor::TYPE_GROUP; } -#ifdef PROTOBUF_FUTURE_EDITIONS template void CopyFeaturesToOptions(const FeatureSet* features, OptionsT* options) { if (features != &FeatureSet::default_instance()) { *options->mutable_features() = *features; } } -#endif // PROTOBUF_FUTURE_EDITIONS bool RetrieveOptionsAssumingRightPool( int depth, const Message& options, @@ -3295,12 +3244,10 @@ std::string FileDescriptor::DebugStringWithOptions( SourceLocationCommentPrinter syntax_comment(this, path, "", debug_string_options); syntax_comment.AddPreComment(&contents); -#ifdef PROTOBUF_FUTURE_EDITIONS if (FileDescriptorLegacy(this).syntax() == FileDescriptorLegacy::SYNTAX_EDITIONS) { absl::SubstituteAndAppend(&contents, "edition = \"$0\";\n\n", edition()); } else // NOLINT(readability/braces) -#endif // PROTOBUF_FUTURE_EDITIONS { absl::SubstituteAndAppend(&contents, "syntax = \"$0\";\n\n", FileDescriptorLegacy::SyntaxName( @@ -3341,9 +3288,7 @@ std::string FileDescriptor::DebugStringWithOptions( } FileOptions full_options = options(); -#ifdef PROTOBUF_FUTURE_EDITIONS CopyFeaturesToOptions(proto_features_, &full_options); -#endif // PROTOBUF_FUTURE_EDITIONS if (FormatLineOptions(0, full_options, pool(), &contents)) { contents.append("\n"); // add some space if we had options } @@ -3424,9 +3369,7 @@ void Descriptor::DebugString(int depth, std::string* contents, contents->append(" {\n"); MessageOptions full_options = options(); -#ifdef PROTOBUF_FUTURE_EDITIONS CopyFeaturesToOptions(proto_features_, &full_options); -#endif // PROTOBUF_FUTURE_EDITIONS FormatLineOptions(depth, full_options, file()->pool(), contents); // Find all the 'group' types for fields and extensions; we will not output @@ -3472,9 +3415,7 @@ void Descriptor::DebugString(int depth, std::string* contents, extension_range(i)->end_number() - 1); } ExtensionRangeOptions range_options = extension_range(i)->options(); -#ifdef PROTOBUF_FUTURE_EDITIONS CopyFeaturesToOptions(extension_range(i)->proto_features_, &range_options); -#endif // PROTOBUF_FUTURE_EDITIONS std::string formatted_options; if (FormatBracketedOptions(depth, range_options, file()->pool(), &formatted_options)) { @@ -3586,14 +3527,12 @@ void FieldDescriptor::DebugString( (is_optional() && !FieldDescriptorLegacy(this).has_optional_keyword())) { label.clear(); } -#ifdef PROTOBUF_FUTURE_EDITIONS // Label is omitted for optional and required fields under editions. if ((is_optional() || is_required()) && FileDescriptorLegacy(file()).syntax() == FileDescriptorLegacy::SYNTAX_EDITIONS) { label.clear(); } -#endif // PROTOBUF_FUTURE_EDITIONS SourceLocationCommentPrinter comment_printer(this, prefix, debug_string_options); @@ -3622,9 +3561,7 @@ void FieldDescriptor::DebugString( } FieldOptions full_options = options(); -#ifdef PROTOBUF_FUTURE_EDITIONS CopyFeaturesToOptions(proto_features_, &full_options); -#endif // PROTOBUF_FUTURE_EDITIONS std::string formatted_options; if (FormatBracketedOptions(depth, full_options, file()->pool(), &formatted_options)) { @@ -3674,9 +3611,7 @@ void OneofDescriptor::DebugString( absl::SubstituteAndAppend(contents, "$0oneof $1 {", prefix, name()); OneofOptions full_options = options(); -#ifdef PROTOBUF_FUTURE_EDITIONS CopyFeaturesToOptions(proto_features_, &full_options); -#endif // PROTOBUF_FUTURE_EDITIONS FormatLineOptions(depth, full_options, containing_type()->file()->pool(), contents); @@ -3717,9 +3652,7 @@ void EnumDescriptor::DebugString( absl::SubstituteAndAppend(contents, "$0enum $1 {\n", prefix, name()); EnumOptions full_options = options(); -#ifdef PROTOBUF_FUTURE_EDITIONS CopyFeaturesToOptions(proto_features_, &full_options); -#endif // PROTOBUF_FUTURE_EDITIONS FormatLineOptions(depth, full_options, file()->pool(), contents); for (int i = 0; i < value_count(); i++) { @@ -3780,9 +3713,7 @@ void EnumValueDescriptor::DebugString( absl::SubstituteAndAppend(contents, "$0$1 = $2", prefix, name(), number()); EnumValueOptions full_options = options(); -#ifdef PROTOBUF_FUTURE_EDITIONS CopyFeaturesToOptions(proto_features_, &full_options); -#endif // PROTOBUF_FUTURE_EDITIONS std::string formatted_options; if (FormatBracketedOptions(depth, full_options, type()->file()->pool(), &formatted_options)) { @@ -3815,9 +3746,7 @@ void ServiceDescriptor::DebugString( absl::SubstituteAndAppend(contents, "service $0 {\n", name()); ServiceOptions full_options = options(); -#ifdef PROTOBUF_FUTURE_EDITIONS CopyFeaturesToOptions(proto_features_, &full_options); -#endif // PROTOBUF_FUTURE_EDITIONS FormatLineOptions(1, full_options, file()->pool(), contents); for (int i = 0; i < method_count(); i++) { @@ -3857,9 +3786,7 @@ void MethodDescriptor::DebugString( client_streaming() ? "stream " : "", server_streaming() ? "stream " : ""); MethodOptions full_options = options(); -#ifdef PROTOBUF_FUTURE_EDITIONS CopyFeaturesToOptions(proto_features_, &full_options); -#endif // PROTOBUF_FUTURE_EDITIONS std::string formatted_options; if (FormatLineOptions(depth, full_options, service()->file()->pool(), &formatted_options)) { @@ -3875,23 +3802,12 @@ void MethodDescriptor::DebugString( // Feature methods =============================================== bool EnumDescriptor::is_closed() const { -#ifdef PROTOBUF_FUTURE_EDITIONS return features().enum_type() == FeatureSet::CLOSED; -#else // PROTOBUF_FUTURE_EDITIONS - PROTOBUF_IGNORE_DEPRECATION_START - return file()->syntax() != FileDescriptor::SYNTAX_PROTO3; - PROTOBUF_IGNORE_DEPRECATION_STOP -#endif // PROTOBUF_FUTURE_EDITIONS } bool FieldDescriptor::is_packed() const { if (!is_packable()) return false; -#ifdef PROTOBUF_FUTURE_EDITIONS if (features().repeated_field_encoding() != FeatureSet::PACKED) { -#else // PROTOBUF_FUTURE_EDITIONS - if (FileDescriptorLegacy(file_).syntax() == - FileDescriptorLegacy::Syntax::SYNTAX_PROTO2) { -#endif // PROTOBUF_FUTURE_EDITIONS return (options_ != nullptr) && options_->packed(); } else { return options_ == nullptr || !options_->has_packed() || options_->packed(); @@ -3899,13 +3815,8 @@ bool FieldDescriptor::is_packed() const { } static bool IsStrictUtf8(const FieldDescriptor* field) { -#ifdef PROTOBUF_FUTURE_EDITIONS return internal::InternalFeatureHelper::GetFeatures(*field) .string_field_validation() == FeatureSet::MANDATORY; -#else // PROTOBUF_FUTURE_EDITIONS - return FileDescriptorLegacy(field->file()).syntax() == - FileDescriptorLegacy::Syntax::SYNTAX_PROTO3; -#endif // PROTOBUF_FUTURE_EDITIONS } bool FieldDescriptor::requires_utf8_validation() const { @@ -3915,25 +3826,17 @@ bool FieldDescriptor::requires_utf8_validation() const { bool FieldDescriptor::has_presence() const { if (is_repeated()) return false; return cpp_type() == CPPTYPE_MESSAGE || containing_oneof() || -#ifdef PROTOBUF_FUTURE_EDITIONS features().field_presence() != FeatureSet::IMPLICIT; -#else // PROTOBUF_FUTURE_EDITIONS - FileDescriptorLegacy(file_).syntax() == - FileDescriptorLegacy::Syntax::SYNTAX_PROTO2; -#endif // PROTOBUF_FUTURE_EDITIONS } bool FieldDescriptor::legacy_enum_field_treated_as_closed() const { -#ifdef PROTOBUF_FUTURE_EDITIONS return type() == TYPE_ENUM && (features().GetExtension(pb::cpp).legacy_closed_enum() || enum_type()->is_closed()); -#else // PROTOBUF_FUTURE_EDITIONS return type() == TYPE_ENUM && (FileDescriptorLegacy(file_).syntax() == FileDescriptorLegacy::Syntax::SYNTAX_PROTO2 || enum_type()->is_closed()); -#endif // PROTOBUF_FUTURE_EDITIONS } // Location methods =============================================== @@ -4134,9 +4037,7 @@ class DescriptorBuilder { DescriptorPool::Tables* tables_; // for convenience DescriptorPool::ErrorCollector* error_collector_; -#ifdef PROTOBUF_FUTURE_EDITIONS absl::optional feature_resolver_ = absl::nullopt; -#endif // PROTOBUF_FUTURE_EDITIONS // As we build descriptors we store copies of the options messages in // them. We put pointers to those copies in this vector, as we build, so we @@ -4331,7 +4232,6 @@ class DescriptorBuilder { absl::Span options_path, absl::string_view option_name, internal::FlatAllocator& alloc); -#ifdef PROTOBUF_FUTURE_EDITIONS // Allocates and resolves any feature sets that need to be owned by a given // descriptor. This also strips features out of the mutable options message to // prevent leaking of unresolved features. @@ -4361,7 +4261,6 @@ class DescriptorBuilder { const DescriptorT* descriptor); void PostProcessFieldFeatures(FieldDescriptor& field); -#endif // PROTOBUF_FUTURE_EDITIONS // Allocates an array of two strings, the first one is a copy of // `proto_name`, and the second one is the full name. Full proto name is @@ -4469,13 +4368,11 @@ class DescriptorBuilder { // Otherwise returns true. bool InterpretOptions(OptionsToInterpret* options_to_interpret); -#ifdef PROTOBUF_FUTURE_EDITIONS // Interprets the uninterpreted feature options in the specified Options // message. On error, calls AddError() on the underlying builder and returns // false. Otherwise returns true. bool InterpretFeatures(OptionsToInterpret* options_to_interpret); -#endif // PROTOBUF_FUTURE_EDITIONS // Updates the given source code info by re-writing uninterpreted option // locations to refer to the corresponding interpreted option. void UpdateSourceCodeInfo(SourceCodeInfo* info); @@ -4721,14 +4618,12 @@ DescriptorBuilder::DescriptorBuilder( had_errors_(false), possible_undeclared_dependency_(nullptr), undefine_resolved_name_("") { -#ifdef PROTOBUF_FUTURE_EDITIONS // Ensure that any lazily loaded static initializers from the generated pool // (e.g. from bootstrapped protos) are run before building any descriptors. We // have to avoid registering these pre-main, because we need to ensure that // the linker --gc-sections step can strip out the full runtime if it is // unused. pb::cpp.LazyRegister(); -#endif // PROTOBUF_FUTURE_EDITIONS } DescriptorBuilder::~DescriptorBuilder() {} @@ -5080,10 +4975,8 @@ Symbol DescriptorPool::NewPlaceholderWithMutexHeld( alloc.AllocateStrings(placeholder_name, placeholder_full_name); placeholder_enum->file_ = placeholder_file; placeholder_enum->options_ = &EnumOptions::default_instance(); -#ifdef PROTOBUF_FUTURE_EDITIONS placeholder_enum->proto_features_ = &FeatureSet::default_instance(); placeholder_enum->merged_features_ = &FeatureSet::default_instance(); -#endif // PROTOBUF_FUTURE_EDITIONS placeholder_enum->is_placeholder_ = true; placeholder_enum->is_unqualified_placeholder_ = (name[0] != '.'); @@ -5121,10 +5014,8 @@ Symbol DescriptorPool::NewPlaceholderWithMutexHeld( alloc.AllocateStrings(placeholder_name, placeholder_full_name); placeholder_message->file_ = placeholder_file; placeholder_message->options_ = &MessageOptions::default_instance(); -#ifdef PROTOBUF_FUTURE_EDITIONS placeholder_message->proto_features_ = &FeatureSet::default_instance(); placeholder_message->merged_features_ = &FeatureSet::default_instance(); -#endif // PROTOBUF_FUTURE_EDITIONS placeholder_message->is_placeholder_ = true; placeholder_message->is_unqualified_placeholder_ = (name[0] != '.'); @@ -5137,12 +5028,10 @@ Symbol DescriptorPool::NewPlaceholderWithMutexHeld( placeholder_message->extension_ranges_[0].end_ = FieldDescriptor::kMaxNumber + 1; placeholder_message->extension_ranges_[0].options_ = nullptr; -#ifdef PROTOBUF_FUTURE_EDITIONS placeholder_message->extension_ranges_[0].proto_features_ = &FeatureSet::default_instance(); placeholder_message->extension_ranges_[0].merged_features_ = &FeatureSet::default_instance(); -#endif // PROTOBUF_FUTURE_EDITIONS } return Symbol(placeholder_message); @@ -5172,10 +5061,8 @@ FileDescriptor* DescriptorPool::NewPlaceholderFileWithMutexHeld( placeholder->package_ = &internal::GetEmptyString(); placeholder->pool_ = this; placeholder->options_ = &FileOptions::default_instance(); -#ifdef PROTOBUF_FUTURE_EDITIONS placeholder->proto_features_ = &FeatureSet::default_instance(); placeholder->merged_features_ = &FeatureSet::default_instance(); -#endif // PROTOBUF_FUTURE_EDITIONS placeholder->tables_ = &FileDescriptorTables::GetEmptyInstance(); placeholder->source_code_info_ = &SourceCodeInfo::default_instance(); placeholder->is_placeholder_ = true; @@ -5322,10 +5209,8 @@ void DescriptorBuilder::AllocateOptions( descriptor->full_name(), descriptor->full_name(), proto, options_path, option_name, alloc); descriptor->options_ = options; -#ifdef PROTOBUF_FUTURE_EDITIONS descriptor->proto_features_ = &FeatureSet::default_instance(); descriptor->merged_features_ = &FeatureSet::default_instance(); -#endif // PROTOBUF_FUTURE_EDITIONS } // We specialize for FileDescriptor. @@ -5339,10 +5224,8 @@ void DescriptorBuilder::AllocateOptions(const FileDescriptorProto& proto, absl::StrCat(descriptor->package(), ".dummy"), descriptor->name(), proto, options_path, "google.protobuf.FileOptions", alloc); descriptor->options_ = options; -#ifdef PROTOBUF_FUTURE_EDITIONS descriptor->proto_features_ = &FeatureSet::default_instance(); descriptor->merged_features_ = &FeatureSet::default_instance(); -#endif // PROTOBUF_FUTURE_EDITIONS } template @@ -5405,7 +5288,6 @@ typename DescriptorT::OptionsType* DescriptorBuilder::AllocateOptionsImpl( return options; } -#ifdef PROTOBUF_FUTURE_EDITIONS template void DescriptorBuilder::ResolveFeaturesImpl( const typename DescriptorT::Proto& proto, DescriptorT* descriptor, @@ -5510,8 +5392,6 @@ void DescriptorBuilder::PostProcessFieldFeatures(FieldDescriptor& field) { } } -#endif // PROTOBUF_FUTURE_EDITIONS - // A common pattern: We want to convert a repeated field in the descriptor // to an array of values, calling some method to build each value. #define BUILD_ARRAY(INPUT, OUTPUT, NAME, METHOD, PARENT) \ @@ -5595,9 +5475,7 @@ static void PlanAllocationSize( alloc.PlanArray(2 * values.size()); // name + full_name for (const auto& v : values) { if (v.has_options()) alloc.PlanArray(1); -#ifdef PROTOBUF_FUTURE_EDITIONS if (HasFeatures(v.options())) alloc.PlanArray(2); -#endif // !PROTOBUF_FUTURE_EDITIONS } } @@ -5608,9 +5486,7 @@ static void PlanAllocationSize( alloc.PlanArray(2 * enums.size()); // name + full_name for (const auto& e : enums) { if (e.has_options()) alloc.PlanArray(1); -#ifdef PROTOBUF_FUTURE_EDITIONS if (HasFeatures(e.options())) alloc.PlanArray(2); -#endif // !PROTOBUF_FUTURE_EDITIONS PlanAllocationSize(e.value(), alloc); alloc.PlanArray(e.reserved_range_size()); alloc.PlanArray(e.reserved_name_size()); @@ -5625,9 +5501,7 @@ static void PlanAllocationSize( alloc.PlanArray(2 * oneofs.size()); // name + full_name for (const auto& oneof : oneofs) { if (oneof.has_options()) alloc.PlanArray(1); -#ifdef PROTOBUF_FUTURE_EDITIONS if (HasFeatures(oneof.options())) alloc.PlanArray(2); -#endif // !PROTOBUF_FUTURE_EDITIONS } } @@ -5637,9 +5511,7 @@ static void PlanAllocationSize( alloc.PlanArray(fields.size()); for (const auto& field : fields) { if (field.has_options()) alloc.PlanArray(1); -#ifdef PROTOBUF_FUTURE_EDITIONS if (HasFeatures(field.options())) alloc.PlanArray(2); -#endif // !PROTOBUF_FUTURE_EDITIONS alloc.PlanFieldNames(field.name(), field.has_json_name() ? &field.json_name() : nullptr); if (field.has_default_value() && field.has_type() && @@ -5657,9 +5529,7 @@ static void PlanAllocationSize( alloc.PlanArray(ranges.size()); for (const auto& r : ranges) { if (r.has_options()) alloc.PlanArray(1); -#ifdef PROTOBUF_FUTURE_EDITIONS if (HasFeatures(r.options())) alloc.PlanArray(2); -#endif // !PROTOBUF_FUTURE_EDITIONS } } @@ -5671,9 +5541,7 @@ static void PlanAllocationSize( for (const auto& message : messages) { if (message.has_options()) alloc.PlanArray(1); -#ifdef PROTOBUF_FUTURE_EDITIONS if (HasFeatures(message.options())) alloc.PlanArray(2); -#endif // !PROTOBUF_FUTURE_EDITIONS PlanAllocationSize(message.nested_type(), alloc); PlanAllocationSize(message.field(), alloc); PlanAllocationSize(message.extension(), alloc); @@ -5693,9 +5561,7 @@ static void PlanAllocationSize( alloc.PlanArray(2 * methods.size()); // name + full_name for (const auto& m : methods) { if (m.has_options()) alloc.PlanArray(1); -#ifdef PROTOBUF_FUTURE_EDITIONS if (HasFeatures(m.options())) alloc.PlanArray(2); -#endif // !PROTOBUF_FUTURE_EDITIONS } } @@ -5706,9 +5572,7 @@ static void PlanAllocationSize( alloc.PlanArray(2 * services.size()); // name + full_name for (const auto& service : services) { if (service.has_options()) alloc.PlanArray(1); -#ifdef PROTOBUF_FUTURE_EDITIONS if (HasFeatures(service.options())) alloc.PlanArray(2); -#endif // !PROTOBUF_FUTURE_EDITIONS PlanAllocationSize(service.method(), alloc); } } @@ -5717,20 +5581,15 @@ static void PlanAllocationSize(const FileDescriptorProto& proto, internal::FlatAllocator& alloc) { alloc.PlanArray(1); alloc.PlanArray(1); - alloc.PlanArray(2 -#ifdef PROTOBUF_FUTURE_EDITIONS - + (proto.has_edition() ? 1 : 0) -#endif // !PROTOBUF_FUTURE_EDITIONS - ); // name + package + alloc.PlanArray( + 2 + (proto.has_edition() ? 1 : 0)); // name + package if (proto.has_options()) alloc.PlanArray(1); -#ifdef PROTOBUF_FUTURE_EDITIONS if (proto.has_edition()) { alloc.PlanArray(1); if (HasFeatures(proto.options())) { alloc.PlanArray(1); } } -#endif // !PROTOBUF_FUTURE_EDITIONS if (proto.has_source_code_info()) alloc.PlanArray(1); PlanAllocationSize(proto.service(), alloc); @@ -5832,7 +5691,6 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl( FileDescriptor* result = alloc.AllocateArray(1); file_ = result; -#ifdef PROTOBUF_FUTURE_EDITIONS if (proto.has_edition()) { Symbol symbol = FindSymbolNotEnforcingDeps("google.protobuf.FeatureSet"); const Descriptor* descriptor = symbol.descriptor(); @@ -5854,7 +5712,6 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl( feature_resolver_.emplace(std::move(feature_resolver).value()); } } -#endif // PROTOBUF_FUTURE_EDITIONS result->is_placeholder_ = false; result->finished_building_ = false; @@ -5881,21 +5738,17 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl( file_->syntax_ = FileDescriptorLegacy::SYNTAX_PROTO2; } else if (proto.syntax() == "proto3") { file_->syntax_ = FileDescriptorLegacy::SYNTAX_PROTO3; -#ifdef PROTOBUF_FUTURE_EDITIONS } else if (proto.syntax() == "editions") { file_->syntax_ = FileDescriptorLegacy::SYNTAX_EDITIONS; -#endif // !PROTOBUF_FUTURE_EDITIONS } else { file_->syntax_ = FileDescriptorLegacy::SYNTAX_UNKNOWN; AddError(proto.name(), proto, DescriptorPool::ErrorCollector::OTHER, [&] { return absl::StrCat("Unrecognized syntax: ", proto.syntax()); }); } -#ifdef PROTOBUF_FUTURE_EDITIONS if (proto.has_edition()) { file_->edition_ = alloc.AllocateStrings(proto.edition()); } -#endif // !PROTOBUF_FUTURE_EDITIONS result->name_ = alloc.AllocateStrings(proto.name()); if (proto.has_package()) { @@ -5964,7 +5817,6 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl( return nullptr; } -#ifdef PROTOBUF_FUTURE_EDITIONS // Look for feature extensions in regular imports. if (feature_resolver_.has_value() && dependency != nullptr) { absl::Status status = feature_resolver_->RegisterExtensions(*dependency); @@ -5974,7 +5826,6 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl( [&] { return std::string(status.message()); }); } } -#endif // PROTOBUF_FUTURE_EDITIONS if (dependency == nullptr) { if (!pool_->lazily_build_dependencies_) { @@ -6097,7 +5948,6 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl( SuggestFieldNumbers(result, proto); } -#ifdef PROTOBUF_FUTURE_EDITIONS // Interpret only the feature options first. This has to be done in two // passes, since options defined in this file may have features attached // to them. @@ -6130,7 +5980,6 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl( internal::VisitDescriptors(*result, [&](const FieldDescriptor& field) { PostProcessFieldFeatures(const_cast(field)); }); -#endif // PROTOBUF_FUTURE_EDITIONS // Interpret any remaining uninterpreted options gathered into // options_to_interpret_ during descriptor building. Cross-linking has made @@ -6479,15 +6328,11 @@ void DescriptorBuilder::CheckFieldJsonNameUniqueness( }; bool involves_default = !details.is_custom || !match.is_custom; -#ifdef PROTOBUF_FUTURE_EDITIONS if (descriptor->features().json_format() == FeatureSet::LEGACY_BEST_EFFORT && involves_default) { -#else // PROTOBUF_FUTURE_EDITIONS - if (syntax == FileDescriptorLegacy::SYNTAX_PROTO2 && involves_default) { -#endif // PROTOBUF_FUTURE_EDITIONS - // TODO(b/261750676) Upgrade this to an error once downstream protos have - // been fixed. + // TODO(b/261750676) Upgrade this to an error once downstream protos + // have been fixed. AddWarning(message_name, field, DescriptorPool::ErrorCollector::NAME, make_error); } else { @@ -8004,7 +7849,6 @@ static bool IsStringMapType(const FieldDescriptor* field) { void DescriptorBuilder::ValidateFieldFeatures( const FieldDescriptor* field, const FieldDescriptorProto& proto) { -#ifdef PROTOBUF_FUTURE_EDITIONS // Rely on our legacy validation for proto2/proto3 files. if (IsLegacyFeatureSet(field->features())) return; @@ -8060,7 +7904,6 @@ void DescriptorBuilder::ValidateFieldFeatures( AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::NAME, "Only repeated fields can specify `repeated_field_encoding`."); } -#endif // PROTOBUF_FUTURE_EDITIONS } void DescriptorBuilder::ValidateOptions(const EnumDescriptor* enm, @@ -8459,12 +8302,10 @@ bool DescriptorBuilder::OptionInterpreter::InterpretOptions( OptionsToInterpret* options_to_interpret) { return InterpretOptionsImpl(options_to_interpret, /*features=*/false); } -#ifdef PROTOBUF_FUTURE_EDITIONS bool DescriptorBuilder::OptionInterpreter::InterpretFeatures( OptionsToInterpret* options_to_interpret) { return InterpretOptionsImpl(options_to_interpret, /*features=*/true); } -#endif // PROTOBUF_FUTURE_EDITIONS bool DescriptorBuilder::OptionInterpreter::InterpretOptionsImpl( OptionsToInterpret* options_to_interpret, bool features) { // Note that these may be in different pools, so we can't use the same @@ -9612,12 +9453,10 @@ Utf8CheckMode GetUtf8CheckMode(const FieldDescriptor* field, bool is_lite) { } bool IsLazilyInitializedFile(absl::string_view filename) { -#ifdef PROTOBUF_FUTURE_EDITIONS if (filename == "third_party/protobuf/cpp_features.proto" || filename == "google/protobuf/cpp_features.proto") { return true; } -#endif // PROTOBUF_FUTURE_EDITIONS return filename == "net/proto2/proto/descriptor.proto" || filename == "google/protobuf/descriptor.proto"; } @@ -9625,7 +9464,6 @@ bool IsLazilyInitializedFile(absl::string_view filename) { } // namespace cpp } // namespace internal -#ifdef PROTOBUF_FUTURE_EDITIONS absl::string_view FileDescriptor::edition() const { // ASLR will help give this a random value across processes. static const void* kAntiHyrumText = &kAntiHyrumText; @@ -9635,7 +9473,6 @@ absl::string_view FileDescriptor::edition() const { return edition_ == nullptr ? anti_hyrum_string : *edition_; } -#endif // !PROTOBUF_FUTURE_EDITIONS } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h index bebaca08d4..1671d864bf 100644 --- a/src/google/protobuf/descriptor.h +++ b/src/google/protobuf/descriptor.h @@ -258,7 +258,6 @@ class PROTOBUF_EXPORT SymbolBase { template class PROTOBUF_EXPORT SymbolBaseN : public SymbolBase {}; -#ifdef PROTOBUF_FUTURE_EDITIONS // This class is for internal use only and provides access to the FeatureSets // defined on descriptors. These features are not designed to be stable, and // depending directly on them (vs the public descriptor APIs) is not safe. @@ -288,7 +287,6 @@ class PROTOBUF_EXPORT InternalFeatureHelper { // for every descriptor. static FileDescriptorProto GetGeneratorProto(const FileDescriptor& file); }; -#endif // PROTOBUF_FUTURE_EDITIONS } // namespace internal @@ -504,19 +502,15 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase { private: const Descriptor* containing_type_; -#ifdef PROTOBUF_FUTURE_EDITIONS const FeatureSet* proto_features_; const FeatureSet* merged_features_; -#endif // PROTOBUF_FUTURE_EDITIONS -#ifdef PROTOBUF_FUTURE_EDITIONS // Get the merged features that apply to this extension range. 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 any backend-specific extensions to it. const FeatureSet& features() const { return *merged_features_; } friend class internal::InternalFeatureHelper; -#endif // PROTOBUF_FUTURE_EDITIONS // Walks up the descriptor tree to generate the source location path // to this descriptor from the file root. @@ -641,14 +635,12 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase { friend class io::Printer; friend class compiler::cpp::Formatter; -#ifdef PROTOBUF_FUTURE_EDITIONS // Get the merged features that apply to this message type. 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 any backend-specific extensions to it. const FeatureSet& features() const { return *merged_features_; } friend class internal::InternalFeatureHelper; -#endif // PROTOBUF_FUTURE_EDITIONS // Fill the json_name field of FieldDescriptorProto. void CopyJsonNameTo(DescriptorProto* proto) const; @@ -688,10 +680,8 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase { const FileDescriptor* file_; const Descriptor* containing_type_; const MessageOptions* options_; -#ifdef PROTOBUF_FUTURE_EDITIONS const FeatureSet* proto_features_; const FeatureSet* merged_features_; -#endif // PROTOBUF_FUTURE_EDITIONS // These arrays are separated from their sizes to minimize padding on 64-bit. FieldDescriptor* fields_; @@ -728,11 +718,7 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase { friend class FileDescriptor; }; -#ifdef PROTOBUF_FUTURE_EDITIONS PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(Descriptor, 152); -#else // PROTOBUF_FUTURE_EDITIONS -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(Descriptor, 136); -#endif // PROTOBUF_FUTURE_EDITIONS // Describes a single field of a message. To get the descriptor for a given // field, first get the Descriptor for the message in which it is defined, @@ -1046,14 +1032,12 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase { private: -#ifdef PROTOBUF_FUTURE_EDITIONS // 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 // any backend-specific extensions to it. const FeatureSet& features() const { return *merged_features_; } friend class internal::InternalFeatureHelper; -#endif // PROTOBUF_FUTURE_EDITIONS // Fill the json_name field of FieldDescriptorProto. void CopyJsonNameTo(FieldDescriptorProto* proto) const; @@ -1122,10 +1106,8 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase { mutable const EnumDescriptor* enum_type; } type_descriptor_; const FieldOptions* options_; -#ifdef PROTOBUF_FUTURE_EDITIONS const FeatureSet* proto_features_; const FeatureSet* merged_features_; -#endif // PROTOBUF_FUTURE_EDITIONS // IMPORTANT: If you add a new field, make sure to search for all instances // of Allocate() and AllocateArray() in // descriptor.cc and update them to initialize the field. @@ -1160,11 +1142,7 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase { friend class OneofDescriptor; }; -#ifdef PROTOBUF_FUTURE_EDITIONS PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(FieldDescriptor, 88); -#else // PROTOBUF_FUTURE_EDITIONS -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(FieldDescriptor, 72); -#endif // PROTOBUF_FUTURE_EDITIONS // Describes a oneof defined in a message type. class PROTOBUF_EXPORT OneofDescriptor : private internal::SymbolBase { @@ -1231,14 +1209,12 @@ class PROTOBUF_EXPORT OneofDescriptor : private internal::SymbolBase { private: -#ifdef PROTOBUF_FUTURE_EDITIONS // Get the merged features that apply to this oneof. These are specified in // the .proto file through the feature options in the oneof definition. // Allowed features are defined by Features in descriptor.proto, along with // any backend-specific extensions to it. const FeatureSet& features() const { return *merged_features_; } friend class internal::InternalFeatureHelper; -#endif // PROTOBUF_FUTURE_EDITIONS // See Descriptor::DebugString(). void DebugString(int depth, std::string* contents, @@ -1254,10 +1230,8 @@ class PROTOBUF_EXPORT OneofDescriptor : private internal::SymbolBase { const std::string* all_names_; const Descriptor* containing_type_; const OneofOptions* options_; -#ifdef PROTOBUF_FUTURE_EDITIONS const FeatureSet* proto_features_; const FeatureSet* merged_features_; -#endif // PROTOBUF_FUTURE_EDITIONS const FieldDescriptor* fields_; // IMPORTANT: If you add a new field, make sure to search for all instances @@ -1271,11 +1245,7 @@ class PROTOBUF_EXPORT OneofDescriptor : private internal::SymbolBase { friend class FieldDescriptor; }; -#ifdef PROTOBUF_FUTURE_EDITIONS PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(OneofDescriptor, 56); -#else // PROTOBUF_FUTURE_EDITIONS -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(OneofDescriptor, 40); -#endif // PROTOBUF_FUTURE_EDITIONS // Describes an enum type defined in a .proto file. To get the EnumDescriptor // for a generated enum type, call TypeName_descriptor(). Use DescriptorPool @@ -1406,14 +1376,12 @@ class PROTOBUF_EXPORT EnumDescriptor : private internal::SymbolBase { // Allow access to FindValueByNumberCreatingIfUnknown. friend class descriptor_unittest::DescriptorTest; -#ifdef PROTOBUF_FUTURE_EDITIONS // Get the merged features that apply to this enum type. 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 // any backend-specific extensions to it. const FeatureSet& features() const { return *merged_features_; } friend class internal::InternalFeatureHelper; -#endif // PROTOBUF_FUTURE_EDITIONS // Looks up a value by number. If the value does not exist, dynamically // creates a new EnumValueDescriptor for that value, assuming that it was @@ -1455,10 +1423,8 @@ class PROTOBUF_EXPORT EnumDescriptor : private internal::SymbolBase { const FileDescriptor* file_; const Descriptor* containing_type_; const EnumOptions* options_; -#ifdef PROTOBUF_FUTURE_EDITIONS const FeatureSet* proto_features_; const FeatureSet* merged_features_; -#endif // PROTOBUF_FUTURE_EDITIONS EnumValueDescriptor* values_; int reserved_range_count_; @@ -1482,11 +1448,7 @@ class PROTOBUF_EXPORT EnumDescriptor : private internal::SymbolBase { friend class Reflection; }; -#ifdef PROTOBUF_FUTURE_EDITIONS PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(EnumDescriptor, 88); -#else // PROTOBUF_FUTURE_EDITIONS -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(EnumDescriptor, 72); -#endif // PROTOBUF_FUTURE_EDITIONS // Describes an individual enum constant of a particular type. To get the // EnumValueDescriptor for a given enum value, first get the EnumDescriptor @@ -1549,14 +1511,12 @@ class PROTOBUF_EXPORT EnumValueDescriptor : private internal::SymbolBaseN<0>, friend class io::Printer; friend class compiler::cpp::Formatter; -#ifdef PROTOBUF_FUTURE_EDITIONS // Get the merged features that apply to this enum value. 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 // any backend-specific extensions to it. const FeatureSet& features() const { return *merged_features_; } friend class internal::InternalFeatureHelper; -#endif // PROTOBUF_FUTURE_EDITIONS // See Descriptor::DebugString(). void DebugString(int depth, std::string* contents, @@ -1571,10 +1531,8 @@ class PROTOBUF_EXPORT EnumValueDescriptor : private internal::SymbolBaseN<0>, const std::string* all_names_; const EnumDescriptor* type_; const EnumValueOptions* options_; -#ifdef PROTOBUF_FUTURE_EDITIONS const FeatureSet* proto_features_; const FeatureSet* merged_features_; -#endif // PROTOBUF_FUTURE_EDITIONS // IMPORTANT: If you add a new field, make sure to search for all instances // of Allocate() and AllocateArray() // in descriptor.cc and update them to initialize the field. @@ -1588,11 +1546,7 @@ class PROTOBUF_EXPORT EnumValueDescriptor : private internal::SymbolBaseN<0>, friend class Reflection; }; -#ifdef PROTOBUF_FUTURE_EDITIONS PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(EnumValueDescriptor, 48); -#else // PROTOBUF_FUTURE_EDITIONS -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(EnumValueDescriptor, 32); -#endif // PROTOBUF_FUTURE_EDITIONS // Describes an RPC service. Use DescriptorPool to construct your own // descriptors. @@ -1654,14 +1608,12 @@ class PROTOBUF_EXPORT ServiceDescriptor : private internal::SymbolBase { friend class io::Printer; friend class compiler::cpp::Formatter; -#ifdef PROTOBUF_FUTURE_EDITIONS // Get the merged features that apply to this service type. These are // specified in the .proto file through the feature options in the service // definition. Allowed features are defined by Features in descriptor.proto, // along with any backend-specific extensions to it. const FeatureSet& features() const { return *merged_features_; } friend class internal::InternalFeatureHelper; -#endif // PROTOBUF_FUTURE_EDITIONS // See Descriptor::DebugString(). void DebugString(std::string* contents, @@ -1675,10 +1627,8 @@ class PROTOBUF_EXPORT ServiceDescriptor : private internal::SymbolBase { const std::string* all_names_; const FileDescriptor* file_; const ServiceOptions* options_; -#ifdef PROTOBUF_FUTURE_EDITIONS const FeatureSet* proto_features_; const FeatureSet* merged_features_; -#endif // PROTOBUF_FUTURE_EDITIONS MethodDescriptor* methods_; int method_count_; // IMPORTANT: If you add a new field, make sure to search for all instances @@ -1692,11 +1642,7 @@ class PROTOBUF_EXPORT ServiceDescriptor : private internal::SymbolBase { friend class MethodDescriptor; }; -#ifdef PROTOBUF_FUTURE_EDITIONS PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(ServiceDescriptor, 64); -#else // PROTOBUF_FUTURE_EDITIONS -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(ServiceDescriptor, 48); -#endif // PROTOBUF_FUTURE_EDITIONS // Describes an individual service method. To obtain a MethodDescriptor given // a service, first get its ServiceDescriptor, then call @@ -1763,14 +1709,12 @@ class PROTOBUF_EXPORT MethodDescriptor : private internal::SymbolBase { friend class io::Printer; friend class compiler::cpp::Formatter; -#ifdef PROTOBUF_FUTURE_EDITIONS // Get the merged features that apply to this method. These are specified in // the .proto file through the feature options in the method definition. // Allowed features are defined by Features in descriptor.proto, along with // any backend-specific extensions to it. const FeatureSet& features() const { return *merged_features_; } friend class internal::InternalFeatureHelper; -#endif // PROTOBUF_FUTURE_EDITIONS // See Descriptor::DebugString(). void DebugString(int depth, std::string* contents, @@ -1788,10 +1732,8 @@ class PROTOBUF_EXPORT MethodDescriptor : private internal::SymbolBase { mutable internal::LazyDescriptor input_type_; mutable internal::LazyDescriptor output_type_; const MethodOptions* options_; -#ifdef PROTOBUF_FUTURE_EDITIONS const FeatureSet* proto_features_; const FeatureSet* merged_features_; -#endif // PROTOBUF_FUTURE_EDITIONS // IMPORTANT: If you add a new field, make sure to search for all instances // of Allocate() and AllocateArray() in // descriptor.cc and update them to initialize the field. @@ -1802,11 +1744,7 @@ class PROTOBUF_EXPORT MethodDescriptor : private internal::SymbolBase { friend class ServiceDescriptor; }; -#ifdef PROTOBUF_FUTURE_EDITIONS PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(MethodDescriptor, 80); -#else // PROTOBUF_FUTURE_EDITIONS -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(MethodDescriptor, 64); -#endif // PROTOBUF_FUTURE_EDITIONS // Describes a whole .proto file. To get the FileDescriptor for a compiled-in // file, get the descriptor for something defined in that file and call @@ -1905,9 +1843,7 @@ class PROTOBUF_EXPORT FileDescriptor : private internal::SymbolBase { SYNTAX_UNKNOWN = 0, SYNTAX_PROTO2 = 2, SYNTAX_PROTO3 = 3, -#ifdef PROTOBUF_FUTURE_EDITIONS SYNTAX_EDITIONS = 99, -#endif // PROTOBUF_FUTURE_EDITIONS }; PROTOBUF_IGNORE_DEPRECATION_START ABSL_DEPRECATED( @@ -1927,10 +1863,8 @@ class PROTOBUF_EXPORT FileDescriptor : private internal::SymbolBase { PROTOBUF_IGNORE_DEPRECATION_STOP public: -#ifdef PROTOBUF_FUTURE_EDITIONS // Returns an unspecified value if syntax() is not SYNTAX_EDITIONS. absl::string_view edition() const; -#endif // PROTOBUF_FUTURE_EDITIONS // Find a top-level message type by name (not full_name). Returns nullptr if // not found. @@ -2009,18 +1943,14 @@ class PROTOBUF_EXPORT FileDescriptor : private internal::SymbolBase { const std::string* name_; const std::string* package_; const DescriptorPool* pool_; -#ifdef PROTOBUF_FUTURE_EDITIONS const std::string* edition_ = nullptr; -#endif // PROTOBUF_FUTURE_EDITIONS -#ifdef PROTOBUF_FUTURE_EDITIONS // Get the merged features that apply to this file. These are specified in // the .proto file through the feature options in the message definition. // Allowed features are defined by FeatureSet in descriptor.proto, along with // any backend-specific extensions to it. const FeatureSet& features() const { return *merged_features_; } friend class internal::InternalFeatureHelper; -#endif // PROTOBUF_FUTURE_EDITIONS // dependencies_once_ contain a once_flag followed by N NUL terminated // strings. Dependencies that do not need to be loaded will be empty. ie just @@ -2045,10 +1975,8 @@ class PROTOBUF_EXPORT FileDescriptor : private internal::SymbolBase { ServiceDescriptor* services_; FieldDescriptor* extensions_; const FileOptions* options_; -#ifdef PROTOBUF_FUTURE_EDITIONS const FeatureSet* proto_features_; const FeatureSet* merged_features_; -#endif // PROTOBUF_FUTURE_EDITIONS const FileDescriptorTables* tables_; const SourceCodeInfo* source_code_info_; @@ -2070,11 +1998,7 @@ class PROTOBUF_EXPORT FileDescriptor : private internal::SymbolBase { friend class ServiceDescriptor; }; -#ifdef PROTOBUF_FUTURE_EDITIONS PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(FileDescriptor, 168); -#else // PROTOBUF_FUTURE_EDITIONS -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(FileDescriptor, 152); -#endif // PROTOBUF_FUTURE_EDITIONS // =================================================================== @@ -2220,10 +2144,8 @@ class PROTOBUF_EXPORT DescriptorPool { OPTION_NAME, // name in assignment OPTION_VALUE, // value in option assignment IMPORT, // import error -#ifdef PROTOBUF_FUTURE_EDITIONS - EDITIONS, // editions-related error -#endif // PROTOBUF_FUTURE_EDITIONS - OTHER // some other problem + EDITIONS, // editions-related error + OTHER // some other problem }; static absl::string_view ErrorLocationName(ErrorLocation location); diff --git a/src/google/protobuf/descriptor_legacy.h b/src/google/protobuf/descriptor_legacy.h index 8d04b203fe..4cba0e06e3 100644 --- a/src/google/protobuf/descriptor_legacy.h +++ b/src/google/protobuf/descriptor_legacy.h @@ -79,9 +79,7 @@ class PROTOBUF_EXPORT FileDescriptorLegacy { SYNTAX_UNKNOWN = FileDescriptor::SYNTAX_UNKNOWN, SYNTAX_PROTO2 = FileDescriptor::SYNTAX_PROTO2, SYNTAX_PROTO3 = FileDescriptor::SYNTAX_PROTO3, -#ifdef PROTOBUF_FUTURE_EDITIONS SYNTAX_EDITIONS = FileDescriptor::SYNTAX_EDITIONS, -#endif // PROTOBUF_FUTURE_EDITIONS }; Syntax syntax() const { return static_cast(desc_->syntax()); } static absl::string_view SyntaxName(Syntax syntax) { diff --git a/src/google/protobuf/descriptor_unittest.cc b/src/google/protobuf/descriptor_unittest.cc index cb59fa1645..f1430a8d65 100644 --- a/src/google/protobuf/descriptor_unittest.cc +++ b/src/google/protobuf/descriptor_unittest.cc @@ -42,40 +42,38 @@ #include #include +#include "google/protobuf/stubs/common.h" #include "google/protobuf/any.pb.h" #include "google/protobuf/compiler/importer.h" #include "google/protobuf/compiler/parser.h" #include "google/protobuf/descriptor.pb.h" +#include "google/protobuf/descriptor.pb.h" +#include "google/protobuf/descriptor_database.h" +#include "google/protobuf/dynamic_message.h" +#include "google/protobuf/text_format.h" +#include +#include "google/protobuf/testing/googletest.h" +#include #include "absl/container/btree_set.h" #include "absl/container/flat_hash_set.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/log/die_if_null.h" #include "absl/log/scoped_mock_log.h" #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" +#include "absl/strings/substitute.h" +#include "google/protobuf/cpp_features.pb.h" #include "google/protobuf/descriptor_legacy.h" #include "google/protobuf/test_textproto.h" #include "google/protobuf/unittest.pb.h" #include "google/protobuf/unittest_custom_options.pb.h" -#ifdef PROTOBUF_FUTURE_EDITIONS -#include "google/protobuf/cpp_features.pb.h" #include "google/protobuf/unittest_features.pb.h" #include "google/protobuf/unittest_invalid_features.pb.h" -#endif // PROTOBUF_FUTURE_EDITIONS -#include "google/protobuf/stubs/common.h" -#include "google/protobuf/descriptor.pb.h" -#include "google/protobuf/descriptor_database.h" -#include "google/protobuf/dynamic_message.h" -#include "google/protobuf/text_format.h" -#include -#include "google/protobuf/testing/googletest.h" -#include -#include "absl/log/absl_check.h" -#include "absl/log/absl_log.h" #include "google/protobuf/unittest_lazy_dependencies.pb.h" #include "google/protobuf/unittest_lazy_dependencies_custom_option.pb.h" #include "google/protobuf/unittest_lazy_dependencies_enum.pb.h" #include "google/protobuf/unittest_proto3_arena.pb.h" -#include "absl/strings/substitute.h" // Must be included last. @@ -497,7 +495,6 @@ TEST_F(FileDescriptorTest, Syntax) { file->CopyTo(&other); EXPECT_EQ("proto3", other.syntax()); } -#ifdef PROTOBUF_FUTURE_EDITIONS { proto.set_syntax("editions"); proto.set_edition("very-cool"); @@ -512,7 +509,6 @@ TEST_F(FileDescriptorTest, Syntax) { EXPECT_EQ("editions", other.syntax()); EXPECT_EQ("very-cool", other.edition()); } -#endif // PROTOBUF_FUTURE_EDITIONS } TEST_F(FileDescriptorTest, CopyHeadingTo) { @@ -536,7 +532,6 @@ TEST_F(FileDescriptorTest, CopyHeadingTo) { EXPECT_EQ(other.syntax(), "proto3"); EXPECT_EQ(other.options().java_package(), "foo.bar.baz"); EXPECT_TRUE(other.message_type().empty()); -#ifdef PROTOBUF_FUTURE_EDITIONS EXPECT_EQ(&other.options().features(), &FeatureSet::default_instance()); { proto.set_syntax("editions"); @@ -556,7 +551,6 @@ TEST_F(FileDescriptorTest, CopyHeadingTo) { EXPECT_TRUE(other.message_type().empty()); EXPECT_EQ(&other.options().features(), &FeatureSet::default_instance()); } -#endif // PROTOBUF_FUTURE_EDITIONS } void ExtractDebugString( @@ -7178,7 +7172,6 @@ TEST_F(ValidationErrorTest, UnusedImportWithOtherError) { "foo.proto: Foo.foo: EXTENDEE: \"Baz\" is not defined.\n"); } -#ifdef PROTOBUF_FUTURE_EDITIONS using FeaturesTest = ValidationErrorTest; template @@ -9915,8 +9908,6 @@ INSTANTIATE_TEST_SUITE_P( [](const ::testing::TestParamInfo& info) { return std::string(std::get<0>(info.param)); }); -#endif // PROTOBUF_FUTURE_EDITIONS - TEST_F(ValidationErrorTest, PackageTooLong) { diff --git a/src/google/protobuf/extension_set.h b/src/google/protobuf/extension_set.h index 52b22c798e..f6070ff2ab 100644 --- a/src/google/protobuf/extension_set.h +++ b/src/google/protobuf/extension_set.h @@ -77,9 +77,7 @@ class Message; // message.h class MessageFactory; // message.h class Reflection; // message.h class UnknownFieldSet; // unknown_field_set.h -#ifdef PROTOBUF_FUTURE_EDITIONS class FeatureSet; -#endif // PROTOBUF_FUTURE_EDITIONS namespace internal { class FieldSkipper; // wire_format_lite.h class WireFormat; @@ -87,11 +85,9 @@ enum class LazyVerifyOption; } // namespace internal } // namespace protobuf } // namespace google -#ifdef PROTOBUF_FUTURE_EDITIONS namespace pb { class CppFeatures; } // namespace pb -#endif // PROTOBUF_FUTURE_EDITIONS namespace google { namespace protobuf { @@ -1554,7 +1550,6 @@ class ExtensionIdentifier { extern PROTOBUF_ATTRIBUTE_WEAK ExtensionSet::LazyMessageExtension* MaybeCreateLazyExtension(Arena* arena); -#ifdef PROTOBUF_FUTURE_EDITIONS // Define a specialization of ExtensionIdentifier for bootstrapped extensions // that we need to register lazily. template <> @@ -1586,7 +1581,6 @@ class ExtensionIdentifier, 11, mutable absl::once_flag once_; }; -#endif // PROTOBUF_FUTURE_EDITIONS } // namespace internal diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index 640b476f31..be117423b6 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -224,10 +224,6 @@ static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and static_assert(PROTOBUF_ABSL_MIN(20230125, 3), "Protobuf only supports Abseil version 20230125.3 and newer."); -// Enable editions infrastructure by default. This should be a no-op without -// the --experimental_editions protoc flag. -#define PROTOBUF_FUTURE_EDITIONS 1 - // Future versions of protobuf will include breaking changes to some APIs. // This macro can be set to enable these API changes ahead of time, so that // user code can be updated before upgrading versions of protobuf.