From a16b05f371d5d2f22727940357edda0136d11dcf Mon Sep 17 00:00:00 2001 From: MrGVSV <gino.valente.code@gmail.com> Date: Fri, 4 Feb 2022 13:32:28 -0800 Subject: [PATCH] Fix warnings --- kayak_core/src/flo_binding/binding_context.rs | 4 ++-- kayak_render_macros/src/child.rs | 2 -- kayak_render_macros/src/function_component.rs | 16 ++++++++-------- kayak_render_macros/src/widget.rs | 4 +--- kayak_render_macros/src/widget_attributes.rs | 3 +-- kayak_render_macros/src/widget_props.rs | 5 ++--- src/widgets/app.rs | 2 +- src/widgets/background.rs | 1 - src/widgets/button.rs | 1 - src/widgets/clip.rs | 3 +-- src/widgets/element.rs | 3 +-- src/widgets/fold.rs | 1 - src/widgets/if_element.rs | 6 ++---- src/widgets/image.rs | 3 +-- src/widgets/inspector.rs | 2 +- src/widgets/nine_patch.rs | 3 +-- src/widgets/text.rs | 5 ++--- src/widgets/text_box.rs | 1 - src/widgets/tooltip.rs | 1 - src/widgets/window.rs | 1 - 20 files changed, 24 insertions(+), 43 deletions(-) diff --git a/kayak_core/src/flo_binding/binding_context.rs b/kayak_core/src/flo_binding/binding_context.rs index d1d611a..ea4ee4f 100644 --- a/kayak_core/src/flo_binding/binding_context.rs +++ b/kayak_core/src/flo_binding/binding_context.rs @@ -105,7 +105,7 @@ pub struct BindingContext { dependencies: BindingDependencies, /// None, or the binding context that this context was created within - nested: Option<Box<BindingContext>>, + _nested: Option<Box<BindingContext>>, } impl BindingContext { @@ -139,7 +139,7 @@ impl BindingContext { let dependencies = BindingDependencies::new(); let new_context = BindingContext { dependencies: dependencies.clone(), - nested: previous_context.clone().map(Box::new), + _nested: previous_context.clone().map(Box::new), }; // Make the current context the same as the new context diff --git a/kayak_render_macros/src/child.rs b/kayak_render_macros/src/child.rs index 04f7d15..f832af6 100644 --- a/kayak_render_macros/src/child.rs +++ b/kayak_render_macros/src/child.rs @@ -1,7 +1,5 @@ -use proc_macro_error::emit_error; use quote::{quote, ToTokens}; use syn::parse::{Parse, ParseStream, Result}; -use syn::spanned::Spanned; use crate::widget::Widget; diff --git a/kayak_render_macros/src/function_component.rs b/kayak_render_macros/src/function_component.rs index b94e91a..10c6a1e 100644 --- a/kayak_render_macros/src/function_component.rs +++ b/kayak_render_macros/src/function_component.rs @@ -1,6 +1,6 @@ use proc_macro::TokenStream; -use proc_macro_error::{emit_error, emit_warning}; -use quote::{quote, ToTokens}; +use proc_macro_error::emit_error; +use quote::quote; use syn::{FnArg, Pat, Type}; use syn::spanned::Spanned; use crate::get_core_crate; @@ -15,7 +15,7 @@ impl Default for WidgetArguments { } } -pub fn create_function_widget(f: syn::ItemFn, widget_arguments: WidgetArguments) -> TokenStream { +pub fn create_function_widget(f: syn::ItemFn, _widget_arguments: WidgetArguments) -> TokenStream { let struct_name = f.sig.ident.clone(); let (impl_generics, ty_generics, where_clause) = f.sig.generics.split_for_impl(); @@ -36,25 +36,25 @@ pub fn create_function_widget(f: syn::ItemFn, widget_arguments: WidgetArguments) } err => { emit_error!(err.span(), "Expected identifier, but got {:?}", err); - return TokenStream::new() + return TokenStream::new(); } }; let ty = match *typed.ty.clone() { Type::Path(type_path) => { type_path.path - }, + } err => { emit_error!(err.span(), "Invalid widget prop type: {:?}", err); - return TokenStream::new() + return TokenStream::new(); } }; (ident, ty) - }, + } FnArg::Receiver(receiver) => { emit_error!(receiver.span(), "Functional widget cannot use 'self'"); - return TokenStream::new() + return TokenStream::new(); } }; diff --git a/kayak_render_macros/src/widget.rs b/kayak_render_macros/src/widget.rs index a19cd42..3be7ea0 100644 --- a/kayak_render_macros/src/widget.rs +++ b/kayak_render_macros/src/widget.rs @@ -1,10 +1,8 @@ use proc_macro2::TokenStream; -use proc_macro_error::{emit_error, emit_warning}; use quote::{format_ident, quote}; use quote::ToTokens; use syn::parse::{Parse, ParseStream, Result}; use syn::Path; -use syn::spanned::Spanned; use crate::widget_builder::build_widget_stream; use crate::children::Children; @@ -110,7 +108,7 @@ impl Widget { let attrs = attrs.assign_attributes(&prop_ident); let props = quote! { - let mut #prop_ident = <#name as kayak_core::Widget>::Props::default(); + let mut #prop_ident = <#name as #kayak_core::Widget>::Props::default(); #attrs }; diff --git a/kayak_render_macros/src/widget_attributes.rs b/kayak_render_macros/src/widget_attributes.rs index 7ac896f..45f85a6 100644 --- a/kayak_render_macros/src/widget_attributes.rs +++ b/kayak_render_macros/src/widget_attributes.rs @@ -1,4 +1,4 @@ -use proc_macro_error::{emit_error, emit_warning}; +use proc_macro_error::emit_error; use quote::{quote, ToTokens}; use std::collections::HashSet; use proc_macro2::{Ident, TokenStream}; @@ -9,7 +9,6 @@ use syn::{ }; use crate::{attribute::Attribute, children::Children, get_core_crate}; -use crate::attribute::AttributeKey; use crate::child::Child; #[derive(Clone)] diff --git a/kayak_render_macros/src/widget_props.rs b/kayak_render_macros/src/widget_props.rs index e01e2cd..7fc4084 100644 --- a/kayak_render_macros/src/widget_props.rs +++ b/kayak_render_macros/src/widget_props.rs @@ -1,10 +1,9 @@ use proc_macro::TokenStream; use proc_macro2::{Ident}; -use proc_macro_error::{emit_error, emit_warning}; +use proc_macro_error::emit_error; use quote::quote; -use syn::{AttributeArgs, Data, DeriveInput, Field, Fields, ItemStruct, Meta, NestedMeta, parse_macro_input, spanned::Spanned}; -use crate::attribute::Attribute; +use syn::{Data, DeriveInput, Field, Meta, NestedMeta, parse_macro_input, spanned::Spanned}; use crate::get_core_crate; diff --git a/src/widgets/app.rs b/src/widgets/app.rs index 03216d9..a93b220 100644 --- a/src/widgets/app.rs +++ b/src/widgets/app.rs @@ -1,4 +1,4 @@ -use crate::core::derivative::*; + use crate::core::{ render_command::RenderCommand, OnEvent, rsx, WidgetProps, diff --git a/src/widgets/background.rs b/src/widgets/background.rs index be08aac..b91db38 100644 --- a/src/widgets/background.rs +++ b/src/widgets/background.rs @@ -1,6 +1,5 @@ use crate::core::{ render_command::RenderCommand, - derivative::Derivative, OnEvent, rsx, WidgetProps, styles::{Style, StyleProp}, widget, Children, Fragment, diff --git a/src/widgets/button.rs b/src/widgets/button.rs index 7c790d2..8f9abd1 100644 --- a/src/widgets/button.rs +++ b/src/widgets/button.rs @@ -1,6 +1,5 @@ use crate::core::{ render_command::RenderCommand, - derivative::Derivative, Color, OnEvent, rsx, WidgetProps, styles::{Style, StyleProp, Units}, widget, Children, Fragment, diff --git a/src/widgets/clip.rs b/src/widgets/clip.rs index d710339..f70e4cd 100644 --- a/src/widgets/clip.rs +++ b/src/widgets/clip.rs @@ -1,9 +1,8 @@ use crate::core::{ render_command::RenderCommand, - derivative::Derivative, OnEvent, rsx, WidgetProps, styles::{Style, StyleProp, Units}, - widget, Children, Fragment, + widget, Children, }; #[derive(WidgetProps, Default, Debug, PartialEq, Clone)] diff --git a/src/widgets/element.rs b/src/widgets/element.rs index 6d0a4ca..e671e6b 100644 --- a/src/widgets/element.rs +++ b/src/widgets/element.rs @@ -1,9 +1,8 @@ use crate::core::{ render_command::RenderCommand, - derivative::Derivative, OnEvent, rsx, WidgetProps, styles::{Style, StyleProp}, - widget, Children, Fragment, + widget, Children, }; #[derive(WidgetProps, Default, Debug, PartialEq, Clone)] diff --git a/src/widgets/fold.rs b/src/widgets/fold.rs index c9a2b40..a88f676 100644 --- a/src/widgets/fold.rs +++ b/src/widgets/fold.rs @@ -1,6 +1,5 @@ use crate::core::{ render_command::RenderCommand, - derivative::Derivative, OnEvent, rsx, WidgetProps, styles::{Style, StyleProp, Units}, use_state, widget, Children, EventType, Handler, diff --git a/src/widgets/if_element.rs b/src/widgets/if_element.rs index 3fdb090..807a229 100644 --- a/src/widgets/if_element.rs +++ b/src/widgets/if_element.rs @@ -1,9 +1,7 @@ use crate::core::{ - render_command::RenderCommand, - derivative::Derivative, OnEvent, rsx, WidgetProps, - styles::{Style, StyleProp}, - widget, Children, Fragment, + styles::{Style}, + widget, Children, }; #[derive(WidgetProps, Default, Debug, PartialEq, Clone)] diff --git a/src/widgets/image.rs b/src/widgets/image.rs index 79d421c..f73dc23 100644 --- a/src/widgets/image.rs +++ b/src/widgets/image.rs @@ -1,9 +1,8 @@ use crate::core::{ render_command::RenderCommand, - derivative::Derivative, OnEvent, rsx, WidgetProps, styles::{Style, StyleProp}, - widget, Children, Fragment, + widget, Children, }; #[derive(WidgetProps, Default, Debug, PartialEq, Clone)] diff --git a/src/widgets/inspector.rs b/src/widgets/inspector.rs index 2b5cb7f..d77251a 100644 --- a/src/widgets/inspector.rs +++ b/src/widgets/inspector.rs @@ -2,7 +2,7 @@ use kayak_core::styles::{PositionType, Style, StyleProp, Units}; use kayak_core::{Bound, Color, EventType, OnEvent, VecTracker}; use kayak_render_macros::{constructor, use_state}; -use crate::core::derivative::*; + use crate::core::{rsx, widget, WidgetProps, MutableBound}; use crate::widgets::{Background, Button, Text}; diff --git a/src/widgets/nine_patch.rs b/src/widgets/nine_patch.rs index 830c61e..48627e0 100644 --- a/src/widgets/nine_patch.rs +++ b/src/widgets/nine_patch.rs @@ -1,10 +1,9 @@ use crate::core::{ render_command::RenderCommand, layout_cache::Space, - derivative::Derivative, OnEvent, rsx, WidgetProps, styles::{Style, StyleProp}, - widget, Children, Fragment, + widget, Children, }; #[derive(WidgetProps, Default, Debug, PartialEq, Clone)] diff --git a/src/widgets/text.rs b/src/widgets/text.rs index b1845c5..5b6562d 100644 --- a/src/widgets/text.rs +++ b/src/widgets/text.rs @@ -3,10 +3,9 @@ use kayak_font::{CoordinateSystem, KayakFont}; use crate::core::{ render_command::RenderCommand, - derivative::Derivative, - OnEvent, rsx, WidgetProps, + OnEvent, WidgetProps, styles::{Style, StyleProp}, - widget, Children, Fragment, + widget, }; #[derive(WidgetProps, Default, Debug, PartialEq, Clone)] diff --git a/src/widgets/text_box.rs b/src/widgets/text_box.rs index 14aa3e3..360b7bf 100644 --- a/src/widgets/text_box.rs +++ b/src/widgets/text_box.rs @@ -1,6 +1,5 @@ use crate::core::{ render_command::RenderCommand, - derivative::Derivative, Children, rsx, WidgetProps, styles::{Style, StyleProp, Units}, widget, Bound, Color, EventType, MutableBound, OnEvent, diff --git a/src/widgets/tooltip.rs b/src/widgets/tooltip.rs index ccdff94..e80dc93 100644 --- a/src/widgets/tooltip.rs +++ b/src/widgets/tooltip.rs @@ -1,6 +1,5 @@ use crate::core::{ render_command::RenderCommand, - derivative::Derivative, rsx, WidgetProps, styles::{PositionType, Style, StyleProp, Units}, widget, Bound, Children, Color, EventType, MutableBound, OnEvent, diff --git a/src/widgets/window.rs b/src/widgets/window.rs index c6366e8..08b3bec 100644 --- a/src/widgets/window.rs +++ b/src/widgets/window.rs @@ -1,7 +1,6 @@ use crate::core::{ color::Color, render_command::RenderCommand, - derivative::Derivative, rsx, WidgetProps, styles::{PositionType, Style, StyleProp, Units}, use_state, widget, Children, EventType, OnEvent, -- GitLab