Browse Source

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 <jkelleyrtp@gmail.com>
Gerald E Butler 1 month ago
parent
commit
f9d89b0ac1

+ 1 - 0
.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

+ 6 - 6
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!(

+ 2 - 2
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 {

+ 1 - 1
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! {

+ 4 - 3
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 {

+ 2 - 2
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};
 ///

+ 12 - 3
packages/router/src/contexts/outlet.rs

@@ -75,10 +75,19 @@ impl<R> OutletContext<R> {
 /// # 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::<MyRouter>();
 /// println!("Current nesting level: {}", outlet_ctx.level());

+ 1 - 1
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<Args, Ret> = lazy_loader!(SomeFunction);

+ 1 - 1
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<Args, Ret> = wasm_split::lazy_loader!(extern "auto" fn SomeFunction(args: Args) -> Ret);
 ///
 /// fn SomeFunction(args: Args) -> Ret {