DioxusLabs/dioxus · error · syn::Error

css_module cannot be applied to generic structs

Error message

css_module cannot be applied to generic structs

What it means

Error "css_module cannot be applied to generic structs" thrown in DioxusLabs/dioxus.

Source

Thrown at packages/manganis/manganis-macro/src/css_module.rs:56

    }
}

pub(crate) fn expand_css_module_struct(
    tokens: &mut proc_macro2::TokenStream,
    attribute: &CssModuleAttribute,
    item_struct: &ItemStruct,
) {
    if !item_struct.fields.is_empty() {
        let err = syn::Error::new(
            item_struct.fields.span(),
            "css_module can only be applied to unit structs",
        )
        .into_compile_error();
        tokens.append_all(err);
        return;
    }
    if !item_struct.generics.params.is_empty() {
        let err = syn::Error::new(
            item_struct.generics.span(),
            "css_module cannot be applied to generic structs",
        )
        .into_compile_error();
        tokens.append_all(err);
        return;
    }
    let struct_vis = &item_struct.vis;
    let struct_name = &item_struct.ident;
    let struct_name_private = format_ident!("__{}", struct_name);

    // Use the regular asset parser to generate the linker bridge.
    let mut linker_tokens = quote! {
        /// Auto-generated Manganis asset for css modules.
        #[allow(missing_docs)]
        const ASSET: manganis::Asset =
    };
    attribute.asset_parser.to_tokens(&mut linker_tokens);

View on GitHub (pinned to 393d190a80)

When it happens

Trigger: Thrown at packages/manganis/manganis-macro/src/css_module.rs:56 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of DioxusLabs/dioxus@393d190a80 (2026-08-16). Data as JSON: /api/errors/9251908002613c57. Report an issue: GitHub.