From 7ec36f2626aa601f4b1cd85e9712bc81903e6170 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sun, 9 Dec 2018 17:04:02 +0100 Subject: [PATCH] Fix Rust 2018 edition idioms --- build.rs | 10 ++++------ src/ansi.rs | 4 ++-- src/cli.rs | 6 +++--- src/config.rs | 24 ++++++++++++------------ src/display.rs | 8 ++++---- src/event.rs | 4 ++-- src/grid/mod.rs | 36 ++++++++++++++++++------------------ src/grid/row.rs | 2 +- src/index.rs | 6 +++--- src/input.rs | 2 +- src/lib.rs | 28 ---------------------------- src/logging.rs | 4 ++-- src/main.rs | 2 +- src/meter.rs | 2 +- src/renderer/mod.rs | 14 +++++++------- src/sync.rs | 2 +- src/term/color.rs | 2 +- src/term/mod.rs | 14 +++++++------- src/tty/mod.rs | 2 +- src/tty/unix.rs | 4 ++-- src/util.rs | 4 ++-- src/window.rs | 4 ++-- tests/ref.rs | 3 +-- 23 files changed, 78 insertions(+), 109 deletions(-) diff --git a/build.rs b/build.rs index 22799c95..4036dad2 100644 --- a/build.rs +++ b/build.rs @@ -12,15 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. #[cfg(windows)] -extern crate embed_resource; +use embed_resource; #[cfg(windows)] -extern crate tempfile; +use tempfile; #[cfg(windows)] -extern crate reqwest; +use reqwest; #[cfg(windows)] -extern crate zip; - -extern crate gl_generator; +use zip; use gl_generator::{Api, Fallbacks, GlobalGenerator, Profile, Registry}; diff --git a/src/ansi.rs b/src/ansi.rs index eb36454b..db8022e2 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -112,7 +112,7 @@ struct ProcessorState { /// /// Processor creates a Performer when running advance and passes the Performer /// to `vte::Parser`. -struct Performer<'a, H: Handler + TermInfo + 'a, W: io::Write + 'a> { +struct Performer<'a, H: Handler + TermInfo, W: io::Write> { _state: &'a mut ProcessorState, handler: &'a mut H, writer: &'a mut W @@ -1225,7 +1225,7 @@ fn parse_color(attrs: &[i64], i: &mut usize) -> Option { *i += 2; let idx = attrs[*i]; match idx { - 0 ... 255 => { + 0 ..= 255 => { Some(Color::Indexed(idx as u8)) }, _ => { diff --git a/src/cli.rs b/src/cli.rs index 6a41f5ea..2eeb0c0b 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -extern crate log; +use ::log; use clap::{Arg, App}; use crate::index::{Line, Column}; use crate::config::{Dimensions, Shell}; @@ -186,11 +186,11 @@ impl Options { self.dimensions } - pub fn command(&self) -> Option<&Shell> { + pub fn command(&self) -> Option<&Shell<'_>> { self.command.as_ref() } - pub fn config_path(&self) -> Option> { + pub fn config_path(&self) -> Option> { self.config.as_ref().map(|p| Cow::Borrowed(p.as_path())) } } diff --git a/src/config.rs b/src/config.rs index b1d33061..39a5c024 100644 --- a/src/config.rs +++ b/src/config.rs @@ -296,7 +296,7 @@ impl<'de> Deserialize<'de> for Decorations { impl<'de> Visitor<'de> for DecorationsVisitor { type Value = Decorations; - fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("Some subset of full|transparent|buttonless|none") } @@ -709,7 +709,7 @@ impl<'a> de::Deserialize<'a> for ModsWrapper { impl<'a> Visitor<'a> for ModsVisitor { type Value = ModsWrapper; - fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("Some subset of Command|Shift|Super|Alt|Option|Control") } @@ -752,7 +752,7 @@ impl<'a> de::Deserialize<'a> for ActionWrapper { impl<'a> Visitor<'a> for ActionVisitor { type Value = ActionWrapper; - fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("Paste, Copy, PasteSelection, IncreaseFontSize, DecreaseFontSize, \ ResetFontSize, ScrollPageUp, ScrollPageDown, ScrollToTop, \ ScrollToBottom, ClearHistory, Hide, ClearLogNotice or Quit") @@ -827,7 +827,7 @@ impl<'a> de::Deserialize<'a> for ModeWrapper { impl<'a> Visitor<'a> for ModeVisitor { type Value = ModeWrapper; - fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("Combination of AppCursor | AppKeypad, possibly with negation (~)") } @@ -873,7 +873,7 @@ impl<'a> de::Deserialize<'a> for MouseButton { impl<'a> Visitor<'a> for MouseButtonVisitor { type Value = MouseButton; - fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("Left, Right, Middle, or a number") } @@ -967,7 +967,7 @@ impl<'a> de::Deserialize<'a> for RawBinding { impl<'a> Visitor<'a> for FieldVisitor { type Value = Field; - fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("binding fields") } @@ -995,7 +995,7 @@ impl<'a> de::Deserialize<'a> for RawBinding { impl<'a> Visitor<'a> for RawBindingVisitor { type Value = RawBinding; - fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("binding specification") } @@ -1357,7 +1357,7 @@ fn rgb_from_hex<'a, D>(deserializer: D) -> ::std::result::Result impl<'a> Visitor<'a> for RgbVisitor { type Value = Rgb; - fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("Hex colors spec like 'ffaabb'") } @@ -1416,7 +1416,7 @@ impl FromStr for Rgb { } impl ::std::error::Error for Error { - fn cause(&self) -> Option<&::std::error::Error> { + fn cause(&self) -> Option<&dyn (::std::error::Error)> { match *self { Error::NotFound | Error::Empty => None, Error::ReadingEnvHome(ref err) => Some(err), @@ -1437,7 +1437,7 @@ impl ::std::error::Error for Error { } impl ::std::fmt::Display for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { match *self { Error::NotFound | Error::Empty => write!(f, "{}", ::std::error::Error::description(self)), Error::ReadingEnvHome(ref err) => { @@ -1625,7 +1625,7 @@ impl Config { .map(|p| p.as_path()) } - pub fn shell(&self) -> Option<&Shell> { + pub fn shell(&self) -> Option<&Shell<'_>> { self.shell.as_ref() } @@ -1831,7 +1831,7 @@ impl DeserializeSize for Size { { type Value = f64; - fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("f64 or u64") } diff --git a/src/display.rs b/src/display.rs index 40c85b20..99889c67 100644 --- a/src/display.rs +++ b/src/display.rs @@ -44,7 +44,7 @@ pub enum Error { } impl ::std::error::Error for Error { - fn cause(&self) -> Option<&::std::error::Error> { + fn cause(&self) -> Option<&dyn (::std::error::Error)> { match *self { Error::Window(ref err) => Some(err), Error::Font(ref err) => Some(err), @@ -62,7 +62,7 @@ impl ::std::error::Error for Error { } impl ::std::fmt::Display for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { match *self { Error::Window(ref err) => err.fmt(f), Error::Font(ref err) => err.fmt(f), @@ -292,9 +292,9 @@ impl Display { /// Process pending resize events pub fn handle_resize( &mut self, - terminal: &mut MutexGuard, + terminal: &mut MutexGuard<'_, Term>, config: &Config, - items: &mut [&mut OnResize], + items: &mut [&mut dyn OnResize], ) { // Resize events new_size and are handled outside the poll_events // iterator. This has the effect of coalescing multiple resize diff --git a/src/event.rs b/src/event.rs index b0b6b333..39ed25f6 100644 --- a/src/event.rs +++ b/src/event.rs @@ -34,7 +34,7 @@ pub trait Notify { fn notify>>(&mut self, _: B); } -pub struct ActionContext<'a, N: 'a> { +pub struct ActionContext<'a, N> { pub notifier: &'a mut N, pub terminal: &'a mut Term, pub size_info: &'a mut SizeInfo, @@ -456,7 +456,7 @@ impl Processor { { // Ditto on lazy initialization for context and processor. let context; - let mut processor: input::Processor>; + let mut processor: input::Processor<'_, ActionContext<'_, N>>; let print_events = self.print_events; diff --git a/src/grid/mod.rs b/src/grid/mod.rs index f39bc686..a00fed40 100644 --- a/src/grid/mod.rs +++ b/src/grid/mod.rs @@ -99,7 +99,7 @@ pub struct Grid { max_scroll_limit: usize, } -pub struct GridIterator<'a, T: 'a> { +pub struct GridIterator<'a, T> { /// Immutable grid reference grid: &'a Grid, @@ -411,7 +411,7 @@ impl Grid { self.lines } - pub fn display_iter(&self) -> DisplayIter { + pub fn display_iter(&self) -> DisplayIter<'_, T> { DisplayIter::new(self) } @@ -454,7 +454,7 @@ impl Grid { self.raw.truncate(); } - pub fn iter_from(&self, point: Point) -> GridIterator { + pub fn iter_from(&self, point: Point) -> GridIterator<'_, T> { GridIterator { grid: self, cur: point, @@ -557,7 +557,7 @@ impl<'point, T> IndexMut<&'point Point> for Grid { /// A subset of lines in the grid /// /// May be constructed using Grid::region(..) -pub struct Region<'a, T: 'a> { +pub struct Region<'a, T> { start: Line, end: Line, raw: &'a Storage, @@ -566,7 +566,7 @@ pub struct Region<'a, T: 'a> { /// A mutable subset of lines in the grid /// /// May be constructed using Grid::region_mut(..) -pub struct RegionMut<'a, T: 'a> { +pub struct RegionMut<'a, T> { start: Line, end: Line, raw: &'a mut Storage, @@ -585,14 +585,14 @@ impl<'a, T> RegionMut<'a, T> { pub trait IndexRegion { /// Get an immutable region of Self - fn region(&self, _: I) -> Region; + fn region(&self, _: I) -> Region<'_, T>; /// Get a mutable region of Self - fn region_mut(&mut self, _: I) -> RegionMut; + fn region_mut(&mut self, _: I) -> RegionMut<'_, T>; } impl IndexRegion, T> for Grid { - fn region(&self, index: Range) -> Region { + fn region(&self, index: Range) -> Region<'_, T> { assert!(index.start < self.num_lines()); assert!(index.end <= self.num_lines()); assert!(index.start <= index.end); @@ -602,7 +602,7 @@ impl IndexRegion, T> for Grid { raw: &self.raw } } - fn region_mut(&mut self, index: Range) -> RegionMut { + fn region_mut(&mut self, index: Range) -> RegionMut<'_, T> { assert!(index.start < self.num_lines()); assert!(index.end <= self.num_lines()); assert!(index.start <= index.end); @@ -615,7 +615,7 @@ impl IndexRegion, T> for Grid { } impl IndexRegion, T> for Grid { - fn region(&self, index: RangeTo) -> Region { + fn region(&self, index: RangeTo) -> Region<'_, T> { assert!(index.end <= self.num_lines()); Region { start: Line(0), @@ -623,7 +623,7 @@ impl IndexRegion, T> for Grid { raw: &self.raw } } - fn region_mut(&mut self, index: RangeTo) -> RegionMut { + fn region_mut(&mut self, index: RangeTo) -> RegionMut<'_, T> { assert!(index.end <= self.num_lines()); RegionMut { start: Line(0), @@ -634,7 +634,7 @@ impl IndexRegion, T> for Grid { } impl IndexRegion, T> for Grid { - fn region(&self, index: RangeFrom) -> Region { + fn region(&self, index: RangeFrom) -> Region<'_, T> { assert!(index.start < self.num_lines()); Region { start: index.start, @@ -642,7 +642,7 @@ impl IndexRegion, T> for Grid { raw: &self.raw } } - fn region_mut(&mut self, index: RangeFrom) -> RegionMut { + fn region_mut(&mut self, index: RangeFrom) -> RegionMut<'_, T> { assert!(index.start < self.num_lines()); RegionMut { start: index.start, @@ -653,7 +653,7 @@ impl IndexRegion, T> for Grid { } impl IndexRegion for Grid { - fn region(&self, _: RangeFull) -> Region { + fn region(&self, _: RangeFull) -> Region<'_, T> { Region { start: Line(0), end: self.num_lines(), @@ -661,7 +661,7 @@ impl IndexRegion for Grid { } } - fn region_mut(&mut self, _: RangeFull) -> RegionMut { + fn region_mut(&mut self, _: RangeFull) -> RegionMut<'_, T> { RegionMut { start: Line(0), end: self.num_lines(), @@ -670,13 +670,13 @@ impl IndexRegion for Grid { } } -pub struct RegionIter<'a, T: 'a> { +pub struct RegionIter<'a, T> { end: Line, cur: Line, raw: &'a Storage, } -pub struct RegionIterMut<'a, T: 'a> { +pub struct RegionIterMut<'a, T> { end: Line, cur: Line, raw: &'a mut Storage, @@ -741,7 +741,7 @@ impl<'a, T> Iterator for RegionIterMut<'a, T> { // ------------------------------------------------------------------------------------------------- /// Iterates over the visible area accounting for buffer transform -pub struct DisplayIter<'a, T: 'a> { +pub struct DisplayIter<'a, T> { grid: &'a Grid, offset: usize, limit: usize, diff --git a/src/grid/row.rs b/src/grid/row.rs index 0db0c0c1..72c79b02 100644 --- a/src/grid/row.rs +++ b/src/grid/row.rs @@ -85,7 +85,7 @@ impl Row { self.inner.len() } - pub fn iter(&self) -> slice::Iter { + pub fn iter(&self) -> slice::Iter<'_, T> { self.inner.iter() } } diff --git a/src/index.rs b/src/index.rs index 8f998bf0..93f1727e 100644 --- a/src/index.rs +++ b/src/index.rs @@ -77,7 +77,7 @@ impl From for Point { pub struct Line(pub usize); impl fmt::Display for Line { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.0) } } @@ -89,7 +89,7 @@ impl fmt::Display for Line { pub struct Column(pub usize); impl fmt::Display for Column { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.0) } } @@ -101,7 +101,7 @@ impl fmt::Display for Column { pub struct Linear(pub usize); impl fmt::Display for Linear { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "Linear({})", self.0) } } diff --git a/src/input.rs b/src/input.rs index 9a3d9f6d..07887ad9 100644 --- a/src/input.rs +++ b/src/input.rs @@ -939,7 +939,7 @@ mod tests { processor.mouse_input(state, button, modifiers); }; - assert!(match mouse.click_state { + assert!(match processor.ctx.mouse.click_state { $end_state => processor.ctx.last_action == $last_action, _ => false }); diff --git a/src/lib.rs b/src/lib.rs index 61f61ccf..31130608 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,10 +23,6 @@ #[macro_use] extern crate serde_derive; #[macro_use] extern crate static_assertions; -#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", - target_os = "openbsd"))] -extern crate x11_dl; - #[cfg(windows)] extern crate mio_named_pipes; #[cfg(windows)] @@ -42,30 +38,6 @@ extern crate image; #[macro_use] extern crate objc; -extern crate arraydeque; -extern crate cgmath; -extern crate copypasta; -extern crate env_logger; -extern crate errno; -extern crate fnv; -extern crate font; -extern crate glutin; -extern crate libc; -extern crate mio; -extern crate mio_more; -extern crate notify; -extern crate parking_lot; -extern crate serde; -extern crate serde_json; -extern crate serde_yaml; -extern crate unicode_width; -extern crate vte; -extern crate xdg; -extern crate base64; -extern crate terminfo; -extern crate url; -extern crate time; - #[macro_use] pub mod macros; diff --git a/src/logging.rs b/src/logging.rs index eb9016bf..1767724c 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -120,11 +120,11 @@ impl Logger { } impl log::Log for Logger { - fn enabled(&self, metadata: &log::Metadata) -> bool { + fn enabled(&self, metadata: &log::Metadata<'_>) -> bool { metadata.level() <= self.level } - fn log(&self, record: &log::Record) { + fn log(&self, record: &log::Record<'_>) { if self.enabled(record.metadata()) && record.target().starts_with("alacritty") { let msg = format!( "[{}] [{}] {}\n", diff --git a/src/main.rs b/src/main.rs index 9d57f086..212ab79e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -118,7 +118,7 @@ fn run( mut config: Config, options: &cli::Options, mut logger_proxy: LoggerProxy, -) -> Result<(), Box> { +) -> Result<(), Box> { info!("Welcome to Alacritty."); if let Some(config_path) = config.path() { info!("Configuration loaded from {}", config_path.display()); diff --git a/src/meter.rs b/src/meter.rs index 952dedf8..32650e4d 100644 --- a/src/meter.rs +++ b/src/meter.rs @@ -86,7 +86,7 @@ impl Meter { } /// Get a sampler - pub fn sampler(&mut self) -> Sampler { + pub fn sampler(&mut self) -> Sampler<'_> { Sampler::new(self) } diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs index 85de1fd6..02d31524 100644 --- a/src/renderer/mod.rs +++ b/src/renderer/mod.rs @@ -65,7 +65,7 @@ pub enum Error { } impl ::std::error::Error for Error { - fn cause(&self) -> Option<&::std::error::Error> { + fn cause(&self) -> Option<&dyn (::std::error::Error)> { match *self { Error::ShaderCreation(ref err) => Some(err), } @@ -79,7 +79,7 @@ impl ::std::error::Error for Error { } impl ::std::fmt::Display for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { match *self { Error::ShaderCreation(ref err) => { write!(f, "There was an error initializing the shaders: {}", err) @@ -660,7 +660,7 @@ impl QuadRenderer { func: F, ) -> T where - F: FnOnce(RenderApi) -> T, + F: FnOnce(RenderApi<'_>) -> T, { while let Ok(msg) = self.rx.try_recv() { match msg { @@ -704,7 +704,7 @@ impl QuadRenderer { pub fn with_loader(&mut self, func: F) -> T where - F: FnOnce(LoaderApi) -> T, + F: FnOnce(LoaderApi<'_>) -> T, { unsafe { gl::ActiveTexture(gl::TEXTURE0); @@ -897,7 +897,7 @@ impl<'a> RenderApi<'a> { }; // Add cell to batch - let glyph = glyph_cache.get(glyph_key, self); // borrowck multiple mutable borrows + let glyph = glyph_cache.get(glyph_key, self); self.add_render_item(&cell, glyph); // Render zero-width characters @@ -1288,7 +1288,7 @@ pub enum ShaderCreationError { } impl ::std::error::Error for ShaderCreationError { - fn cause(&self) -> Option<&::std::error::Error> { + fn cause(&self) -> Option<&dyn (::std::error::Error)> { match *self { ShaderCreationError::Io(ref err) => Some(err), _ => None, @@ -1305,7 +1305,7 @@ impl ::std::error::Error for ShaderCreationError { } impl ::std::fmt::Display for ShaderCreationError { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { match *self { ShaderCreationError::Io(ref err) => write!(f, "couldn't read shader: {}", err), ShaderCreationError::Compile(ref _path, ref s) => { diff --git a/src/sync.rs b/src/sync.rs index e314b7e8..06d6cea4 100644 --- a/src/sync.rs +++ b/src/sync.rs @@ -38,7 +38,7 @@ impl FairMutex { } /// Lock the mutex - pub fn lock(&self) -> MutexGuard { + pub fn lock(&self) -> MutexGuard<'_, T> { // Must bind to a temporary or the lock will be freed before going // into data.lock() let _next = self.next.lock(); diff --git a/src/term/color.rs b/src/term/color.rs index 7211b043..638cbd76 100644 --- a/src/term/color.rs +++ b/src/term/color.rs @@ -154,7 +154,7 @@ impl List { } impl fmt::Debug for List { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("List[..]") } } diff --git a/src/term/mod.rs b/src/term/mod.rs index fe6724c9..c0989add 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -391,9 +391,9 @@ impl<'a> RenderableCellsIter<'a> { cell.flags & Flags::DIM_BOLD, idx ) { - (true, self::cell::Flags::BOLD, 0...7) => idx as usize + 8, - (false, self::cell::Flags::DIM, 8...15) => idx as usize - 8, - (false, self::cell::Flags::DIM, 0...7) => idx as usize + 260, + (true, self::cell::Flags::BOLD, 0..=7) => idx as usize + 8, + (false, self::cell::Flags::DIM, 8..=15) => idx as usize - 8, + (false, self::cell::Flags::DIM, 0..=7) => idx as usize + 260, _ => idx as usize, }; @@ -1128,7 +1128,7 @@ impl Term { &'b self, config: &'b Config, window_focused: bool, - ) -> RenderableCellsIter { + ) -> RenderableCellsIter<'_> { let alt_screen = self.mode.contains(TermMode::ALT_SCREEN); let selection = self.grid.selection.as_ref() .and_then(|s| s.to_span(self, alt_screen)) @@ -2068,7 +2068,7 @@ impl ansi::Handler for Term { #[cfg(test)] mod tests { - extern crate serde_json; + use serde_json; use super::{Cell, Term, SizeInfo}; use crate::term::{cell, Search}; @@ -2419,8 +2419,8 @@ mod benches { use std::mem; use std::path::Path; - use grid::Grid; - use config::Config; + use crate::grid::Grid; + use crate::config::Config; use super::{SizeInfo, Term}; use super::cell::Cell; diff --git a/src/tty/mod.rs b/src/tty/mod.rs index ef6b9db0..cedb010e 100644 --- a/src/tty/mod.rs +++ b/src/tty/mod.rs @@ -40,7 +40,7 @@ pub trait EventedReadWrite { fn register( &mut self, _: &mio::Poll, - _: &mut Iterator, + _: &mut dyn Iterator, _: mio::Ready, _: mio::PollOpt, ) -> io::Result<()>; diff --git a/src/tty/unix.rs b/src/tty/unix.rs index b1125fe5..b341638f 100644 --- a/src/tty/unix.rs +++ b/src/tty/unix.rs @@ -149,7 +149,7 @@ struct Passwd<'a> { /// # Unsafety /// /// If `buf` is changed while `Passwd` is alive, bad thing will almost certainly happen. -fn get_pw_entry(buf: &mut [i8; 1024]) -> Passwd { +fn get_pw_entry(buf: &mut [i8; 1024]) -> Passwd<'_> { // Create zeroed passwd struct let mut entry: libc::passwd = unsafe { ::std::mem::uninitialized() }; @@ -329,7 +329,7 @@ impl EventedReadWrite for Pty { fn register( &mut self, poll: &mio::Poll, - token: &mut Iterator, + token: &mut dyn Iterator, interest: mio::Ready, poll_opts: mio::PollOpt, ) -> io::Result<()> { diff --git a/src/util.rs b/src/util.rs index 3b981aa6..0b3b6644 100644 --- a/src/util.rs +++ b/src/util.rs @@ -50,13 +50,13 @@ pub mod fmt { pub struct $s(pub T); impl fmt::Display for $s { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, concat!("\x1b[", $color, "m{}\x1b[0m"), self.0) } } impl fmt::Debug for $s { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, concat!("\x1b[", $color, "m{:?}\x1b[0m"), self.0) } } diff --git a/src/window.rs b/src/window.rs index 37905b00..ebff59c1 100644 --- a/src/window.rs +++ b/src/window.rs @@ -93,7 +93,7 @@ pub struct DeviceProperties { } impl ::std::error::Error for Error { - fn cause(&self) -> Option<&::std::error::Error> { + fn cause(&self) -> Option<&dyn (::std::error::Error)> { match *self { Error::ContextCreation(ref err) => Some(err), Error::Context(ref err) => Some(err), @@ -109,7 +109,7 @@ impl ::std::error::Error for Error { } impl Display for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { match *self { Error::ContextCreation(ref err) => write!(f, "Error creating GL context; {}", err), Error::Context(ref err) => write!(f, "Error operating on render context; {}", err), diff --git a/tests/ref.rs b/tests/ref.rs index 6546921d..1ab012d4 100644 --- a/tests/ref.rs +++ b/tests/ref.rs @@ -1,7 +1,6 @@ #[macro_use] extern crate serde_derive; -extern crate serde_json as json; -extern crate alacritty; +use serde_json as json; use std::fs::File; use std::io::{self, Read};