bevyengine/bevy · error · syn::Error

#[derive({derive_name})] must be accompanied by #[specialize

Error message

#[derive({derive_name})] must be accompanied by #[specialize(..targets)].
 Example usages: #[specialize(RenderPipeline)], #[specialize(all)]

What it means

The `Specializer` (and `SpecializerKey`) derive requires a companion `#[specialize(..targets)]` attribute on the same type naming the pipelines to implement for: either `all` or a comma-separated list of target paths. If no such list attribute is found on the derive input, the macro fails with this error at the call site.

Source

Thrown at crates/bevy_render/macros/src/specializer.rs:204

    }

    Ok(field_info)
}

fn get_specialize_targets(
    ast: &DeriveInput,
    derive_name: &str,
) -> syn::Result<SpecializeImplTargets> {
    let specialize_attr = ast.attrs.iter().find_map(|attr| {
        if attr.path().is_ident(SPECIALIZE_ATTR_IDENT)
            && let Meta::List(meta_list) = &attr.meta
        {
            return Some(meta_list);
        }
        None
    });
    let Some(specialize_meta_list) = specialize_attr else {
        return Err(syn::Error::new(
            Span::call_site(),
            format!("#[derive({derive_name})] must be accompanied by #[specialize(..targets)].\n Example usages: #[specialize(RenderPipeline)], #[specialize(all)]")
        ));
    };
    syn::parse::<SpecializeImplTargets>(specialize_meta_list.tokens.clone().into())
}

macro_rules! guard {
    ($expr: expr) => {
        match $expr {
            Ok(__val) => __val,
            Err(err) => return err.to_compile_error().into(),
        }
    };
}

pub fn impl_specializer(input: TokenStream) -> TokenStream {
    let bevy_render_path: Path = crate::bevy_render_path();

View on GitHub (pinned to 396ca72708)

Solutions

  1. Add `#[specialize(all)]` or `#[specialize(SomeTargetPath)]` directly on the type carrying the derive
  2. Write it as a list: `#[specialize(RenderPipeline)]`, not `#[specialize]`
  3. Make sure the attribute path is exactly `specialize` (the derive only recognizes that identifier)

Example fix

// before
#[derive(Specializer)]
struct MyPipeline;

// after
#[derive(Specializer)]
#[specialize(all)]
struct MyPipeline;
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: `#[derive(Specializer)]` on a type without any `#[specialize(...)]` attribute, or with a bare `#[specialize]` that has no parenthesized list payload.

Common situations: Adding the derive via IDE completion without the helper attribute; renaming the attribute so it no longer matches the exact `specialize` path; deleting the attribute while cleaning up 'unused' lints.

Related errors


AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20). Data as JSON: /api/errors/184897aed3f2fb80. Report an issue: GitHub.