bevyengine/bevy · error · syn::Error

cannot use `#[type_name = "..."]` without a `#[type_path = "

Error message

cannot use `#[type_name = "..."]` without a `#[type_path = "..."]` attribute.

What it means

Compile-time error from the Reflect derive macro: a #[type_name = "..."] attribute appeared without the required #[type_path = "..."] attribute. type_name only customizes the final identifier, so a type_path must accompany it; add the type_path attribute or remove type_name.

Source

Thrown at crates/bevy_reflect/derive/src/derive_data.rs:261

                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,
            }
        }
        match (&mut custom_path, custom_type_name) {
            (Some(path), custom_type_name) => {
                let ident = custom_type_name.unwrap_or_else(|| input.ident.clone());
                path.segments.push(PathSegment::from(ident));
            }
            (None, Some(name)) => {
                return Err(syn::Error::new(
                    name.span(),
                    format!("cannot use `#[{TYPE_NAME_ATTRIBUTE_NAME} = \"...\"]` without a `#[{TYPE_PATH_ATTRIBUTE_NAME} = \"...\"]` attribute."),
                ));
            }
            _ => (),
        }

        let type_path = ReflectTypePath::Internal {
            ident: &input.ident,
            custom_path,
            generics: &input.generics,
        };

        let meta = ReflectMeta::new(type_path, container_attributes);

        if provenance.source == ReflectImplSource::ImplRemoteType
            && meta.type_path_attrs().should_auto_derive()
            && !meta.type_path().has_custom_path()

View on GitHub (pinned to 396ca72708)

Solutions

  1. Add a #[type_path = "..."] attribute alongside #[type_name]
  2. Remove the #[type_name] attribute if a custom name is not needed
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/bevy_reflect/derive/src/derive_data.rs:261 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/087b5adf22c9f8cd. Report an issue: GitHub.