From f9d89b0ac1e121039a0cd52b71eea0a3344314bc Mon Sep 17 00:00:00 2001 From: Gerald E Butler Date: Wed, 7 May 2025 16:58:37 -0400 Subject: [PATCH] adhoc: Fix Clippy lints in const-serialize etc. (#3880) * adhox: Fix Clippy lints in const-serialize etc. Fix the clippy lints that were preventing building: * const-serialize/src/lib.rs * core/src/nodes.rs * fullstack/src/serve_config.rs * adhoc: Change the way to satisfy the lint for 1.85 The lint for pointer comparison is only in 1.85. The solution uses a mechanism that was only stabilized with 1.85. Instead of using that solution, will just allow the lint on this function for now. Once the MSRV of Dioxus is updated to 1.85 or above, this can be changed to use the recommeneded solution. * adhoc: Fix the 'cargo make test' tests There were a number of tests failing to compile and/or run. Fixed those that could be meaningfully fixed. Those that were incomplete examples that could not be fixed are marked as 'ignore'. * adhoc: GitIgnore test results in playwright tests * fix wry rollback --------- Co-authored-by: Jonathan Kelley --- .gitignore | 1 + packages/const-serialize/src/lib.rs | 12 ++++++------ packages/core/src/nodes.rs | 4 ++-- packages/dioxus/src/launch.rs | 2 +- packages/html/src/events/mounted.rs | 7 ++++--- packages/logger/src/lib.rs | 4 ++-- packages/router/src/contexts/outlet.rs | 15 ++++++++++++--- packages/wasm-split/wasm-split-macro/src/lib.rs | 2 +- packages/wasm-split/wasm-split/src/lib.rs | 2 +- 9 files changed, 30 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 5605d470d..07974b162 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /target /packages/playwright-tests/web/dist /packages/playwright-tests/fullstack/dist +/packages/playwright-tests/test-results /dist .DS_Store /examples/assets/test_video.mp4 diff --git a/packages/const-serialize/src/lib.rs b/packages/const-serialize/src/lib.rs index 6a911be6b..0a32d503b 100644 --- a/packages/const-serialize/src/lib.rs +++ b/packages/const-serialize/src/lib.rs @@ -516,18 +516,18 @@ const fn char_to_bytes(char: char) -> ([u8; 4], usize) { bytes[0] = code as u8; } 2 => { - bytes[0] = (code >> 6 & 0x1F) as u8 | BYTE_CHAR_BOUNDARIES[1]; + bytes[0] = ((code >> 6) & 0x1F) as u8 | BYTE_CHAR_BOUNDARIES[1]; bytes[1] = (code & 0x3F) as u8 | CONTINUED_CHAR_MASK; } 3 => { - bytes[0] = (code >> 12 & 0x0F) as u8 | BYTE_CHAR_BOUNDARIES[2]; - bytes[1] = (code >> 6 & 0x3F) as u8 | CONTINUED_CHAR_MASK; + bytes[0] = ((code >> 12) & 0x0F) as u8 | BYTE_CHAR_BOUNDARIES[2]; + bytes[1] = ((code >> 6) & 0x3F) as u8 | CONTINUED_CHAR_MASK; bytes[2] = (code & 0x3F) as u8 | CONTINUED_CHAR_MASK; } 4 => { - bytes[0] = (code >> 18 & 0x07) as u8 | BYTE_CHAR_BOUNDARIES[3]; - bytes[1] = (code >> 12 & 0x3F) as u8 | CONTINUED_CHAR_MASK; - bytes[2] = (code >> 6 & 0x3F) as u8 | CONTINUED_CHAR_MASK; + bytes[0] = ((code >> 18) & 0x07) as u8 | BYTE_CHAR_BOUNDARIES[3]; + bytes[1] = ((code >> 12) & 0x3F) as u8 | CONTINUED_CHAR_MASK; + bytes[2] = ((code >> 6) & 0x3F) as u8 | CONTINUED_CHAR_MASK; bytes[3] = (code & 0x3F) as u8 | CONTINUED_CHAR_MASK; } _ => panic!( diff --git a/packages/core/src/nodes.rs b/packages/core/src/nodes.rs index 66e7c9bcf..8946054f7 100644 --- a/packages/core/src/nodes.rs +++ b/packages/core/src/nodes.rs @@ -378,12 +378,12 @@ pub struct Template { // Are identical static items merged in the current build. Rust doesn't have a cfg(merge_statics) attribute // so we have to check this manually -#[allow(unpredictable_function_pointer_comparisons)] +#[allow(unpredictable_function_pointer_comparisons)] // This attribute should be removed once MSRV is 1.85 or greater and the below change is made fn static_items_merged() -> bool { fn a() {} fn b() {} - a as fn() == b as fn() + // std::ptr::fn_addr_eq(a as fn(), b as fn()) <<<<---- This should replace the a as fn() === b as fn() once the MSRV is 1.85 or greater } impl std::hash::Hash for Template { diff --git a/packages/dioxus/src/launch.rs b/packages/dioxus/src/launch.rs index 087be1ca6..cb9b8c08d 100644 --- a/packages/dioxus/src/launch.rs +++ b/packages/dioxus/src/launch.rs @@ -261,7 +261,7 @@ impl LaunchBuilder { /// # Example /// ```rust, no_run /// use dioxus::prelude::*; - /// use dioxus_desktop::{Config,WindowBuilder}; + /// use dioxus_desktop::{Config, WindowBuilder}; /// /// fn app() -> Element { /// rsx! { diff --git a/packages/html/src/events/mounted.rs b/packages/html/src/events/mounted.rs index 156dd40d1..b7ef31329 100644 --- a/packages/html/src/events/mounted.rs +++ b/packages/html/src/events/mounted.rs @@ -255,9 +255,10 @@ impl_event! [ /// /// The `MountedData` struct contains cross platform APIs that work on the desktop, mobile, liveview and web platforms. For the web platform, you can also downcast the `MountedData` event to the `web-sys::Element` type for more web specific APIs: /// - /// ```rust, no_run - /// # use dioxus::prelude::*; - /// # use dioxus_web::WebEventExt; + /// ```rust, ignore + /// use dioxus::prelude::*; + /// use dioxus_web::WebEventExt; // provides [`as_web_event()`] method + /// /// fn App() -> Element { /// rsx! { /// div { diff --git a/packages/logger/src/lib.rs b/packages/logger/src/lib.rs index ce0a7a0f7..bfc7fd6d8 100644 --- a/packages/logger/src/lib.rs +++ b/packages/logger/src/lib.rs @@ -16,7 +16,7 @@ pub use tracing; /// /// # Example /// -/// ```rust,no_run +/// ```rust, ignore /// use dioxus::prelude::*; /// use tracing::info; /// @@ -55,7 +55,7 @@ pub fn initialize_default() { /// /// # Example /// -/// ```rust,no_run +/// ```rust, ignore /// use dioxus::prelude::*; /// use dioxus::logger::tracing::{Level, info}; /// diff --git a/packages/router/src/contexts/outlet.rs b/packages/router/src/contexts/outlet.rs index 78c336fcf..c3fd5c5f6 100644 --- a/packages/router/src/contexts/outlet.rs +++ b/packages/router/src/contexts/outlet.rs @@ -75,10 +75,19 @@ impl OutletContext { /// # Examples /// /// ```rust, no_run -/// # use dioxus::prelude::*; +/// # use dioxus_lib::prelude::*; +/// # use dioxus_router::prelude::{use_outlet_context,Routable}; /// -/// #[derive(Clone)] -/// struct MyRouter; +/// # #[derive(Routable,Clone,PartialEq)] +/// # enum MyRouter { +/// # #[route("/")] +/// # MyView +/// # } +/// +/// # #[component] +/// # fn MyView() -> Element { +/// # rsx!{ div { "My Text" } } +/// # } /// /// let outlet_ctx = use_outlet_context::(); /// println!("Current nesting level: {}", outlet_ctx.level()); diff --git a/packages/wasm-split/wasm-split-macro/src/lib.rs b/packages/wasm-split/wasm-split-macro/src/lib.rs index ddf572fd7..57fa02b93 100644 --- a/packages/wasm-split/wasm-split-macro/src/lib.rs +++ b/packages/wasm-split/wasm-split-macro/src/lib.rs @@ -114,7 +114,7 @@ pub fn wasm_split(args: TokenStream, input: TokenStream) -> TokenStream { /// Create a lazy loader for a given function. Meant to be used in statics. Designed for libraries to /// integrate with. /// -/// ```rust, no_run +/// ```rust, ignore /// fn SomeFunction(args: Args) -> Ret {} /// /// static LOADER: wasm_split::LazyLoader = lazy_loader!(SomeFunction); diff --git a/packages/wasm-split/wasm-split/src/lib.rs b/packages/wasm-split/wasm-split/src/lib.rs index 46f31d58b..0a3d17d9c 100644 --- a/packages/wasm-split/wasm-split/src/lib.rs +++ b/packages/wasm-split/wasm-split/src/lib.rs @@ -34,7 +34,7 @@ impl std::fmt::Display for SplitLoaderError { /// which module the function should be loaded from. If you don't know which module to use, use `auto` /// and wasm-split will automatically combine all the modules into one. /// -/// ```rust, no_run +/// ```rust, ignore /// static LOADER: wasm_split::LazyLoader = wasm_split::lazy_loader!(extern "auto" fn SomeFunction(args: Args) -> Ret); /// /// fn SomeFunction(args: Args) -> Ret {