Allow error(transparent) inside an enum that has error("...")

This commit is contained in:
David Tolnay 2024-11-05 16:59:45 -05:00
parent 71adf02435
commit 65f1990265
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82

View file

@ -91,14 +91,13 @@ impl<'a> Enum<'a> {
.iter()
.map(|node| {
let mut variant = Variant::from_syn(node, &scope)?;
if let display @ None = &mut variant.attrs.display {
display.clone_from(&attrs.display);
if variant.attrs.display.is_none() && variant.attrs.transparent.is_none() {
variant.attrs.display.clone_from(&attrs.display);
variant.attrs.transparent = attrs.transparent;
}
if let Some(display) = &mut variant.attrs.display {
let container = ContainerKind::from_variant(node);
display.expand_shorthand(&variant.fields, container)?;
} else if variant.attrs.transparent.is_none() {
variant.attrs.transparent = attrs.transparent;
}
Ok(variant)
})