From 9ec474962bb8ca333af55feac431ef9cb1994602 Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Tue, 19 Aug 2025 19:34:13 -0700 Subject: [PATCH] fix lints on rust 1.89 (#4587) --- packages/cli/src/build/patch.rs | 4 ++-- packages/core-macro/src/component.rs | 2 +- packages/core-macro/src/props/mod.rs | 2 +- packages/core/src/effect.rs | 12 +++++----- packages/core/src/error_boundary.rs | 2 +- packages/core/src/scheduler.rs | 11 ++++----- packages/core/src/scope_context.rs | 2 +- packages/core/src/suspense/mod.rs | 2 +- packages/desktop/src/ipc.rs | 2 +- packages/manganis/manganis-core/src/asset.rs | 1 + packages/router-macro/src/lib.rs | 2 ++ packages/router-macro/src/query.rs | 1 + packages/router-macro/src/route.rs | 1 + packages/signals/src/read.rs | 23 +++++++++++-------- packages/wasm-split/wasm-split-cli/src/lib.rs | 2 +- packages/web/src/history.rs | 16 ++++++++----- 16 files changed, 48 insertions(+), 37 deletions(-) diff --git a/packages/cli/src/build/patch.rs b/packages/cli/src/build/patch.rs index ed38220e0..7f16ac959 100644 --- a/packages/cli/src/build/patch.rs +++ b/packages/cli/src/build/patch.rs @@ -1329,7 +1329,7 @@ fn name_is_bindgen_symbol(name: &str) -> bool { /// We need to do this for data symbols because walrus doesn't provide the right range and offset /// information for data segments. Fortunately, it provides it for code sections, so we only need to /// do a small amount extra of parsing here. -fn parse_bytes_to_data_segment(bytes: &[u8]) -> Result { +fn parse_bytes_to_data_segment(bytes: &[u8]) -> Result> { let parser = wasmparser::Parser::new(0); let mut parser = parser.parse_all(bytes); let mut segments = vec![]; @@ -1441,7 +1441,7 @@ struct ParsedModule<'a> { /// Parse a module and return the mapping of index to FunctionID. /// We'll use this mapping to remap ModuleIDs -fn parse_module_with_ids(bindgened: &[u8]) -> Result { +fn parse_module_with_ids(bindgened: &[u8]) -> Result> { let ids = Arc::new(RwLock::new(Vec::new())); let ids_ = ids.clone(); let module = Module::from_buffer_with_config( diff --git a/packages/core-macro/src/component.rs b/packages/core-macro/src/component.rs index 97c345b98..776871b66 100644 --- a/packages/core-macro/src/component.rs +++ b/packages/core-macro/src/component.rs @@ -401,7 +401,7 @@ struct DocField<'a> { input_arg_doc: String, } -fn build_doc_fields(f: &FnArg) -> Option { +fn build_doc_fields(f: &FnArg) -> Option> { let FnArg::Typed(pt) = f else { unreachable!() }; let arg_doc = pt diff --git a/packages/core-macro/src/props/mod.rs b/packages/core-macro/src/props/mod.rs index eb31ed296..9ad36ea67 100644 --- a/packages/core-macro/src/props/mod.rs +++ b/packages/core-macro/src/props/mod.rs @@ -197,7 +197,7 @@ mod field_info { ordinal: usize, field: &syn::Field, field_defaults: FieldBuilderAttr, - ) -> Result { + ) -> Result, Error> { if let Some(ref name) = field.ident { let mut builder_attr = field_defaults.with(&field.attrs)?; diff --git a/packages/core/src/effect.rs b/packages/core/src/effect.rs index 7c928ed71..2c6d3e966 100644 --- a/packages/core/src/effect.rs +++ b/packages/core/src/effect.rs @@ -36,18 +36,18 @@ impl Effect { } } -impl PartialOrd for Effect { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.order.cmp(&other.order)) - } -} - impl Ord for Effect { fn cmp(&self, other: &Self) -> std::cmp::Ordering { self.order.cmp(&other.order) } } +impl PartialOrd for Effect { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + impl PartialEq for Effect { fn eq(&self, other: &Self) -> bool { self.order == other.order diff --git a/packages/core/src/error_boundary.rs b/packages/core/src/error_boundary.rs index 05697cc61..67651da6f 100644 --- a/packages/core/src/error_boundary.rs +++ b/packages/core/src/error_boundary.rs @@ -250,7 +250,7 @@ impl ErrorContext { } /// Get all errors thrown from child components - pub fn errors(&self) -> Ref<[CapturedError]> { + pub fn errors(&self) -> Ref<'_, [CapturedError]> { Ref::map(self.errors.borrow(), |errors| errors.as_slice()) } diff --git a/packages/core/src/scheduler.rs b/packages/core/src/scheduler.rs index ba0fea6c0..bd30aa637 100644 --- a/packages/core/src/scheduler.rs +++ b/packages/core/src/scheduler.rs @@ -265,17 +265,16 @@ impl Borrow for DirtyTasks { } } -impl PartialOrd for DirtyTasks { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.order.cmp(&other.order)) - } -} - impl Ord for DirtyTasks { fn cmp(&self, other: &Self) -> std::cmp::Ordering { self.order.cmp(&other.order) } } +impl PartialOrd for DirtyTasks { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} impl PartialEq for DirtyTasks { fn eq(&self, other: &Self) -> bool { diff --git a/packages/core/src/scope_context.rs b/packages/core/src/scope_context.rs index cab4aaeda..2fc38957f 100644 --- a/packages/core/src/scope_context.rs +++ b/packages/core/src/scope_context.rs @@ -294,7 +294,7 @@ impl Scope { for ctx in contexts.iter_mut() { // Swap the ptr directly if let Some(ctx) = ctx.downcast_mut::() { - std::mem::swap(ctx, &mut value.clone()); + *ctx = value.clone(); return value; } } diff --git a/packages/core/src/suspense/mod.rs b/packages/core/src/suspense/mod.rs index ca44442f7..bccb53b0c 100644 --- a/packages/core/src/suspense/mod.rs +++ b/packages/core/src/suspense/mod.rs @@ -170,7 +170,7 @@ impl SuspenseContext { } /// Get all suspended tasks - pub fn suspended_futures(&self) -> Ref<[SuspendedFuture]> { + pub fn suspended_futures(&self) -> Ref<'_, [SuspendedFuture]> { Ref::map(self.inner.suspended_tasks.borrow(), |tasks| { tasks.as_slice() }) diff --git a/packages/desktop/src/ipc.rs b/packages/desktop/src/ipc.rs index 9dfbf104b..3f744bbba 100644 --- a/packages/desktop/src/ipc.rs +++ b/packages/desktop/src/ipc.rs @@ -66,7 +66,7 @@ pub enum IpcMethod<'a> { } impl IpcMessage { - pub(crate) fn method(&self) -> IpcMethod { + pub(crate) fn method(&self) -> IpcMethod<'_> { match self.method.as_str() { "file_dialog" => IpcMethod::FileDialog, "user_event" => IpcMethod::UserEvent, diff --git a/packages/manganis/manganis-core/src/asset.rs b/packages/manganis/manganis-core/src/asset.rs index bcef65511..92c543599 100644 --- a/packages/manganis/manganis-core/src/asset.rs +++ b/packages/manganis/manganis-core/src/asset.rs @@ -94,6 +94,7 @@ impl BundledAsset { /// img { src: ASSET } /// }; /// ``` +#[allow(unpredictable_function_pointer_comparisons)] #[derive(PartialEq, Clone, Copy)] pub struct Asset { /// A function that returns a pointer to the bundled asset. This will be resolved after the linker has run and diff --git a/packages/router-macro/src/lib.rs b/packages/router-macro/src/lib.rs index b791df943..3b7af200d 100644 --- a/packages/router-macro/src/lib.rs +++ b/packages/router-macro/src/lib.rs @@ -694,6 +694,7 @@ impl RouteEnum { } } +#[allow(clippy::large_enum_variant)] enum RouteEndpoint { Route(Route), Redirect(Redirect), @@ -751,6 +752,7 @@ impl ToTokens for SiteMapSegment { } } +#[allow(clippy::large_enum_variant)] enum SegmentType { Static(String), Dynamic(String), diff --git a/packages/router-macro/src/query.rs b/packages/router-macro/src/query.rs index ae6f17f29..7a4a79ba7 100644 --- a/packages/router-macro/src/query.rs +++ b/packages/router-macro/src/query.rs @@ -3,6 +3,7 @@ use syn::{Ident, Type}; use proc_macro2::TokenStream as TokenStream2; +#[allow(clippy::large_enum_variant)] #[derive(Debug)] pub enum QuerySegment { Single(FullQuerySegment), diff --git a/packages/router-macro/src/route.rs b/packages/router-macro/src/route.rs index d7b3f1a56..08b38f535 100644 --- a/packages/router-macro/src/route.rs +++ b/packages/router-macro/src/route.rs @@ -461,6 +461,7 @@ impl Route { } } +#[allow(clippy::large_enum_variant)] #[derive(Debug)] pub(crate) enum RouteType { Child(Field), diff --git a/packages/signals/src/read.rs b/packages/signals/src/read.rs index 31a27671a..2604e2a88 100644 --- a/packages/signals/src/read.rs +++ b/packages/signals/src/read.rs @@ -73,7 +73,7 @@ pub trait ReadableExt: Readable { /// If the value has been dropped, this will panic. Calling this on a Signal is the same as /// using the signal() syntax to read and subscribe to its value #[track_caller] - fn read(&self) -> ReadableRef + fn read(&self) -> ReadableRef<'_, Self> where Self::Target: 'static, { @@ -82,7 +82,7 @@ pub trait ReadableExt: Readable { /// Try to get the current value of the state. If this is a signal, this will subscribe the current scope to the signal. #[track_caller] - fn try_read(&self) -> Result, generational_box::BorrowError> + fn try_read(&self) -> Result, generational_box::BorrowError> where Self::Target: 'static, { @@ -136,7 +136,7 @@ pub trait ReadableExt: Readable { /// } /// ``` #[track_caller] - fn peek(&self) -> ReadableRef + fn peek(&self) -> ReadableRef<'_, Self> where Self::Target: 'static, { @@ -146,7 +146,7 @@ pub trait ReadableExt: Readable { /// Try to peek the current value of the signal without subscribing to updates. If the value has /// been dropped, this will return an error. #[track_caller] - fn try_peek(&self) -> Result, generational_box::BorrowError> + fn try_peek(&self) -> Result, generational_box::BorrowError> where Self::Target: 'static, { @@ -229,7 +229,10 @@ pub trait ReadableExt: Readable { /// Index into the inner value and return a reference to the result. If the value has been dropped or the index is invalid, this will panic. #[track_caller] - fn index(&self, index: I) -> ReadableRef>::Output> + fn index( + &self, + index: I, + ) -> ReadableRef<'_, Self, >::Output> where Self::Target: std::ops::Index + 'static, { @@ -313,7 +316,7 @@ pub trait ReadableVecExt: Readable> { /// Get the first element of the inner vector. #[track_caller] - fn first(&self) -> Option> + fn first(&self) -> Option> where T: 'static, { @@ -322,7 +325,7 @@ pub trait ReadableVecExt: Readable> { /// Get the last element of the inner vector. #[track_caller] - fn last(&self) -> Option> + fn last(&self) -> Option> where T: 'static, { @@ -331,7 +334,7 @@ pub trait ReadableVecExt: Readable> { /// Get the element at the given index of the inner vector. #[track_caller] - fn get(&self, index: usize) -> Option> + fn get(&self, index: usize) -> Option> where T: 'static, { @@ -382,7 +385,7 @@ pub trait ReadableOptionExt: Readable> { /// Attempts to read the inner value of the Option. #[track_caller] - fn as_ref(&self) -> Option> + fn as_ref(&self) -> Option> where T: 'static, { @@ -408,7 +411,7 @@ pub trait ReadableResultExt: Readable> { /// Attempts to read the inner value of the Option. #[track_caller] - fn as_ref(&self) -> Result, ReadableRef> + fn as_ref(&self) -> Result, ReadableRef<'_, Self, E>> where T: 'static, E: 'static, diff --git a/packages/wasm-split/wasm-split-cli/src/lib.rs b/packages/wasm-split/wasm-split-cli/src/lib.rs index 90ed4dc5d..bcf9d347f 100644 --- a/packages/wasm-split/wasm-split-cli/src/lib.rs +++ b/packages/wasm-split/wasm-split-cli/src/lib.rs @@ -1466,7 +1466,7 @@ struct DataSymbol { /// We need to do this for data symbols because walrus doesn't provide the right range and offset /// information for data segments. Fortunately, it provides it for code sections, so we only need to /// do a small amount extra of parsing here. -fn parse_bytes_to_data_segment(bytes: &[u8]) -> Result { +fn parse_bytes_to_data_segment(bytes: &[u8]) -> Result> { let parser = wasmparser::Parser::new(0); let mut parser = parser.parse_all(bytes); let mut segments = vec![]; diff --git a/packages/web/src/history.rs b/packages/web/src/history.rs index a5cb4f709..dc3850581 100644 --- a/packages/web/src/history.rs +++ b/packages/web/src/history.rs @@ -74,9 +74,11 @@ impl WebHistory { } fn scroll_pos(&self) -> ScrollPosition { - self.do_scroll_restoration - .then(|| ScrollPosition::of_window(&self.window)) - .unwrap_or_default() + if self.do_scroll_restoration { + ScrollPosition::of_window(&self.window) + } else { + Default::default() + } } fn create_state(&self) -> [f64; 2] { @@ -239,9 +241,11 @@ impl HashHistory { } fn scroll_pos(&self) -> ScrollPosition { - self.do_scroll_restoration - .then(|| ScrollPosition::of_window(&self.window)) - .unwrap_or_default() + if self.do_scroll_restoration { + ScrollPosition::of_window(&self.window) + } else { + Default::default() + } } fn create_state(&self) -> [f64; 2] {