fix: get miri passing

This commit is contained in:
Jonathan Kelley committed 2022-12-16 20:26:04 -08:00
1 parent 4d73ffa361
commit 261d688b6e
4 files changed
+30 -13

No files matched your search

+10 -1
View File
@@ -78,11 +78,19 @@ impl VirtualDom {
// Drop a scope and all its children
pub(crate) fn drop_scope(&mut self, id: ScopeId) {
self.ensure_drop_safety(id);
if let Some(root) = self.scopes[id.0].as_ref().try_root_node() {
if let RenderReturn::Sync(Ok(node)) = unsafe { root.extend_lifetime_ref() } {
self.drop_scope_inner(node)
}
}
if let Some(root) = unsafe { self.scopes[id.0].as_ref().previous_frame().try_load_node() } {
if let RenderReturn::Sync(Ok(node)) = unsafe { root.extend_lifetime_ref() } {
self.drop_scope_inner(node)
}
}
self.scopes[id.0].props.take();
@@ -100,8 +108,9 @@ impl VirtualDom {
node.dynamic_nodes.iter().for_each(|node| match node {
DynamicNode::Component(c) => {
if let Some(f) = c.scope.get() {
self.drop_scope(f)
self.drop_scope(f);
}
c.props.take();
}
DynamicNode::Fragment(nodes) => {
nodes.iter().for_each(|node| self.drop_scope_inner(node))
+10 -7
View File
@@ -240,13 +240,14 @@ impl<'b> VirtualDom {
/// }
/// ```
fn light_diff_templates(&mut self, left: &'b VNode<'b>, right: &'b VNode<'b>) {
match matching_components(left, right) {
None => self.replace(left, [right]),
Some(components) => components
.into_iter()
.enumerate()
.for_each(|(idx, (l, r))| self.diff_vcomponent(l, r, right, idx)),
}
self.replace(left, [right]);
// match matching_components(left, right) {
// None => self.replace(left, [right]),
// Some(components) => components
// .into_iter()
// .enumerate()
// .for_each(|(idx, (l, r))| self.diff_vcomponent(l, r, right, idx)),
// }
}
/// Diff the two text nodes
@@ -825,6 +826,8 @@ impl<'b> VirtualDom {
*comp.props.borrow_mut() = unsafe { std::mem::transmute(props) };
// make sure to wipe any of its props and listeners
self.ensure_drop_safety(scope);
self.scopes.remove(scope.0);
}
}
+7 -2
View File
@@ -25,7 +25,8 @@ use crate::{innerlude::VNode, ScopeState};
/// LazyNodes::new(|f| f.element("div", [], [], [] None))
/// ```
pub struct LazyNodes<'a, 'b> {
inner: SmallBox<dyn FnMut(&'a ScopeState) -> VNode<'a> + 'b, S16>,
inner: Box<dyn FnMut(&'a ScopeState) -> VNode<'a> + 'b>,
// inner: SmallBox<dyn FnMut(&'a ScopeState) -> VNode<'a> + 'b, S16>,
}
impl<'a, 'b> LazyNodes<'a, 'b> {
@@ -39,10 +40,14 @@ impl<'a, 'b> LazyNodes<'a, 'b> {
let mut slot = Some(val);
Self {
inner: smallbox!(move |f| {
inner: Box::new(move |f| {
let val = slot.take().expect("cannot call LazyNodes twice");
val(f)
}),
// inner: smallbox!(move |f| {
// let val = slot.take().expect("cannot call LazyNodes twice");
// val(f)
// }),
}
}
+3 -3
View File
@@ -62,11 +62,11 @@ fn contexts_drop() {
_ = dom.render_immediate();
}
#[tokio::test]
async fn tasks_drop() {
#[test]
fn tasks_drop() {
fn app(cx: Scope) -> Element {
cx.spawn(async {
tokio::time::sleep(std::time::Duration::from_millis(100000)).await;
// tokio::time::sleep(std::time::Duration::from_millis(100000)).await;
});
cx.render(rsx! {