summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHamir Mahal <hamirmahal@gmail.com>2024-07-23 18:37:35 -0700
committerGitHub <noreply@github.com>2024-07-24 01:37:35 +0000
commitd021a7b6f871f4078073848cf8744881561eb254 (patch)
tree5ba0877c432f38d887d88c5fe7aba9f7163f6918
parent6bd1674bd80e73df0d41e4342ad4e34bb7d04f84 (diff)
Unify string formatting
-rw-r--r--alacritty/src/cli.rs2
-rw-r--r--alacritty/src/config/bindings.rs11
-rw-r--r--alacritty/src/config/mod.rs10
-rw-r--r--alacritty/src/daemon.rs2
-rw-r--r--alacritty/src/display/mod.rs2
-rw-r--r--alacritty/src/display/window.rs2
-rw-r--r--alacritty/src/input/keyboard.rs2
-rw-r--r--alacritty/src/input/mod.rs2
-rw-r--r--alacritty/src/ipc.rs2
-rw-r--r--alacritty/src/logging.rs4
-rw-r--r--alacritty/src/renderer/mod.rs8
-rw-r--r--alacritty/src/renderer/shader.rs6
-rw-r--r--alacritty_config_derive/src/serde_replace.rs4
13 files changed, 27 insertions, 30 deletions
diff --git a/alacritty/src/cli.rs b/alacritty/src/cli.rs
index 803c1f8c..f0c9be7e 100644
--- a/alacritty/src/cli.rs
+++ b/alacritty/src/cli.rs
@@ -524,7 +524,7 @@ mod tests {
let generated = String::from_utf8_lossy(&generated);
let mut completion = String::new();
- let mut file = File::open(format!("../extra/completions/{}", file)).unwrap();
+ let mut file = File::open(format!("../extra/completions/{file}")).unwrap();
file.read_to_string(&mut completion).unwrap();
assert_eq!(generated, completion);
diff --git a/alacritty/src/config/bindings.rs b/alacritty/src/config/bindings.rs
index 62ca03a0..dfe31853 100644
--- a/alacritty/src/config/bindings.rs
+++ b/alacritty/src/config/bindings.rs
@@ -287,7 +287,7 @@ impl Display for Action {
Action::ViMotion(motion) => motion.fmt(f),
Action::Vi(action) => action.fmt(f),
Action::Mouse(action) => action.fmt(f),
- _ => write!(f, "{:?}", self),
+ _ => write!(f, "{self:?}"),
}
}
}
@@ -1024,8 +1024,7 @@ impl<'a> Deserialize<'a> for RawBinding {
},
Err(_) => {
return Err(<V::Error as Error>::custom(format!(
- "Invalid key binding, scancode is too big: {}",
- scancode
+ "Invalid key binding, scancode is too big: {scancode}"
)));
},
},
@@ -1080,8 +1079,7 @@ impl<'a> Deserialize<'a> for RawBinding {
_ => return Err(err),
};
return Err(V::Error::custom(format!(
- "unknown keyboard action `{}`",
- value
+ "unknown keyboard action `{value}`"
)));
},
}
@@ -1122,8 +1120,7 @@ impl<'a> Deserialize<'a> for RawBinding {
(Some(action @ Action::Mouse(_)), None, None) => {
if mouse.is_none() {
return Err(V::Error::custom(format!(
- "action `{}` is only available for mouse bindings",
- action,
+ "action `{action}` is only available for mouse bindings",
)));
}
action
diff --git a/alacritty/src/config/mod.rs b/alacritty/src/config/mod.rs
index 488ef537..f8fccb13 100644
--- a/alacritty/src/config/mod.rs
+++ b/alacritty/src/config/mod.rs
@@ -76,12 +76,12 @@ impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Error::ReadingEnvHome(err) => {
- write!(f, "Unable to read $HOME environment variable: {}", err)
+ write!(f, "Unable to read $HOME environment variable: {err}")
},
- Error::Io(err) => write!(f, "Error reading config file: {}", err),
- Error::Toml(err) => write!(f, "Config error: {}", err),
- Error::TomlSe(err) => write!(f, "Yaml conversion error: {}", err),
- Error::Yaml(err) => write!(f, "Config error: {}", err),
+ Error::Io(err) => write!(f, "Error reading config file: {err}"),
+ Error::Toml(err) => write!(f, "Config error: {err}"),
+ Error::TomlSe(err) => write!(f, "Yaml conversion error: {err}"),
+ Error::Yaml(err) => write!(f, "Config error: {err}"),
}
}
}
diff --git a/alacritty/src/daemon.rs b/alacritty/src/daemon.rs
index df66646a..c8fb88d1 100644
--- a/alacritty/src/daemon.rs
+++ b/alacritty/src/daemon.rs
@@ -94,7 +94,7 @@ pub fn foreground_process_path(
}
#[cfg(not(any(target_os = "macos", target_os = "freebsd")))]
- let link_path = format!("/proc/{}/cwd", pid);
+ let link_path = format!("/proc/{pid}/cwd");
#[cfg(target_os = "freebsd")]
let link_path = format!("/compat/linux/proc/{}/cwd", pid);
diff --git a/alacritty/src/display/mod.rs b/alacritty/src/display/mod.rs
index 1841b167..7809c824 100644
--- a/alacritty/src/display/mod.rs
+++ b/alacritty/src/display/mod.rs
@@ -1241,7 +1241,7 @@ impl Display {
fn draw_search(&mut self, config: &UiConfig, text: &str) {
// Assure text length is at least num_cols.
let num_cols = self.size_info.columns();
- let text = format!("{:<1$}", text, num_cols);
+ let text = format!("{text:<num_cols$}");
let point = Point::new(self.size_info.screen_lines(), Column(0));
diff --git a/alacritty/src/display/window.rs b/alacritty/src/display/window.rs
index da5d85bc..2bb59b2c 100644
--- a/alacritty/src/display/window.rs
+++ b/alacritty/src/display/window.rs
@@ -76,7 +76,7 @@ impl std::error::Error for Error {
impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
- Error::WindowCreation(err) => write!(f, "Error creating GL context; {}", err),
+ Error::WindowCreation(err) => write!(f, "Error creating GL context; {err}"),
Error::Font(err) => err.fmt(f),
}
}
diff --git a/alacritty/src/input/keyboard.rs b/alacritty/src/input/keyboard.rs
index d63da9f2..4bc3ffee 100644
--- a/alacritty/src/input/keyboard.rs
+++ b/alacritty/src/input/keyboard.rs
@@ -294,7 +294,7 @@ fn build_sequence(key: KeyEvent, mods: ModifiersState, mode: TermMode) -> Vec<u8
_ => return Vec::new(),
};
- let mut payload = format!("\x1b[{}", payload);
+ let mut payload = format!("\x1b[{payload}");
// Add modifiers information.
if kitty_event_type || !modifiers.is_empty() || associated_text.is_some() {
diff --git a/alacritty/src/input/mod.rs b/alacritty/src/input/mod.rs
index 9f7074f4..c10777f2 100644
--- a/alacritty/src/input/mod.rs
+++ b/alacritty/src/input/mod.rs
@@ -809,7 +809,7 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> {
if self.ctx.terminal().mode().contains(TermMode::FOCUS_IN_OUT) {
let chr = if is_focused { "I" } else { "O" };
- let msg = format!("\x1b[{}", chr);
+ let msg = format!("\x1b[{chr}");
self.ctx.write_to_pty(msg.into_bytes());
}
}
diff --git a/alacritty/src/ipc.rs b/alacritty/src/ipc.rs
index 1cb7a1c8..d06d395e 100644
--- a/alacritty/src/ipc.rs
+++ b/alacritty/src/ipc.rs
@@ -111,7 +111,7 @@ fn find_socket(socket_path: Option<PathBuf>) -> IoResult<UnixStream> {
if let Some(socket_path) = socket_path {
// Ensure we inform the user about an invalid path.
return UnixStream::connect(&socket_path).map_err(|err| {
- let message = format!("invalid socket path {:?}", socket_path);
+ let message = format!("invalid socket path {socket_path:?}");
IoError::new(err.kind(), message)
});
}
diff --git a/alacritty/src/logging.rs b/alacritty/src/logging.rs
index 59303649..08e79469 100644
--- a/alacritty/src/logging.rs
+++ b/alacritty/src/logging.rs
@@ -108,7 +108,7 @@ impl Logger {
};
#[cfg(not(windows))]
- let env_var = format!("${}", ALACRITTY_LOG_ENV);
+ let env_var = format!("${ALACRITTY_LOG_ENV}");
#[cfg(windows)]
let env_var = format!("%{}%", ALACRITTY_LOG_ENV);
@@ -227,7 +227,7 @@ impl OnDemandLogFile {
writeln!(io::stdout(), "Created log file at \"{}\"", self.path.display());
},
Err(e) => {
- let _ = writeln!(io::stdout(), "Unable to create log file: {}", e);
+ let _ = writeln!(io::stdout(), "Unable to create log file: {e}");
return Err(e);
},
}
diff --git a/alacritty/src/renderer/mod.rs b/alacritty/src/renderer/mod.rs
index f4f1397f..16885b31 100644
--- a/alacritty/src/renderer/mod.rs
+++ b/alacritty/src/renderer/mod.rs
@@ -66,10 +66,10 @@ impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Shader(err) => {
- write!(f, "There was an error initializing the shaders: {}", err)
+ write!(f, "There was an error initializing the shaders: {err}")
},
Error::Other(err) => {
- write!(f, "{}", err)
+ write!(f, "{err}")
},
}
}
@@ -111,9 +111,9 @@ fn gl_get_string(
Ok(CStr::from_ptr(string_ptr as *const _).to_string_lossy())
},
gl::INVALID_ENUM => {
- Err(format!("OpenGL error requesting {}: invalid enum", description).into())
+ Err(format!("OpenGL error requesting {description}: invalid enum").into())
},
- error_id => Err(format!("OpenGL error {} requesting {}", error_id, description).into()),
+ error_id => Err(format!("OpenGL error {error_id} requesting {description}").into()),
}
}
}
diff --git a/alacritty/src/renderer/shader.rs b/alacritty/src/renderer/shader.rs
index e3baab9e..86938e45 100644
--- a/alacritty/src/renderer/shader.rs
+++ b/alacritty/src/renderer/shader.rs
@@ -196,9 +196,9 @@ impl std::error::Error for ShaderError {}
impl fmt::Display for ShaderError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
- Self::Compile(reason) => write!(f, "Failed compiling shader: {}", reason),
- Self::Link(reason) => write!(f, "Failed linking shader: {}", reason),
- Self::Uniform(name) => write!(f, "Failed to get uniform location of {:?}", name),
+ Self::Compile(reason) => write!(f, "Failed compiling shader: {reason}"),
+ Self::Link(reason) => write!(f, "Failed linking shader: {reason}"),
+ Self::Uniform(name) => write!(f, "Failed to get uniform location of {name:?}"),
}
}
}
diff --git a/alacritty_config_derive/src/serde_replace.rs b/alacritty_config_derive/src/serde_replace.rs
index ddd0cf75..cd56b3bc 100644
--- a/alacritty_config_derive/src/serde_replace.rs
+++ b/alacritty_config_derive/src/serde_replace.rs
@@ -112,11 +112,11 @@ fn match_arms<T>(fields: &Punctuated<Field, T>) -> Result<TokenStream2, syn::Err
.map(|parsed| {
let value = parsed
.param
- .ok_or_else(|| format!("Field \"{}\" has no alias value", ident))?
+ .ok_or_else(|| format!("Field \"{ident}\" has no alias value"))?
.value();
if value.trim().is_empty() {
- return Err(format!("Field \"{}\" has an empty alias value", ident));
+ return Err(format!("Field \"{ident}\" has an empty alias value"));
}
Ok(value)