aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/renderer
diff options
context:
space:
mode:
authorsterlingjensen <5555776+sterlingjensen@users.noreply.github.com>2020-01-02 18:17:22 -0600
committerChristian Duerr <contact@christianduerr.com>2020-01-03 00:17:22 +0000
commit05df4f4dbabd82bc71cea6b81ee9383a55b32088 (patch)
tree839acbe3cde075efbd06449e65521b58b093a18d /alacritty/src/renderer
parentd774c7f3a3466b6d7dbcce4c149d74c041036c9f (diff)
downloadr-alacritty-05df4f4dbabd82bc71cea6b81ee9383a55b32088.tar.gz
r-alacritty-05df4f4dbabd82bc71cea6b81ee9383a55b32088.tar.bz2
r-alacritty-05df4f4dbabd82bc71cea6b81ee9383a55b32088.zip
Replace deprecated Error methods
Diffstat (limited to 'alacritty/src/renderer')
-rw-r--r--alacritty/src/renderer/mod.rs81
1 files changed, 32 insertions, 49 deletions
diff --git a/alacritty/src/renderer/mod.rs b/alacritty/src/renderer/mod.rs
index 2d124ccc..60847234 100644
--- a/alacritty/src/renderer/mod.rs
+++ b/alacritty/src/renderer/mod.rs
@@ -38,6 +38,7 @@ use alacritty_terminal::term::cell::{self, Flags};
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 @@ pub enum Error {
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 @@ pub struct GlyphCache {
/// glyph offset
glyph_offset: Delta<i8>,
- metrics: ::font::Metrics,
+ metrics: font::Metrics,
}
impl GlyphCache {
@@ -205,7 +196,7 @@ impl GlyphCache {
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 @@ impl GlyphCache {
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 @@ pub struct Batch {
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 @@ impl QuadRenderer {
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 @@ impl QuadRenderer {
});
}
- let mut renderer = QuadRenderer {
+ let mut renderer = Self {
program,
rect_program,
vao,
@@ -1028,7 +1019,7 @@ impl<'a, C> RenderApi<'a, C> {
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 @@ impl TextShaderProgram {
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 @@ impl RectShaderProgram {
// 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 @@ pub enum ShaderCreationError {
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 @@ enum AtlasInsertError {
}
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 @@ impl Atlas {
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) {