Fix a few minor clippy lints

This commit is contained in:
Yuri Astrakhan 2022-06-01 21:22:50 -04:00 committed by GitHub
parent e20541a83e
commit 56a69c0bfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 25 additions and 26 deletions

View File

@ -174,7 +174,7 @@ fn parse_class(input: &str) -> Result<Class, String> {
}
/// Terminal specific cli options which can be passed to new windows via IPC.
#[derive(Serialize, Deserialize, Args, Default, Debug, Clone, PartialEq)]
#[derive(Serialize, Deserialize, Args, Default, Debug, Clone, PartialEq, Eq)]
pub struct TerminalOptions {
/// Start the shell in the specified working directory.
#[clap(long)]
@ -225,7 +225,7 @@ impl From<TerminalOptions> for PtyConfig {
}
/// Window specific cli options which can be passed to new windows via IPC.
#[derive(Serialize, Deserialize, Args, Default, Debug, Clone, PartialEq)]
#[derive(Serialize, Deserialize, Args, Default, Debug, Clone, PartialEq, Eq)]
pub struct WindowIdentity {
/// Defines the window title [default: Alacritty].
#[clap(short, long)]
@ -270,14 +270,14 @@ pub struct MessageOptions {
/// Available socket messages.
#[cfg(unix)]
#[derive(Subcommand, Serialize, Deserialize, Debug, Clone, PartialEq)]
#[derive(Subcommand, Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
pub enum SocketMessage {
/// Create a new window in the same Alacritty process.
CreateWindow(WindowOptions),
}
/// Subset of options that we pass to a 'create-window' subcommand.
#[derive(Serialize, Deserialize, Args, Default, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Args, Default, Clone, Debug, PartialEq, Eq)]
pub struct WindowOptions {
/// Terminal options which can be passed via IPC.
#[clap(flatten)]

View File

@ -1009,7 +1009,7 @@ impl<'a> Deserialize<'a> for RawBinding {
let val = map.next_value::<SerdeValue>()?;
if val.is_u64() {
let scancode = val.as_u64().unwrap();
if scancode > u64::from(std::u32::MAX) {
if scancode > u64::from(u32::MAX) {
return Err(<V::Error as Error>::custom(format!(
"Invalid key binding, scancode too big: {}",
scancode

View File

@ -144,7 +144,7 @@ impl UiConfig {
}
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
struct KeyBindings(Vec<KeyBinding>);
impl Default for KeyBindings {
@ -162,7 +162,7 @@ impl<'de> Deserialize<'de> for KeyBindings {
}
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
struct MouseBindings(Vec<MouseBinding>);
impl Default for MouseBindings {

View File

@ -106,7 +106,7 @@ impl WindowConfig {
}
}
#[derive(ConfigDeserialize, Debug, Clone, PartialEq)]
#[derive(ConfigDeserialize, Debug, Clone, PartialEq, Eq)]
pub struct Identity {
/// Window title.
pub title: String,

View File

@ -164,7 +164,7 @@ impl HintState {
}
/// Hint match which was selected by the user.
#[derive(PartialEq, Debug, Clone)]
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct HintMatch {
/// Action for handling the text.
pub action: HintAction,

View File

@ -293,7 +293,7 @@ impl TermDimensions for SizeInfo {
}
}
#[derive(Default, Clone, Debug, PartialEq)]
#[derive(Default, Clone, Debug, PartialEq, Eq)]
pub struct DisplayUpdate {
pub dirty: bool,

View File

@ -14,6 +14,7 @@ compile_error!(r#"at least one of the "x11"/"wayland" features must be enabled"#
#[cfg(target_os = "macos")]
use std::env;
use std::fmt::Write as _;
use std::io::{self, Write};
use std::path::PathBuf;
use std::string::ToString;
@ -233,7 +234,7 @@ fn log_config_path(config: &UiConfig) {
let mut msg = String::from("Configuration files loaded from:");
for path in &config.config_paths {
msg.push_str(&format!("\n {:?}", path.display()));
let _ = write!(msg, "\n {:?}", path.display());
}
info!("{}", msg);

View File

@ -256,7 +256,7 @@ impl Atlas {
}
#[inline]
pub fn clear_atlas(atlas: &mut Vec<Atlas>, current_atlas: &mut usize) {
pub fn clear_atlas(atlas: &mut [Atlas], current_atlas: &mut usize) {
for atlas in atlas.iter_mut() {
atlas.clear();
}

View File

@ -33,7 +33,7 @@ pub struct Config {
pub pty_config: PtyConfig,
}
#[derive(ConfigDeserialize, Clone, Debug, PartialEq, Default)]
#[derive(ConfigDeserialize, Clone, Debug, PartialEq, Eq, Default)]
pub struct PtyConfig {
/// Path to a shell program to run on startup.
pub shell: Option<Program>,

View File

@ -24,7 +24,7 @@ use crate::{ansi, thread, tty};
const READ_BUFFER_SIZE: usize = 0x10_0000;
/// Max bytes to read from the PTY while the terminal is locked.
const MAX_LOCKED_READ: usize = u16::max_value() as usize;
const MAX_LOCKED_READ: usize = u16::MAX as usize;
/// Messages that may be sent to the `EventLoop`.
#[derive(Debug)]

View File

@ -16,7 +16,7 @@ use crate::term::cell::{Cell, Flags};
use crate::term::Term;
/// A Point and side within that point.
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
struct Anchor {
point: Point,
side: Side,
@ -89,7 +89,7 @@ impl SelectionRange {
}
/// Different kinds of selection.
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum SelectionType {
Simple,
Block,
@ -115,7 +115,7 @@ pub enum SelectionType {
/// [`semantic`]: enum.Selection.html#method.semantic
/// [`lines`]: enum.Selection.html#method.lines
/// [`update`]: enum.Selection.html#method.update
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Selection {
pub ty: SelectionType,
region: Range<Anchor>,
@ -236,13 +236,13 @@ impl Selection {
let range_top = match range.start_bound() {
Bound::Included(&range_start) => range_start,
Bound::Excluded(&range_start) => range_start + 1,
Bound::Unbounded => Line(i32::min_value()),
Bound::Unbounded => Line(i32::MIN),
};
let range_bottom = match range.end_bound() {
Bound::Included(&range_end) => range_end,
Bound::Excluded(&range_end) => range_end - 1,
Bound::Unbounded => Line(i32::max_value()),
Bound::Unbounded => Line(i32::MAX),
};
range_bottom >= start && range_top <= end

View File

@ -287,23 +287,21 @@ impl IndexMut<NamedColor> for Colors {
mod tests {
use super::*;
use std::f64::EPSILON;
#[test]
fn contrast() {
let rgb1 = Rgb { r: 0xff, g: 0xff, b: 0xff };
let rgb2 = Rgb { r: 0x00, g: 0x00, b: 0x00 };
assert!((rgb1.contrast(rgb2) - 21.).abs() < EPSILON);
assert!((rgb1.contrast(rgb2) - 21.).abs() < f64::EPSILON);
let rgb1 = Rgb { r: 0xff, g: 0xff, b: 0xff };
assert!((rgb1.contrast(rgb1) - 1.).abs() < EPSILON);
assert!((rgb1.contrast(rgb1) - 1.).abs() < f64::EPSILON);
let rgb1 = Rgb { r: 0xff, g: 0x00, b: 0xff };
let rgb2 = Rgb { r: 0x00, g: 0xff, b: 0x00 };
assert!((rgb1.contrast(rgb2) - 2.285_543_608_124_253_3).abs() < EPSILON);
assert!((rgb1.contrast(rgb2) - 2.285_543_608_124_253_3).abs() < f64::EPSILON);
let rgb1 = Rgb { r: 0x12, g: 0x34, b: 0x56 };
let rgb2 = Rgb { r: 0xfe, g: 0xdc, b: 0xba };
assert!((rgb1.contrast(rgb2) - 9.786_558_997_257_74).abs() < EPSILON);
assert!((rgb1.contrast(rgb2) - 9.786_558_997_257_74).abs() < f64::EPSILON);
}
}

View File

@ -39,7 +39,7 @@ pub trait EventedReadWrite {
}
/// Events concerning TTY child processes.
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum ChildEvent {
/// Indicates the child has exited.
Exited,