Add a trivial 2023 edition test case for Rust.
PiperOrigin-RevId: 588874094
diff --git a/rust/test/BUILD b/rust/test/BUILD
index 03b16fb..5b5e216 100644
--- a/rust/test/BUILD
+++ b/rust/test/BUILD
@@ -181,6 +181,32 @@
)
proto_library(
+ name = "edition2023_proto",
+ testonly = True,
+ srcs = ["edition2023.proto"],
+)
+
+cc_proto_library(
+ name = "edition2023_cc_proto",
+ testonly = True,
+ deps = [":edition2023_proto"],
+)
+
+rust_cc_proto_library(
+ name = "edition2023_cc_rust_proto",
+ testonly = True,
+ visibility = ["//rust/test/shared:__subpackages__"],
+ deps = [":edition2023_cc_proto"],
+)
+
+rust_upb_proto_library(
+ name = "edition2023_upb_rust_proto",
+ testonly = True,
+ visibility = ["//rust/test/shared:__subpackages__"],
+ deps = [":edition2023_proto"],
+)
+
+proto_library(
name = "no_package_import_proto",
testonly = True,
srcs = ["no_package_import.proto"],
diff --git a/rust/test/edition2023.proto b/rust/test/edition2023.proto
new file mode 100644
index 0000000..d5c48a2
--- /dev/null
+++ b/rust/test/edition2023.proto
@@ -0,0 +1,8 @@
+edition = "2023";
+
+package test;
+
+message EditionsMessage {
+ int32 plain_field = 1;
+ int32 implicit_presence_field = 2 [features.field_presence = IMPLICIT];
+}
diff --git a/rust/test/shared/BUILD b/rust/test/shared/BUILD
index 86d31c9..3541f06 100644
--- a/rust/test/shared/BUILD
+++ b/rust/test/shared/BUILD
@@ -69,6 +69,32 @@
)
rust_test(
+ name = "edition2023_cpp_test",
+ srcs = ["edition2023_test.rs"],
+ tags = [
+ # TODO: Enable testing on arm once we support sanitizers for Rust on Arm.
+ "not_build:arm",
+ ],
+ deps = [
+ "@crate_index//:googletest",
+ "//rust/test:edition2023_cc_rust_proto",
+ ],
+)
+
+rust_test(
+ name = "edition2023_upb_test",
+ srcs = ["edition2023_test.rs"],
+ tags = [
+ # TODO: Enable testing on arm once we support sanitizers for Rust on Arm.
+ "not_build:arm",
+ ],
+ deps = [
+ "@crate_index//:googletest",
+ "//rust/test:edition2023_upb_rust_proto",
+ ],
+)
+
+rust_test(
name = "package_cpp_test",
srcs = ["package_test.rs"],
tags = [
diff --git a/rust/test/shared/edition2023_test.rs b/rust/test/shared/edition2023_test.rs
new file mode 100644
index 0000000..f5f631a
--- /dev/null
+++ b/rust/test/shared/edition2023_test.rs
@@ -0,0 +1,23 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2023 Google LLC. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file or at
+// https://developers.google.com/open-source/licenses/bsd
+
+use googletest::prelude::*;
+
+// Tests that an proto file that declares edition="2023" works. Note that this
+// is _not_ a test for Rust Edition 2023 (which doesn't exist) but instead
+// Protobuf Edition 2023 (which exists).
+
+#[test]
+fn check_edition2023_works() {
+ let mut msg = edition2023_proto::test::EditionsMessage::new();
+
+ // plain_field supports presence.
+ assert_that!(msg.plain_field_mut().or_default().get(), eq(0));
+
+ // implicit presence fields' _mut() skips FieldEntry.
+ assert_that!(msg.implicit_presence_field_mut().get(), eq(0));
+}