Skip to content

Commit

Permalink
Fix a few minor clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik authored Jun 2, 2022
1 parent e20541a commit 56a69c0
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 26 deletions.
8 changes: 4 additions & 4 deletions alacritty/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion alacritty/src/config/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions alacritty/src/config/ui_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl UiConfig {
}
}

#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
struct KeyBindings(Vec<KeyBinding>);

impl Default for KeyBindings {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion alacritty/src/config/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion alacritty/src/display/hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion alacritty/src/display/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
3 changes: 2 additions & 1 deletion alacritty/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion alacritty/src/renderer/text/atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion alacritty_terminal/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down
2 changes: 1 addition & 1 deletion alacritty_terminal/src/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
10 changes: 5 additions & 5 deletions alacritty_terminal/src/selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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>,
Expand Down Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions alacritty_terminal/src/term/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion alacritty_terminal/src/tty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 56a69c0

Please sign in to comment.