aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2025-07-01 23:52:08 +0900
committerGitHub <noreply@github.com>2025-07-01 23:52:08 +0900
commit2d79edab16fecfa1ce352c86c9698d078dbbb7d4 (patch)
tree6bf1542e3bb003cbcf1d995e1e424c3e60e0011d /alacritty/src
parent3ea13aeadcfab1515367fb5e5ed5e2494b25b9a2 (diff)
downloadr-alacritty-2d79edab16fecfa1ce352c86c9698d078dbbb7d4.tar.gz
r-alacritty-2d79edab16fecfa1ce352c86c9698d078dbbb7d4.tar.bz2
r-alacritty-2d79edab16fecfa1ce352c86c9698d078dbbb7d4.zip
Remove cstr! macro in favor of literal notation
Also apply clippy changes while at it. Closes #8002.
Diffstat (limited to 'alacritty/src')
-rw-r--r--alacritty/src/cli.rs4
-rw-r--r--alacritty/src/clipboard.rs4
-rw-r--r--alacritty/src/config/mod.rs8
-rw-r--r--alacritty/src/config/monitor.rs8
-rw-r--r--alacritty/src/config/ui_config.rs6
-rw-r--r--alacritty/src/config/window.rs9
-rw-r--r--alacritty/src/display/mod.rs8
-rw-r--r--alacritty/src/display/window.rs2
-rw-r--r--alacritty/src/event.rs6
-rw-r--r--alacritty/src/ipc.rs2
-rw-r--r--alacritty/src/main.rs2
-rw-r--r--alacritty/src/renderer/mod.rs12
-rw-r--r--alacritty/src/renderer/rects.rs17
-rw-r--r--alacritty/src/renderer/text/builtin_font.rs2
-rw-r--r--alacritty/src/renderer/text/gles2.rs6
-rw-r--r--alacritty/src/renderer/text/glsl3.rs8
-rw-r--r--alacritty/src/renderer/text/glyph_cache.rs2
17 files changed, 47 insertions, 59 deletions
diff --git a/alacritty/src/cli.rs b/alacritty/src/cli.rs
index 19faead1..3f3b6cc2 100644
--- a/alacritty/src/cli.rs
+++ b/alacritty/src/cli.rs
@@ -181,7 +181,7 @@ impl TerminalOptions {
if working_directory.is_dir() {
pty_config.working_directory = Some(working_directory.to_owned());
} else {
- error!("Invalid working directory: {:?}", working_directory);
+ error!("Invalid working directory: {working_directory:?}");
}
}
@@ -384,7 +384,7 @@ impl ParsedOptions {
Err(err) => {
error!(
target: LOG_TARGET_IPC_CONFIG,
- "Unable to override option '{}': {}", option, err
+ "Unable to override option '{option}': {err}"
);
self.config_options.swap_remove(i);
},
diff --git a/alacritty/src/clipboard.rs b/alacritty/src/clipboard.rs
index 7853de47..6751bf27 100644
--- a/alacritty/src/clipboard.rs
+++ b/alacritty/src/clipboard.rs
@@ -62,7 +62,7 @@ impl Clipboard {
};
clipboard.set_contents(text.into()).unwrap_or_else(|err| {
- warn!("Unable to store text in clipboard: {}", err);
+ warn!("Unable to store text in clipboard: {err}");
});
}
@@ -74,7 +74,7 @@ impl Clipboard {
match clipboard.get_contents() {
Err(err) => {
- debug!("Unable to load text from clipboard: {}", err);
+ debug!("Unable to load text from clipboard: {err}");
String::new()
},
Ok(text) => text,
diff --git a/alacritty/src/config/mod.rs b/alacritty/src/config/mod.rs
index 77baf533..db57c102 100644
--- a/alacritty/src/config/mod.rs
+++ b/alacritty/src/config/mod.rs
@@ -148,7 +148,7 @@ pub fn load(options: &mut Options) -> UiConfig {
/// Attempt to reload the configuration file.
pub fn reload(config_path: &Path, options: &mut Options) -> Result<UiConfig> {
- debug!("Reloading configuration file: {:?}", config_path);
+ debug!("Reloading configuration file: {config_path:?}");
// Load config, propagating errors.
let mut config = load_from(config_path)?;
@@ -169,11 +169,11 @@ fn load_from(path: &Path) -> Result<UiConfig> {
match read_config(path) {
Ok(config) => Ok(config),
Err(Error::Io(io)) if io.kind() == io::ErrorKind::NotFound => {
- error!(target: LOG_TARGET_CONFIG, "Unable to load config {:?}: File not found", path);
+ error!(target: LOG_TARGET_CONFIG, "Unable to load config {path:?}: File not found");
Err(Error::Io(io))
},
Err(err) => {
- error!(target: LOG_TARGET_CONFIG, "Unable to load config {:?}: {}", path, err);
+ error!(target: LOG_TARGET_CONFIG, "Unable to load config {path:?}: {err}");
Err(err)
},
}
@@ -268,7 +268,7 @@ fn load_imports(
continue;
},
Err(err) => {
- error!(target: LOG_TARGET_CONFIG, "Unable to import config {:?}: {}", path, err)
+ error!(target: LOG_TARGET_CONFIG, "Unable to import config {path:?}: {err}")
},
}
}
diff --git a/alacritty/src/config/monitor.rs b/alacritty/src/config/monitor.rs
index 48271baf..b4ea361f 100644
--- a/alacritty/src/config/monitor.rs
+++ b/alacritty/src/config/monitor.rs
@@ -63,7 +63,7 @@ impl ConfigMonitor {
) {
Ok(watcher) => watcher,
Err(err) => {
- error!("Unable to watch config file: {}", err);
+ error!("Unable to watch config file: {err}");
return None;
},
};
@@ -84,7 +84,7 @@ impl ConfigMonitor {
// Watch all configuration file directories.
for parent in &parents {
if let Err(err) = watcher.watch(parent, RecursiveMode::NonRecursive) {
- debug!("Unable to watch config directory {:?}: {}", parent, err);
+ debug!("Unable to watch config directory {parent:?}: {err}");
}
}
@@ -135,10 +135,10 @@ impl ConfigMonitor {
}
},
Ok(Err(err)) => {
- debug!("Config watcher errors: {:?}", err);
+ debug!("Config watcher errors: {err:?}");
},
Err(err) => {
- debug!("Config watcher channel dropped unexpectedly: {}", err);
+ debug!("Config watcher channel dropped unexpectedly: {err}");
break;
},
};
diff --git a/alacritty/src/config/ui_config.rs b/alacritty/src/config/ui_config.rs
index 0e240622..a10fe1cf 100644
--- a/alacritty/src/config/ui_config.rs
+++ b/alacritty/src/config/ui_config.rs
@@ -205,7 +205,7 @@ where
match Binding::<T>::deserialize(value) {
Ok(binding) => bindings.push(binding),
Err(err) => {
- error!(target: LOG_TARGET_CONFIG, "Config error: {}; ignoring binding", err);
+ error!(target: LOG_TARGET_CONFIG, "Config error: {err}; ignoring binding");
},
}
}
@@ -410,7 +410,7 @@ impl<'de> Deserialize<'de> for HintContent {
Err(err) => {
error!(
target: LOG_TARGET_CONFIG,
- "Config error: hint's regex: {}", err
+ "Config error: hint's regex: {err}"
);
},
},
@@ -419,7 +419,7 @@ impl<'de> Deserialize<'de> for HintContent {
Err(err) => {
error!(
target: LOG_TARGET_CONFIG,
- "Config error: hint's hyperlinks: {}", err
+ "Config error: hint's hyperlinks: {err}"
);
},
},
diff --git a/alacritty/src/config/window.rs b/alacritty/src/config/window.rs
index e6a2ad22..a116bec6 100644
--- a/alacritty/src/config/window.rs
+++ b/alacritty/src/config/window.rs
@@ -110,10 +110,7 @@ impl WindowConfig {
warn!(
target: LOG_TARGET_CONFIG,
"Both `lines` and `columns` must be non-zero for `window.dimensions` to take \
- effect. Configured value of `{}` is 0 while that of `{}` is {}",
- zero_key,
- non_zero_key,
- non_zero_value,
+ effect. Configured value of `{zero_key}` is 0 while that of `{non_zero_key}` is {non_zero_value}",
);
None
@@ -255,7 +252,7 @@ impl<'de> Deserialize<'de> for Class {
Err(err) => {
error!(
target: LOG_TARGET_CONFIG,
- "Config error: class.instance: {}", err
+ "Config error: class.instance: {err}"
);
},
},
@@ -264,7 +261,7 @@ impl<'de> Deserialize<'de> for Class {
Err(err) => {
error!(
target: LOG_TARGET_CONFIG,
- "Config error: class.instance: {}", err
+ "Config error: class.instance: {err}"
);
},
},
diff --git a/alacritty/src/display/mod.rs b/alacritty/src/display/mod.rs
index 8f875df2..56280f55 100644
--- a/alacritty/src/display/mod.rs
+++ b/alacritty/src/display/mod.rs
@@ -458,7 +458,7 @@ impl Display {
config.window.dynamic_padding && config.window.dimensions().is_none(),
);
- info!("Cell size: {} x {}", cell_width, cell_height);
+ info!("Cell size: {cell_width} x {cell_height}");
info!("Padding: {} x {}", size_info.padding_x(), size_info.padding_y());
info!("Width: {}, Height: {}", size_info.width(), size_info.height());
@@ -511,7 +511,7 @@ impl Display {
// Disable vsync.
if let Err(err) = surface.set_swap_interval(&context, SwapInterval::DontWait) {
- info!("Failed to disable vsync: {}", err);
+ info!("Failed to disable vsync: {err}");
}
Ok(Self {
@@ -618,7 +618,7 @@ impl Display {
(surface, context) => surface.swap_buffers(context),
};
if let Err(err) = res {
- debug!("error calling swap_buffers: {}", err);
+ debug!("error calling swap_buffers: {err}");
}
}
@@ -674,7 +674,7 @@ impl Display {
cell_width = cell_dimensions.0;
cell_height = cell_dimensions.1;
- info!("Cell size: {} x {}", cell_width, cell_height);
+ info!("Cell size: {cell_width} x {cell_height}");
// Mark entire terminal as damaged since glyph size could change without cell size
// changes.
diff --git a/alacritty/src/display/window.rs b/alacritty/src/display/window.rs
index 28056e3f..3f9848f9 100644
--- a/alacritty/src/display/window.rs
+++ b/alacritty/src/display/window.rs
@@ -198,7 +198,7 @@ impl Window {
use_srgb_color_space(&window);
let scale_factor = window.scale_factor();
- log::info!("Window scale factor: {}", scale_factor);
+ log::info!("Window scale factor: {scale_factor}");
let is_x11 = matches!(window.window_handle().unwrap().as_raw(), RawWindowHandle::Xlib(_));
Ok(Self {
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs
index a0d05aa0..5ef29430 100644
--- a/alacritty/src/event.rs
+++ b/alacritty/src/event.rs
@@ -384,7 +384,7 @@ impl ApplicationHandler<Event> for Processor {
event_loop.exit();
}
} else if let Err(err) = self.create_window(event_loop, options) {
- error!("Could not open window: {:?}", err);
+ error!("Could not open window: {err:?}");
}
},
// Process events affecting all windows.
@@ -507,7 +507,7 @@ impl ApplicationHandler<Event> for Processor {
// SAFETY: The clipboard must be dropped before the event loop, so use the nop clipboard
// as a safe placeholder.
- mem::swap(&mut self.clipboard, &mut Clipboard::new_nop());
+ self.clipboard = Clipboard::new_nop();
}
}
@@ -905,7 +905,7 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon
let result = spawn_daemon(program, args);
match result {
- Ok(_) => debug!("Launched {} with args {:?}", program, args),
+ Ok(_) => debug!("Launched {program} with args {args:?}"),
Err(err) => warn!("Unable to launch {program} with args {args:?}: {err}"),
}
}
diff --git a/alacritty/src/ipc.rs b/alacritty/src/ipc.rs
index 73af6d8a..86f37c09 100644
--- a/alacritty/src/ipc.rs
+++ b/alacritty/src/ipc.rs
@@ -58,7 +58,7 @@ pub fn spawn_ipc_socket(
let message: SocketMessage = match serde_json::from_str(&data) {
Ok(message) => message,
Err(err) => {
- warn!("Failed to convert data from socket: {}", err);
+ warn!("Failed to convert data from socket: {err}");
continue;
},
};
diff --git a/alacritty/src/main.rs b/alacritty/src/main.rs
index 9260bfa4..7a4109a6 100644
--- a/alacritty/src/main.rs
+++ b/alacritty/src/main.rs
@@ -187,7 +187,7 @@ fn alacritty(mut options: Options) -> Result<(), Box<dyn Error>> {
Ok(path) => Some(path),
Err(err) if options.daemon => return Err(err.into()),
Err(err) => {
- log::warn!("Unable to create socket: {:?}", err);
+ log::warn!("Unable to create socket: {err:?}");
None
},
}
diff --git a/alacritty/src/renderer/mod.rs b/alacritty/src/renderer/mod.rs
index 92998e58..a89ba7c4 100644
--- a/alacritty/src/renderer/mod.rs
+++ b/alacritty/src/renderer/mod.rs
@@ -33,14 +33,6 @@ pub use text::{GlyphCache, LoaderApi};
use shader::ShaderVersion;
use text::{Gles2Renderer, Glsl3Renderer, TextRenderer};
-macro_rules! cstr {
- ($s:literal) => {
- // This can be optimized into an no-op with pre-allocated NUL-terminated bytes.
- unsafe { std::ffi::CStr::from_ptr(concat!($s, "\0").as_ptr().cast()) }
- };
-}
-pub(crate) use cstr;
-
/// Whether the OpenGL functions have been loaded.
pub static GL_FUNS_LOADED: AtomicBool = AtomicBool::new(false);
@@ -303,7 +295,7 @@ impl Renderer {
_ => "invalid",
};
- info!("GPU reset ({})", reason);
+ info!("GPU reset ({reason})");
true
}
@@ -404,5 +396,5 @@ extern "system" fn gl_debug_log(
_: *mut std::os::raw::c_void,
) {
let msg = unsafe { CStr::from_ptr(msg).to_string_lossy() };
- debug!("[gl_render] {}", msg);
+ debug!("[gl_render] {msg}");
}
diff --git a/alacritty/src/renderer/rects.rs b/alacritty/src/renderer/rects.rs
index 5ec2f1ef..52fbca79 100644
--- a/alacritty/src/renderer/rects.rs
+++ b/alacritty/src/renderer/rects.rs
@@ -12,10 +12,9 @@ use alacritty_terminal::term::cell::Flags;
use crate::display::color::Rgb;
use crate::display::content::RenderableCell;
use crate::display::SizeInfo;
-use crate::gl;
use crate::gl::types::*;
use crate::renderer::shader::{ShaderError, ShaderProgram, ShaderVersion};
-use crate::renderer::{self, cstr};
+use crate::{gl, renderer};
#[derive(Debug, Copy, Clone)]
pub struct RenderRect {
@@ -447,13 +446,13 @@ impl RectShaderProgram {
let program = ShaderProgram::new(shader_version, header, RECT_SHADER_V, RECT_SHADER_F)?;
Ok(Self {
- u_cell_width: program.get_uniform_location(cstr!("cellWidth")).ok(),
- u_cell_height: program.get_uniform_location(cstr!("cellHeight")).ok(),
- u_padding_x: program.get_uniform_location(cstr!("paddingX")).ok(),
- u_padding_y: program.get_uniform_location(cstr!("paddingY")).ok(),
- u_underline_position: program.get_uniform_location(cstr!("underlinePosition")).ok(),
- u_underline_thickness: program.get_uniform_location(cstr!("underlineThickness")).ok(),
- u_undercurl_position: program.get_uniform_location(cstr!("undercurlPosition")).ok(),
+ u_cell_width: program.get_uniform_location(c"cellWidth").ok(),
+ u_cell_height: program.get_uniform_location(c"cellHeight").ok(),
+ u_padding_x: program.get_uniform_location(c"paddingX").ok(),
+ u_padding_y: program.get_uniform_location(c"paddingY").ok(),
+ u_underline_position: program.get_uniform_location(c"underlinePosition").ok(),
+ u_underline_thickness: program.get_uniform_location(c"underlineThickness").ok(),
+ u_undercurl_position: program.get_uniform_location(c"undercurlPosition").ok(),
program,
})
}
diff --git a/alacritty/src/renderer/text/builtin_font.rs b/alacritty/src/renderer/text/builtin_font.rs
index 3d25ec94..1d7664f9 100644
--- a/alacritty/src/renderer/text/builtin_font.rs
+++ b/alacritty/src/renderer/text/builtin_font.rs
@@ -73,7 +73,7 @@ fn box_drawing(character: char, metrics: &Metrics, offset: &Delta<i8>) -> Raster
y_end += y_offset;
let k = y_end / x_end;
- let f_x = |x: f32, h: f32| -> f32 { -1. * k * x + h + y_offset };
+ let f_x = |x: f32, h: f32| -> f32 { -k * x + h + y_offset };
let g_x = |x: f32, h: f32| -> f32 { k * x + h + y_offset };
let from_x = 0.;
diff --git a/alacritty/src/renderer/text/gles2.rs b/alacritty/src/renderer/text/gles2.rs
index f14fa7ba..f319ff01 100644
--- a/alacritty/src/renderer/text/gles2.rs
+++ b/alacritty/src/renderer/text/gles2.rs
@@ -11,7 +11,7 @@ use crate::display::SizeInfo;
use crate::gl;
use crate::gl::types::*;
use crate::renderer::shader::{ShaderProgram, ShaderVersion};
-use crate::renderer::{cstr, Error, GlExtensions};
+use crate::renderer::{Error, GlExtensions};
use super::atlas::{Atlas, ATLAS_SIZE};
use super::{
@@ -482,8 +482,8 @@ impl TextShaderProgram {
let program = ShaderProgram::new(shader_version, None, TEXT_SHADER_V, fragment_shader)?;
Ok(Self {
- u_projection: program.get_uniform_location(cstr!("projection"))?,
- u_rendering_pass: program.get_uniform_location(cstr!("renderingPass"))?,
+ u_projection: program.get_uniform_location(c"projection")?,
+ u_rendering_pass: program.get_uniform_location(c"renderingPass")?,
program,
})
}
diff --git a/alacritty/src/renderer/text/glsl3.rs b/alacritty/src/renderer/text/glsl3.rs
index 8cf06784..832b4fd2 100644
--- a/alacritty/src/renderer/text/glsl3.rs
+++ b/alacritty/src/renderer/text/glsl3.rs
@@ -11,7 +11,7 @@ use crate::display::SizeInfo;
use crate::gl;
use crate::gl::types::*;
use crate::renderer::shader::{ShaderProgram, ShaderVersion};
-use crate::renderer::{cstr, Error};
+use crate::renderer::Error;
use super::atlas::{Atlas, ATLAS_SIZE};
use super::{
@@ -426,9 +426,9 @@ impl TextShaderProgram {
pub fn new(shader_version: ShaderVersion) -> Result<TextShaderProgram, Error> {
let program = ShaderProgram::new(shader_version, None, TEXT_SHADER_V, TEXT_SHADER_F)?;
Ok(Self {
- u_projection: program.get_uniform_location(cstr!("projection"))?,
- u_cell_dim: program.get_uniform_location(cstr!("cellDim"))?,
- u_rendering_pass: program.get_uniform_location(cstr!("renderingPass"))?,
+ u_projection: program.get_uniform_location(c"projection")?,
+ u_cell_dim: program.get_uniform_location(c"cellDim")?,
+ u_rendering_pass: program.get_uniform_location(c"renderingPass")?,
program,
})
}
diff --git a/alacritty/src/renderer/text/glyph_cache.rs b/alacritty/src/renderer/text/glyph_cache.rs
index 3ad3a36b..bba1c417 100644
--- a/alacritty/src/renderer/text/glyph_cache.rs
+++ b/alacritty/src/renderer/text/glyph_cache.rs
@@ -170,7 +170,7 @@ impl GlyphCache {
match rasterizer.load_font(description, size) {
Ok(font) => Ok(font),
Err(err) => {
- error!("{}", err);
+ error!("{err}");
let fallback_desc =
Self::make_desc(Font::default().normal(), Slant::Normal, Weight::Normal);