Replace deprecated Error methods


diff --git a/alacritty/src/config/mod.rs b/alacritty/src/config/mod.rs
index beaffd8..91ca693 100644
--- a/alacritty/src/config/mod.rs
+++ b/alacritty/src/config/mod.rs
@@ -1,4 +1,6 @@
 use std::env;
+use std::fmt::{self, Display, Formatter};
+use std::fs;
 use std::io;
 use std::path::PathBuf;
 
@@ -24,7 +26,7 @@
 pub type Config = TermConfig<UIConfig>;
 
 /// Result from config loading
-pub type Result<T> = ::std::result::Result<T, Error>;
+pub type Result<T> = std::result::Result<T, Error>;
 
 /// Errors occurring during config loading
 #[derive(Debug)]
@@ -43,46 +45,37 @@
 }
 
 impl std::error::Error for Error {
-    fn cause(&self) -> Option<&dyn (::std::error::Error)> {
-        match *self {
+    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
+        match self {
             Error::NotFound => None,
-            Error::ReadingEnvHome(ref err) => Some(err),
-            Error::Io(ref err) => Some(err),
-            Error::Yaml(ref err) => Some(err),
-        }
-    }
-
-    fn description(&self) -> &str {
-        match *self {
-            Error::NotFound => "Couldn't locate config file",
-            Error::ReadingEnvHome(ref err) => err.description(),
-            Error::Io(ref err) => err.description(),
-            Error::Yaml(ref err) => err.description(),
+            Error::ReadingEnvHome(err) => err.source(),
+            Error::Io(err) => err.source(),
+            Error::Yaml(err) => err.source(),
         }
     }
 }
 
-impl std::fmt::Display for Error {
-    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
-        match *self {
-            Error::NotFound => write!(f, "{}", ::std::error::Error::description(self)),
-            Error::ReadingEnvHome(ref err) => {
+impl Display for Error {
+    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
+        match self {
+            Error::NotFound => write!(f, "Couldn't locate config file"),
+            Error::ReadingEnvHome(err) => {
                 write!(f, "Couldn't read $HOME environment variable: {}", err)
             },
-            Error::Io(ref err) => write!(f, "Error reading config file: {}", err),
-            Error::Yaml(ref err) => write!(f, "Problem with config: {}", err),
+            Error::Io(err) => write!(f, "Error reading config file: {}", err),
+            Error::Yaml(err) => write!(f, "Problem with config: {}", err),
         }
     }
 }
 
 impl From<env::VarError> for Error {
-    fn from(val: env::VarError) -> Error {
+    fn from(val: env::VarError) -> Self {
         Error::ReadingEnvHome(val)
     }
 }
 
 impl From<io::Error> for Error {
-    fn from(val: io::Error) -> Error {
+    fn from(val: io::Error) -> Self {
         if val.kind() == io::ErrorKind::NotFound {
             Error::NotFound
         } else {
@@ -92,7 +85,7 @@
 }
 
 impl From<serde_yaml::Error> for Error {
-    fn from(val: serde_yaml::Error) -> Error {
+    fn from(val: serde_yaml::Error) -> Self {
         Error::Yaml(val)
     }
 }
@@ -154,7 +147,7 @@
 }
 
 fn read_config(path: &PathBuf) -> Result<Config> {
-    let mut contents = std::fs::read_to_string(path)?;
+    let mut contents = fs::read_to_string(path)?;
 
     // Remove UTF-8 BOM
     if contents.chars().nth(0) == Some('\u{FEFF}') {
@@ -165,10 +158,10 @@
 }
 
 fn parse_config(contents: &str) -> Result<Config> {
-    match serde_yaml::from_str(&contents) {
+    match serde_yaml::from_str(contents) {
         Err(error) => {
             // Prevent parsing error with an empty string and commented out file.
-            if std::error::Error::description(&error) == "EOF while parsing a value" {
+            if error.to_string() == "EOF while parsing a value" {
                 Ok(Config::default())
             } else {
                 Err(Error::Yaml(error))
diff --git a/alacritty/src/display.rs b/alacritty/src/display.rs
index 5e800ed..0b1a64a 100644
--- a/alacritty/src/display.rs
+++ b/alacritty/src/display.rs
@@ -15,7 +15,7 @@
 //! The display subsystem including window management, font rasterization, and
 //! GPU drawing.
 use std::f64;
-use std::fmt;
+use std::fmt::{self, Formatter};
 use std::time::Instant;
 
 use glutin::dpi::{PhysicalPosition, PhysicalSize};
@@ -61,56 +61,47 @@
 }
 
 impl std::error::Error for Error {
-    fn cause(&self) -> Option<&dyn (std::error::Error)> {
-        match *self {
-            Error::Window(ref err) => Some(err),
-            Error::Font(ref err) => Some(err),
-            Error::Render(ref err) => Some(err),
-            Error::ContextError(ref err) => Some(err),
-        }
-    }
-
-    fn description(&self) -> &str {
-        match *self {
-            Error::Window(ref err) => err.description(),
-            Error::Font(ref err) => err.description(),
-            Error::Render(ref err) => err.description(),
-            Error::ContextError(ref err) => err.description(),
+    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
+        match self {
+            Error::Window(err) => err.source(),
+            Error::Font(err) => err.source(),
+            Error::Render(err) => err.source(),
+            Error::ContextError(err) => err.source(),
         }
     }
 }
 
 impl fmt::Display for Error {
-    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        match *self {
-            Error::Window(ref err) => err.fmt(f),
-            Error::Font(ref err) => err.fmt(f),
-            Error::Render(ref err) => err.fmt(f),
-            Error::ContextError(ref err) => err.fmt(f),
+    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
+        match self {
+            Error::Window(err) => err.fmt(f),
+            Error::Font(err) => err.fmt(f),
+            Error::Render(err) => err.fmt(f),
+            Error::ContextError(err) => err.fmt(f),
         }
     }
 }
 
 impl From<window::Error> for Error {
-    fn from(val: window::Error) -> Error {
+    fn from(val: window::Error) -> Self {
         Error::Window(val)
     }
 }
 
 impl From<font::Error> for Error {
-    fn from(val: font::Error) -> Error {
+    fn from(val: font::Error) -> Self {
         Error::Font(val)
     }
 }
 
 impl From<renderer::Error> for Error {
-    fn from(val: renderer::Error) -> Error {
+    fn from(val: renderer::Error) -> Self {
         Error::Render(val)
     }
 }
 
 impl From<glutin::ContextError> for Error {
-    fn from(val: glutin::ContextError) -> Error {
+    fn from(val: glutin::ContextError) -> Self {
         Error::ContextError(val)
     }
 }
@@ -241,7 +232,7 @@
             _ => (),
         }
 
-        Ok(Display {
+        Ok(Self {
             window,
             renderer,
             glyph_cache,
diff --git a/alacritty/src/renderer/mod.rs b/alacritty/src/renderer/mod.rs
index 2d124cc..6084723 100644
--- a/alacritty/src/renderer/mod.rs
+++ b/alacritty/src/renderer/mod.rs
@@ -38,6 +38,7 @@
 use alacritty_terminal::term::color::Rgb;
 use alacritty_terminal::term::{self, CursorKey, RenderableCell, RenderableCellContent, SizeInfo};
 use alacritty_terminal::util;
+use std::fmt::{self, Display, Formatter};
 
 pub mod rects;
 
@@ -77,32 +78,22 @@
     ShaderCreation(ShaderCreationError),
 }
 
-impl ::std::error::Error for Error {
-    fn cause(&self) -> Option<&dyn (::std::error::Error)> {
-        match *self {
-            Error::ShaderCreation(ref err) => Some(err),
-        }
-    }
-
-    fn description(&self) -> &str {
-        match *self {
-            Error::ShaderCreation(ref err) => err.description(),
+impl std::error::Error for Error {
+    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
+        match self {
+            Error::ShaderCreation(err) => err.source(),
         }
     }
 }
 
-impl ::std::fmt::Display for Error {
-    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)
-            },
-        }
+impl Display for Error {
+    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
+        write!(f, "There was an error initializing the shaders: {}", self)
     }
 }
 
 impl From<ShaderCreationError> for Error {
-    fn from(val: ShaderCreationError) -> Error {
+    fn from(val: ShaderCreationError) -> Self {
         Error::ShaderCreation(val)
     }
 }
@@ -184,7 +175,7 @@
     /// glyph offset
     glyph_offset: Delta<i8>,
 
-    metrics: ::font::Metrics,
+    metrics: font::Metrics,
 }
 
 impl GlyphCache {
@@ -205,7 +196,7 @@
 
         let metrics = rasterizer.metrics(regular, font.size)?;
 
-        let mut cache = GlyphCache {
+        let mut cache = Self {
             cache: HashMap::default(),
             cursor_cache: HashMap::default(),
             rasterizer,
@@ -288,7 +279,7 @@
         FontDesc::new(desc.family.clone(), style)
     }
 
-    pub fn get<'a, L>(&'a mut self, glyph_key: GlyphKey, loader: &mut L) -> &'a Glyph
+    pub fn get<L>(&mut self, glyph_key: GlyphKey, loader: &mut L) -> &Glyph
     where
         L: LoadGlyph,
     {
@@ -461,8 +452,8 @@
 
 impl Batch {
     #[inline]
-    pub fn new() -> Batch {
-        Batch { tex: 0, instances: Vec::with_capacity(BATCH_MAX) }
+    pub fn new() -> Self {
+        Self { tex: 0, instances: Vec::with_capacity(BATCH_MAX) }
     }
 
     pub fn add_item(&mut self, mut cell: RenderableCell, glyph: &Glyph) {
@@ -668,7 +659,7 @@
 
         if cfg!(feature = "live-shader-reload") {
             util::thread::spawn_named("live shader reload", move || {
-                let (tx, rx) = ::std::sync::mpsc::channel();
+                let (tx, rx) = std::sync::mpsc::channel();
                 // The Duration argument is a debouncing period.
                 let mut watcher =
                     watcher(tx, Duration::from_millis(10)).expect("create file watcher");
@@ -695,7 +686,7 @@
             });
         }
 
-        let mut renderer = QuadRenderer {
+        let mut renderer = Self {
             program,
             rect_program,
             vao,
@@ -1028,7 +1019,7 @@
                         cursor_key.is_wide,
                     ))
                 });
-                self.add_render_item(cell, &glyph);
+                self.add_render_item(cell, glyph);
                 return;
             },
             RenderableCellContent::Chars(chars) => chars,
@@ -1195,7 +1186,7 @@
 
         assert_uniform_valid!(projection, cell_dim, background);
 
-        let shader = TextShaderProgram {
+        let shader = Self {
             id: program,
             u_projection: projection,
             u_cell_dim: cell_dim,
@@ -1273,7 +1264,7 @@
         // get uniform locations
         let u_color = unsafe { gl::GetUniformLocation(program, b"color\0".as_ptr() as *const _) };
 
-        let shader = RectShaderProgram { id: program, u_color };
+        let shader = Self { id: program, u_color };
 
         unsafe { gl::UseProgram(0) }
 
@@ -1427,37 +1418,29 @@
     Link(String),
 }
 
-impl ::std::error::Error for ShaderCreationError {
-    fn cause(&self) -> Option<&dyn (::std::error::Error)> {
-        match *self {
-            ShaderCreationError::Io(ref err) => Some(err),
+impl std::error::Error for ShaderCreationError {
+    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
+        match self {
+            ShaderCreationError::Io(err) => err.source(),
             _ => None,
         }
     }
-
-    fn description(&self) -> &str {
-        match *self {
-            ShaderCreationError::Io(ref err) => err.description(),
-            ShaderCreationError::Compile(ref _path, ref s) => s.as_str(),
-            ShaderCreationError::Link(ref s) => s.as_str(),
-        }
-    }
 }
 
-impl ::std::fmt::Display for ShaderCreationError {
-    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 log) => {
+impl Display for ShaderCreationError {
+    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
+        match self {
+            ShaderCreationError::Io(err) => write!(f, "Couldn't read shader: {}", err),
+            ShaderCreationError::Compile(path, log) => {
                 write!(f, "Failed compiling shader at {}: {}", path.display(), log)
             },
-            ShaderCreationError::Link(ref log) => write!(f, "Failed linking shader: {}", log),
+            ShaderCreationError::Link(log) => write!(f, "Failed linking shader: {}", log),
         }
     }
 }
 
 impl From<io::Error> for ShaderCreationError {
-    fn from(val: io::Error) -> ShaderCreationError {
+    fn from(val: io::Error) -> Self {
         ShaderCreationError::Io(val)
     }
 }
@@ -1516,7 +1499,7 @@
 }
 
 impl Atlas {
-    fn new(size: i32) -> Atlas {
+    fn new(size: i32) -> Self {
         let mut id: GLuint = 0;
         unsafe {
             gl::PixelStorei(gl::UNPACK_ALIGNMENT, 1);
@@ -1542,7 +1525,7 @@
             gl::BindTexture(gl::TEXTURE_2D, 0);
         }
 
-        Atlas { id, width: size, height: size, row_extent: 0, row_baseline: 0, row_tallest: 0 }
+        Self { id, width: size, height: size, row_extent: 0, row_baseline: 0, row_tallest: 0 }
     }
 
     pub fn clear(&mut self) {
diff --git a/alacritty/src/window.rs b/alacritty/src/window.rs
index b471918..159e746 100644
--- a/alacritty/src/window.rs
+++ b/alacritty/src/window.rs
@@ -14,7 +14,7 @@
 use std::convert::From;
 #[cfg(not(any(target_os = "macos", windows)))]
 use std::ffi::c_void;
-use std::fmt;
+use std::fmt::{self, Display, Formatter};
 #[cfg(not(any(target_os = "macos", windows)))]
 use std::os::raw::c_ulong;
 
@@ -61,50 +61,42 @@
 }
 
 /// Result of fallible operations concerning a Window.
-type Result<T> = ::std::result::Result<T, Error>;
+type Result<T> = std::result::Result<T, Error>;
 
-impl ::std::error::Error for Error {
-    fn cause(&self) -> Option<&dyn (::std::error::Error)> {
-        match *self {
-            Error::ContextCreation(ref err) => Some(err),
-            Error::Context(ref err) => Some(err),
-            Error::Font(ref err) => Some(err),
-        }
-    }
-
-    fn description(&self) -> &str {
-        match *self {
-            Error::ContextCreation(ref _err) => "Error creating gl context",
-            Error::Context(ref _err) => "Error operating on render context",
-            Error::Font(ref err) => err.description(),
+impl std::error::Error for Error {
+    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
+        match self {
+            Error::ContextCreation(err) => err.source(),
+            Error::Context(err) => err.source(),
+            Error::Font(err) => err.source(),
         }
     }
 }
 
-impl fmt::Display for Error {
-    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> 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),
-            Error::Font(ref err) => err.fmt(f),
+impl Display for Error {
+    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
+        match self {
+            Error::ContextCreation(err) => write!(f, "Error creating GL context; {}", err),
+            Error::Context(err) => write!(f, "Error operating on render context; {}", err),
+            Error::Font(err) => err.fmt(f),
         }
     }
 }
 
 impl From<glutin::CreationError> for Error {
-    fn from(val: glutin::CreationError) -> Error {
+    fn from(val: glutin::CreationError) -> Self {
         Error::ContextCreation(val)
     }
 }
 
 impl From<glutin::ContextError> for Error {
-    fn from(val: glutin::ContextError) -> Error {
+    fn from(val: glutin::ContextError) -> Self {
         Error::Context(val)
     }
 }
 
 impl From<font::Error> for Error {
-    fn from(val: font::Error) -> Error {
+    fn from(val: font::Error) -> Self {
         Error::Font(val)
     }
 }
@@ -126,7 +118,7 @@
         .build_windowed(window, event_loop)?;
 
     // Make the context current so OpenGL operations can run
-    let windowed_context = unsafe { windowed_context.make_current().map_err(|(_, e)| e)? };
+    let windowed_context = unsafe { windowed_context.make_current().map_err(|(_, err)| err)? };
 
     Ok(windowed_context)
 }
@@ -171,7 +163,7 @@
             }
         }
 
-        Ok(Window { current_mouse_cursor, mouse_visible: true, windowed_context })
+        Ok(Self { current_mouse_cursor, mouse_visible: true, windowed_context })
     }
 
     pub fn set_inner_size(&mut self, size: LogicalSize) {
diff --git a/font/src/ft/mod.rs b/font/src/ft/mod.rs
index 431a500..206d604 100644
--- a/font/src/ft/mod.rs
+++ b/font/src/ft/mod.rs
@@ -15,7 +15,7 @@
 //! Rasterization powered by FreeType and FontConfig
 use std::cmp::{min, Ordering};
 use std::collections::HashMap;
-use std::fmt;
+use std::fmt::{self, Display, Formatter};
 use std::path::PathBuf;
 
 use freetype::freetype_sys;
@@ -46,7 +46,7 @@
 }
 
 impl fmt::Debug for Face {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
         f.debug_struct("Face")
             .field("ft_face", &self.ft_face)
             .field("key", &self.key)
@@ -668,32 +668,23 @@
 }
 
 impl std::error::Error for Error {
-    fn cause(&self) -> Option<&dyn std::error::Error> {
-        match *self {
-            Error::FreeType(ref err) => Some(err),
+    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
+        match self {
+            Error::FreeType(err) => err.source(),
             _ => None,
         }
     }
-
-    fn description(&self) -> &str {
-        match *self {
-            Error::FreeType(ref err) => err.description(),
-            Error::MissingFont(ref _desc) => "Couldn't find the requested font",
-            Error::FontNotLoaded => "Tried to operate on font that hasn't been loaded",
-            Error::MissingSizeMetrics => "Tried to get size metrics from a face without a size",
-        }
-    }
 }
 
-impl std::fmt::Display for Error {
-    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
-        match *self {
-            Error::FreeType(ref err) => err.fmt(f),
-            Error::MissingFont(ref desc) => write!(
+impl Display for Error {
+    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+        match self {
+            Error::FreeType(err) => err.fmt(f),
+            Error::MissingFont(err) => write!(
                 f,
                 "Couldn't find a font with {}\n\tPlease check the font config in your \
                  alacritty.yml.",
-                desc
+                err
             ),
             Error::FontNotLoaded => f.write_str("Tried to use a font that hasn't been loaded"),
             Error::MissingSizeMetrics => {
diff --git a/winpty/src/windows.rs b/winpty/src/windows.rs
index 25bf9d3..fb2b1e8 100644
--- a/winpty/src/windows.rs
+++ b/winpty/src/windows.rs
@@ -83,8 +83,8 @@
 }
 
 impl std::error::Error for Error {
-    fn description(&self) -> &str {
-        &self.message
+    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
+        None
     }
 }