{"record":{"id":"4fba559ccc4434a1","repo":"slint-ui/slint","slug":"component-should-cleanly-upgrade-here","errorCode":null,"errorMessage":"Component should cleanly upgrade here","messagePattern":"Component should cleanly upgrade here","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/compiler/object_tree.rs","lineNumber":5028,"sourceCode":"    }\n\n    pub fn retain(\n        &mut self,\n        func: impl FnMut(&mut (ExportedName, Either<Rc<Component>, Type>)) -> bool,\n    ) {\n        self.components_or_types.retain_mut(func)\n    }\n\n    pub(crate) fn snapshot(&self, snapshotter: &mut crate::typeloader::Snapshotter) -> Self {\n        let components_or_types = self\n            .components_or_types\n            .iter()\n            .map(|(en, either)| {\n                let en = en.clone();\n                let either = match either {\n                    itertools::Either::Left(l) => itertools::Either::Left({\n                        Weak::upgrade(&snapshotter.use_component(l))\n                            .expect(\"Component should cleanly upgrade here\")\n                    }),\n                    itertools::Either::Right(r) => itertools::Either::Right(r.clone()),\n                };\n                (en, either)\n            })\n            .collect();\n\n        Self { components_or_types }\n    }\n}\n\nimpl std::iter::IntoIterator for Exports {\n    type Item = (ExportedName, Either<Rc<Component>, Type>);\n\n    type IntoIter = std::vec::IntoIter<Self::Item>;\n\n    fn into_iter(self) -> Self::IntoIter {\n        self.components_or_types.into_iter()","sourceCodeStart":5010,"sourceCodeEnd":5046,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/internal/compiler/object_tree.rs#L5010-L5046","documentation":"This panic occurs in object_tree.rs:4968 during the component snapshotting/restore logic. The code maps entries of `use_component` weak references back to strong `Component` references and asserts the `Weak::upgrade` succeeds — the referenced component must still be alive at this point in the pipeline. If it was already dropped, the compiler's ownership invariant around component snapshots is violated.","triggerScenarios":"Running the compiler pass that restores recorded component usage (rebuilding a map from en -> Either<Weak<Component>, ...>) when a recorded weak component reference has been freed — e.g. components dropped between snapshot and restore due to a pass-ordering bug or re-entrant compilation of the same document.","commonSituations":"Compiler development touching the snapshot/restore mechanism (e.g. around `compile_with_builtin_libraries` or dependency tracking); nightly compiler builds; unusual import graphs that cause components to be dropped early.","solutions":["Retry compilation with the latest stable Slint compiler version to rule out a known regression.","Simplify the .slint import graph — remove cyclic or redundant imports that may interact with the snapshot mechanism.","For compiler contributors: verify `use_component` entries are kept alive (strong refs held) until this restore point runs.","File a minimal reproducer as a compiler bug."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Prefer flat, acyclic import graphs\nfn validate_imports(files: &[String]) -> Result<(), String> {\n    // reject duplicate and cyclic imports before invoking the compiler\n    // e.g. build a graph and check with toposort\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid redundant/cyclic .slint imports that stress the snapshot mechanism.","Compile with stable Slint releases, not ad-hoc builds.","Contributors: hold strong references to snapshotted components until restore completes."],"tags":["rust","compiler","internal-panic","weak-reference"],"backgroundTag":"internal-invariant-violation","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"}