Skip to content

Commit

Permalink
Use u32 instead of isize as the discriminant of the Rust oneof 'tagge…
Browse files Browse the repository at this point in the history
…d 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
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Dec 20, 2024
1 parent e7a4afe commit 05af18d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/google/protobuf/compiler/rust/oneof.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ void GenerateOneofDefinition(Context& ctx, const OneofDescriptor& oneof) {
}
}},
},
// TODO: Revisit if isize is the optimal repr for this enum.
// Note: This enum deliberately has a 'msg lifetime associated with it
// even if all fields were scalars; we could conditionally exclude the
// lifetime under that case, but it would mean changing the .proto file
Expand All @@ -161,7 +160,7 @@ void GenerateOneofDefinition(Context& ctx, const OneofDescriptor& oneof) {
#[non_exhaustive]
#[derive(Debug, Clone, Copy)]
#[allow(dead_code)]
#[repr(isize)]
#[repr(u32)]
pub enum $view_enum_name$<'msg> {
$view_fields$
Expand Down

0 comments on commit 05af18d

Please sign in to comment.