diff --git a/rust/test/shared/accessors_test.rs b/rust/test/shared/accessors_test.rs index b33b51a1e0..a0d21890fe 100644 --- a/rust/test/shared/accessors_test.rs +++ b/rust/test/shared/accessors_test.rs @@ -34,14 +34,16 @@ use unittest_proto::proto2_unittest::TestAllTypes; #[test] fn test_default_accessors() { let msg = TestAllTypes::new(); - assert_eq!(msg.default_fixed32(), 47); - assert_eq!(msg.default_fixed64(), 48); assert_eq!(msg.default_int32(), 41); assert_eq!(msg.default_int64(), 42); - assert_eq!(msg.default_sint32(), -45); - assert_eq!(msg.default_sint64(), 46); assert_eq!(msg.default_uint32(), 43); assert_eq!(msg.default_uint64(), 44); + assert_eq!(msg.default_sint32(), -45); + assert_eq!(msg.default_sint64(), 46); + assert_eq!(msg.default_fixed32(), 47); + assert_eq!(msg.default_fixed64(), 48); + assert_eq!(msg.default_sfixed32(), 49); + assert_eq!(msg.default_sfixed64(), -50); assert_eq!(msg.default_float(), 51.5); assert_eq!(msg.default_double(), 52000.0); assert_eq!(msg.default_bool(), true); diff --git a/src/google/protobuf/compiler/rust/accessors/accessors.cc b/src/google/protobuf/compiler/rust/accessors/accessors.cc index 728dba2f57..d0b5ffaa39 100644 --- a/src/google/protobuf/compiler/rust/accessors/accessors.cc +++ b/src/google/protobuf/compiler/rust/accessors/accessors.cc @@ -53,6 +53,8 @@ std::unique_ptr AccessorGenerator::For( case FieldDescriptor::TYPE_INT64: case FieldDescriptor::TYPE_FIXED32: case FieldDescriptor::TYPE_FIXED64: + case FieldDescriptor::TYPE_SFIXED32: + case FieldDescriptor::TYPE_SFIXED64: case FieldDescriptor::TYPE_SINT32: case FieldDescriptor::TYPE_SINT64: case FieldDescriptor::TYPE_UINT32: diff --git a/src/google/protobuf/compiler/rust/naming.cc b/src/google/protobuf/compiler/rust/naming.cc index 2cb3897b10..ee2cb924b2 100644 --- a/src/google/protobuf/compiler/rust/naming.cc +++ b/src/google/protobuf/compiler/rust/naming.cc @@ -111,20 +111,18 @@ absl::string_view PrimitiveRsTypeName(Context field) { switch (field.desc().type()) { case FieldDescriptor::TYPE_BOOL: return "bool"; - case FieldDescriptor::TYPE_FIXED32: - return "i32"; - case FieldDescriptor::TYPE_FIXED64: - return "i64"; case FieldDescriptor::TYPE_INT32: - return "i32"; - case FieldDescriptor::TYPE_INT64: - return "i64"; case FieldDescriptor::TYPE_SINT32: + case FieldDescriptor::TYPE_SFIXED32: return "i32"; + case FieldDescriptor::TYPE_INT64: case FieldDescriptor::TYPE_SINT64: + case FieldDescriptor::TYPE_SFIXED64: return "i64"; + case FieldDescriptor::TYPE_FIXED32: case FieldDescriptor::TYPE_UINT32: return "u32"; + case FieldDescriptor::TYPE_FIXED64: case FieldDescriptor::TYPE_UINT64: return "u64"; case FieldDescriptor::TYPE_FLOAT: @@ -140,25 +138,6 @@ absl::string_view PrimitiveRsTypeName(Context field) { return ""; } -bool IsSupportedFieldType(Context field) { - return !field.desc().is_repeated() && - // We do not support [ctype=FOO] (used to set the field type in C++ to - // cord or string_piece) in V0 API. - !field.desc().options().has_ctype() && - (field.desc().type() == FieldDescriptor::TYPE_BOOL || - field.desc().type() == FieldDescriptor::TYPE_FIXED32 || - field.desc().type() == FieldDescriptor::TYPE_FIXED64 || - field.desc().type() == FieldDescriptor::TYPE_INT32 || - field.desc().type() == FieldDescriptor::TYPE_INT64 || - field.desc().type() == FieldDescriptor::TYPE_SINT32 || - field.desc().type() == FieldDescriptor::TYPE_SINT64 || - field.desc().type() == FieldDescriptor::TYPE_UINT32 || - field.desc().type() == FieldDescriptor::TYPE_UINT64 || - field.desc().type() == FieldDescriptor::TYPE_FLOAT || - field.desc().type() == FieldDescriptor::TYPE_DOUBLE || - field.desc().type() == FieldDescriptor::TYPE_BYTES); -} - std::string RustModule(Context msg) { absl::string_view package = msg.desc().file()->package(); if (package.empty()) return ""; diff --git a/src/google/protobuf/compiler/rust/naming.h b/src/google/protobuf/compiler/rust/naming.h index 07dba8796e..757e08df57 100644 --- a/src/google/protobuf/compiler/rust/naming.h +++ b/src/google/protobuf/compiler/rust/naming.h @@ -51,8 +51,6 @@ std::string GetHeaderFile(Context file); std::string Thunk(Context field, absl::string_view op); std::string Thunk(Context msg, absl::string_view op); -bool IsSupportedFieldType(Context field); - absl::string_view PrimitiveRsTypeName(Context field); std::string FieldInfoComment(Context field);