Skip to content

Commit

Permalink
Define lifetimes of edition 2023 features
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 623690798
  • Loading branch information
mkruskal-google authored and copybara-github committed Apr 11, 2024
1 parent 22c1178 commit 77f62de
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 89 deletions.
19 changes: 19 additions & 0 deletions java/core/src/main/resources/google/protobuf/java_features.proto
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ message JavaFeatures {
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
targets = TARGET_TYPE_FILE,
// TODO Enable this in google3 once protoc rolls out.
feature_support = {
edition_introduced: EDITION_2023,
edition_deprecated: EDITION_2023,
deprecation_warning: "The legacy closed enum treatment in Java is "
"deprecated and is scheduled to be removed in "
"edition 2025. Mark enum type on the enum "
"definitions themselves rather than on fields.",
},
edition_defaults = { edition: EDITION_PROTO2, value: "true" },
edition_defaults = { edition: EDITION_PROTO3, value: "false" }
];
Expand All @@ -47,6 +56,16 @@ message JavaFeatures {
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
targets = TARGET_TYPE_FILE,
// TODO Enable this in google3 once protoc rolls out.
feature_support = {
edition_introduced: EDITION_2023,
edition_deprecated: EDITION_2023,
deprecation_warning: "The Java-specific utf8 validation feature is "
"deprecated and is scheduled to be removed in "
"edition 2025. Utf8 validation behavior should "
"use the global cross-language utf8_validation "
"feature.",
},
edition_defaults = { edition: EDITION_PROTO2, value: "DEFAULT" }
];
}
9 changes: 6 additions & 3 deletions src/google/protobuf/compiler/cpp/generator_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ TEST_F(CppGeneratorTest, LegacyClosedEnum) {

RunProtoc(
"protocol_compiler --proto_path=$tmpdir --cpp_out=$tmpdir foo.proto");

ExpectNoErrors();
ExpectWarningSubstring(
"foo.proto:9:16: warning: Feature pb.CppFeatures.legacy_closed_enum has "
"been deprecated in edition 2023");
}

TEST_F(CppGeneratorTest, LegacyClosedEnumInherited) {
Expand All @@ -119,7 +120,9 @@ TEST_F(CppGeneratorTest, LegacyClosedEnumInherited) {
RunProtoc(
"protocol_compiler --proto_path=$tmpdir --cpp_out=$tmpdir foo.proto");

ExpectNoErrors();
ExpectWarningSubstring(
"foo.proto: warning: Feature pb.CppFeatures.legacy_closed_enum has "
"been deprecated in edition 2023");
}

TEST_F(CppGeneratorTest, LegacyClosedEnumImplicit) {
Expand Down
30 changes: 20 additions & 10 deletions src/google/protobuf/compiler/java/java_features.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 15 additions & 10 deletions src/google/protobuf/cpp_features.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src/google/protobuf/cpp_features.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ message CppFeatures {
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
targets = TARGET_TYPE_FILE,
// TODO Enable this in google3 once protoc rolls out.
feature_support = {
edition_introduced: EDITION_2023,
edition_deprecated: EDITION_2023,
deprecation_warning: "The legacy closed enum treatment in C++ is "
"deprecated and is scheduled to be removed in "
"edition 2025. Mark enum type on the enum "
"definitions themselves rather than on fields.",
},
edition_defaults = { edition: EDITION_PROTO2, value: "true" },
edition_defaults = { edition: EDITION_PROTO3, value: "false" }
];
Expand All @@ -39,6 +48,10 @@ message CppFeatures {
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
targets = TARGET_TYPE_FILE,
// TODO Enable this in google3 once protoc rolls out.
feature_support = {
edition_introduced: EDITION_2023,
},
edition_defaults = { edition: EDITION_PROTO2, value: "STRING" },
edition_defaults = { edition: EDITION_2024, value: "VIEW" }
];
Expand Down
133 changes: 67 additions & 66 deletions src/google/protobuf/descriptor.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 77f62de

Please sign in to comment.