DioxusLabs/dioxus · error

doc attribute is not a name-value attribute

Error message

doc attribute is not a name-value attribute

What it means

While iterating a function's doc attributes in the fullstack macro, an attribute named doc was not in Meta::NameValue form. Doc comments are always name-value string literals when produced by rustc, so a hand-written #[doc = ...] of another shape triggers this guard in doc_iter.

Source

Thrown at packages/fullstack-macro/src/lib.rs:1318

        if self.summary.is_none() {
            self.summary = doc_iter(&function.attrs)
                .next()
                .map(|item| (parse_quote!(summary), item.clone()))
        }
        if self.id.is_none() {
            let id = &function.sig.ident;
            self.id = Some((parse_quote!(id), LitStr::new(&id.to_string(), id.span())));
        }
    }
}

fn doc_iter(attrs: &[Attribute]) -> impl Iterator<Item = &LitStr> + '_ {
    attrs
        .iter()
        .filter(|attr| attr.path().is_ident("doc"))
        .map(|attr| {
            let Meta::NameValue(meta) = &attr.meta else {
                panic!("doc attribute is not a name-value attribute");
            };
            let Expr::Lit(lit) = &meta.value else {
                panic!("doc attribute is not a string literal");
            };
            let Lit::Str(lit_str) = &lit.lit else {
                panic!("doc attribute is not a string literal");
            };
            lit_str
        })
}

struct Route {
    method: Option<Method>,
    path_params: Vec<(Slash, PathParam)>,
    query_params: Vec<QueryParam>,
    route_lit: Option<LitStr>,
    prefix: Option<LitStr>,
    oapi_options: Option<OapiOptions>,

View on GitHub (pinned to 24f6a829df)

Solutions

  1. Write the doc attribute in name-value form: #[doc = 'text'].
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/fullstack-macro/src/lib.rs:1318 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/4258834da3c16c33. Report an issue: GitHub.