Skip to content

Commit cf6bb2a

Browse files
committed
Test: reject union type
1 parent e16e8cd commit cf6bb2a

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

impl/src/types/fmt/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,19 @@ mod tests {
287287
"expected `display` to be a list attribute: `#[display(\"template...\")]`"
288288
);
289289
}
290+
291+
#[test]
292+
fn union_type_is_rejected() {
293+
let derive_input = syn::parse2::<DeriveInput>(
294+
quote! { union CustomType { f1: u32, f2: f32 } },
295+
)
296+
.expect("malformed test stream");
297+
let err = FormatData::new(&derive_input).expect_err(
298+
"stream with union type was parsed successfully as FormatData",
299+
);
300+
assert_eq!(
301+
err.to_string(),
302+
"`#[derive(Error)]` only supports structs and enums"
303+
);
304+
}
290305
}

0 commit comments

Comments
 (0)