DioxusLabs/dioxus · error · syn::Error

attribute path is not `deprecated`

Error message

attribute path is not `deprecated`

What it means

Guard in DeprecatedAttribute::from_meta: the caller passed a Meta whose path is not `deprecated`. This is a caller-contract violation of the helper (it only parses #[deprecated] metas) rather than user input error; component attribute collection filters for deprecated before calling.

Solutions

  1. Use the `deprecated` attribute path exactly, e.g. #[deprecated = "..."]; other attribute names are not accepted in this position.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/core-macro/src/utils.rs:48 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/9e2da5607fe48118. Report an issue: GitHub.

Appendix: source

Thrown at packages/core-macro/src/utils.rs:48

    let ty_formatted = ty_unformatted.replace(' ', "");

    ty_formatted.to_string()
}

/// Represents the `#[deprecated]` attribute.
///
/// You can use the [`DeprecatedAttribute::from_meta`] function to try to parse an attribute to this struct.
#[derive(Default)]
pub struct DeprecatedAttribute {
    pub since: Option<String>,
    pub note: Option<String>,
}

impl DeprecatedAttribute {
    /// Returns `None` if the given attribute was not a valid form of the `#[deprecated]` attribute.
    pub fn from_meta(meta: &Meta) -> syn::Result<Self> {
        if meta.path() != &parse_quote!(deprecated) {
            return Err(syn::Error::new(
                meta.span(),
                "attribute path is not `deprecated`",
            ));
        }

        match &meta {
            Meta::Path(_) => Ok(Self::default()),
            Meta::NameValue(name_value) => {
                let Expr::Lit(expr_lit) = &name_value.value else {
                    return Err(syn::Error::new(
                        name_value.span(),
                        "literal in `deprecated` value must be a string",
                    ));
                };

                Ok(Self {
                    since: None,
                    note: lit_to_string(expr_lit.lit.clone()).map(|s| s.trim().to_string()),

View on GitHub (pinned to 24f6a829df)