Use string interpolation (#13482)

Hamir Mahal and Marshall Bowers created

Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>

Change summary

crates/zed/src/main.rs              | 10 +++++-----
crates/zed/src/reliability.rs       |  6 +++---
crates/zed/src/zed/open_listener.rs | 11 ++++-------
3 files changed, 12 insertions(+), 15 deletions(-)

Detailed changes

crates/zed/src/main.rs 🔗

@@ -56,11 +56,11 @@ use crate::zed::inline_completion_registry;
 static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
 
 fn fail_to_launch(e: anyhow::Error) {
-    eprintln!("Zed failed to launch: {:?}", e);
+    eprintln!("Zed failed to launch: {e:?}");
     App::new().run(move |cx| {
         if let Ok(window) = cx.open_window(gpui::WindowOptions::default(), |cx| cx.new_view(|_| gpui::Empty)) {
             window.update(cx, |_, cx| {
-                let response = cx.prompt(gpui::PromptLevel::Critical, "Zed failed to launch", Some(&format!("{}\n\nFor help resolving this, please open an issue on https://github.com/zed-industries/zed", e)), &["Exit"]);
+                let response = cx.prompt(gpui::PromptLevel::Critical, "Zed failed to launch", Some(&format!("{e}\n\nFor help resolving this, please open an issue on https://github.com/zed-industries/zed")), &["Exit"]);
 
                 cx.spawn(|_, mut cx| async move {
                     response.await?;
@@ -80,7 +80,7 @@ fn fail_to_open_window_async(e: anyhow::Error, cx: &mut AsyncAppContext) {
 }
 
 fn fail_to_open_window(e: anyhow::Error, _cx: &mut AppContext) {
-    eprintln!("Zed failed to open a window: {:?}", e);
+    eprintln!("Zed failed to open a window: {e:?}");
     #[cfg(not(target_os = "linux"))]
     {
         process::exit(1);
@@ -99,7 +99,7 @@ fn fail_to_open_window(e: anyhow::Error, _cx: &mut AppContext) {
                 .add_notification(
                     notification_id,
                     Notification::new("Zed failed to launch")
-                        .body(Some(format!("{:?}", e).as_str()))
+                        .body(Some(format!("{e:?}").as_str()))
                         .priority(Priority::High)
                         .icon(ashpd::desktop::Icon::with_names(&[
                             "dialog-question-symbolic",
@@ -751,7 +751,7 @@ fn init_stdout_logger() {
             )?;
             write!(buf, "{:<5}", buf.default_styled_level(record.level()))?;
             if let Some(path) = record.module_path() {
-                write!(buf, " {}", path)?;
+                write!(buf, " {path}")?;
             }
             write!(buf, "{}", subtle.value("]"))?;
             writeln!(buf, " {}", record.args())

crates/zed/src/reliability.rs 🔗

@@ -113,14 +113,14 @@ pub fn init_panic_hook(
         if !is_pty {
             if let Some(panic_data_json) = serde_json::to_string(&panic_data).log_err() {
                 let timestamp = chrono::Utc::now().format("%Y_%m_%d %H_%M_%S").to_string();
-                let panic_file_path = paths::logs_dir().join(format!("zed-{}.panic", timestamp));
+                let panic_file_path = paths::logs_dir().join(format!("zed-{timestamp}.panic"));
                 let panic_file = std::fs::OpenOptions::new()
                     .append(true)
                     .create(true)
                     .open(&panic_file_path)
                     .log_err();
                 if let Some(mut panic_file) = panic_file {
-                    writeln!(&mut panic_file, "{}", panic_data_json).log_err();
+                    writeln!(&mut panic_file, "{panic_data_json}").log_err();
                     panic_file.flush().log_err();
                 }
             }
@@ -494,7 +494,7 @@ async fn upload_previous_crashes(
 
             if let Some((panicked_on, payload)) = most_recent_panic.as_ref() {
                 request = request
-                    .header("x-zed-panicked-on", format!("{}", panicked_on))
+                    .header("x-zed-panicked-on", format!("{panicked_on}"))
                     .header("x-zed-panic", payload)
             }
             if let Some(installation_id) = installation_id.as_ref() {

crates/zed/src/zed/open_listener.rs 🔗

@@ -247,7 +247,7 @@ pub async fn handle_cli_connection(
                         Err(error) => {
                             responses
                                 .send(CliResponse::Stderr {
-                                    message: format!("{}", error),
+                                    message: format!("{error}"),
                                 })
                                 .log_err();
                             responses.send(CliResponse::Exit { status: 1 }).log_err();
@@ -263,7 +263,7 @@ pub async fn handle_cli_connection(
                 {
                     responses
                         .send(CliResponse::Stderr {
-                            message: format!("{}", e),
+                            message: format!("{e}"),
                         })
                         .log_err();
                     responses.send(CliResponse::Exit { status: 1 }).log_err();
@@ -342,10 +342,7 @@ pub async fn handle_cli_connection(
                                     Some(Err(err)) => {
                                         responses
                                             .send(CliResponse::Stderr {
-                                                message: format!(
-                                                    "error opening {:?}: {}",
-                                                    path, err
-                                                ),
+                                                message: format!("error opening {path:?}: {err}"),
                                             })
                                             .log_err();
                                         errored = true;
@@ -392,7 +389,7 @@ pub async fn handle_cli_connection(
                             errored = true;
                             responses
                                 .send(CliResponse::Stderr {
-                                    message: format!("error opening {:?}: {}", paths, error),
+                                    message: format!("error opening {paths:?}: {error}"),
                                 })
                                 .log_err();
                         }