summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2018-05-11 20:22:36 +0200
committerJoe Wilm <jwilm@users.noreply.github.com>2018-05-11 16:54:19 -0700
commite34dccdabf210612666cbb9d22d7afff23487eaf (patch)
tree01cfc895cf42fc3f31427cc4543ab62265af3eb8 /src
parent57281363503ddd1ebb373ed5de2b84c79d5aa3aa (diff)
Fix clippy lints
Diffstat (limited to 'src')
-rw-r--r--src/config.rs4
-rw-r--r--src/display.rs12
-rw-r--r--src/event.rs21
-rw-r--r--src/main.rs21
-rw-r--r--src/renderer/mod.rs22
-rw-r--r--src/term/mod.rs5
-rw-r--r--src/util.rs4
7 files changed, 48 insertions, 41 deletions
diff --git a/src/config.rs b/src/config.rs
index 814b726b..40c550b0 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -1718,10 +1718,10 @@ mod tests {
.expect("deserialize config");
// Sanity check that mouse bindings are being parsed
- assert!(config.mouse_bindings.len() >= 1);
+ assert!(!config.mouse_bindings.is_empty());
// Sanity check that key bindings are being parsed
- assert!(config.key_bindings.len() >= 1);
+ assert!(!config.key_bindings.is_empty());
}
}
diff --git a/src/display.rs b/src/display.rs
index bd8ae401..a237a10f 100644
--- a/src/display.rs
+++ b/src/display.rs
@@ -162,8 +162,8 @@ impl Display {
let height = cell_height as u32 * dimensions.lines_u32();
let new_viewport_size = Size {
- width: Pixels(width + 2 * config.padding().x as u32),
- height: Pixels(height + 2 * config.padding().y as u32),
+ width: Pixels(width + 2 * u32::from(config.padding().x)),
+ height: Pixels(height + 2 * u32::from(config.padding().y)),
};
window.set_inner_size(&new_viewport_size);
@@ -178,8 +178,8 @@ impl Display {
height: viewport_size.height.0 as f32,
cell_width: cell_width as f32,
cell_height: cell_height as f32,
- padding_x: config.padding().x as f32,
- padding_y: config.padding().y as f32,
+ padding_x: f32::from(config.padding().x),
+ padding_y: f32::from(config.padding().y),
};
// Channel for resize events
@@ -238,8 +238,8 @@ impl Display {
// font metrics should be computed before creating the window in the first
// place so that a resize is not needed.
let metrics = glyph_cache.font_metrics();
- let cell_width = metrics.average_advance as f32 + font.offset().x as f32;
- let cell_height = metrics.line_height as f32 + font.offset().y as f32;
+ let cell_width = metrics.average_advance as f32 + f32::from(font.offset().x);
+ let cell_height = metrics.line_height as f32 + f32::from(font.offset().y);
// Prevent invalid cell sizes
if cell_width < 1. || cell_height < 1. {
diff --git a/src/event.rs b/src/event.rs
index d85fab2b..a4ca5365 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -57,17 +57,16 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
fn copy_selection(&self, buffer: ::copypasta::Buffer) {
if let Some(ref selection) = *self.selection {
- selection.to_span(self.terminal)
- .map(|span| {
- let buf = self.terminal.string_from_selection(&span);
- if !buf.is_empty() {
- Clipboard::new()
- .and_then(|mut clipboard| clipboard.store(buf, buffer))
- .unwrap_or_else(|err| {
- warn!("Error storing selection to clipboard. {}", Red(err));
- });
- }
- });
+ if let Some(ref span) = selection.to_span(self.terminal) {
+ let buf = self.terminal.string_from_selection(&span);
+ if !buf.is_empty() {
+ Clipboard::new()
+ .and_then(|mut clipboard| clipboard.store(buf, buffer))
+ .unwrap_or_else(|err| {
+ warn!("Error storing selection to clipboard. {}", Red(err));
+ });
+ }
+ }
}
}
diff --git a/src/main.rs b/src/main.rs
index 4b24b1a5..c45dfda5 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -94,9 +94,9 @@ fn run(mut config: Config, options: &cli::Options) -> Result<(), Box<Error>> {
logging::initialize(options)?;
info!("Welcome to Alacritty.");
- config.path().map(|config_path| {
+ if let Some(config_path) = config.path() {
info!("Configuration loaded from {}", config_path.display());
- });
+ };
// Create a display.
//
@@ -179,15 +179,16 @@ fn run(mut config: Config, options: &cli::Options) -> Result<(), Box<Error>> {
let mut terminal = processor.process_events(&terminal, display.window());
// Handle config reloads
- config_monitor.as_ref()
+ if let Some(new_config) = config_monitor
+ .as_ref()
.and_then(|monitor| monitor.pending_config())
- .map(|new_config| {
- config = new_config;
- display.update_config(&config);
- processor.update_config(&config);
- terminal.update_config(&config);
- terminal.dirty = true;
- });
+ {
+ config = new_config;
+ display.update_config(&config);
+ processor.update_config(&config);
+ terminal.update_config(&config);
+ terminal.dirty = true;
+ }
// Maybe draw the terminal
if terminal.needs_draw() {
diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs
index 56ae4b14..0d474123 100644
--- a/src/renderer/mod.rs
+++ b/src/renderer/mod.rs
@@ -285,8 +285,8 @@ impl GlyphCache {
let mut rasterized = rasterizer.get_glyph(glyph_key)
.unwrap_or_else(|_| Default::default());
- rasterized.left += glyph_offset.x as i32;
- rasterized.top += glyph_offset.y as i32;
+ rasterized.left += i32::from(glyph_offset.x);
+ rasterized.top += i32::from(glyph_offset.y);
rasterized.top -= metrics.descent as i32;
loader.load_glyph(&rasterized)
@@ -719,8 +719,8 @@ impl QuadRenderer {
}
pub fn resize(&mut self, width: i32, height: i32) {
- let padding_x = self.program.padding_x as i32;
- let padding_y = self.program.padding_y as i32;
+ let padding_x = i32::from(self.program.padding_x);
+ let padding_y = i32::from(self.program.padding_y);
// viewport
unsafe {
@@ -1030,8 +1030,8 @@ impl ShaderProgram {
fn update_projection(&self, width: f32, height: f32) {
// Bounds check
- if (width as u32) < (2 * self.padding_x as u32) ||
- (height as u32) < (2 * self.padding_y as u32)
+ if (width as u32) < (2 * u32::from(self.padding_x)) ||
+ (height as u32) < (2 * u32::from(self.padding_y))
{
return;
}
@@ -1041,8 +1041,14 @@ impl ShaderProgram {
// NB Not sure why padding change only requires changing the vertical
// translation in the projection, but this makes everything work
// correctly.
- let ortho = cgmath::ortho(0., width - 2. * self.padding_x as f32, 2. * self.padding_y as f32,
- height, -1., 1.);
+ let ortho = cgmath::ortho(
+ 0.,
+ width - 2. * f32::from(self.padding_x),
+ 2. * f32::from(self.padding_y),
+ height,
+ -1.,
+ 1.,
+ );
let projection: [[f32; 4]; 4] = ortho.into();
info!("width: {}, height: {}", width, height);
diff --git a/src/term/mod.rs b/src/term/mod.rs
index 5ba192ff..4f56e7fc 100644
--- a/src/term/mod.rs
+++ b/src/term/mod.rs
@@ -917,8 +917,9 @@ impl Term {
let range = Some(cols.start..line_end);
if cols.end >= grid.num_cols() - 1 {
- range.as_ref()
- .map(|range| self.maybe_newline(grid, line, range.end));
+ if let Some(ref range) = range {
+ self.maybe_newline(grid, line, range.end);
+ }
}
range
diff --git a/src/util.rs b/src/util.rs
index 7227f1a0..f51a41f8 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -57,13 +57,13 @@ pub mod fmt {
impl<T: fmt::Display> fmt::Display for $s<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "\x1b[{}m{}\x1b[0m", $color, self.0)
+ write!(f, concat!("\x1b[", $color, "m{}\x1b[0m"), self.0)
}
}
impl<T: fmt::Debug> fmt::Debug for $s<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "\x1b[{}m{:?}\x1b[0m", $color, self.0)
+ write!(f, concat!("\x1b[", $color, "m{:?}\x1b[0m"), self.0)
}
}
)*