{"record":{"id":"7f56381019adb535","repo":"slint-ui/slint","slug":"components-written-in-rust-can-not-get-embedded-ye","errorCode":null,"errorMessage":"Components written in Rust can not get embedded yet.","messagePattern":"Components written in Rust can not get embedded yet\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/compiler/generator/rust.rs","lineNumber":2358,"sourceCode":"        quote!(SharedGlobals::new(sp::VRc::downgrade(&self_dyn_rc)))\n    };\n    // The root component owns the freshly created `SharedGlobals` and is responsible for running\n    // its eager initialization. The root's own `globals` field must be set *before* that init\n    // runs, because a global binding (e.g. `Palette.color-scheme`) may resolve the root's window\n    // adapter through `globals` during evaluation. Popups and sub-components receive an already\n    // initialized `SharedGlobals`, so they skip this step.\n    let set_and_init_globals = if is_root_component {\n        quote!(\n            let _ = sp::VRc::map(self_rc.clone(), |x| x).as_pin_ref().globals.set(globals.clone());\n            globals.init_globals();\n        )\n    } else {\n        quote!()\n    };\n    let globals_arg = is_popup.then(|| quote!(globals: sp::Rc<SharedGlobals>));\n\n    let embedding_function = if parent_ctx.is_some() {\n        quote!(todo!(\"Components written in Rust can not get embedded yet.\"))\n    } else {\n        quote!(false)\n    };\n\n    let parent_item_expression = parent_ctx.map(|parent| parent.repeater_index.map_or_else(|| {\n        // No repeater index, this could be a PopupWindow\n        quote!{\n            if let Some(parent_rc) = self.parent.clone().upgrade() {\n                let parent_origin = sp::VRcMapped::origin(&parent_rc);\n                // TODO: store popup index in ctx and set it here instead of 0?\n                *_result = sp::ItemRc::new_root(parent_origin).downgrade();\n            }\n        }\n    }, |idx| {\n        let current_sub_component = &root.sub_components[parent.sub_component];\n        let sub_component_offset = current_sub_component.repeated[idx].index_in_tree;\n\n        quote!{","sourceCodeStart":2340,"sourceCodeEnd":2376,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/internal/compiler/generator/rust.rs#L2340-L2376","documentation":"The Rust code generator emits a todo!() when it must generate code for a component that is embedded into a parent item tree, because embedding components written in Rust is not yet supported by the generator. The resulting binary panics at runtime with 'Components written in Rust can not get embedded yet.' if that code path executes.","triggerScenarios":"Compiling a .slint component that is instantiated inside another element's tree (parent_ctx.is_some()) rather than as a top-level component, when generating Rust code — i.e. an embedded/nested component in the Rust backend.","commonSituations":"Using advanced slint! setups where sub-components get embedded; popups or nested component instantiation patterns hitting the embedding path; migrating a design from the interpreter (which supports embedding) to generated Rust.","solutions":["Restructure the .slint so the Rust-generated component is only used as a top-level component, not embedded","Flatten the nesting: inline the child component's contents into the parent","Use the interpreter API for components that need embedding, or file an issue/upstream feature request"],"exampleFix":"// before (App.slint embeds Child generated for Rust)\ncomponent Child { ... } component App { Child {} }\n// after: make Child a top-level component and instantiate it from Rust as its own component instance","handlingStrategy":"validation","validationCode":"// design-time check: keep Rust-backend components top-level\ndfn/audit .slint files so no component intended for Rust codegen is nested inside another element tree","typeGuard":null,"tryCatchPattern":"// todo!() aborts; the guard is structural: never generate embedded Rust components\n// flatten nested components in the .slint before codegen","preventionTips":["Keep components instantiated from Rust as top-level components only","Prefer inlining child components in .slint markup over embedding patterns","Track upstream Slint issue for Rust component embedding before adopting nested designs"],"tags":["rust","codegen","compiler","unimplemented"],"backgroundTag":"unsupported-operation","analyzedSha":"3a7e700487dc74d404cad0726378053ab763d4e0","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}