From c7ca7c227325dee85fec0f1bc7d8ab00cbf68f66 Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Tue, 13 Jul 2021 16:48:47 -0400 Subject: [PATCH] wip: cargo fix --- packages/core/src/arena.rs | 8 ++++---- packages/core/src/context.rs | 24 +++++++++++----------- packages/core/src/diff.rs | 34 ++++++++++++++++---------------- packages/core/src/events.rs | 2 +- packages/core/src/nodes.rs | 12 +++++------ packages/core/src/scope.rs | 14 ++++++------- packages/core/src/tasks.rs | 8 ++++---- packages/core/src/util.rs | 27 ++++++++++++------------- packages/core/src/virtual_dom.rs | 6 +++--- 9 files changed, 67 insertions(+), 68 deletions(-) diff --git a/packages/core/src/arena.rs b/packages/core/src/arena.rs index c8e519413..82415d45f 100644 --- a/packages/core/src/arena.rs +++ b/packages/core/src/arena.rs @@ -59,8 +59,8 @@ impl SharedArena { pub fn with_scope<'b, O: 'static>( &'b self, - id: ScopeIdx, - f: impl FnOnce(&'b mut Scope) -> O, + _id: ScopeIdx, + _f: impl FnOnce(&'b mut Scope) -> O, ) -> Result { todo!() } @@ -69,8 +69,8 @@ impl SharedArena { // this is useful for merging lifetimes pub fn with_scope_vnode<'b>( &self, - id: ScopeIdx, - f: impl FnOnce(&mut Scope) -> &VNode<'b>, + _id: ScopeIdx, + _f: impl FnOnce(&mut Scope) -> &VNode<'b>, ) -> Result<&VNode<'b>> { todo!() } diff --git a/packages/core/src/context.rs b/packages/core/src/context.rs index b38b83b8e..8993715ae 100644 --- a/packages/core/src/context.rs +++ b/packages/core/src/context.rs @@ -1,13 +1,13 @@ -use crate::hooklist::HookList; -use crate::{arena::SharedArena, innerlude::*}; -use appendlist::AppendList; -use bumpalo::Bump; -use futures_util::{pin_mut, FutureExt}; -use slotmap::DefaultKey; -use slotmap::SlotMap; + +use crate::{innerlude::*}; + + +use futures_util::{FutureExt}; + + use std::borrow::BorrowMut; use std::marker::PhantomData; -use std::sync::{Arc, RwLock}; + use std::{ any::{Any, TypeId}, cell::{Cell, RefCell}, @@ -137,7 +137,7 @@ impl<'src, P> Context<'src, P> { self, initializer: Init, runner: Run, - cleanup: Cleanup, + _cleanup: Cleanup, ) -> Output where State: 'static, @@ -280,7 +280,7 @@ Any function prefixed with "use" should not be called conditionally. /// /// /// - pub fn submit_task(&self, task: Pin>>) -> TaskHandle { + pub fn submit_task(&self, _task: Pin>>) -> TaskHandle { // let r = task.then(|f| async { // // // }); @@ -356,8 +356,8 @@ Any function prefixed with "use" should not be called conditionally. /// pub fn suspend( &'src self, - task_initializer: impl FnOnce() -> Fut + 'src, - callback: impl FnOnce(SuspendedContext, Out) -> VNode<'src> + 'src, + _task_initializer: impl FnOnce() -> Fut + 'src, + _callback: impl FnOnce(SuspendedContext, Out) -> VNode<'src> + 'src, ) -> VNode<'src> where Out: 'src, diff --git a/packages/core/src/diff.rs b/packages/core/src/diff.rs index 72cd3a2cb..c7b747898 100644 --- a/packages/core/src/diff.rs +++ b/packages/core/src/diff.rs @@ -49,7 +49,7 @@ //! - https://hacks.mozilla.org/2019/03/fast-bump-allocated-virtual-doms-with-rust-and-wasm/ use crate::{arena::SharedArena, innerlude::*, tasks::TaskQueue}; -use fxhash::{FxHashMap, FxHashSet}; +use fxhash::{FxHashSet}; use std::any::Any; @@ -360,9 +360,9 @@ where attributes, children, namespace, - static_attrs, - static_children, - static_listeners, + static_attrs: _, + static_children: _, + static_listeners: _, } = el; let real_id = if let Some(namespace) = namespace { @@ -559,7 +559,7 @@ impl<'a, 'bump, Dom: RealDom<'bump>> DiffMachine<'a, 'bump, Dom> { // if any characteristics changed, remove and then re-add // if nothing changed, then just move on - let event_type = new_l.event; + let _event_type = new_l.event; for old_l in old { if new_l.event == old_l.event { @@ -821,8 +821,8 @@ impl<'a, 'bump, Dom: RealDom<'bump>> DiffMachine<'a, 'bump, Dom> { // Upon exit, the change list stack is the same. fn diff_keyed_prefix( &self, - old: &'bump [VNode<'bump>], - new: &'bump [VNode<'bump>], + _old: &'bump [VNode<'bump>], + _new: &'bump [VNode<'bump>], ) -> KeyedPrefixResult { todo!() // self.dom.go_down(); @@ -910,11 +910,11 @@ impl<'a, 'bump, Dom: RealDom<'bump>> DiffMachine<'a, 'bump, Dom> { // Upon exit from this function, it will be restored to that same state. fn diff_keyed_middle( &self, - old: &[VNode<'bump>], - mut new: &[VNode<'bump>], - shared_prefix_count: usize, - shared_suffix_count: usize, - old_shared_suffix_start: usize, + _old: &[VNode<'bump>], + _new: &[VNode<'bump>], + _shared_prefix_count: usize, + _shared_suffix_count: usize, + _old_shared_suffix_start: usize, ) { todo!() // // Should have already diffed the shared-key prefixes and suffixes. @@ -1138,9 +1138,9 @@ impl<'a, 'bump, Dom: RealDom<'bump>> DiffMachine<'a, 'bump, Dom> { // When this function exits, the change list stack remains the same. fn diff_keyed_suffix( &self, - old: &[VNode<'bump>], - new: &[VNode<'bump>], - new_shared_suffix_start: usize, + _old: &[VNode<'bump>], + _new: &[VNode<'bump>], + _new_shared_suffix_start: usize, ) { todo!() // debug_assert_eq!(old.len(), new.len()); @@ -1178,7 +1178,7 @@ impl<'a, 'bump, Dom: RealDom<'bump>> DiffMachine<'a, 'bump, Dom> { // [... parent child] // todo!() - for (i, (new_child, old_child)) in new.iter().zip(old.iter()).enumerate() { + for (_i, (new_child, old_child)) in new.iter().zip(old.iter()).enumerate() { // [... parent prev_child] // self.dom.go_to_sibling(i); // [... parent this_child] @@ -1247,7 +1247,7 @@ impl<'a, 'bump, Dom: RealDom<'bump>> DiffMachine<'a, 'bump, Dom> { pub fn remove_self_and_next_siblings(&self, old: &[VNode<'bump>]) { // debug_assert!(self.dom.traversal_is_committed()); for child in old { - if let VNodeKind::Component(vcomp) = child.kind { + if let VNodeKind::Component(_vcomp) = child.kind { // dom // .create_text_node("placeholder for vcomponent"); diff --git a/packages/core/src/events.rs b/packages/core/src/events.rs index c3cd9b8d6..1fb836e12 100644 --- a/packages/core/src/events.rs +++ b/packages/core/src/events.rs @@ -4,7 +4,7 @@ //! 3rd party renderers are responsible for converting their native events into these virtual event types. Events might //! be heavy or need to interact through FFI, so the events themselves are designed to be lazy. -use std::{cell::Cell, ops::Deref, rc::Rc}; + use crate::innerlude::{RealDomNode, ScopeIdx}; diff --git a/packages/core/src/nodes.rs b/packages/core/src/nodes.rs index f63e85633..7f09e7573 100644 --- a/packages/core/src/nodes.rs +++ b/packages/core/src/nodes.rs @@ -173,10 +173,10 @@ impl<'a> NodeFactory<'a> { pub fn raw_element( &self, - tag: &'static str, - listeners: &[Listener], - attributes: &[Attribute], - children: &'a [VNode<'a>], + _tag: &'static str, + _listeners: &[Listener], + _attributes: &[Attribute], + _children: &'a [VNode<'a>], ) -> VNode<'a> { todo!() } @@ -295,7 +295,7 @@ impl<'a> NodeFactory<'a> { let res = component(cx); // submit any async tasks to the scope - for task in tasks.borrow_mut().drain(..) { + for _task in tasks.borrow_mut().drain(..) { // scp.submit_task(task); } @@ -453,7 +453,7 @@ impl Debug for VNode<'_> { } mod tests { - use super::*; + static B1: &str = "hello world!"; static B2: &str = "hello world!"; diff --git a/packages/core/src/scope.rs b/packages/core/src/scope.rs index 0e833d8df..eeb90bba2 100644 --- a/packages/core/src/scope.rs +++ b/packages/core/src/scope.rs @@ -1,11 +1,11 @@ use crate::hooklist::HookList; use crate::{arena::SharedArena, innerlude::*}; -use appendlist::AppendList; -use bumpalo::Bump; -use slotmap::DefaultKey; -use slotmap::SlotMap; -use std::marker::PhantomData; -use std::sync::Arc; + + + + + + use std::{ any::{Any, TypeId}, cell::{Cell, RefCell}, @@ -182,7 +182,7 @@ impl Scope { self.arena_idx ); - let mut listners = self.listeners.borrow_mut(); + let listners = self.listeners.borrow_mut(); // let listener = listners.get(trigger); let raw_listener = listners.iter().find(|(domptr, _)| { diff --git a/packages/core/src/tasks.rs b/packages/core/src/tasks.rs index 4a7aec86e..3fd8067b7 100644 --- a/packages/core/src/tasks.rs +++ b/packages/core/src/tasks.rs @@ -16,7 +16,7 @@ use std::{ task::{Context, Poll}, }; -use futures_util::{Future, Stream, StreamExt}; +use futures_util::{Future, Stream}; use slotmap::{DefaultKey, SlotMap}; use crate::{events::EventTrigger, innerlude::ScopeIdx}; @@ -64,19 +64,19 @@ impl Stream for TaskQueue { /// We can never be finished polling fn poll_next( - mut self: Pin<&mut Self>, + self: Pin<&mut Self>, cx: &mut std::task::Context<'_>, ) -> std::task::Poll> { // let yield_every = self.len(); // let mut polled = 0; let mut slots = self.slots.write().unwrap(); - for (key, slot) in slots.iter_mut() { + for (_key, slot) in slots.iter_mut() { if slot.dead.get() { continue; } let r = slot.fut; - let mut fut = unsafe { &mut *r }; + let fut = unsafe { &mut *r }; // use futures::{future::Future, poll, FutureExt}; let f2 = fut.as_mut(); diff --git a/packages/core/src/util.rs b/packages/core/src/util.rs index 0e38bd04b..9b4ee7793 100644 --- a/packages/core/src/util.rs +++ b/packages/core/src/util.rs @@ -1,7 +1,6 @@ use std::{ cell::{Cell, RefCell, RefMut}, rc::Rc, - vec::Drain, }; use futures_util::StreamExt; @@ -89,23 +88,23 @@ impl DebugDom { } } impl<'a> RealDom<'a> for DebugDom { - fn push(&mut self, root: RealDomNode) {} + fn push(&mut self, _root: RealDomNode) {} fn pop(&mut self) {} - fn append_children(&mut self, many: u32) {} + fn append_children(&mut self, _many: u32) {} - fn replace_with(&mut self, many: u32) {} + fn replace_with(&mut self, _many: u32) {} fn remove(&mut self) {} fn remove_all_children(&mut self) {} - fn create_text_node(&mut self, text: &str) -> RealDomNode { + fn create_text_node(&mut self, _text: &str) -> RealDomNode { self.counter += 1; RealDomNode::new(self.counter) } - fn create_element(&mut self, tag: &str, ns: Option<&'a str>) -> RealDomNode { + fn create_element(&mut self, _tag: &str, _ns: Option<&'a str>) -> RealDomNode { self.counter += 1; RealDomNode::new(self.counter) } @@ -117,20 +116,20 @@ impl<'a> RealDom<'a> for DebugDom { fn new_event_listener( &mut self, - event: &str, - scope: ScopeIdx, - element_id: usize, - realnode: RealDomNode, + _event: &str, + _scope: ScopeIdx, + _element_id: usize, + _realnode: RealDomNode, ) { } - fn remove_event_listener(&mut self, event: &str) {} + fn remove_event_listener(&mut self, _event: &str) {} - fn set_text(&mut self, text: &str) {} + fn set_text(&mut self, _text: &str) {} - fn set_attribute(&mut self, name: &str, value: &str, namespace: Option<&str>) {} + fn set_attribute(&mut self, _name: &str, _value: &str, _namespace: Option<&str>) {} - fn remove_attribute(&mut self, name: &str) {} + fn remove_attribute(&mut self, _name: &str) {} fn raw_node_as_any_mut(&self) -> &mut dyn std::any::Any { todo!() diff --git a/packages/core/src/virtual_dom.rs b/packages/core/src/virtual_dom.rs index 2b0d12758..fca5b6c10 100644 --- a/packages/core/src/virtual_dom.rs +++ b/packages/core/src/virtual_dom.rs @@ -21,13 +21,13 @@ use crate::tasks::TaskQueue; use crate::{arena::SharedArena, innerlude::*}; -use appendlist::AppendList; + use slotmap::DefaultKey; use slotmap::SlotMap; use std::any::Any; -use std::cell::RefCell; + use std::pin::Pin; -use std::{any::TypeId, fmt::Debug, rc::Rc}; +use std::{any::TypeId}; pub type ScopeIdx = DefaultKey;