From 71b4f52e5ee7b547bd59c733c28b7e9afbdbe134 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 26 Oct 2019 13:12:01 -0700 Subject: [PATCH] clippy --- src/frontend/software/termwindow.rs | 1 + term/src/selection.rs | 5 ++--- term/src/terminalstate.rs | 2 +- window/src/egl.rs | 8 ++++---- window/src/os/x11/bitmap.rs | 1 + window/src/os/x11/connection.rs | 11 +++-------- window/src/os/x11/window.rs | 12 +++++------- 7 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/frontend/software/termwindow.rs b/src/frontend/software/termwindow.rs index 52d15e5a9..6bcc6c9b3 100644 --- a/src/frontend/software/termwindow.rs +++ b/src/frontend/software/termwindow.rs @@ -639,6 +639,7 @@ impl OpenGLRenderState { } } +#[allow(clippy::large_enum_variant)] enum RenderState { Software(SoftwareRenderState), GL(OpenGLRenderState), diff --git a/term/src/selection.rs b/term/src/selection.rs index de95c0a6b..0519d9627 100644 --- a/term/src/selection.rs +++ b/term/src/selection.rs @@ -37,7 +37,7 @@ impl SelectionRange { height: usize, ) -> SelectionRange { let offset = -viewport_offset as ScrollbackOrVisibleRowIndex; - let res = SelectionRange { + SelectionRange { start: SelectionCoordinate { x: self.start.x, y: self.start.y.max(offset) - offset, @@ -50,8 +50,7 @@ impl SelectionRange { .min(offset + height as ScrollbackOrVisibleRowIndex) - offset, }, - }; - res + } } /// Returns an extended selection that it ends at the specified location diff --git a/term/src/terminalstate.rs b/term/src/terminalstate.rs index 83a64b2bb..daf469d35 100644 --- a/term/src/terminalstate.rs +++ b/term/src/terminalstate.rs @@ -591,7 +591,7 @@ impl TerminalState { } pub fn selection_range(&self) -> Option { - self.selection_range.clone().map(|r| r.normalize()) + self.selection_range.map(|r| r.normalize()) } fn mouse_drag_left(&mut self, event: MouseEvent) -> Result<(), Error> { diff --git a/window/src/egl.rs b/window/src/egl.rs index 884a078a6..7162d20b0 100644 --- a/window/src/egl.rs +++ b/window/src/egl.rs @@ -1,7 +1,7 @@ use failure::Fallible; use std::ffi::c_void; -#[allow(non_camel_case_types)] +#[allow(non_camel_case_types, clippy::unreadable_literal)] pub mod ffi { // gl_generator emits these weird cyclical and redundant type references; // the types appear to have to be in a module and need to reference super, @@ -121,7 +121,7 @@ impl EglWrapper { attributes: &[u32], ) -> Fallible> { failure::ensure!( - attributes.len() > 0 && attributes[attributes.len() - 1] == ffi::NONE, + !attributes.is_empty() && attributes[attributes.len() - 1] == ffi::NONE, "attributes list must be terminated with ffi::NONE" ); @@ -179,7 +179,7 @@ impl EglWrapper { attributes: &[u32], ) -> Fallible { failure::ensure!( - attributes.len() > 0 && attributes[attributes.len() - 1] == ffi::NONE, + !attributes.is_empty() && attributes[attributes.len() - 1] == ffi::NONE, "attributes list must be terminated with ffi::NONE" ); let context = unsafe { @@ -285,7 +285,7 @@ unsafe impl glium::backend::Backend for GlState { unsafe fn get_proc_address(&self, symbol: &str) -> *const c_void { let sym_name = std::ffi::CString::new(symbol).expect("symbol to be cstring compatible"); - std::mem::transmute(self.egl.egl.GetProcAddress(sym_name.as_ptr())) + self.egl.egl.GetProcAddress(sym_name.as_ptr()) as *const c_void } fn get_framebuffer_dimensions(&self) -> (u32, u32) { diff --git a/window/src/os/x11/bitmap.rs b/window/src/os/x11/bitmap.rs index 9b03a8395..8cc14fa45 100644 --- a/window/src/os/x11/bitmap.rs +++ b/window/src/os/x11/bitmap.rs @@ -35,6 +35,7 @@ impl Context { /// Copy an area from one drawable to another using the settings /// defined in this context. + #[allow(clippy::too_many_arguments)] pub fn copy_area( &self, src: &dyn Drawable, diff --git a/window/src/os/x11/connection.rs b/window/src/os/x11/connection.rs index 1391a1a35..99e7dfb3d 100644 --- a/window/src/os/x11/connection.rs +++ b/window/src/os/x11/connection.rs @@ -58,11 +58,7 @@ impl TimerList { fn first_is_ready(&self, now: Instant) -> bool { if let Some(first) = self.timers.front() { - if first.due > now { - false - } else { - true - } + first.due <= now } else { false } @@ -200,8 +196,7 @@ fn server_supports_shm() -> bool { eprintln!("While probing for X SHM support: {}", err); return false; } - let shm_available = !reply.ptr.is_null() && reply.shared_pixmaps(); - shm_available + !reply.ptr.is_null() && reply.shared_pixmaps() } Err(err) => { eprintln!("While probing for X SHM support: {}", err); @@ -400,7 +395,7 @@ impl Connection { let (keyboard, kbd_ev) = Keyboard::new(&conn)?; - let cursor_font_id = conn.generate_id().into(); + let cursor_font_id = conn.generate_id(); let cursor_font_name = "cursor"; xcb::open_font_checked(&conn, cursor_font_id, cursor_font_name); diff --git a/window/src/os/x11/window.rs b/window/src/os/x11/window.rs index 538a79bf0..49ca54469 100644 --- a/window/src/os/x11/window.rs +++ b/window/src/os/x11/window.rs @@ -101,7 +101,7 @@ impl WindowInner { let mut frame = glium::Frame::new( Rc::clone(&gl_context), - (self.width as u32, self.height as u32), + (u32::from(self.width), u32::from(self.height)), ); self.callbacks.paint_opengl(&mut frame); @@ -212,7 +212,7 @@ impl WindowInner { MouseCursor::Text => 152, }; - let cursor_id: xcb::ffi::xcb_cursor_t = self.conn.generate_id().into(); + let cursor_id: xcb::ffi::xcb_cursor_t = self.conn.generate_id(); xcb::create_glyph_cursor( &self.conn, cursor_id, @@ -322,10 +322,8 @@ impl WindowInner { } xcb::CLIENT_MESSAGE => { let msg: &xcb::ClientMessageEvent = unsafe { xcb::cast_event(event) }; - if msg.data().data32()[0] == self.conn.atom_delete() { - if self.callbacks.can_close() { - xcb::destroy_window(self.conn.conn(), self.window_id); - } + if msg.data().data32()[0] == self.conn.atom_delete() && self.callbacks.can_close() { + xcb::destroy_window(self.conn.conn(), self.window_id); } } xcb::DESTROY_NOTIFY => { @@ -411,7 +409,7 @@ impl Window { Arc::new(Mutex::new(WindowInner { window_id, conn: Rc::clone(&conn), - callbacks: callbacks, + callbacks, window_context, width: width.try_into()?, height: height.try_into()?,