DioxusLabs/dioxus · error

literal in `deprecated` value must be a string

Error message

literal in `deprecated` value must be a string

What it means

While collecting a component's doc fields, the core macro found a #[deprecated] attribute whose value meta could not be parsed by DeprecatedAttribute::from_meta — the attribute's value must be a string literal. The panic surfaces the parse error string from the proc macro.

Solutions

  1. Write the deprecated attribute with a string literal, e.g. #[deprecated = 'use other instead'].
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/core-macro/src/component.rs:449 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/3ce8dfbf088f3dd4. Report an issue: GitHub.

Appendix: source

Thrown at packages/core-macro/src/component.rs:449

        })
        .fold(String::new(), |mut doc, next_doc_line| {
            doc.push('\n');
            doc.push_str(&next_doc_line);
            doc
        });

    Some(DocField {
        arg_name: &pt.pat,
        arg_type: &pt.ty,
        deprecation: pt.attrs.iter().find_map(|attr| {
            if !attr.path().is_ident("deprecated") {
                return None;
            }

            let res = crate::utils::DeprecatedAttribute::from_meta(&attr.meta);

            match res {
                Err(e) => panic!("{}", e.to_string()),
                Ok(v) => Some(v),
            }
        }),
        input_arg_doc: arg_doc,
    })
}

fn validate_component_fn(item_fn: &ItemFn) -> Result<()> {
    // Do some validation....
    // 1. Ensure the component returns *something*
    if item_fn.sig.output == ReturnType::Default {
        return Err(Error::new(
            item_fn.sig.output.span(),
            "Must return a <dioxus_core::Element>".to_string(),
        ));
    }

    // 2. make sure there's no lifetimes on the component - we don't know how to handle those

View on GitHub (pinned to 24f6a829df)