From f493139305dee635bf191b3dcc4eeb2315dc3380 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 21 Dec 2019 23:13:26 -0800 Subject: [PATCH] clippy --- src/config/mod.rs | 4 ++-- src/font/ftwrap.rs | 1 + src/font/locator/mod.rs | 2 +- src/frontend/gui/tabbar.rs | 2 +- term/src/config.rs | 12 +++++------- termwiz/src/surface/line.rs | 6 +++--- termwiz/src/widgets/layout.rs | 4 ++-- window/src/bitmaps/mod.rs | 6 ++++++ window/src/os/wayland/window.rs | 2 +- window/src/os/x11/window.rs | 2 +- 10 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/config/mod.rs b/src/config/mod.rs index 0c6d91da7..2ac789969 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -623,8 +623,8 @@ fn default_hyperlink_rules() -> Vec { fn default_harfbuzz_features() -> Vec { ["kern", "liga", "clig"] - .into_iter() - .map(|s| s.to_string()) + .iter() + .map(|&s| s.to_string()) .collect() } diff --git a/src/font/ftwrap.rs b/src/font/ftwrap.rs index a3901e902..09aaa206e 100644 --- a/src/font/ftwrap.rs +++ b/src/font/ftwrap.rs @@ -50,6 +50,7 @@ pub fn compute_load_flags_from_config() -> i32 { // If the bitmaps are in color, we want those! let flags = flags | FT_LOAD_COLOR; + #[allow(clippy::let_and_return)] let flags = if config.font_antialias == FontAntiAliasing::None { // When AA is disabled, force outline rendering to monochrome flags | FT_LOAD_MONOCHROME diff --git a/src/font/locator/mod.rs b/src/font/locator/mod.rs index 16ce36a86..4a225e3ec 100644 --- a/src/font/locator/mod.rs +++ b/src/font/locator/mod.rs @@ -117,7 +117,7 @@ impl FontLocatorSelection { #[cfg(not(any(target_os = "macos", windows)))] panic!("fontkit not compiled in"); } - Self::ConfigDirsOnly => return Box::new(NopSystemSource {}), + Self::ConfigDirsOnly => Box::new(NopSystemSource {}), } } } diff --git a/src/frontend/gui/tabbar.rs b/src/frontend/gui/tabbar.rs index ddfbf5208..2f6f60b47 100644 --- a/src/frontend/gui/tabbar.rs +++ b/src/frontend/gui/tabbar.rs @@ -139,7 +139,7 @@ impl TabBarState { line.set_cell(x, Cell::new(' ', cell_attrs.clone())); line.set_cell(x + 1, Cell::new('+', cell_attrs.clone())); - line.set_cell(x + 2, Cell::new(' ', cell_attrs.clone())); + line.set_cell(x + 2, Cell::new(' ', cell_attrs)); x += 3; } diff --git a/term/src/config.rs b/term/src/config.rs index f60977fb1..c97fa211b 100644 --- a/term/src/config.rs +++ b/term/src/config.rs @@ -16,15 +16,13 @@ pub trait TerminalConfiguration: std::fmt::Debug { // TODO: expose is_double_click_word in config file fn is_double_click_word(&self, s: &str) -> bool { - if s.len() > 1 { - true - } else if s.len() == 1 { - match s.chars().nth(0).unwrap() { + match s.len() { + 1 => match s.chars().nth(0).unwrap() { ' ' | '\t' | '\n' | '{' | '[' | '}' | ']' | '(' | ')' | '"' | '\'' => false, _ => true, - } - } else { - false + }, + 0 => false, + _ => true, } } diff --git a/termwiz/src/surface/line.rs b/termwiz/src/surface/line.rs index c07d72988..c36d45678 100644 --- a/termwiz/src/surface/line.rs +++ b/termwiz/src/surface/line.rs @@ -385,7 +385,7 @@ impl Line { if num_trailing_spaces > 0 { if !left.is_empty() { - result.push(Change::Text(left.to_string())); + result.push(Change::Text(left)); } else if result.len() == 1 { // if the only queued result prior to clearing // to the end of the line is an attribute change, @@ -405,10 +405,10 @@ impl Line { result.push(Change::ClearToEndOfLine(attr.background)); } } else { - result.push(Change::Text(text_run.clone())); + result.push(Change::Text(text_run)); } } else { - result.push(Change::Text(text_run.clone())); + result.push(Change::Text(text_run)); } } diff --git a/termwiz/src/widgets/layout.rs b/termwiz/src/widgets/layout.rs index d98d76ef4..f0a6b38b6 100644 --- a/termwiz/src/widgets/layout.rs +++ b/termwiz/src/widgets/layout.rs @@ -332,7 +332,7 @@ impl LayoutState { ) .map_err(adderr)?; self.solver - .add_constraint(state.left | GE(REQUIRED) | parent_left.clone()) + .add_constraint(state.left | GE(REQUIRED) | parent_left) .map_err(adderr)?; self.solver @@ -341,7 +341,7 @@ impl LayoutState { ) .map_err(adderr)?; self.solver - .add_constraint(state.top | GE(REQUIRED) | parent_top.clone()) + .add_constraint(state.top | GE(REQUIRED) | parent_top) .map_err(adderr)?; if is_root_widget { diff --git a/window/src/bitmaps/mod.rs b/window/src/bitmaps/mod.rs index a83da49bd..97391ac00 100644 --- a/window/src/bitmaps/mod.rs +++ b/window/src/bitmaps/mod.rs @@ -170,9 +170,15 @@ mod avx { /// storage filled in by the trait implementation. pub trait BitmapImage { /// Obtain a read only pointer to the pixel data + /// # Safety + /// The caller is responsible for ensuring that pixel + /// access is bounded by the image_dimensions unsafe fn pixel_data(&self) -> *const u8; /// Obtain a mutable pointer to the pixel data + /// # Safety + /// The caller is responsible for ensuring that pixel + /// access is bounded by the image_dimensions unsafe fn pixel_data_mut(&mut self) -> *mut u8; /// Return the pair (width, height) of the image, measured in pixels diff --git a/window/src/os/wayland/window.rs b/window/src/os/wayland/window.rs index 18aeedd94..b6d40cec8 100644 --- a/window/src/os/wayland/window.rs +++ b/window/src/os/wayland/window.rs @@ -287,7 +287,7 @@ impl WaylandWindowInner { // Avoid redundant key == raw_key let (key, raw_key) = match (key, raw_key) { // Avoid eg: \x01 when we can use CTRL-A - (KeyCode::Char(c), Some(raw)) if c.is_ascii_control() => (raw.clone(), None), + (KeyCode::Char(c), Some(raw)) if c.is_ascii_control() => (raw, None), (key, Some(raw)) if key == raw => (key, None), pair => pair, }; diff --git a/window/src/os/x11/window.rs b/window/src/os/x11/window.rs index 27a2cc576..7c8ce0096 100644 --- a/window/src/os/x11/window.rs +++ b/window/src/os/x11/window.rs @@ -690,7 +690,7 @@ impl XWindow { window.lock().unwrap().callbacks.created(&window_handle); - conn.windows.borrow_mut().insert(window_id, window.clone()); + conn.windows.borrow_mut().insert(window_id, window); window_handle.set_title(name); window_handle.show();