Commit aba2075
Add #[non_exhaustive] on the oneof-case enum
The enum for the oneof accessor (which holds a both which case was set and the value of that field as a tagged-union) was already marked non_exhaustive, but the Case enum (which only signals which field is set) was not.
There are known tradeoffs to this choice: in other languages we are generally comfortable treating the oneof case enum as closed and letting people write exhaustive switches on the case enum if they want to.
The main reason to do this in Rust is because people may use protobuf messages as their exposed API on a Rust library: adding a new field to a preexisting message should not demand a semver major version bump for that library. With messages, enums, non-oneof fields, and enum-values the gencode is already designed such that adding to it would not be a breaking change, but only for "fields in oneofs" adding a new field to the message would result in a semver breaking change and require a major version bump on that Rust crate API due unless we make the case enum non_exhaustive.
PiperOrigin-RevId: 7549052681 parent 9e9ecf6 commit aba2075
1 file changed
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| 193 | + | |
193 | 194 | | |
194 | 195 | | |
195 | 196 | | |
| |||
0 commit comments