{"record":{"id":"4d4176d4c3d48504","repo":"bevyengine/bevy","slug":"no-variant-found-with-the-from-world-attribut","errorCode":null,"errorMessage":"No variant found with the `#[from_world]` attribute","messagePattern":"No variant found with the `#\\[from_world\\]` attribute","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/macros/src/lib.rs","lineNumber":902,"sourceCode":"#[proc_macro_derive(FromWorld, attributes(from_world))]\npub fn derive_from_world(input: TokenStream) -> TokenStream {\n    let bevy_ecs_path = bevy_ecs_path();\n    let ast = parse_macro_input!(input as DeriveInput);\n    let name = ast.ident;\n    let (impl_generics, ty_generics, where_clauses) = ast.generics.split_for_impl();\n\n    let (fields, variant_ident) = match &ast.data {\n        Data::Struct(data) => (&data.fields, None),\n        Data::Enum(data) => {\n            match data.variants.iter().find(|variant| {\n                variant\n                    .attrs\n                    .iter()\n                    .any(|attr| attr.path().is_ident(\"from_world\"))\n            }) {\n                Some(variant) => (&variant.fields, Some(&variant.ident)),\n                None => {\n                    return syn::Error::new(\n                        Span::call_site(),\n                        \"No variant found with the `#[from_world]` attribute\",\n                    )\n                    .into_compile_error()\n                    .into();\n                }\n            }\n        }\n        Data::Union(_) => {\n            return syn::Error::new(\n                Span::call_site(),\n                \"#[derive(FromWorld)]` does not support unions\",\n            )\n            .into_compile_error()\n            .into();\n        }\n    };\n","sourceCodeStart":884,"sourceCodeEnd":920,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/macros/src/lib.rs#L884-L920","documentation":"Compile error from derive_from_world when the input is an enum: the search over variants for one carrying the #[from_world] attribute found none, so no variant was selected for the generated FromWorld impl. The derive requires exactly one designated variant on enums.","triggerScenarios":"Thrown at crates/bevy_ecs/macros/src/lib.rs:902 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Mark exactly one enum variant with #[from_world]: #[from_world] Variant(Type,)","Use a struct instead, where the whole type gets the derived FromWorld impl","Ensure the attribute spelling matches `from_world` exactly"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}