bevyengine/bevy · error · syn::Error
`#[type_name = "..."]` must be a string literal
Error message
`#[type_name = "..."]` must be a string literal
What it means
Compile-time error from the Reflect derive macro (from_input): the #[type_name = "..."] attribute was given something other than a string literal. Rewrite the attribute value as an ordinary string literal.
Source
Thrown at crates/bevy_reflect/derive/src/derive_data.rs:234
else {
return Err(syn::Error::new(
pair.span(),
format_args!("`#[{TYPE_PATH_ATTRIBUTE_NAME} = \"...\"]` must be a string literal"),
));
};
custom_path = Some(syn::parse::Parser::parse_str(
parse_path_no_leading_colon,
&lit.value(),
)?);
}
Meta::NameValue(pair) if pair.path.is_ident(TYPE_NAME_ATTRIBUTE_NAME) => {
let syn::Expr::Lit(syn::ExprLit {
lit: syn::Lit::Str(lit),
..
}) = &pair.value
else {
return Err(syn::Error::new(
pair.span(),
format_args!("`#[{TYPE_NAME_ATTRIBUTE_NAME} = \"...\"]` must be a string literal"),
));
};
custom_type_name = Some(parse_str(&lit.value())?);
}
#[cfg(feature = "reflect_documentation")]
Meta::NameValue(pair) if pair.path.is_ident("doc") => {
if let syn::Expr::Lit(syn::ExprLit {
lit: syn::Lit::Str(lit),
..
}) = &pair.value
{
doc.push(lit.value());
}
}
_ => continue,View on GitHub (pinned to 396ca72708)
Solutions
- Change the #[type_name] attribute value to a string literal
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/bevy_reflect/derive/src/derive_data.rs:234 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20).
Data as JSON: /api/errors/f1d920ec68cbffb7.
Report an issue: GitHub.