Fix clippy issues

This commit is contained in:
Christian Duerr 2018-07-01 16:31:46 +00:00 committed by GitHub
parent d5690f6cc7
commit 12afbd007d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 64 additions and 64 deletions

View File

@ -162,7 +162,7 @@ impl ::Rasterize for Rasterizer {
}
/// Get rasterized glyph for given glyph key
fn get_glyph(&mut self, glyph: &GlyphKey) -> Result<RasterizedGlyph, Error> {
fn get_glyph(&mut self, glyph: GlyphKey) -> Result<RasterizedGlyph, Error> {
// get loaded font
let font = self.fonts
@ -246,7 +246,7 @@ impl Rasterizer {
// Helper to try and get a glyph for a given font. Used for font fallback.
fn maybe_get_glyph(
&self,
glyph: &GlyphKey,
glyph: GlyphKey,
font: &Font,
) -> Option<Result<RasterizedGlyph, Error>> {
let scaled_size = self.device_pixel_ratio * glyph.size.as_f32_pts();
@ -356,7 +356,7 @@ impl Descriptor {
let menlo = ct_new_from_descriptor(&descriptor.ct_descriptor, size);
// TODO fixme, hardcoded en for english
let mut fallbacks = cascade_list_for_languages(&menlo, &vec!["en".to_owned()])
let mut fallbacks = cascade_list_for_languages(&menlo, &["en".to_owned()])
.into_iter()
.filter(|desc| desc.font_path != "")
.map(|desc| desc.to_font(size, false))

View File

@ -180,9 +180,9 @@ pub enum Width {
}
impl Width {
fn to_isize(&self) -> isize {
fn to_isize(self) -> isize {
use self::Width::*;
match *self {
match self {
Ultracondensed => 50,
Extracondensed => 63,
Condensed => 75,

View File

@ -102,7 +102,7 @@ impl ::Rasterize for FreeTypeRasterizer {
self.get_face(desc, size)
}
fn get_glyph(&mut self, glyph_key: &GlyphKey) -> Result<RasterizedGlyph, Error> {
fn get_glyph(&mut self, glyph_key: GlyphKey) -> Result<RasterizedGlyph, Error> {
self.get_rendered_glyph(glyph_key)
}
@ -264,7 +264,7 @@ impl FreeTypeRasterizer {
}
}
fn face_for_glyph(&mut self, glyph_key: &GlyphKey, have_recursed: bool) -> Result<FontKey, Error> {
fn face_for_glyph(&mut self, glyph_key: GlyphKey, have_recursed: bool) -> Result<FontKey, Error> {
let c = glyph_key.c;
let use_initial_face = if self.faces.contains_key(&glyph_key.font_key) {
@ -285,7 +285,7 @@ impl FreeTypeRasterizer {
}
}
fn get_rendered_glyph(&mut self, glyph_key: &GlyphKey)
fn get_rendered_glyph(&mut self, glyph_key: GlyphKey)
-> Result<RasterizedGlyph, Error> {
// Render a custom symbol for the underline and beam cursor
match glyph_key.c {

View File

@ -344,5 +344,5 @@ pub trait Rasterize {
fn load_font(&mut self, &FontDesc, Size) -> Result<FontKey, Self::Err>;
/// Rasterize the glyph described by `GlyphKey`.
fn get_glyph(&mut self, &GlyphKey) -> Result<RasterizedGlyph, Self::Err>;
fn get_glyph(&mut self, GlyphKey) -> Result<RasterizedGlyph, Self::Err>;
}

View File

@ -561,8 +561,8 @@ pub enum NamedColor {
}
impl NamedColor {
pub fn to_bright(&self) -> Self {
match *self {
pub fn to_bright(self) -> Self {
match self {
NamedColor::Black => NamedColor::BrightBlack,
NamedColor::Red => NamedColor::BrightRed,
NamedColor::Green => NamedColor::BrightGreen,
@ -583,8 +583,8 @@ impl NamedColor {
}
}
pub fn to_dim(&self) -> Self {
match *self {
pub fn to_dim(self) -> Self {
match self {
NamedColor::Black => NamedColor::DimBlack,
NamedColor::Red => NamedColor::DimRed,
NamedColor::Green => NamedColor::DimGreen,

View File

@ -242,7 +242,7 @@ impl Alpha {
}
#[inline]
pub fn get(&self) -> f32 {
pub fn get(self) -> f32 {
self.0
}
@ -1925,10 +1925,10 @@ enum Key {
}
impl Key {
fn to_glutin_key(&self) -> ::glutin::VirtualKeyCode {
fn to_glutin_key(self) -> ::glutin::VirtualKeyCode {
use ::glutin::VirtualKeyCode::*;
// Thank you, vim macros!
match *self {
match self {
Key::Key1 => Key1,
Key::Key2 => Key2,
Key::Key3 => Key3,

View File

@ -291,7 +291,7 @@ impl<N: Notify> Processor<N> {
},
KeyboardInput { input, .. } => {
let glutin::KeyboardInput { state, virtual_keycode, modifiers, .. } = input;
processor.process_key(state, virtual_keycode, &modifiers);
processor.process_key(state, virtual_keycode, modifiers);
if state == ElementState::Pressed {
// Hide cursor while typing
*hide_cursor = true;

View File

@ -270,7 +270,7 @@ macro_rules! inclusive {
match *self {
Empty { .. } => (0, Some(0)),
NonEmpty { ref start, ref end } => {
NonEmpty { start, end } => {
let added = $steps_add_one(start, end);
match added {
Some(hint) => (hint.saturating_add(1), hint.checked_add(1)),
@ -283,9 +283,9 @@ macro_rules! inclusive {
}
}
fn steps_add_one_u8(start: &u8, end: &u8) -> Option<usize> {
if *start < *end {
Some((*end - *start) as usize)
fn steps_add_one_u8(start: u8, end: u8) -> Option<usize> {
if start < end {
Some((end - start) as usize)
} else {
None
}
@ -330,11 +330,11 @@ 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 {
fn steps_between(start: $ty, end: $ty, by: $ty) -> Option<usize> {
if by == $construct(0) { return None; }
if start < end {
// Note: We assume $t <= usize here
let diff = (*end - *start).0;
let diff = (end - start).0;
let by = by.0;
if diff % by > 0 {
Some(diff / by + 1)
@ -347,8 +347,8 @@ macro_rules! ops {
}
#[inline]
fn steps_between_by_one(start: &$ty, end: &$ty) -> Option<usize> {
Self::steps_between(start, end, &$construct(1))
fn steps_between_by_one(start: $ty, end: $ty) -> Option<usize> {
Self::steps_between(start, end, $construct(1))
}
}
@ -366,7 +366,7 @@ macro_rules! ops {
}
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
match Self::Item::steps_between_by_one(&self.0.start, &self.0.end) {
match Self::Item::steps_between_by_one(self.0.start, self.0.end) {
Some(hint) => (hint, Some(hint)),
None => (0, None)
}

View File

@ -102,15 +102,15 @@ impl<T: Eq> Binding<T> {
fn is_triggered_by(
&self,
mode: TermMode,
mods: &ModifiersState,
mods: ModifiersState,
input: &T
) -> bool {
// Check input first since bindings are stored in one big list. This is
// the most likely item to fail so prioritizing it here allows more
// checks to be short circuited.
self.trigger == *input &&
self.mode_matches(&mode) &&
self.not_mode_matches(&mode) &&
self.mode_matches(mode) &&
self.not_mode_matches(mode) &&
self.mods_match(mods)
}
}
@ -123,12 +123,12 @@ impl<T> Binding<T> {
}
#[inline]
fn mode_matches(&self, mode: &TermMode) -> bool {
fn mode_matches(&self, mode: TermMode) -> bool {
self.mode.is_empty() || mode.intersects(self.mode)
}
#[inline]
fn not_mode_matches(&self, mode: &TermMode) -> bool {
fn not_mode_matches(&self, mode: TermMode) -> bool {
self.notmode.is_empty() || !mode.intersects(self.notmode)
}
@ -136,10 +136,10 @@ impl<T> Binding<T> {
///
/// Optimized to use single check instead of four (one per modifier)
#[inline]
fn mods_match(&self, mods: &ModifiersState) -> bool {
fn mods_match(&self, mods: ModifiersState) -> bool {
debug_assert!(4 == mem::size_of::<ModifiersState>());
unsafe {
mem::transmute_copy::<_, u32>(&self.mods) == mem::transmute_copy::<_, u32>(mods)
mem::transmute_copy::<_, u32>(&self.mods) == mem::transmute_copy::<_, u32>(&mods)
}
}
}
@ -532,7 +532,7 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> {
return;
}
self.process_mouse_bindings(&ModifiersState::default(), button);
self.process_mouse_bindings(ModifiersState::default(), button);
}
/// Process key input
@ -542,11 +542,11 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> {
&mut self,
state: ElementState,
key: Option<VirtualKeyCode>,
mods: &ModifiersState,
mods: ModifiersState,
) {
match (key, state) {
(Some(key), ElementState::Pressed) => {
*self.ctx.last_modifiers() = *mods;
*self.ctx.last_modifiers() = mods;
*self.ctx.received_count() = 0;
*self.ctx.suppress_chars() = false;
@ -587,7 +587,7 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> {
/// for its action to be executed.
///
/// Returns true if an action is executed.
fn process_key_bindings(&mut self, mods: &ModifiersState, key: VirtualKeyCode) -> bool {
fn process_key_bindings(&mut self, mods: ModifiersState, key: VirtualKeyCode) -> bool {
for binding in self.key_bindings {
if binding.is_triggered_by(self.ctx.terminal_mode(), mods, &key) {
// binding was triggered; run the action
@ -605,7 +605,7 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> {
/// for its action to be executed.
///
/// Returns true if an action is executed.
fn process_mouse_bindings(&mut self, mods: &ModifiersState, button: MouseButton) -> bool {
fn process_mouse_bindings(&mut self, mods: ModifiersState, button: MouseButton) -> bool {
for binding in self.mouse_bindings {
if binding.is_triggered_by(self.ctx.terminal_mode(), mods, &button) {
// binding was triggered; run the action
@ -782,9 +782,9 @@ mod tests {
#[test]
fn $name() {
if $triggers {
assert!($binding.is_triggered_by($mode, &$mods, &KEY));
assert!($binding.is_triggered_by($mode, $mods, &KEY));
} else {
assert!(!$binding.is_triggered_by($mode, &$mods, &KEY));
assert!(!$binding.is_triggered_by($mode, $mods, &KEY));
}
}
}

View File

@ -183,7 +183,7 @@ impl GlyphCache {
// Need to load at least one glyph for the face before calling metrics.
// The glyph requested here ('m' at the time of writing) has no special
// meaning.
rasterizer.get_glyph(&GlyphKey { font_key: regular, c: 'm', size: font.size() })?;
rasterizer.get_glyph(GlyphKey { font_key: regular, c: 'm', size: font.size() })?;
let metrics = rasterizer.metrics(regular)?;
let mut cache = GlyphCache {
@ -211,7 +211,7 @@ impl GlyphCache {
) {
let size = self.font_size;
for i in RangeInclusive::new(32u8, 128u8) {
self.get(&GlyphKey {
self.get(GlyphKey {
font_key: font,
c: i as char,
size,
@ -273,14 +273,14 @@ impl GlyphCache {
.expect("metrics load since font is loaded at glyph cache creation")
}
pub fn get<'a, L>(&'a mut self, glyph_key: &GlyphKey, loader: &mut L) -> &'a Glyph
pub fn get<'a, L>(&'a mut self, glyph_key: GlyphKey, loader: &mut L) -> &'a Glyph
where L: LoadGlyph
{
let glyph_offset = self.glyph_offset;
let rasterizer = &mut self.rasterizer;
let metrics = &self.metrics;
self.cache
.entry(*glyph_key)
.entry(glyph_key)
.or_insert_with(|| {
let mut rasterized = rasterizer.get_glyph(glyph_key)
.unwrap_or_else(|_| Default::default());
@ -306,7 +306,7 @@ impl GlyphCache {
let font = font.to_owned().with_size(size);
info!("Font size changed: {:?}", font.size);
let (regular, bold, italic) = Self::compute_font_keys(&font, &mut self.rasterizer)?;
self.rasterizer.get_glyph(&GlyphKey { font_key: regular, c: 'm', size: font.size() })?;
self.rasterizer.get_glyph(GlyphKey { font_key: regular, c: 'm', size: font.size() })?;
let metrics = self.rasterizer.metrics(regular)?;
self.font_size = font.size;
@ -842,7 +842,7 @@ impl<'a> RenderApi<'a> {
// Add cell to batch
{
let glyph = glyph_cache.get(&glyph_key, self);
let glyph = glyph_cache.get(glyph_key, self);
self.add_render_item(&cell, glyph);
}
@ -856,7 +856,7 @@ impl<'a> RenderApi<'a> {
c: '_'
};
let underscore = glyph_cache.get(&glyph_key, self);
let underscore = glyph_cache.get(glyph_key, self);
self.add_render_item(&cell, underscore);
}
}

View File

@ -152,7 +152,7 @@ impl Selection {
Selection::Semantic { ref region, ref initial_expansion } => {
Selection::span_semantic(grid, region, initial_expansion)
},
Selection::Lines { ref region, ref initial_line } => {
Selection::Lines { ref region, initial_line } => {
Selection::span_lines(grid, region, initial_line)
}
}
@ -192,18 +192,18 @@ impl Selection {
})
}
fn span_lines<G>(grid: &G, region: &Region<Point>, initial_line: &Line) -> Option<Span>
fn span_lines<G>(grid: &G, region: &Region<Point>, initial_line: Line) -> Option<Span>
where G: Dimensions
{
// First, create start and end points based on initial line and the grid
// dimensions.
let mut start = Point {
col: Column(0),
line: *initial_line
line: initial_line
};
let mut end = Point {
col: grid.dimensions().col - 1,
line: *initial_line
line: initial_line
};
// Now, expand lines based on where cursor started and ended.

View File

@ -269,9 +269,9 @@ impl<'a> RenderableCellsIter<'a> {
self.mode.contains(mode::TermMode::SHOW_CURSOR) && self.grid.contains(self.cursor)
}
fn compute_fg_rgb(&self, fg: &Color, cell: &Cell) -> Rgb {
fn compute_fg_rgb(&self, fg: Color, cell: &Cell) -> Rgb {
use self::cell::Flags;
match *fg {
match fg {
Color::Spec(rgb) => rgb,
Color::Named(ansi) => {
match (self.config.draw_bold_text_with_bright_colors(), cell.flags & Flags::DIM_BOLD) {
@ -302,15 +302,15 @@ impl<'a> RenderableCellsIter<'a> {
}
#[inline]
fn compute_bg_alpha(&self, bg: &Color) -> f32 {
match *bg {
fn compute_bg_alpha(&self, bg: Color) -> f32 {
match bg {
Color::Named(NamedColor::Background) => 0.0,
_ => 1.0
}
}
fn compute_bg_rgb(&self, bg: &Color) -> Rgb {
match *bg {
fn compute_bg_rgb(&self, bg: Color) -> Rgb {
match bg {
Color::Spec(rgb) => rgb,
Color::Named(ansi) => self.colors[ansi],
Color::Indexed(idx) => self.colors[idx],
@ -387,13 +387,13 @@ impl<'a> Iterator for RenderableCellsIter<'a> {
fg_rgb = self.colors[NamedColor::Background];
bg_alpha = 1.0
} else {
bg_rgb = self.compute_fg_rgb(&cell.fg, &cell);
fg_rgb = self.compute_bg_rgb(&cell.bg);
bg_rgb = self.compute_fg_rgb(cell.fg, &cell);
fg_rgb = self.compute_bg_rgb(cell.bg);
}
} else {
fg_rgb = self.compute_fg_rgb(&cell.fg, &cell);
bg_rgb = self.compute_bg_rgb(&cell.bg);
bg_alpha = self.compute_bg_alpha(&cell.bg);
fg_rgb = self.compute_fg_rgb(cell.fg, &cell);
bg_rgb = self.compute_bg_rgb(cell.bg);
bg_alpha = self.compute_bg_alpha(cell.bg);
}
return Some(RenderableCell {