diff --git a/packages/core/tests/fuzzing.rs b/packages/core/tests/fuzzing.rs index 303ef768d..b16d9b3bb 100644 --- a/packages/core/tests/fuzzing.rs +++ b/packages/core/tests/fuzzing.rs @@ -2,7 +2,7 @@ use dioxus::prelude::Props; use dioxus_core::{MountedAttribute, *}; -use std::{cfg, collections::HashSet}; +use std::{cell::Cell, cfg, collections::HashSet}; fn random_ns() -> Option<&'static str> { let namespace = rand::random::() % 2; @@ -177,7 +177,7 @@ fn create_random_dynamic_node(cx: &ScopeState, depth: usize) -> DynamicNode { // Template { // ======= cx.vnode( - None, + None.into(), Default::default(), Cell::new(Template { // >>>>>>> 9fe172e9 (Fix leak in render macro) @@ -293,7 +293,7 @@ fn create_random_element(cx: Scope) -> Element { // ======= // println!("{template:#?}"); let node = cx.vnode( - None, + None.into(), None, Cell::new(template), bumpalo::collections::Vec::new_in(cx.bump()).into(), diff --git a/packages/native-core/tests/fuzzing.rs b/packages/native-core/tests/fuzzing.rs index 652ad301f..2496b1f1c 100644 --- a/packages/native-core/tests/fuzzing.rs +++ b/packages/native-core/tests/fuzzing.rs @@ -1,3 +1,5 @@ +use std::cell::Cell; + use dioxus::prelude::Props; use dioxus_core::*; use dioxus_native_core::prelude::*; @@ -178,27 +180,16 @@ fn create_random_dynamic_node(cx: &ScopeState, depth: usize) -> DynamicNode { match rand::random::() % range { 0 => DynamicNode::Placeholder(Default::default()), 1 => cx.make_node((0..(rand::random::() % 5)).map(|_| { - // <<<<<<< HEAD - // VNode::new( - // None, - // Template { - // ======= cx.vnode( - None, + None.into(), Default::default(), Cell::new(Template { - // >>>>>>> 9fe172e9 (Fix leak in render macro) name: concat!(file!(), ":", line!(), ":", column!(), ":0"), roots: &[TemplateNode::Dynamic { id: 0 }], node_paths: &[&[0]], attr_paths: &[], - // <<<<<<< HEAD - // }, - // dioxus::core::exports::bumpalo::collections::Vec::new_in(cx.bump()), - // ======= }), dioxus::core::exports::bumpalo::collections::Vec::new_in(cx.bump()).into(), - // >>>>>>> 9fe172e9 (Fix leak in render macro) cx.bump().alloc([cx.component( create_random_element, DepthProps { depth, root: false }, @@ -216,20 +207,6 @@ fn create_random_dynamic_node(cx: &ScopeState, depth: usize) -> DynamicNode { } } -fn create_random_dynamic_mounted_attr(cx: &ScopeState) -> MountedAttribute { - match rand::random::() % 2 { - 0 => MountedAttribute::from( - &*cx.bump().alloc( - (0..(rand::random::() % 3) as usize) - .map(|_| create_random_dynamic_attr(cx)) - .collect::>(), - ), - ), - 1 => MountedAttribute::from(create_random_dynamic_attr(cx)), - _ => unreachable!(), - } -} - fn create_random_dynamic_attr(cx: &ScopeState) -> Attribute { let value = match rand::random::() % 6 { 0 => AttributeValue::Text(Box::leak( @@ -242,6 +219,7 @@ fn create_random_dynamic_attr(cx: &ScopeState) -> Attribute { 5 => AttributeValue::None, _ => unreachable!(), }; + Attribute::new( Box::leak(format!("attr{}", rand::random::()).into_boxed_str()), value, @@ -278,18 +256,11 @@ fn create_random_element(cx: Scope) -> Element { .into_boxed_str(), )); println!("{template:#?}"); - // <<<<<<< HEAD - // let node = VNode::new( - // None, - // template, - // dioxus::core::exports::bumpalo::collections::Vec::new_in(cx.bump()), - // ======= let node = cx.vnode( - None, + None.into(), None, Cell::new(template), dioxus::core::exports::bumpalo::collections::Vec::new_in(cx.bump()).into(), - // >>>>>>> 9fe172e9 (Fix leak in render macro) { let dynamic_nodes: Vec<_> = dynamic_node_types .iter() @@ -304,21 +275,13 @@ fn create_random_element(cx: Scope) -> Element { .collect(); cx.bump().alloc(dynamic_nodes) }, - // <<<<<<< HEAD - // cx.bump() - // .alloc( - // (0..template.attr_paths.len()) - // .map(|_| create_random_dynamic_mounted_attr(cx)) - // .collect::>(), - // ) - // .as_slice(), - // ======= - cx.bump().alloc( - (0..template.attr_paths.len()) - .map(|_| create_random_dynamic_attr(cx)) - .collect::>(), - ), - // >>>>>>> 9fe172e9 (Fix leak in render macro) + cx.bump() + .alloc( + (0..template.attr_paths.len()) + .map(|_| create_random_dynamic_attr(cx).into()) + .collect::>(), + ) + .as_slice(), ); Some(node) } diff --git a/packages/rsx/src/lib.rs b/packages/rsx/src/lib.rs index 1680e338d..5e685680d 100644 --- a/packages/rsx/src/lib.rs +++ b/packages/rsx/src/lib.rs @@ -261,7 +261,7 @@ impl<'a> ToTokens for TemplateRenderer<'a> { // dioxus::core::exports::bumpalo::collections::Vec::with_capacity_in(#root_count, __cx.bump()), // ======= __cx.vnode( - None, + None.into(), #key_tokens, std::cell::Cell::new(TEMPLATE), dioxus::core::exports::bumpalo::collections::Vec::with_capacity_in(#root_count, __cx.bump()).into(),