bevyengine/bevy · error
Lifetimes must be 'static
Error message
Lifetimes must be 'static
What it means
Compile-time error from impl_component: the deriving type has generic lifetime parameters not bounded by 'static. Components must be 'static for storage in the ECS, so the derive adds a 'static requirement and fails when lifetimes cannot satisfy it.
Source
Thrown at crates/bevy_ecs/macro_logic/src/component.rs:194
Ok(attrs)
}
/// Generates a new `Component` trait implementation from this specification.
///
/// Note that this will add Send + Sync + 'static to the where clause
pub fn impl_component(
self,
ast: &mut DeriveInput,
bevy_ecs: &Path,
default_storage: StorageTy,
) -> Result<TokenStream> {
// We want to raise a compile time error when the generic lifetimes
// are not bound to 'static lifetime
let non_static_lifetime_error = ast
.generics
.lifetimes()
.filter(|lifetime| !lifetime.bounds.iter().any(|bound| bound.ident == "static"))
.map(|param| syn::Error::new(param.span(), "Lifetimes must be 'static"))
.reduce(|mut err_acc, err| {
err_acc.combine(err);
err_acc
});
if let Some(err) = non_static_lifetime_error {
return Err(err);
}
let relationship = match self.derive_relationship(ast, bevy_ecs) {
Ok(value) => value,
Err(err) => Some(err.into_compile_error()),
};
let relationship_target = match self.derive_relationship_target(ast, bevy_ecs) {
Ok(value) => value,
Err(err) => Some(err.into_compile_error()),
};
let map_entities = map_entities(View on GitHub (pinned to 396ca72708)
Solutions
- Add a 'static bound to the component's lifetimes (usually by requiring T: 'static style bounds)
- Use owned data (e.g. Box<str>, Arc) instead of borrowed lifetimes
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/bevy_ecs/macro_logic/src/component.rs:194 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/3bcfbd7d2167c296.
Report an issue: GitHub.