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:
Christian Duerr 2018-11-04 00:11:51 +00:00 committed by GitHub
parent d2f4972703
commit 0b1754e73f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 7 additions and 35 deletions

View File

@ -72,7 +72,6 @@ pub fn font_match(
} }
/// list fonts by closeness to the pattern /// list fonts by closeness to the pattern
#[allow(dead_code)]
pub fn font_sort( pub fn font_sort(
config: &ConfigRef, config: &ConfigRef,
pattern: &mut PatternRef, pattern: &mut PatternRef,
@ -104,7 +103,6 @@ pub fn font_sort(
} }
/// List fonts matching pattern /// List fonts matching pattern
#[allow(dead_code)]
pub fn font_list( pub fn font_list(
config: &ConfigRef, config: &ConfigRef,
pattern: &mut PatternRef, pattern: &mut PatternRef,

View File

@ -1459,7 +1459,7 @@ impl Config {
/// 2. $XDG_CONFIG_HOME/alacritty.yml /// 2. $XDG_CONFIG_HOME/alacritty.yml
/// 3. $HOME/.config/alacritty/alacritty.yml /// 3. $HOME/.config/alacritty/alacritty.yml
/// 4. $HOME/.alacritty.yml /// 4. $HOME/.alacritty.yml
#[cfg(not(windows))] #[cfg(not(windows))]
pub fn installed_config<'a>() -> Option<Cow<'a, Path>> { pub fn installed_config<'a>() -> Option<Cow<'a, Path>> {
// Try using XDG location by default // Try using XDG location by default
::xdg::BaseDirectories::with_prefix("alacritty") ::xdg::BaseDirectories::with_prefix("alacritty")
@ -1489,7 +1489,7 @@ impl Config {
} }
#[cfg(windows)] #[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() { if let Some(mut path) = ::std::env::home_dir() {
path.push("alacritty"); path.push("alacritty");
path.set_extension("yml"); path.set_extension("yml");
@ -1512,7 +1512,7 @@ impl Config {
#[cfg(windows)] #[cfg(windows)]
pub fn write_defaults() -> io::Result<Cow<'static, Path>> { pub fn write_defaults() -> io::Result<Cow<'static, Path>> {
let path = ::std::env::home_dir() 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)})?; .and_then(|mut p| {p.push("alacritty"); p.set_extension("yml"); Ok(p)})?;
File::create(&path)?.write_all(DEFAULT_ALACRITTY_CONFIG.as_bytes())?; File::create(&path)?.write_all(DEFAULT_ALACRITTY_CONFIG.as_bytes())?;
Ok(path.into()) 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)] #[derive(Deserialize, Copy, Clone, Debug, Eq, PartialEq)]
pub enum Key { pub enum Key {
Scancode(u32), Scancode(u32),

View File

@ -347,7 +347,6 @@ macro_rules! ops {
impl $ty { impl $ty {
#[inline] #[inline]
#[allow(trivial_numeric_casts)]
fn steps_between(start: $ty, end: $ty, by: $ty) -> Option<usize> { fn steps_between(start: $ty, end: $ty, by: $ty) -> Option<usize> {
if by == $construct(0) { return None; } if by == $construct(0) { return None; }
if start < end { if start < end {

View File

@ -320,10 +320,10 @@ impl RelaxedEq for ModifiersState {
// Make sure that modifiers in the config are always present, // Make sure that modifiers in the config are always present,
// but ignore surplus modifiers. // but ignore surplus modifiers.
fn relaxed_eq(&self, other: Self) -> bool { fn relaxed_eq(&self, other: Self) -> bool {
!((self.shift && !other.shift) (!self.logo || other.logo)
|| (self.ctrl && !other.ctrl) && (!self.alt || other.alt)
|| (self.alt && !other.alt) && (!self.ctrl || other.ctrl)
|| (self.logo && !other.logo)) && (!self.shift || other.shift)
} }
} }

View File

@ -127,9 +127,7 @@ impl Mul<f32> for Rgb {
} }
#[allow(unused_mut)]
pub mod gl { pub mod gl {
#![allow(non_upper_case_globals)]
#![cfg_attr(feature = "cargo-clippy", allow(clippy))] #![cfg_attr(feature = "cargo-clippy", allow(clippy))]
include!(concat!(env!("OUT_DIR"), "/gl_bindings.rs")); include!(concat!(env!("OUT_DIR"), "/gl_bindings.rs"));
} }

View File

@ -89,7 +89,6 @@ fn main() {
/// If a configuration file is given as a command line argument we don't /// 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. /// generate a default file. If an empty configuration file is given, i.e.
/// /dev/null, we load the compiled-in defaults.) /// /dev/null, we load the compiled-in defaults.)
#[cfg(not(windows))]
fn load_config(options: &cli::Options) -> Config { fn load_config(options: &cli::Options) -> Config {
let config_path = options.config_path() let config_path = options.config_path()
.or_else(Config::installed_config) .or_else(Config::installed_config)
@ -103,27 +102,6 @@ fn load_config(options: &cli::Options) -> Config {
Config::default() 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 /// Run Alacritty
/// ///