Skip to content

Commit

Permalink
compiler: Fix bug in snapshotting
Browse files Browse the repository at this point in the history
Do not `take` an ElementRc to move it into the `Component`'s `root_element`.

@ogoffart spotted this! Thanks!
  • Loading branch information
hunger committed Jul 5, 2024
1 parent 5dfa8d5 commit 4b42e42
Show file tree
Hide file tree
Showing 3 changed files with 267 additions and 154 deletions.
2 changes: 1 addition & 1 deletion internal/compiler/namedreference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl NamedReferenceInner {

pub(crate) fn snapshot(&self, snapshotter: &mut crate::typeloader::Snapshotter) -> Self {
let element = if let Some(el) = self.element.upgrade() {
Rc::downgrade(&snapshotter.snapshot_element(&el))
Rc::downgrade(&snapshotter.use_element(&el))
} else {
std::rc::Weak::default()
};
Expand Down
7 changes: 6 additions & 1 deletion internal/compiler/object_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2615,7 +2615,12 @@ impl Exports {
let en = en.clone();
let either = match either {
itertools::Either::Left(l) => {
itertools::Either::Left(snapshotter.snapshot_component(l))
itertools::Either::Left(if !snapshotter.has_component(l) {
snapshotter.create_component(l)
} else {
Weak::upgrade(&snapshotter.use_component(l))
.expect("Component should cleanly upgrade here")
})
}
itertools::Either::Right(r) => itertools::Either::Right(r.clone()),
};
Expand Down
Loading

0 comments on commit 4b42e42

Please sign in to comment.