mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-25 14:05:41 -05:00
Fix clippy issues
This resolves all existing clippy issues and removes some old `allow` annotations which aren't neccesary anymore.
This commit is contained in:
parent
d2f4972703
commit
0b1754e73f
6 changed files with 7 additions and 35 deletions
|
@ -72,7 +72,6 @@ pub fn font_match(
|
|||
}
|
||||
|
||||
/// list fonts by closeness to the pattern
|
||||
#[allow(dead_code)]
|
||||
pub fn font_sort(
|
||||
config: &ConfigRef,
|
||||
pattern: &mut PatternRef,
|
||||
|
@ -104,7 +103,6 @@ pub fn font_sort(
|
|||
}
|
||||
|
||||
/// List fonts matching pattern
|
||||
#[allow(dead_code)]
|
||||
pub fn font_list(
|
||||
config: &ConfigRef,
|
||||
pattern: &mut PatternRef,
|
||||
|
|
|
@ -1459,7 +1459,7 @@ impl Config {
|
|||
/// 2. $XDG_CONFIG_HOME/alacritty.yml
|
||||
/// 3. $HOME/.config/alacritty/alacritty.yml
|
||||
/// 4. $HOME/.alacritty.yml
|
||||
#[cfg(not(windows))]
|
||||
#[cfg(not(windows))]
|
||||
pub fn installed_config<'a>() -> Option<Cow<'a, Path>> {
|
||||
// Try using XDG location by default
|
||||
::xdg::BaseDirectories::with_prefix("alacritty")
|
||||
|
@ -1489,7 +1489,7 @@ impl Config {
|
|||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
pub fn installed_config() -> Option<Cow<'static, Path>> {
|
||||
pub fn installed_config<'a>() -> Option<Cow<'a, Path>> {
|
||||
if let Some(mut path) = ::std::env::home_dir() {
|
||||
path.push("alacritty");
|
||||
path.set_extension("yml");
|
||||
|
@ -1512,7 +1512,7 @@ impl Config {
|
|||
#[cfg(windows)]
|
||||
pub fn write_defaults() -> io::Result<Cow<'static, Path>> {
|
||||
let path = ::std::env::home_dir()
|
||||
.ok_or(io::Error::new(io::ErrorKind::NotFound, "could not find profile directory"))
|
||||
.ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, "could not find profile directory"))
|
||||
.and_then(|mut p| {p.push("alacritty"); p.set_extension("yml"); Ok(p)})?;
|
||||
File::create(&path)?.write_all(DEFAULT_ALACRITTY_CONFIG.as_bytes())?;
|
||||
Ok(path.into())
|
||||
|
@ -2101,7 +2101,6 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(enum_variant_names))]
|
||||
#[derive(Deserialize, Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub enum Key {
|
||||
Scancode(u32),
|
||||
|
|
|
@ -347,7 +347,6 @@ macro_rules! ops {
|
|||
|
||||
impl $ty {
|
||||
#[inline]
|
||||
#[allow(trivial_numeric_casts)]
|
||||
fn steps_between(start: $ty, end: $ty, by: $ty) -> Option<usize> {
|
||||
if by == $construct(0) { return None; }
|
||||
if start < end {
|
||||
|
|
|
@ -320,10 +320,10 @@ impl RelaxedEq for ModifiersState {
|
|||
// Make sure that modifiers in the config are always present,
|
||||
// but ignore surplus modifiers.
|
||||
fn relaxed_eq(&self, other: Self) -> bool {
|
||||
!((self.shift && !other.shift)
|
||||
|| (self.ctrl && !other.ctrl)
|
||||
|| (self.alt && !other.alt)
|
||||
|| (self.logo && !other.logo))
|
||||
(!self.logo || other.logo)
|
||||
&& (!self.alt || other.alt)
|
||||
&& (!self.ctrl || other.ctrl)
|
||||
&& (!self.shift || other.shift)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -127,9 +127,7 @@ impl Mul<f32> for Rgb {
|
|||
}
|
||||
|
||||
|
||||
#[allow(unused_mut)]
|
||||
pub mod gl {
|
||||
#![allow(non_upper_case_globals)]
|
||||
#![cfg_attr(feature = "cargo-clippy", allow(clippy))]
|
||||
include!(concat!(env!("OUT_DIR"), "/gl_bindings.rs"));
|
||||
}
|
||||
|
|
22
src/main.rs
22
src/main.rs
|
@ -89,7 +89,6 @@ fn main() {
|
|||
/// If a configuration file is given as a command line argument we don't
|
||||
/// generate a default file. If an empty configuration file is given, i.e.
|
||||
/// /dev/null, we load the compiled-in defaults.)
|
||||
#[cfg(not(windows))]
|
||||
fn load_config(options: &cli::Options) -> Config {
|
||||
let config_path = options.config_path()
|
||||
.or_else(Config::installed_config)
|
||||
|
@ -103,27 +102,6 @@ fn load_config(options: &cli::Options) -> Config {
|
|||
Config::default()
|
||||
})
|
||||
}
|
||||
#[cfg(windows)]
|
||||
fn load_config(options: &cli::Options) -> Config {
|
||||
let config_path = options
|
||||
.config_path()
|
||||
.or_else(|| Config::installed_config())
|
||||
.unwrap_or_else(|| {
|
||||
Config::write_defaults()
|
||||
.unwrap_or_else(|err| die!("Write defaults config failure: {}", err))
|
||||
});
|
||||
|
||||
Config::load_from(&*config_path).unwrap_or_else(|err| match err {
|
||||
config::Error::NotFound => {
|
||||
die!("Config file not found after writing: {}", config_path.display());
|
||||
}
|
||||
config::Error::Empty => {
|
||||
eprintln!("Empty config; Loading defaults");
|
||||
Config::default()
|
||||
}
|
||||
_ => die!("{}", err),
|
||||
})
|
||||
}
|
||||
|
||||
/// Run Alacritty
|
||||
///
|
||||
|
|
Loading…
Reference in a new issue