From bcc8f13b2bb91dabff36478f7d86c1c0004b6adb Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Tue, 15 Sep 2020 00:49:10 +0200 Subject: [PATCH] Fix most rustc & clippy warnings --- anvil/src/shell.rs | 13 +++++-------- examples/raw_atomic_drm.rs | 10 +++------- examples/raw_legacy_drm.rs | 8 +------- examples/raw_nvidia.rs | 8 +------- src/backend/egl/ffi.rs | 2 +- src/backend/graphics/gl.rs | 2 +- src/backend/session/dbus/mod.rs | 2 +- src/wayland/compositor/roles.rs | 2 +- src/wayland/mod.rs | 1 + 9 files changed, 15 insertions(+), 33 deletions(-) diff --git a/anvil/src/shell.rs b/anvil/src/shell.rs index 8de616f..757c4df 100644 --- a/anvil/src/shell.rs +++ b/anvil/src/shell.rs @@ -784,8 +784,6 @@ fn surface_commit( .with_role_data(surface, |&mut role: &mut SubsurfaceRole| role) .ok(); - let mut next_state = CommitedState::default(); - let (refresh, apply_children) = token.with_surface_data(surface, |attributes| { attributes .user_data @@ -796,13 +794,12 @@ fn surface_commit( .unwrap() .borrow_mut(); - if let Some(ref cached_state) = data.cached_state { + let mut next_state = match data.cached_state { // There is a pending state, accumulate into it - next_state = cached_state.clone(); - } else { - // start from the current state - next_state = data.current_state.clone(); - } + Some(ref cached_state) => cached_state.clone(), + // Start from the current state + None => data.current_state.clone(), + }; if let Some(ref data) = sub_data { next_state.sub_location = data.location; diff --git a/examples/raw_atomic_drm.rs b/examples/raw_atomic_drm.rs index bc1a2bb..d0a0424 100644 --- a/examples/raw_atomic_drm.rs +++ b/examples/raw_atomic_drm.rs @@ -28,8 +28,8 @@ use std::{ sync::Mutex, }; -fn get_property_by_name<'a, D: ControlDevice, T: ResourceHandle>( - dev: &'a D, +fn get_property_by_name( + dev: &D, handle: T, name: &'static str, ) -> Option<(property::ValueType, property::RawValue)> { @@ -84,11 +84,7 @@ fn main() { .unwrap(); let encoder_info = device.get_encoder_info(encoder).unwrap(); - *res_handles - .filter_crtcs(encoder_info.possible_crtcs()) - .iter() - .next() - .unwrap() + res_handles.filter_crtcs(encoder_info.possible_crtcs())[0] } _ => unreachable!("CRTC_ID does not return another property type"), }; diff --git a/examples/raw_legacy_drm.rs b/examples/raw_legacy_drm.rs index f986ad1..0f6a874 100644 --- a/examples/raw_legacy_drm.rs +++ b/examples/raw_legacy_drm.rs @@ -67,13 +67,7 @@ fn main() { let crtc = encoder_info .crtc() // or use the first one that is compatible with the encoder - .unwrap_or_else(|| { - *res_handles - .filter_crtcs(encoder_info.possible_crtcs()) - .iter() - .next() - .unwrap() - }); + .unwrap_or_else(|| res_handles.filter_crtcs(encoder_info.possible_crtcs())[0]); // Assuming we found a good connector and loaded the info into `connector_info` let mode = connector_info.modes()[0]; // Use first mode (usually highest resoltion, but in reality you should filter and sort and check and match with other connectors, if you use more then one.) diff --git a/examples/raw_nvidia.rs b/examples/raw_nvidia.rs index 081ff56..0f4576a 100644 --- a/examples/raw_nvidia.rs +++ b/examples/raw_nvidia.rs @@ -97,13 +97,7 @@ fn main() { let crtc = encoder_info .crtc() // or use the first one that is compatible with the encoder - .unwrap_or_else(|| { - *res_handles - .filter_crtcs(encoder_info.possible_crtcs()) - .iter() - .next() - .unwrap() - }); + .unwrap_or_else(|| res_handles.filter_crtcs(encoder_info.possible_crtcs())[0]); println!("Crtc {:?}", crtc); // Assuming we found a good connector and loaded the info into `connector_info` diff --git a/src/backend/egl/ffi.rs b/src/backend/egl/ffi.rs index 3687347..4d3559e 100644 --- a/src/backend/egl/ffi.rs +++ b/src/backend/egl/ffi.rs @@ -42,7 +42,7 @@ pub fn make_sure_egl_is_loaded() { }); } -#[allow(clippy::all, rust_2018_idioms)] +#[allow(clippy::all)] pub mod egl { use super::*; use libloading::Library; diff --git a/src/backend/graphics/gl.rs b/src/backend/graphics/gl.rs index 272a23b..8aa1fc0 100644 --- a/src/backend/graphics/gl.rs +++ b/src/backend/graphics/gl.rs @@ -4,7 +4,7 @@ use nix::libc::c_void; use super::{PixelFormat, SwapBuffersError}; -#[allow(clippy::all, rust_2018_idioms, missing_docs)] +#[allow(clippy::all, missing_docs)] pub(crate) mod ffi { include!(concat!(env!("OUT_DIR"), "/gl_bindings.rs")); } diff --git a/src/backend/session/dbus/mod.rs b/src/backend/session/dbus/mod.rs index 6525bac..02a3ff9 100644 --- a/src/backend/session/dbus/mod.rs +++ b/src/backend/session/dbus/mod.rs @@ -49,7 +49,7 @@ impl EventSource for DBusConnection { fn process_events(&mut self, _: Readiness, _: Token, mut callback: F) -> io::Result<()> where - F: FnMut(Message, &mut DBusConnection) -> (), + F: FnMut(Message, &mut DBusConnection), { self.cx .channel() diff --git a/src/wayland/compositor/roles.rs b/src/wayland/compositor/roles.rs index 83c718d..865e78c 100644 --- a/src/wayland/compositor/roles.rs +++ b/src/wayland/compositor/roles.rs @@ -245,7 +245,7 @@ macro_rules! define_roles( Ok(data) } else { // put it back in place - ::std::mem::replace(self, temp); + *self = temp; Err($crate::wayland::compositor::roles::WrongRole) } } diff --git a/src/wayland/mod.rs b/src/wayland/mod.rs index ad0bf3e..8906e7e 100644 --- a/src/wayland/mod.rs +++ b/src/wayland/mod.rs @@ -103,6 +103,7 @@ mod tests { } #[test] + #[allow(clippy::eq_op)] fn serial_equals_self() { let counter = create_serial_counter(0); let serial = counter.next_serial();