diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d2bef24e1..9e72fa02b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -112,4 +112,5 @@ jobs: # -A clippy::comparison_chain \ # -A clippy::if_same_then_else \ # -A clippy::single-match \ + # -A clippy::redundant_pattern_matching \ # -A clippy::unit_arg diff --git a/crates/kas-core/src/app/window.rs b/crates/kas-core/src/app/window.rs index e0c613441..cd99b81bf 100644 --- a/crates/kas-core/src/app/window.rs +++ b/crates/kas-core/src/app/window.rs @@ -338,9 +338,7 @@ impl> Window { } pub(super) fn update_timer(&mut self, state: &mut AppState) -> Option { - let Some(ref window) = self.window else { - return None; - }; + let window = self.window.as_ref()?; let widget = self.widget.as_node(&state.data); let mut messages = MessageStack::new(); diff --git a/crates/kas-core/src/core/widget_id.rs b/crates/kas-core/src/core/widget_id.rs index ab0429ca0..8f0288e17 100644 --- a/crates/kas-core/src/core/widget_id.rs +++ b/crates/kas-core/src/core/widget_id.rs @@ -236,6 +236,7 @@ impl<'a> Iterator for WidgetPathIter<'a> { /// [`Display`]: std::fmt::Display /// [`Action::RECONFIGURE`]: crate::Action::RECONFIGURE /// [`ConfigCx::configure`]: crate::event::ConfigCx::configure +#[allow(clippy::assigning_clones)] #[derive(Clone)] pub struct Id(IntOrPtr); diff --git a/crates/kas-core/src/event/cx/mod.rs b/crates/kas-core/src/event/cx/mod.rs index 3a3aeedc5..803dc120c 100644 --- a/crates/kas-core/src/event/cx/mod.rs +++ b/crates/kas-core/src/event/cx/mod.rs @@ -15,7 +15,6 @@ use std::future::Future; use std::ops::{Deref, DerefMut}; use std::pin::Pin; use std::time::Instant; -use std::u16; use super::config::WindowConfig; use super::*; diff --git a/crates/kas-core/src/layout/visitor.rs b/crates/kas-core/src/layout/visitor.rs index 2f5f2cbb8..078874575 100644 --- a/crates/kas-core/src/layout/visitor.rs +++ b/crates/kas-core/src/layout/visitor.rs @@ -58,6 +58,7 @@ pub trait Visitable { /// /// This is templated over `cell_info: C` where `C = ()` for lists or /// `C = GridCellInfo` for grids. +#[allow(clippy::len_without_is_empty)] #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] pub trait VisitableList { diff --git a/crates/kas-macros/src/collection.rs b/crates/kas-macros/src/collection.rs index 6e0cf522d..b4f5a904c 100644 --- a/crates/kas-macros/src/collection.rs +++ b/crates/kas-macros/src/collection.rs @@ -16,25 +16,24 @@ use syn::{Expr, Ident, Lifetime, LitInt, LitStr, Token}; #[derive(Debug)] pub enum StorIdent { - Named(Ident, Span), - Generated(Ident, Span), + Named(Ident), + Generated(Ident), } impl From for StorIdent { - fn from(lt: Lifetime) -> StorIdent { - let span = lt.span(); - StorIdent::Named(lt.ident, span) + fn from(mut lt: Lifetime) -> StorIdent { + lt.ident.set_span(lt.span()); + StorIdent::Named(lt.ident) } } impl From for StorIdent { fn from(ident: Ident) -> StorIdent { - let span = ident.span(); - StorIdent::Generated(ident, span) + StorIdent::Generated(ident) } } impl ToTokens for StorIdent { fn to_tokens(&self, toks: &mut Toks) { match self { - StorIdent::Named(ident, _) | StorIdent::Generated(ident, _) => ident.to_tokens(toks), + StorIdent::Named(ident) | StorIdent::Generated(ident) => ident.to_tokens(toks), } } } diff --git a/crates/kas-macros/src/make_layout.rs b/crates/kas-macros/src/make_layout.rs index f4482f86c..77a78d530 100644 --- a/crates/kas-macros/src/make_layout.rs +++ b/crates/kas-macros/src/make_layout.rs @@ -70,30 +70,26 @@ impl Tree { &self, children: I, ) -> std::result::Result { - match &self.0 { - layout => { - let mut v = Vec::new(); - layout.nav_next(children, &mut v).map(|()| { - quote! { - fn nav_next(&self, reverse: bool, from: Option) -> Option { - let mut iter = [#(#v),*].into_iter(); - if !reverse { - if let Some(wi) = from { - let _ = iter.find(|x| *x == wi); - } - iter.next() - } else { - let mut iter = iter.rev(); - if let Some(wi) = from { - let _ = iter.find(|x| *x == wi); - } - iter.next() - } + let mut v = Vec::new(); + self.0.nav_next(children, &mut v).map(|()| { + quote! { + fn nav_next(&self, reverse: bool, from: Option) -> Option { + let mut iter = [#(#v),*].into_iter(); + if !reverse { + if let Some(wi) = from { + let _ = iter.find(|x| *x == wi); } + iter.next() + } else { + let mut iter = iter.rev(); + if let Some(wi) = from { + let _ = iter.find(|x| *x == wi); + } + iter.next() } - }) + } } - } + }) } /// If field `ident` is included in the layout, return Span of usage @@ -477,7 +473,7 @@ impl Layout { ); // Clear remainder of input stream to avoid a redundant error - let _ = input.step(|cursor| { + input.step(|cursor| { let mut rest = *cursor; while let Some((_, next)) = rest.token_tree() { rest = next; @@ -1090,12 +1086,10 @@ impl Layout { } Layout::Widget(ident, _) => { for (i, child) in children.enumerate() { - if let ChildIdent::CoreField(ref child_ident) = child.ident { - if let Member::Named(ref ci) = child_ident { - if *ident == *ci { - output.push(i); - return Ok(()); - } + if let ChildIdent::CoreField(Member::Named(ref ci)) = child.ident { + if *ident == *ci { + output.push(i); + return Ok(()); } } } diff --git a/crates/kas-macros/src/widget.rs b/crates/kas-macros/src/widget.rs index ce3ebb811..27af60616 100644 --- a/crates/kas-macros/src/widget.rs +++ b/crates/kas-macros/src/widget.rs @@ -31,14 +31,18 @@ mod kw { #[derive(Debug)] pub struct BoolToken { + #[allow(dead_code)] pub kw_span: Span, + #[allow(dead_code)] pub eq: Eq, pub lit: syn::LitBool, } #[derive(Debug)] pub struct ExprToken { + #[allow(dead_code)] pub kw_span: Span, + #[allow(dead_code)] pub eq: Eq, pub expr: syn::Expr, } @@ -176,7 +180,7 @@ pub struct Child { impl Child { pub fn new_core(ident: Member) -> Self { Child { - ident: ChildIdent::CoreField(ident.into()), + ident: ChildIdent::CoreField(ident), attr_span: None, data_binding: None, } diff --git a/crates/kas-resvg/src/canvas.rs b/crates/kas-resvg/src/canvas.rs index 9552d1b27..1cad121a0 100644 --- a/crates/kas-resvg/src/canvas.rs +++ b/crates/kas-resvg/src/canvas.rs @@ -113,13 +113,13 @@ impl_scope! { /// Use [`Self::with_size`] or [`Self::with_scaling`] to set the initial size. #[inline] pub fn new(program: P) -> Self { - let mut scaling = PixmapScaling::default(); - scaling.size = LogicalSize(128.0, 128.0); - scaling.stretch = Stretch::High; - Canvas { core: Default::default(), - scaling, + scaling: PixmapScaling { + size: LogicalSize(128.0, 128.0), + stretch: Stretch::High, + ..Default::default() + }, inner: State::Initial(program), image: None, } diff --git a/crates/kas-view/src/filter/filter_list.rs b/crates/kas-view/src/filter/filter_list.rs index 9714ff472..4565627c0 100644 --- a/crates/kas-view/src/filter/filter_list.rs +++ b/crates/kas-view/src/filter/filter_list.rs @@ -7,6 +7,7 @@ use super::Filter; use crate::{ListData, SharedData}; +use kas::classes::HasStr; use kas::event::{ConfigCx, EventCx}; use kas::{autoimpl, impl_scope, Events, Widget}; use kas_widgets::edit::{EditBox, EditField, EditGuard}; @@ -26,7 +27,7 @@ impl EditGuard for KeystrokeGuard { type Data = (); fn edit(edit: &mut EditField, cx: &mut EventCx, _: &Self::Data) { - cx.push(SetFilter(edit.to_string())); + cx.push(SetFilter(edit.get_string())); } } @@ -42,7 +43,7 @@ impl EditGuard for AflGuard { #[inline] fn focus_lost(edit: &mut EditField, cx: &mut EventCx, _: &Self::Data) { - cx.push(SetFilter(edit.to_string())); + cx.push(SetFilter(edit.get_string())); } } @@ -196,6 +197,7 @@ impl_scope! { } impl Self { + #[allow(clippy::missing_transmute_annotations)] // fields and fn parameters are annotated unsafe fn new<'a>(data: &'a A, view: &'a [A::Key]) -> Self { UnsafeFilteredList { data: std::mem::transmute(data), diff --git a/crates/kas-widgets/src/edit.rs b/crates/kas-widgets/src/edit.rs index 3efac0e96..423bda02c 100644 --- a/crates/kas-widgets/src/edit.rs +++ b/crates/kas-widgets/src/edit.rs @@ -455,12 +455,6 @@ impl_scope! { action } } - - impl ToString for Self { - fn to_string(&self) -> String { - self.inner.to_string() - } - } } impl EditBox { @@ -904,6 +898,10 @@ impl_scope! { fn get_str(&self) -> &str { self.text.text() } + + fn get_string(&self) -> String { + self.text.text().clone() + } } impl HasString for Self { @@ -925,12 +923,6 @@ impl_scope! { action | self.set_error_state(false) } } - - impl ToString for Self { - fn to_string(&self) -> String { - self.text.text().clone() - } - } } impl EditField { diff --git a/examples/times-tables.rs b/examples/times-tables.rs index fae5cfd05..dd4ffc726 100644 --- a/examples/times-tables.rs +++ b/examples/times-tables.rs @@ -29,10 +29,12 @@ impl MatrixData for TableSize { (self.0, self.0) } + #[allow(refining_impl_trait)] fn col_iter_from(&self, start: usize, limit: usize) -> std::ops::Range { let end = self.0.min(start + limit); start..end } + #[allow(refining_impl_trait)] fn row_iter_from(&self, start: usize, limit: usize) -> std::ops::Range { let end = self.0.min(start + limit); start..end