1
1
mirror of https://github.com/wez/wezterm.git synced 2024-09-11 14:25:57 +03:00

lint: fix some clippy stuff

This commit is contained in:
Wez Furlong 2021-03-25 10:05:34 -07:00
parent 3bec6fb5c0
commit 2902a76c5c
17 changed files with 50 additions and 58 deletions

View File

@ -70,7 +70,7 @@ fn main() {
}
}
let target = std::env::var("TARGET").unwrap_or("unknown".to_string());
let target = std::env::var("TARGET").unwrap_or_else(|_| "unknown".to_string());
println!("cargo:rustc-env=WEZTERM_TARGET_TRIPLE={}", target);
println!("cargo:rustc-env=WEZTERM_CI_TAG={}", ci_tag);

View File

@ -1,5 +1,3 @@
use pkg_config;
fn main() {
if let Ok(lib) = pkg_config::Config::new()
.atleast_version("2.10.1")

View File

@ -8,6 +8,7 @@ bindgen bindings.h -o src/lib.rs \
--raw-line "#![allow(non_camel_case_types)]" \
--raw-line "#![allow(non_upper_case_globals)]" \
--raw-line "#![allow(clippy::unreadable_literal)]" \
--raw-line "#![allow(clippy::upper_case_acronyms)]" \
--raw-line "pub type FT_Int16 = i16;" \
--raw-line "pub type FT_UInt16 = u16;" \
--raw-line "pub type FT_Int32 = i32;" \

View File

@ -4,6 +4,7 @@
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
#![allow(clippy::unreadable_literal)]
#![allow(clippy::upper_case_acronyms)]
pub type FT_Int16 = i16;
pub type FT_UInt16 = u16;
pub type FT_Int32 = i32;

View File

@ -96,7 +96,7 @@ fn harfbuzz() {
cfg.define("HAVE_FT_Done_MM_Var", Some("1"));
// Import the include dirs exported from deps/freetype/build.rs
for inc in std::env::var("DEP_FREETYPE_INCLUDE").unwrap().split(";") {
for inc in std::env::var("DEP_FREETYPE_INCLUDE").unwrap().split(';') {
cfg.include(inc);
}

View File

@ -7,6 +7,7 @@ bindgen bindings.h -o src/lib.rs \
--raw-line "#![allow(non_camel_case_types)]" \
--raw-line "#![allow(non_upper_case_globals)]" \
--raw-line "#![allow(clippy::unreadable_literal)]" \
--raw-line "#![allow(clippy::upper_case_acronyms)]" \
--default-enum-style rust \
--generate=functions,types,vars \
--whitelist-function="hb_.*" \

View File

@ -4,6 +4,7 @@
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
#![allow(clippy::unreadable_literal)]
#![allow(clippy::upper_case_acronyms)]
pub type __int8_t = ::std::os::raw::c_schar;
pub type __uint8_t = ::std::os::raw::c_uchar;

View File

@ -236,7 +236,7 @@ where
// a future version of wezterm where the configuration may
// evolve over time.
if let Some(allowed_fields) = allowed_fields {
if !allowed_fields.iter().any(|&name| name == &pair.0) {
if !allowed_fields.iter().any(|&name| name == pair.0) {
// The field wasn't one of the allowed fields in this
// context. Generate an error message that is hopefully
// helpful; we'll suggest the set of most similar field
@ -262,9 +262,9 @@ where
.filter(|&name| {
!suggestions.iter().any(|candidate| candidate == name)
})
.map(|&name| name)
.copied()
.collect();
fields.sort();
fields.sort_unstable();
let mut message = String::new();
@ -283,7 +283,7 @@ where
message.push_str(candidate);
message.push('`');
}
message.push_str("?");
message.push('?');
}
}
if !fields.is_empty() {
@ -923,7 +923,7 @@ mod test {
struct MyMap {
hello: String,
age: usize,
};
}
let res: MyMap =
from_lua_value(lua.load("{hello=\"hello\", age=42}").eval().unwrap()).unwrap();
@ -952,7 +952,7 @@ mod test {
enum MyEnum {
Foo,
Bar,
};
}
let lua = Lua::new();
let res: MyEnum = from_lua_value(lua.load("\"Foo\"").eval().unwrap()).unwrap();
assert_eq!(res, MyEnum::Foo);
@ -977,11 +977,11 @@ mod test {
enum MyEnum {
Foo,
Bar,
};
}
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
enum AnotherEnum {
ThisOne(Option<MyEnum>),
};
}
let lua = Lua::new();
let res: AnotherEnum =

View File

@ -4,7 +4,6 @@ pub use crate::escape::osc::Hyperlink;
use crate::image::ImageCell;
#[cfg(feature = "use_serde")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std;
use std::mem;
use std::sync::Arc;
use unicode_width::UnicodeWidthStr;

View File

@ -1,6 +1,7 @@
// suppress inscrutable useless_attribute clippy that shows up when
// using derive(FromPrimitive)
#![cfg_attr(feature = "cargo-clippy", allow(clippy::useless_attribute))]
#![allow(clippy::upper_case_acronyms)]
//! This module provides the ability to parse escape sequences and attach
//! semantic meaning to them. It can also encode the semantic values as
//! escape sequences. It provides encoding and decoding functionality

View File

@ -1,7 +1,6 @@
use crate::color::RgbColor;
pub use crate::hyperlink::Hyperlink;
use crate::{bail, ensure, Result};
use base64;
use bitflags::bitflags;
use num_derive::*;
use num_traits::FromPrimitive;

View File

@ -1,3 +1,4 @@
#![allow(clippy::many_single_char_names)]
use crate::color::RgbColor;
use crate::escape::{
Action, DeviceControlMode, EnterDeviceControlMode, Esc, OperatingSystemCommand,

View File

@ -8,7 +8,6 @@ use crate::readbuf::ReadBuffer;
use bitflags::bitflags;
#[cfg(feature = "use_serde")]
use serde::{Deserialize, Serialize};
use std;
#[cfg(windows)]
use winapi::um::wincon::{
@ -199,23 +198,23 @@ impl KeyCode {
/// Return true if the key represents a modifier key.
pub fn is_modifier(self) -> bool {
match self {
matches!(
self,
Self::Hyper
| Self::Super
| Self::Meta
| Self::Shift
| Self::LeftShift
| Self::RightShift
| Self::Control
| Self::LeftControl
| Self::RightControl
| Self::Alt
| Self::LeftAlt
| Self::RightAlt
| Self::LeftWindows
| Self::RightWindows => true,
_ => false,
}
| Self::Super
| Self::Meta
| Self::Shift
| Self::LeftShift
| Self::RightShift
| Self::Control
| Self::LeftControl
| Self::RightControl
| Self::Alt
| Self::LeftAlt
| Self::RightAlt
| Self::LeftWindows
| Self::RightWindows
)
}
}

View File

@ -318,9 +318,7 @@ impl TerminfoRenderer {
match change {
Change::ClearScreen(color) => {
// ClearScreen implicitly resets all to default
let defaults = CellAttributes::default()
.set_background(color.clone())
.clone();
let defaults = CellAttributes::default().set_background(*color).clone();
if self.current_attr != defaults {
self.pending_attr = Some(defaults);
self.flush_pending_attr(out)?;
@ -355,9 +353,7 @@ impl TerminfoRenderer {
}
Change::ClearToEndOfLine(color) => {
// ClearScreen implicitly resets all to default
let defaults = CellAttributes::default()
.set_background(color.clone())
.clone();
let defaults = CellAttributes::default().set_background(*color).clone();
if self.current_attr != defaults {
self.pending_attr = Some(defaults);
self.flush_pending_attr(out)?;
@ -379,9 +375,7 @@ impl TerminfoRenderer {
}
Change::ClearToEndOfScreen(color) => {
// ClearScreen implicitly resets all to default
let defaults = CellAttributes::default()
.set_background(color.clone())
.clone();
let defaults = CellAttributes::default().set_background(*color).clone();
if self.current_attr != defaults {
self.pending_attr = Some(defaults);
self.flush_pending_attr(out)?;

View File

@ -94,10 +94,7 @@ pub enum Change {
impl Change {
pub fn is_text(&self) -> bool {
match self {
Change::Text(_) => true,
_ => false,
}
matches!(self, Change::Text(_))
}
pub fn text(&self) -> &str {

View File

@ -107,9 +107,9 @@ impl Line {
})
.collect();
// The last of the chunks wasn't actually wrapped
lines
.last_mut()
.map(|line| line.set_last_cell_was_wrapped(false));
if let Some(line) = lines.last_mut() {
line.set_last_cell_was_wrapped(false);
}
lines
} else {
vec![self]
@ -209,7 +209,7 @@ impl Line {
if m.range.contains(&byte_idx) {
let attrs = cell.attrs_mut();
// Don't replace existing links
if !attrs.hyperlink().is_some() {
if attrs.hyperlink().is_none() {
attrs.set_hyperlink(Some(Arc::clone(&m.link)));
self.bits |= LineBits::HAS_IMPLICIT_HYPERLINKS;
}

View File

@ -63,10 +63,10 @@ impl Default for CursorShape {
impl CursorShape {
pub fn is_blinking(self) -> bool {
match self {
Self::BlinkingBlock | Self::BlinkingUnderline | Self::BlinkingBar => true,
_ => false,
}
matches!(
self,
Self::BlinkingBlock | Self::BlinkingUnderline | Self::BlinkingBar
)
}
}
@ -584,12 +584,12 @@ impl Surface {
}
fn repaint_all(&self) -> Vec<Change> {
let mut result = Vec::new();
// Home the cursor and clear the screen to defaults. Hide the
// cursor while we're repainting.
result.push(Change::CursorVisibility(CursorVisibility::Hidden));
result.push(Change::ClearScreen(Default::default()));
let mut result = vec![
// Home the cursor and clear the screen to defaults. Hide the
// cursor while we're repainting.
Change::CursorVisibility(CursorVisibility::Hidden),
Change::ClearScreen(Default::default()),
];
if !self.title.is_empty() {
result.push(Change::Title(self.title.to_owned()));