mirror of
https://github.com/rust-windowing/winit.git
synced 2026-09-01 22:30:04 -04:00
chore: fix clippy issues
This commit is contained in:
@@ -1152,7 +1152,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn ensure_attrs_do_not_panic() {
|
fn ensure_attrs_do_not_panic() {
|
||||||
foreach_event!(|event: event::Event<()>| {
|
foreach_event!(|event: event::Event<()>| {
|
||||||
let _ = format!("{:?}", event);
|
let _ = format!("{event:?}");
|
||||||
});
|
});
|
||||||
let _ = event::StartCause::Init.clone();
|
let _ = event::StartCause::Init.clone();
|
||||||
|
|
||||||
|
|||||||
@@ -165,7 +165,6 @@
|
|||||||
//! [`Window`]: window::Window
|
//! [`Window`]: window::Window
|
||||||
//! [`WindowId`]: window::WindowId
|
//! [`WindowId`]: window::WindowId
|
||||||
//! [`WindowAttributes`]: window::WindowAttributes
|
//! [`WindowAttributes`]: window::WindowAttributes
|
||||||
//! [window_new]: window::Window::new
|
|
||||||
//! [`create_window`]: event_loop::ActiveEventLoop::create_window
|
//! [`create_window`]: event_loop::ActiveEventLoop::create_window
|
||||||
//! [`Window::id()`]: window::Window::id
|
//! [`Window::id()`]: window::Window::id
|
||||||
//! [`WindowEvent`]: event::WindowEvent
|
//! [`WindowEvent`]: event::WindowEvent
|
||||||
@@ -185,6 +184,9 @@
|
|||||||
// doc
|
// doc
|
||||||
#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg_hide), doc(cfg_hide(doc, docsrs)))]
|
#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg_hide), doc(cfg_hide(doc, docsrs)))]
|
||||||
#![allow(clippy::missing_safety_doc)]
|
#![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")]
|
#[cfg(feature = "rwh_04")]
|
||||||
pub use rwh_04 as raw_window_handle_04;
|
pub use rwh_04 as raw_window_handle_04;
|
||||||
|
|||||||
@@ -51,19 +51,19 @@ pub trait EventLoopExtPumpEvents {
|
|||||||
/// buffered and handled outside of Winit include:
|
/// buffered and handled outside of Winit include:
|
||||||
/// - `RedrawRequested` events, used to schedule rendering.
|
/// - `RedrawRequested` events, used to schedule rendering.
|
||||||
///
|
///
|
||||||
/// macOS for example uses a `drawRect` callback to drive rendering
|
/// macOS for example uses a `drawRect` callback to drive rendering
|
||||||
/// within applications and expects rendering to be finished before
|
/// within applications and expects rendering to be finished before
|
||||||
/// the `drawRect` callback returns.
|
/// the `drawRect` callback returns.
|
||||||
///
|
///
|
||||||
/// For portability it's strongly recommended that applications should
|
/// For portability it's strongly recommended that applications should
|
||||||
/// keep their rendering inside the closure provided to Winit.
|
/// keep their rendering inside the closure provided to Winit.
|
||||||
/// - Any lifecycle events, such as `Suspended` / `Resumed`.
|
/// - Any lifecycle events, such as `Suspended` / `Resumed`.
|
||||||
///
|
///
|
||||||
/// The handling of these events needs to be synchronized with the
|
/// The handling of these events needs to be synchronized with the
|
||||||
/// operating system and it would never be appropriate to buffer a
|
/// operating system and it would never be appropriate to buffer a
|
||||||
/// notification that your application has been suspended or resumed and
|
/// notification that your application has been suspended or resumed and
|
||||||
/// then handled that later since there would always be a chance that
|
/// then handled that later since there would always be a chance that
|
||||||
/// other lifecycle events occur while the event is buffered.
|
/// other lifecycle events occur while the event is buffered.
|
||||||
///
|
///
|
||||||
/// ## Supported Platforms
|
/// ## Supported Platforms
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ pub trait EventLoopExtRunOnDemand {
|
|||||||
/// are delivered via callbacks based on an event loop that is internal to the browser itself.
|
/// 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.
|
/// - **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.")]
|
#[cfg_attr(not(web_platform), doc = "[^1]: `spawn()` is only available on `wasm` platforms.")]
|
||||||
#[rustfmt::skip]
|
|
||||||
///
|
///
|
||||||
|
#[rustfmt::skip]
|
||||||
/// [`exit()`]: ActiveEventLoop::exit()
|
/// [`exit()`]: ActiveEventLoop::exit()
|
||||||
/// [`set_control_flow()`]: ActiveEventLoop::set_control_flow()
|
/// [`set_control_flow()`]: ActiveEventLoop::set_control_flow()
|
||||||
fn run_app_on_demand<A: ApplicationHandler<Self::UserEvent>>(
|
fn run_app_on_demand<A: ApplicationHandler<Self::UserEvent>>(
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ declare_class!(
|
|||||||
// Pass -delta so that action is reversed
|
// Pass -delta so that action is reversed
|
||||||
(TouchPhase::Cancelled, -recognizer.scale())
|
(TouchPhase::Cancelled, -recognizer.scale())
|
||||||
}
|
}
|
||||||
state => panic!("unexpected recognizer state: {:?}", state),
|
state => panic!("unexpected recognizer state: {state:?}"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let gesture_event = EventWrapper::StaticEvent(Event::WindowEvent {
|
let gesture_event = EventWrapper::StaticEvent(Event::WindowEvent {
|
||||||
@@ -249,7 +249,7 @@ declare_class!(
|
|||||||
// Pass -delta so that action is reversed
|
// Pass -delta so that action is reversed
|
||||||
(TouchPhase::Cancelled, -recognizer.rotation())
|
(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
|
// Make delta negative to match macos, convert to degrees
|
||||||
@@ -300,7 +300,7 @@ declare_class!(
|
|||||||
// Pass -delta so that action is reversed
|
// Pass -delta so that action is reversed
|
||||||
(TouchPhase::Cancelled, -last_pan.x, -last_pan.y)
|
(TouchPhase::Cancelled, -last_pan.x, -last_pan.y)
|
||||||
}
|
}
|
||||||
state => panic!("unexpected recognizer state: {:?}", state),
|
state => panic!("unexpected recognizer state: {state:?}"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ fn push_display(buffer: &mut Vec<u8>, display: &impl std::fmt::Display) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(Writer { buffer }, "{}", display).unwrap();
|
write!(Writer { buffer }, "{display}").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -850,24 +850,24 @@ pub enum X11Error {
|
|||||||
impl fmt::Display for X11Error {
|
impl fmt::Display for X11Error {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
X11Error::Xlib(e) => write!(f, "Xlib error: {}", e),
|
X11Error::Xlib(e) => write!(f, "Xlib error: {e}"),
|
||||||
X11Error::Connect(e) => write!(f, "X11 connection error: {}", e),
|
X11Error::Connect(e) => write!(f, "X11 connection error: {e}"),
|
||||||
X11Error::Connection(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::XidsExhausted(e) => write!(f, "XID range exhausted: {e}"),
|
||||||
X11Error::GetProperty(e) => write!(f, "Failed to get X property {}", e),
|
X11Error::GetProperty(e) => write!(f, "Failed to get X property {e}"),
|
||||||
X11Error::X11(e) => write!(f, "X11 error: {:?}", e),
|
X11Error::X11(e) => write!(f, "X11 error: {e:?}"),
|
||||||
X11Error::UnexpectedNull(s) => write!(f, "Xlib function returned null: {}", s),
|
X11Error::UnexpectedNull(s) => write!(f, "Xlib function returned null: {s}"),
|
||||||
X11Error::InvalidActivationToken(s) => write!(
|
X11Error::InvalidActivationToken(s) => write!(
|
||||||
f,
|
f,
|
||||||
"Invalid activation token: {}",
|
"Invalid activation token: {}",
|
||||||
std::str::from_utf8(s).unwrap_or("<invalid utf8>")
|
std::str::from_utf8(s).unwrap_or("<invalid utf8>")
|
||||||
),
|
),
|
||||||
X11Error::MissingExtension(s) => write!(f, "Missing X11 extension: {}", s),
|
X11Error::MissingExtension(s) => write!(f, "Missing X11 extension: {s}"),
|
||||||
X11Error::NoSuchVisual(visualid) => {
|
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) => {
|
X11Error::XsettingsParse(err) => {
|
||||||
write!(f, "Failed to parse xsettings: {:?}", err)
|
write!(f, "Failed to parse xsettings: {err:?}")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ impl XConnection {
|
|||||||
fn new_xsettings_screen(xcb: &XCBConnection, default_screen: usize) -> Option<xproto::Atom> {
|
fn new_xsettings_screen(xcb: &XCBConnection, default_screen: usize) -> Option<xproto::Atom> {
|
||||||
// Fetch the _XSETTINGS_S[screen number] atom.
|
// Fetch the _XSETTINGS_S[screen number] atom.
|
||||||
let xsettings_screen = xcb
|
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()?
|
.ok()?
|
||||||
.reply()
|
.reply()
|
||||||
.ok()?
|
.ok()?
|
||||||
|
|||||||
@@ -420,7 +420,7 @@ impl Window {
|
|||||||
window::ResizeDirection::West => "L",
|
window::ResizeDirection::West => "L",
|
||||||
};
|
};
|
||||||
self.window_socket
|
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))))?;
|
.map_err(|err| error::ExternalError::Os(os_error!(OsError::new(err))))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1864,14 +1864,14 @@ impl ActivationToken {
|
|||||||
/// won't get focused automatically), but won't yield any errors.
|
/// won't get focused automatically), but won't yield any errors.
|
||||||
///
|
///
|
||||||
/// To obtain a valid token, use
|
/// 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(
|
#[cfg_attr(
|
||||||
not(any(x11_platform, wayland_platform, docsrs)),
|
not(any(x11_platform, wayland_platform, docsrs)),
|
||||||
doc = " `request_activation_token`."
|
doc = " `request_activation_token`."
|
||||||
)]
|
)]
|
||||||
///
|
|
||||||
#[rustfmt::skip]
|
|
||||||
/// [`request_activation_token`]: crate::platform::startup_notify::WindowExtStartupNotify::request_activation_token
|
|
||||||
pub fn from_raw(token: String) -> Self {
|
pub fn from_raw(token: String) -> Self {
|
||||||
Self { token }
|
Self { token }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user