From aaecc92b628b1a36707563972a1f4f2781a3cfd4 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Sun, 6 Apr 2025 15:41:46 +0900 Subject: [PATCH] chore: fix clippy issues --- src/event.rs | 2 +- src/lib.rs | 4 +++- src/platform/pump_events.rs | 20 ++++++++++---------- src/platform/run_on_demand.rs | 2 +- src/platform_impl/ios/view.rs | 6 +++--- src/platform_impl/linux/x11/activation.rs | 2 +- src/platform_impl/linux/x11/mod.rs | 20 ++++++++++---------- src/platform_impl/linux/x11/xdisplay.rs | 2 +- src/platform_impl/orbital/window.rs | 2 +- src/window.rs | 8 ++++---- 10 files changed, 35 insertions(+), 33 deletions(-) diff --git a/src/event.rs b/src/event.rs index 1d14259de..1890aea97 100644 --- a/src/event.rs +++ b/src/event.rs @@ -1152,7 +1152,7 @@ mod tests { #[test] fn ensure_attrs_do_not_panic() { foreach_event!(|event: event::Event<()>| { - let _ = format!("{:?}", event); + let _ = format!("{event:?}"); }); let _ = event::StartCause::Init.clone(); diff --git a/src/lib.rs b/src/lib.rs index ba3e7cd17..9743e4999 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -165,7 +165,6 @@ //! [`Window`]: window::Window //! [`WindowId`]: window::WindowId //! [`WindowAttributes`]: window::WindowAttributes -//! [window_new]: window::Window::new //! [`create_window`]: event_loop::ActiveEventLoop::create_window //! [`Window::id()`]: window::Window::id //! [`WindowEvent`]: event::WindowEvent @@ -185,6 +184,9 @@ // doc #![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg_hide), doc(cfg_hide(doc, docsrs)))] #![allow(clippy::missing_safety_doc)] +#![warn(clippy::uninlined_format_args)] +// TODO: wasm-binding needs to be updated for that to be resolved, for now just silence it. +#![cfg_attr(web_platform, allow(unknown_lints, wasm_c_abi))] #[cfg(feature = "rwh_04")] pub use rwh_04 as raw_window_handle_04; diff --git a/src/platform/pump_events.rs b/src/platform/pump_events.rs index dbe14f6fa..447663535 100644 --- a/src/platform/pump_events.rs +++ b/src/platform/pump_events.rs @@ -51,19 +51,19 @@ pub trait EventLoopExtPumpEvents { /// buffered and handled outside of Winit include: /// - `RedrawRequested` events, used to schedule rendering. /// - /// macOS for example uses a `drawRect` callback to drive rendering - /// within applications and expects rendering to be finished before - /// the `drawRect` callback returns. + /// macOS for example uses a `drawRect` callback to drive rendering + /// within applications and expects rendering to be finished before + /// the `drawRect` callback returns. /// - /// For portability it's strongly recommended that applications should - /// keep their rendering inside the closure provided to Winit. + /// For portability it's strongly recommended that applications should + /// keep their rendering inside the closure provided to Winit. /// - Any lifecycle events, such as `Suspended` / `Resumed`. /// - /// The handling of these events needs to be synchronized with the - /// operating system and it would never be appropriate to buffer a - /// notification that your application has been suspended or resumed and - /// then handled that later since there would always be a chance that - /// other lifecycle events occur while the event is buffered. + /// The handling of these events needs to be synchronized with the + /// operating system and it would never be appropriate to buffer a + /// notification that your application has been suspended or resumed and + /// then handled that later since there would always be a chance that + /// other lifecycle events occur while the event is buffered. /// /// ## Supported Platforms /// diff --git a/src/platform/run_on_demand.rs b/src/platform/run_on_demand.rs index 821e87914..0bb96e92e 100644 --- a/src/platform/run_on_demand.rs +++ b/src/platform/run_on_demand.rs @@ -63,8 +63,8 @@ pub trait EventLoopExtRunOnDemand { /// are delivered via callbacks based on an event loop that is internal to the browser itself. /// - **iOS:** It's not possible to stop and start an `UIApplication` repeatedly on iOS. #[cfg_attr(not(web_platform), doc = "[^1]: `spawn()` is only available on `wasm` platforms.")] - #[rustfmt::skip] /// + #[rustfmt::skip] /// [`exit()`]: ActiveEventLoop::exit() /// [`set_control_flow()`]: ActiveEventLoop::set_control_flow() fn run_app_on_demand>( diff --git a/src/platform_impl/ios/view.rs b/src/platform_impl/ios/view.rs index 9be43e413..418968c70 100644 --- a/src/platform_impl/ios/view.rs +++ b/src/platform_impl/ios/view.rs @@ -190,7 +190,7 @@ declare_class!( // Pass -delta so that action is reversed (TouchPhase::Cancelled, -recognizer.scale()) } - state => panic!("unexpected recognizer state: {:?}", state), + state => panic!("unexpected recognizer state: {state:?}"), }; let gesture_event = EventWrapper::StaticEvent(Event::WindowEvent { @@ -249,7 +249,7 @@ declare_class!( // Pass -delta so that action is reversed (TouchPhase::Cancelled, -recognizer.rotation()) } - state => panic!("unexpected recognizer state: {:?}", state), + state => panic!("unexpected recognizer state: {state:?}"), }; // Make delta negative to match macos, convert to degrees @@ -300,7 +300,7 @@ declare_class!( // Pass -delta so that action is reversed (TouchPhase::Cancelled, -last_pan.x, -last_pan.y) } - state => panic!("unexpected recognizer state: {:?}", state), + state => panic!("unexpected recognizer state: {state:?}"), }; diff --git a/src/platform_impl/linux/x11/activation.rs b/src/platform_impl/linux/x11/activation.rs index 5f83e1c0a..8f4aa7962 100644 --- a/src/platform_impl/linux/x11/activation.rs +++ b/src/platform_impl/linux/x11/activation.rs @@ -172,7 +172,7 @@ fn push_display(buffer: &mut Vec, display: &impl std::fmt::Display) { } } - write!(Writer { buffer }, "{}", display).unwrap(); + write!(Writer { buffer }, "{display}").unwrap(); } #[cfg(test)] diff --git a/src/platform_impl/linux/x11/mod.rs b/src/platform_impl/linux/x11/mod.rs index 6d3f93115..f29b314a7 100644 --- a/src/platform_impl/linux/x11/mod.rs +++ b/src/platform_impl/linux/x11/mod.rs @@ -850,24 +850,24 @@ pub enum X11Error { impl fmt::Display for X11Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - X11Error::Xlib(e) => write!(f, "Xlib error: {}", e), - X11Error::Connect(e) => write!(f, "X11 connection error: {}", e), - X11Error::Connection(e) => write!(f, "X11 connection error: {}", e), - X11Error::XidsExhausted(e) => write!(f, "XID range exhausted: {}", e), - X11Error::GetProperty(e) => write!(f, "Failed to get X property {}", e), - X11Error::X11(e) => write!(f, "X11 error: {:?}", e), - X11Error::UnexpectedNull(s) => write!(f, "Xlib function returned null: {}", s), + X11Error::Xlib(e) => write!(f, "Xlib error: {e}"), + X11Error::Connect(e) => write!(f, "X11 connection error: {e}"), + X11Error::Connection(e) => write!(f, "X11 connection error: {e}"), + X11Error::XidsExhausted(e) => write!(f, "XID range exhausted: {e}"), + X11Error::GetProperty(e) => write!(f, "Failed to get X property {e}"), + X11Error::X11(e) => write!(f, "X11 error: {e:?}"), + X11Error::UnexpectedNull(s) => write!(f, "Xlib function returned null: {s}"), X11Error::InvalidActivationToken(s) => write!( f, "Invalid activation token: {}", std::str::from_utf8(s).unwrap_or("") ), - X11Error::MissingExtension(s) => write!(f, "Missing X11 extension: {}", s), + X11Error::MissingExtension(s) => write!(f, "Missing X11 extension: {s}"), X11Error::NoSuchVisual(visualid) => { - write!(f, "Could not find a matching X11 visual for ID `{:x}`", visualid) + write!(f, "Could not find a matching X11 visual for ID `{visualid:x}`") }, X11Error::XsettingsParse(err) => { - write!(f, "Failed to parse xsettings: {:?}", err) + write!(f, "Failed to parse xsettings: {err:?}") }, } } diff --git a/src/platform_impl/linux/x11/xdisplay.rs b/src/platform_impl/linux/x11/xdisplay.rs index 0a56f290a..902d0ce4c 100644 --- a/src/platform_impl/linux/x11/xdisplay.rs +++ b/src/platform_impl/linux/x11/xdisplay.rs @@ -145,7 +145,7 @@ impl XConnection { fn new_xsettings_screen(xcb: &XCBConnection, default_screen: usize) -> Option { // Fetch the _XSETTINGS_S[screen number] atom. let xsettings_screen = xcb - .intern_atom(false, format!("_XSETTINGS_S{}", default_screen).as_bytes()) + .intern_atom(false, format!("_XSETTINGS_S{default_screen}").as_bytes()) .ok()? .reply() .ok()? diff --git a/src/platform_impl/orbital/window.rs b/src/platform_impl/orbital/window.rs index d90d6a458..3e676c365 100644 --- a/src/platform_impl/orbital/window.rs +++ b/src/platform_impl/orbital/window.rs @@ -420,7 +420,7 @@ impl Window { window::ResizeDirection::West => "L", }; self.window_socket - .write(format!("D,{}", arg).as_bytes()) + .write(format!("D,{arg}").as_bytes()) .map_err(|err| error::ExternalError::Os(os_error!(OsError::new(err))))?; Ok(()) } diff --git a/src/window.rs b/src/window.rs index f59273ed4..fa861dc27 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1864,14 +1864,14 @@ impl ActivationToken { /// won't get focused automatically), but won't yield any errors. /// /// To obtain a valid token, use - #[cfg_attr(any(x11_platform, wayland_platform, docsrs), doc = " [`request_activation_token`].")] + #[cfg_attr( + any(x11_platform, wayland_platform, docsrs), + doc = " [`request_activation_token`](crate::platform::startup_notify::WindowExtStartupNotify::request_activation_token)." + )] #[cfg_attr( not(any(x11_platform, wayland_platform, docsrs)), doc = " `request_activation_token`." )] - /// - #[rustfmt::skip] - /// [`request_activation_token`]: crate::platform::startup_notify::WindowExtStartupNotify::request_activation_token pub fn from_raw(token: String) -> Self { Self { token } }