Skip to content

Commit

Permalink
Fail with an understandable message is number of fields for serializa…
Browse files Browse the repository at this point in the history
…tion is too many
  • Loading branch information
Mingun committed Aug 11, 2024
1 parent fd5b5e9 commit 005cb84
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion serde_derive/src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,13 @@ fn serialize_tuple_struct(
}

fn serialize_struct(params: &Parameters, fields: &[Field], cattrs: &attr::Container) -> Fragment {
assert!(fields.len() as u64 <= u64::from(u32::MAX));
assert!(
fields.len() as u64 <= u64::from(u32::MAX),
"too many fields in {}: {}, maximum supported count is {}",
cattrs.name().serialize_name(),
fields.len(),
u32::MAX
);

if cattrs.has_flatten() {
serialize_struct_as_map(params, fields, cattrs)
Expand Down

0 comments on commit 005cb84

Please # to comment.