Skip to content

Commit

Permalink
chore: silence clippy
Browse files Browse the repository at this point in the history
It appears that clippy's dead code detection has gotten better. This
commit fixes winit's code to match.

Signed-off-by: John Nunley <[email protected]>
  • Loading branch information
notgull authored Mar 27, 2024
1 parent 962241e commit 7b0ef16
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 33 deletions.
1 change: 1 addition & 0 deletions src/platform_impl/linux/common/xkb/keymap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,7 @@ impl Deref for XkbKeymap {
}

/// Modifier index in the keymap.
#[cfg_attr(not(x11_platform), allow(dead_code))]
#[derive(Default, Debug, Clone, Copy)]
pub struct ModsIndices {
pub shift: Option<xkb_mod_index_t>,
Expand Down
1 change: 1 addition & 0 deletions src/platform_impl/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ pub struct X11WindowAttributes {
pub embed_window: Option<x11rb::protocol::xproto::Window>,
}

#[cfg_attr(not(x11_platform), allow(clippy::derivable_impls))]
impl Default for PlatformSpecificWindowAttributes {
fn default() -> Self {
Self {
Expand Down
2 changes: 2 additions & 0 deletions src/platform_impl/linux/wayland/window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ impl Window {
Some(Fullscreen::Exclusive(_)) => {
warn!("`Fullscreen::Exclusive` is ignored on Wayland");
}
#[cfg_attr(not(x11_platform), allow(clippy::bind_instead_of_map))]
Some(Fullscreen::Borderless(monitor)) => {
let output = monitor.and_then(|monitor| match monitor {
PlatformMonitorHandle::Wayland(monitor) => Some(monitor.proxy),
Expand Down Expand Up @@ -499,6 +500,7 @@ impl Window {
Some(Fullscreen::Exclusive(_)) => {
warn!("`Fullscreen::Exclusive` is ignored on Wayland");
}
#[cfg_attr(not(x11_platform), allow(clippy::bind_instead_of_map))]
Some(Fullscreen::Borderless(monitor)) => {
let output = monitor.and_then(|monitor| match monitor {
PlatformMonitorHandle::Wayland(monitor) => Some(monitor.proxy),
Expand Down
8 changes: 4 additions & 4 deletions src/platform_impl/linux/x11/dnd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ pub enum DndState {
#[derive(Debug)]
pub enum DndDataParseError {
EmptyData,
InvalidUtf8(Utf8Error),
HostnameSpecified(String),
UnexpectedProtocol(String),
UnresolvablePath(io::Error),
InvalidUtf8(#[allow(dead_code)] Utf8Error),
HostnameSpecified(#[allow(dead_code)] String),
UnexpectedProtocol(#[allow(dead_code)] String),
UnresolvablePath(#[allow(dead_code)] io::Error),
}

impl From<Utf8Error> for DndDataParseError {
Expand Down
20 changes: 0 additions & 20 deletions src/platform_impl/linux/x11/util/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,6 @@ impl AaRect {
}
}

#[derive(Debug, Default)]
pub struct Geometry {
pub root: xproto::Window,
// If you want positions relative to the root window, use translate_coords.
// Note that the overwhelming majority of window managers are reparenting WMs, thus the window
// ID we get from window creation is for a nested window used as the window's client area. If
// you call get_geometry with that window ID, then you'll get the position of that client area
// window relative to the parent it's nested in (the frame), which isn't helpful if you want
// to know the frame position.
pub x_rel_parent: c_int,
pub y_rel_parent: c_int,
// In that same case, this will give you client area size.
pub width: c_uint,
pub height: c_uint,
// xmonad and dwm were the only WMs tested that use the border return at all.
// The majority of WMs seem to simply fill it with 0 unconditionally.
pub border: c_uint,
pub depth: c_uint,
}

#[derive(Debug, Clone)]
pub struct FrameExtents {
pub left: u32,
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/linux/x11/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ impl UnownedWindow {
if old_fullscreen == fullscreen {
return Ok(None);
}
shared_state_lock.fullscreen = fullscreen.clone();
shared_state_lock.fullscreen.clone_from(&fullscreen);

match (&old_fullscreen, &fullscreen) {
// Store the desktop video mode before entering exclusive
Expand Down
4 changes: 2 additions & 2 deletions src/platform_impl/linux/x11/xsettings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ impl Endianness {
}

/// Parser errors.
#[allow(dead_code)]
#[derive(Debug)]
pub enum ParserError {
/// Ran out of bytes.
Expand All @@ -274,9 +275,8 @@ impl ParserError {
}

#[cfg(test)]
/// Tests for the XSETTINGS parser.
mod tests {
//! Tests for the XSETTINGS parser.
use super::*;

const XSETTINGS: &str = include_str!("tests/xsettings.dat");
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/web/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ async fn from_url(
async fn from_animation(
main_thread: MainThreadMarker,
duration: Duration,
cursors: impl Iterator<Item = CustomCursor> + ExactSizeIterator,
cursors: impl ExactSizeIterator<Item = CustomCursor>,
) -> Result<Animation, CustomCursorError> {
let keyframes = Array::new();
let mut images = Vec::with_capacity(cursors.len());
Expand Down
4 changes: 2 additions & 2 deletions src/platform_impl/web/event_loop/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ impl Shared {
ControlFlow::Poll => {
let cloned = self.clone();
State::Poll {
request: backend::Schedule::new(
_request: backend::Schedule::new(
self.poll_strategy(),
self.window(),
move || cloned.poll(),
Expand All @@ -693,7 +693,7 @@ impl Shared {
State::WaitUntil {
start,
end,
timeout: backend::Schedule::new_with_duration(
_timeout: backend::Schedule::new_with_duration(
self.window(),
move || cloned.resume_time_reached(start, end),
delay,
Expand Down
4 changes: 2 additions & 2 deletions src/platform_impl/web/event_loop/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ use web_time::Instant;
pub enum State {
Init,
WaitUntil {
timeout: backend::Schedule,
_timeout: backend::Schedule,
start: Instant,
end: Instant,
},
Wait {
start: Instant,
},
Poll {
request: backend::Schedule,
_request: backend::Schedule,
},
Exit,
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/windows/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ impl Window {
_ => {}
}

window_state_lock.fullscreen = fullscreen.clone();
window_state_lock.fullscreen.clone_from(&fullscreen);
drop(window_state_lock);

self.thread_executor.execute_in_thread(move || {
Expand Down

0 comments on commit 7b0ef16

Please sign in to comment.