瀏覽代碼

clean up unused code

Evan Almloff 2 年之前
父節點
當前提交
56154d90be

+ 0 - 45
packages/native-core-macro/src/lib.rs

@@ -35,35 +35,6 @@ fn impl_derive_macro(ast: &syn::DeriveInput) -> TokenStream {
         _ => unimplemented!(),
     };
 
-    let clone_or_default = fields.iter().map(|field| {
-        let field_name = field.ident.as_ref().unwrap();
-        let skip_clone = field
-            .attrs
-            .iter()
-            .any(|attr| attr.path.is_ident("skip_clone"));
-        if skip_clone {
-            quote! {
-                Default::default()
-            }
-        } else {
-            quote! {
-                self.#field_name.clone()
-            }
-        }
-    });
-
-    let non_clone_types = fields
-        .iter()
-        .filter(|field| {
-            field
-                .attrs
-                .iter()
-                .any(|attr| attr.path.is_ident("skip_clone"))
-        })
-        .map(|field| &field.ty);
-
-    let names = fields.iter().map(|field| field.ident.as_ref().unwrap());
-
     let types = fields
         .iter()
         .filter(|field| !field.attrs.iter().any(|attr| attr.path.is_ident("skip")))
@@ -78,22 +49,6 @@ fn impl_derive_macro(ast: &syn::DeriveInput) -> TokenStream {
                     ),*
                 ])
             }
-
-            fn clone_or_default(&self) -> Self {
-                Self {
-                    #(
-                        #names: #clone_or_default
-                    ),*
-                }
-            }
-
-            fn non_clone_members() -> Box<[std::any::TypeId]> {
-                Box::new([
-                    #(
-                        std::any::TypeId::of::<#non_clone_types>()
-                    ),*
-                ])
-            }
         }
     };
 

+ 1 - 1
packages/native-core/src/real_dom.rs

@@ -452,7 +452,7 @@ impl<S: State + Send> RealDom<S> {
     fn clone_node(&mut self, node_id: NodeId) -> NodeId {
         let node = self.tree.get(node_id).unwrap();
         let new_node = Node {
-            state: node.state.clone_or_default(),
+            state: node.state.clone(),
             node_data: node.node_data.clone(),
         };
         let new_id = self.create_node(new_node, true);

+ 0 - 11
packages/native-core/src/state.rs

@@ -1,5 +1,4 @@
 use crate::passes::{AnyMapLike, TypeErasedPass};
-use std::any::TypeId;
 use std::cmp::Ordering;
 
 /// Join two sorted iterators
@@ -41,14 +40,4 @@ pub(crate) fn union_ordered_iter<'a>(
 pub trait State: Default + Clone + AnyMapLike + 'static {
     #[doc(hidden)]
     fn create_passes() -> Box<[TypeErasedPass<Self>]>;
-
-    #[doc(hidden)]
-    fn clone_or_default(&self) -> Self {
-        self.clone()
-    }
-
-    #[doc(hidden)]
-    fn non_clone_members() -> Box<[TypeId]> {
-        Box::new([])
-    }
 }

+ 4 - 5
packages/tui/src/node.rs

@@ -9,7 +9,6 @@ pub(crate) type TuiNode = dioxus_native_core::node::Node<NodeState>;
 
 #[derive(Debug, Clone, State, AnyMapLike, Default)]
 pub(crate) struct NodeState {
-    #[skip_clone]
     pub layout: TaffyLayout,
     pub style: StyleModifier,
     pub prevent_default: PreventDefault,
@@ -59,12 +58,12 @@ impl Pass for PreventDefault {
     fn pass<'a>(
         &mut self,
         node_view: dioxus_native_core::node_ref::NodeView,
-        node: <Self::NodeDependencies as Dependancy>::ElementBorrowed<'a>,
-        parent: Option<<Self::ParentDependencies as Dependancy>::ElementBorrowed<'a>>,
-        children: Option<
+        _: <Self::NodeDependencies as Dependancy>::ElementBorrowed<'a>,
+        _: Option<<Self::ParentDependencies as Dependancy>::ElementBorrowed<'a>>,
+        _: Option<
             impl Iterator<Item = <Self::ChildDependencies as Dependancy>::ElementBorrowed<'a>>,
         >,
-        context: &SendAnyMap,
+        _: &SendAnyMap,
     ) -> bool {
         let new = match node_view.attributes().and_then(|mut attrs| {
             attrs