Skip to content

Commit 77f62de

Browse files
mkruskal-googlecopybara-github
authored andcommitted
Define lifetimes of edition 2023 features
PiperOrigin-RevId: 623690798
1 parent 22c1178 commit 77f62de

File tree

7 files changed

+164
-89
lines changed

7 files changed

+164
-89
lines changed

java/core/src/main/resources/google/protobuf/java_features.proto

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ message JavaFeatures {
2727
retention = RETENTION_RUNTIME,
2828
targets = TARGET_TYPE_FIELD,
2929
targets = TARGET_TYPE_FILE,
30+
// TODO Enable this in google3 once protoc rolls out.
31+
feature_support = {
32+
edition_introduced: EDITION_2023,
33+
edition_deprecated: EDITION_2023,
34+
deprecation_warning: "The legacy closed enum treatment in Java is "
35+
"deprecated and is scheduled to be removed in "
36+
"edition 2025. Mark enum type on the enum "
37+
"definitions themselves rather than on fields.",
38+
},
3039
edition_defaults = { edition: EDITION_PROTO2, value: "true" },
3140
edition_defaults = { edition: EDITION_PROTO3, value: "false" }
3241
];
@@ -47,6 +56,16 @@ message JavaFeatures {
4756
retention = RETENTION_RUNTIME,
4857
targets = TARGET_TYPE_FIELD,
4958
targets = TARGET_TYPE_FILE,
59+
// TODO Enable this in google3 once protoc rolls out.
60+
feature_support = {
61+
edition_introduced: EDITION_2023,
62+
edition_deprecated: EDITION_2023,
63+
deprecation_warning: "The Java-specific utf8 validation feature is "
64+
"deprecated and is scheduled to be removed in "
65+
"edition 2025. Utf8 validation behavior should "
66+
"use the global cross-language utf8_validation "
67+
"feature.",
68+
},
5069
edition_defaults = { edition: EDITION_PROTO2, value: "DEFAULT" }
5170
];
5271
}

src/google/protobuf/compiler/cpp/generator_unittest.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ TEST_F(CppGeneratorTest, LegacyClosedEnum) {
9797

9898
RunProtoc(
9999
"protocol_compiler --proto_path=$tmpdir --cpp_out=$tmpdir foo.proto");
100-
101-
ExpectNoErrors();
100+
ExpectWarningSubstring(
101+
"foo.proto:9:16: warning: Feature pb.CppFeatures.legacy_closed_enum has "
102+
"been deprecated in edition 2023");
102103
}
103104

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

122-
ExpectNoErrors();
123+
ExpectWarningSubstring(
124+
"foo.proto: warning: Feature pb.CppFeatures.legacy_closed_enum has "
125+
"been deprecated in edition 2023");
123126
}
124127

125128
TEST_F(CppGeneratorTest, LegacyClosedEnumImplicit) {

src/google/protobuf/compiler/java/java_features.pb.cc

Lines changed: 20 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/google/protobuf/cpp_features.pb.cc

Lines changed: 15 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/google/protobuf/cpp_features.proto

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ message CppFeatures {
2424
retention = RETENTION_RUNTIME,
2525
targets = TARGET_TYPE_FIELD,
2626
targets = TARGET_TYPE_FILE,
27+
// TODO Enable this in google3 once protoc rolls out.
28+
feature_support = {
29+
edition_introduced: EDITION_2023,
30+
edition_deprecated: EDITION_2023,
31+
deprecation_warning: "The legacy closed enum treatment in C++ is "
32+
"deprecated and is scheduled to be removed in "
33+
"edition 2025. Mark enum type on the enum "
34+
"definitions themselves rather than on fields.",
35+
},
2736
edition_defaults = { edition: EDITION_PROTO2, value: "true" },
2837
edition_defaults = { edition: EDITION_PROTO3, value: "false" }
2938
];
@@ -39,6 +48,10 @@ message CppFeatures {
3948
retention = RETENTION_RUNTIME,
4049
targets = TARGET_TYPE_FIELD,
4150
targets = TARGET_TYPE_FILE,
51+
// TODO Enable this in google3 once protoc rolls out.
52+
feature_support = {
53+
edition_introduced: EDITION_2023,
54+
},
4255
edition_defaults = { edition: EDITION_PROTO2, value: "STRING" },
4356
edition_defaults = { edition: EDITION_2024, value: "VIEW" }
4457
];

src/google/protobuf/descriptor.pb.cc

Lines changed: 67 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)