Skip to content

Commit 05af18d

Browse files
Use u32 instead of isize as the discriminant of the Rust oneof 'tagged union' enum type (which is used for the getter that gives you both which field is set and the value of that field).
Note that the oneof case enum (the enum to signals which case is set and not the value of that case) remains a repr(C) enum with no explicit storage type to be ABI compatible with the C++ case enum. PiperOrigin-RevId: 708315860
1 parent e7a4afe commit 05af18d

File tree

1 file changed

+1
-2
lines changed
  • src/google/protobuf/compiler/rust

1 file changed

+1
-2
lines changed

src/google/protobuf/compiler/rust/oneof.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ void GenerateOneofDefinition(Context& ctx, const OneofDescriptor& oneof) {
151151
}
152152
}},
153153
},
154-
// TODO: Revisit if isize is the optimal repr for this enum.
155154
// Note: This enum deliberately has a 'msg lifetime associated with it
156155
// even if all fields were scalars; we could conditionally exclude the
157156
// lifetime under that case, but it would mean changing the .proto file
@@ -161,7 +160,7 @@ void GenerateOneofDefinition(Context& ctx, const OneofDescriptor& oneof) {
161160
#[non_exhaustive]
162161
#[derive(Debug, Clone, Copy)]
163162
#[allow(dead_code)]
164-
#[repr(isize)]
163+
#[repr(u32)]
165164
pub enum $view_enum_name$<'msg> {
166165
$view_fields$
167166

0 commit comments

Comments
 (0)