From 4b378ac81ce3d7f5fd90a1e562e65e6da9396278 Mon Sep 17 00:00:00 2001 From: Shark Date: Mon, 2 Dec 2024 11:46:23 +0100 Subject: [PATCH] fix new clippy lints in newest version --- crates/gosub_css3/src/tokenizer.rs | 8 +++--- crates/gosub_html5/src/document/query.rs | 4 +-- crates/gosub_html5/src/parser/errors.rs | 1 - crates/gosub_html5/src/parser/helper.rs | 2 +- crates/gosub_html5/src/parser/quirks.rs | 2 +- crates/gosub_html5/src/tokenizer.rs | 2 +- crates/gosub_taffy/src/lib.rs | 27 ++++++++++++------- crates/gosub_useragent/src/application.rs | 3 +-- crates/gosub_useragent/src/event_loop.rs | 3 +-- crates/gosub_v8/src/v8.rs | 2 +- .../src/js/value_conversion.rs | 2 +- crates/gosub_webexecutor/tests/interop.rs | 1 + 12 files changed, 32 insertions(+), 25 deletions(-) diff --git a/crates/gosub_css3/src/tokenizer.rs b/crates/gosub_css3/src/tokenizer.rs index 4925cf6e8..cd479e729 100644 --- a/crates/gosub_css3/src/tokenizer.rs +++ b/crates/gosub_css3/src/tokenizer.rs @@ -80,12 +80,12 @@ pub struct Token { impl Debug for Token { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let TokenType::Whitespace(v) = self.token_type.clone() { - return match v.as_str() { + match v.as_str() { "\t" => write!(f, "TAB at {:?}", self.location), "\r" => write!(f, "CR at {:?}", self.location), "\n" => write!(f, "LF at {:?}", self.location), _ => write!(f, "{:?} at {:?}", self.token_type, self.location), - }; + } } else { write!(f, "{:?} at {:?}", self.token_type, self.location) } @@ -647,7 +647,7 @@ impl<'stream> Tokenizer<'stream> { return Token::new_function(value.as_str(), loc); } - return Token::new_ident(value.as_str(), loc); + Token::new_ident(value.as_str(), loc) } /// 4.3.6. [Consume a url token](https://www.w3.org/TR/css-syntax-3/#consume-a-url-token) @@ -691,7 +691,7 @@ impl<'stream> Tokenizer<'stream> { url.push(self.next_char().into()); } - return Token::new_url(url.as_str(), loc); + Token::new_url(url.as_str(), loc) } /// 4.3.14. [Consume the remnants of a bad url](https://www.w3.org/TR/css-syntax-3/#consume-remnants-of-bad-url) diff --git a/crates/gosub_html5/src/document/query.rs b/crates/gosub_html5/src/document/query.rs index 8983f746e..2e09bbd22 100644 --- a/crates/gosub_html5/src/document/query.rs +++ b/crates/gosub_html5/src/document/query.rs @@ -95,14 +95,14 @@ impl, C: CssSystem> DocumentQuery { return false; }; - return current_node_data.classlist().contains(class_name); + current_node_data.classlist().contains(class_name) } Condition::ContainsAttribute(attribute) => { let Some(current_node_data) = current_node.get_element_data() else { return false; }; - return current_node_data.attributes().contains_key(attribute); + current_node_data.attributes().contains_key(attribute) } Condition::ContainsChildTag(child_tag) => { Self::contains_child_tag(doc_handle.clone(), current_node.id(), child_tag) diff --git a/crates/gosub_html5/src/parser/errors.rs b/crates/gosub_html5/src/parser/errors.rs index e339d6935..4eefdc0da 100755 --- a/crates/gosub_html5/src/parser/errors.rs +++ b/crates/gosub_html5/src/parser/errors.rs @@ -176,7 +176,6 @@ impl ErrorLogger { } #[cfg(test)] - mod tests { use super::*; diff --git a/crates/gosub_html5/src/parser/helper.rs b/crates/gosub_html5/src/parser/helper.rs index 3eb25566e..e708d3138 100644 --- a/crates/gosub_html5/src/parser/helper.rs +++ b/crates/gosub_html5/src/parser/helper.rs @@ -29,7 +29,7 @@ pub enum BookMark { InsertAfter(NodeId), } -impl<'chars, D, C> Html5Parser<'chars, D, C> +impl Html5Parser<'_, D, C> where D: Document, C: CssSystem, diff --git a/crates/gosub_html5/src/parser/quirks.rs b/crates/gosub_html5/src/parser/quirks.rs index 084b81d96..31508f96a 100644 --- a/crates/gosub_html5/src/parser/quirks.rs +++ b/crates/gosub_html5/src/parser/quirks.rs @@ -3,7 +3,7 @@ use gosub_shared::traits::css3::CssSystem; use gosub_shared::traits::document::{Document, DocumentFragment}; use gosub_shared::traits::node::{ElementDataType, Node, QuirksMode}; -impl<'chars, D, C> Html5Parser<'chars, D, C> +impl Html5Parser<'_, D, C> where C: CssSystem, D: Document, diff --git a/crates/gosub_html5/src/tokenizer.rs b/crates/gosub_html5/src/tokenizer.rs index 192df95f0..790ea84ef 100644 --- a/crates/gosub_html5/src/tokenizer.rs +++ b/crates/gosub_html5/src/tokenizer.rs @@ -60,7 +60,7 @@ pub struct Tokenizer<'stream> { pub error_logger: Rc>, } -impl<'stream> Tokenizer<'stream> { +impl Tokenizer<'_> { pub(crate) fn insert_tokens_at_queue_start(&mut self, first_tokens: &[Token]) { let mut new_queue = first_tokens.to_owned(); new_queue.extend(self.token_queue.iter().cloned()); diff --git a/crates/gosub_taffy/src/lib.rs b/crates/gosub_taffy/src/lib.rs index e7d62e4df..4c5297da6 100644 --- a/crates/gosub_taffy/src/lib.rs +++ b/crates/gosub_taffy/src/lib.rs @@ -168,7 +168,8 @@ impl TaffyLayouter { pub struct LayoutDocument<'a, LT: LayoutTree>(&'a mut LT); impl> TraversePartialTree for LayoutDocument<'_, LT> { - type ChildIter<'a> = IntoIter + type ChildIter<'a> + = IntoIter where Self: 'a; @@ -251,10 +252,12 @@ impl> LayoutDocument<'_, LT> { } impl> LayoutPartialTree for LayoutDocument<'_, LT> { - type CoreContainerStyle<'a> = &'a Style + type CoreContainerStyle<'a> + = &'a Style where Self: 'a; - type CacheMut<'b> = &'b mut TaffyCache + type CacheMut<'b> + = &'b mut TaffyCache where Self: 'b; @@ -305,10 +308,12 @@ impl> LayoutPartialTree for LayoutDocument<'_, LT> } impl> LayoutBlockContainer for LayoutDocument<'_, LT> { - type BlockContainerStyle<'a> = &'a Style + type BlockContainerStyle<'a> + = &'a Style where Self: 'a; - type BlockItemStyle<'a> = &'a Style + type BlockItemStyle<'a> + = &'a Style where Self: 'a; @@ -322,10 +327,12 @@ impl> LayoutBlockContainer for LayoutDocument<'_, } impl> LayoutFlexboxContainer for LayoutDocument<'_, LT> { - type FlexboxContainerStyle<'a> = &'a Style + type FlexboxContainerStyle<'a> + = &'a Style where Self: 'a; - type FlexboxItemStyle<'a> = &'a Style + type FlexboxItemStyle<'a> + = &'a Style where Self: 'a; @@ -339,10 +346,12 @@ impl> LayoutFlexboxContainer for LayoutDocument<'_ } impl> LayoutGridContainer for LayoutDocument<'_, LT> { - type GridContainerStyle<'a> = &'a Style + type GridContainerStyle<'a> + = &'a Style where Self: 'a; - type GridItemStyle<'a> = &'a Style + type GridItemStyle<'a> + = &'a Style where Self: 'a; diff --git a/crates/gosub_useragent/src/application.rs b/crates/gosub_useragent/src/application.rs index dc2586c98..4322976f4 100644 --- a/crates/gosub_useragent/src/application.rs +++ b/crates/gosub_useragent/src/application.rs @@ -65,7 +65,6 @@ pub struct Application< } impl< - 'a, D: SceneDrawer, B: RenderBackend, L: Layouter, @@ -74,7 +73,7 @@ impl< C: CssSystem, P: Html5Parser, RT: RenderTree, - > ApplicationHandler> for Application<'a, D, B, L, LT, Doc, C, P, RT> + > ApplicationHandler> for Application<'_, D, B, L, LT, Doc, C, P, RT> { fn resumed(&mut self, _event_loop: &ActiveEventLoop) { info!("Resumed"); diff --git a/crates/gosub_useragent/src/event_loop.rs b/crates/gosub_useragent/src/event_loop.rs index a149aa655..bfeda356d 100644 --- a/crates/gosub_useragent/src/event_loop.rs +++ b/crates/gosub_useragent/src/event_loop.rs @@ -14,7 +14,6 @@ use gosub_shared::traits::render_tree::RenderTree; use gosub_shared::types::Result; impl< - 'a, D: SceneDrawer, B: RenderBackend, L: Layouter, @@ -22,7 +21,7 @@ impl< Doc: Document, C: CssSystem, RT: RenderTree, - > Window<'a, D, B, L, LT, Doc, C, RT> + > Window<'_, D, B, L, LT, Doc, C, RT> { pub fn event>( &mut self, diff --git a/crates/gosub_v8/src/v8.rs b/crates/gosub_v8/src/v8.rs index 865fd1a4f..9d5f92147 100644 --- a/crates/gosub_v8/src/v8.rs +++ b/crates/gosub_v8/src/v8.rs @@ -77,7 +77,7 @@ pub struct V8Context<'a> { ctx: Rc>>, } -impl<'a> V8Context<'a> { +impl V8Context<'_> { pub fn error(&self, error: impl Display) { let scope = self.scope(); let err = error.to_string(); diff --git a/crates/gosub_webexecutor/src/js/value_conversion.rs b/crates/gosub_webexecutor/src/js/value_conversion.rs index 745b8c6ed..ea6e56e71 100644 --- a/crates/gosub_webexecutor/src/js/value_conversion.rs +++ b/crates/gosub_webexecutor/src/js/value_conversion.rs @@ -162,7 +162,7 @@ pub enum Ref<'a, T> { Owned(T), } -impl<'a, T> Ref<'a, T> { +impl Ref<'_, T> { fn get_ref(&self) -> &T { match self { Ref::Ref(r) => r, diff --git a/crates/gosub_webexecutor/tests/interop.rs b/crates/gosub_webexecutor/tests/interop.rs index b77d3323f..d7b2cbb7e 100644 --- a/crates/gosub_webexecutor/tests/interop.rs +++ b/crates/gosub_webexecutor/tests/interop.rs @@ -166,6 +166,7 @@ struct Test2 { other_field: String, } +#[allow(clippy::ptr_arg)] impl Test2 { fn cool_fn(&self) -> i32 { self.field