DioxusLabs/dioxus · error · syn::Error

Only structs and enums are supported

Error message

Only structs and enums are supported

What it means

Catch-all rejection in derive_parse for the SerializeConst derive: the annotated item is neither a struct nor an enum (i.e. a union). The derive input at fault is the union declaration; only structs and enums get a SerializeConst impl.

Solutions

  1. Derive the const-serialize trait only on structs and enums, not on this item kind.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/const-serialize-macro/src/lib.rs:230 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23). Data as JSON: /api/errors/d045a5452c446be1. Report an issue: GitHub.

Appendix: source

Thrown at packages/const-serialize-macro/src/lib.rs:230

                        const MEMORY_LAYOUT: #krate::Layout = #krate::Layout::Enum(#krate::EnumLayout::new(
                            ::std::mem::size_of::<Self>(),
                            #krate::PrimitiveLayout::new(
                                #discriminant_size as usize,
                            ),
                            {
                                const DATA: &'static [#krate::EnumVariant] = &[
                                    #(
                                        #variants,
                                    )*
                                ];
                                DATA
                            },
                        ));
                    }
                }.into()
            }
        },
        _ => syn::Error::new(input.ident.span(), "Only structs and enums are supported")
            .to_compile_error()
            .into(),
    }
}

View on GitHub (pinned to 24f6a829df)