diff --git a/src/analyze/contexts.rs b/src/analyze/contexts.rs index e07f80b8a..eb5d34cb4 100644 --- a/src/analyze/contexts.rs +++ b/src/analyze/contexts.rs @@ -191,7 +191,7 @@ fn print_buffer(buffer: &Buffer, title: impl fmt::Display) { let width = out.lines().map(table::str_width).max().unwrap_or(80); table::print_title(title, width); - println!("{}", out); + println!("{out}"); println!(); } diff --git a/src/analyze/mod.rs b/src/analyze/mod.rs index a6b12f368..142c185f7 100644 --- a/src/analyze/mod.rs +++ b/src/analyze/mod.rs @@ -39,7 +39,7 @@ pub async fn interactive(prompt: &mut repl::State, query: &str) -> anyhow::Resul { Ok(input) => input, Err(e) => { - eprintln!("{:#}", e); + eprintln!("{e:#}"); prompt.last_error = Some(e); return Err(QueryError)?; } @@ -55,7 +55,7 @@ pub async fn interactive(prompt: &mut repl::State, query: &str) -> anyhow::Resul .unwrap_or(false) { let json: serde_json::Value = serde_json::from_str(&data).unwrap(); - println!("JSON: {}", json); + println!("JSON: {json}"); } let jd = &mut serde_json::Deserializer::from_str(&data); let output = serde_path_to_error::deserialize(jd).context("parsing explain output")?; diff --git a/src/analyze/model.rs b/src/analyze/model.rs index b0c95cf34..dfba37562 100644 --- a/src/analyze/model.rs +++ b/src/analyze/model.rs @@ -209,7 +209,7 @@ impl fmt::Display for PropValue { write!(f, "ms")?; } Expr(val) => { - write!(f, "{:?}", val)?; + write!(f, "{val:?}")?; } Index(val) => { val.fmt(f)?; diff --git a/src/analyze/table.rs b/src/analyze/table.rs index 81ce1e20e..8509d5b1f 100644 --- a/src/analyze/table.rs +++ b/src/analyze/table.rs @@ -187,7 +187,7 @@ pub fn render(title: Option, table: &[Vec { impl Contents for T { fn width_bounds(&self) -> (usize, usize) { let mut cnt = Counter::new(); - write!(&mut cnt, "{}", self).expect("can write into counter"); + write!(&mut cnt, "{self}").expect("can write into counter"); (cnt.width, cnt.width) } fn height(&self, _width: usize) -> usize { 1 } fn render(&self, _width: usize, _height: usize, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self) + write!(f, "{self}") } } @@ -311,7 +311,7 @@ pub fn str_width(s: &str) -> usize { pub fn display_width(v: impl fmt::Display) -> usize { let mut cnt = Counter::new(); - write!(&mut cnt, "{}", v).expect("can write into counter"); + write!(&mut cnt, "{v}").expect("can write into counter"); cnt.width } @@ -400,7 +400,7 @@ impl Printer for TextPrinter<'_, '_> { counter: Counter::new(), width: self.width, }; - write!(&mut wrapper, "{}", word)?; + write!(&mut wrapper, "{word}")?; if wrapper.counter.width > 0 { self.fmt.write_char('\n')?; } diff --git a/src/analyze/tree.rs b/src/analyze/tree.rs index 32fb8f780..1fdbce754 100644 --- a/src/analyze/tree.rs +++ b/src/analyze/tree.rs @@ -424,7 +424,7 @@ impl table::Contents for ShapeNode<'_> { self.marker.render_head(f)?; write!(f, "{}", self.context)?; if let Some(attr) = self.attribute { - write!(f, ".{}", attr)?; + write!(f, ".{attr}")?; } self.marker.render_tail(height, f)?; Ok(()) diff --git a/src/branch/context.rs b/src/branch/context.rs index 32d25170d..bdf83f67c 100644 --- a/src/branch/context.rs +++ b/src/branch/context.rs @@ -149,6 +149,6 @@ impl Context { let Some(path) = &project_dir else { return Ok(None); }; - Ok(Some(crate::portable::config::read(&path)?)) + Ok(Some(crate::portable::config::read(path)?)) } } diff --git a/src/branch/create.rs b/src/branch/create.rs index d6998288a..0a3018be0 100644 --- a/src/branch/create.rs +++ b/src/branch/create.rs @@ -41,7 +41,7 @@ pub async fn create_branch( eprintln!("WARNING: when --empty is used, --copy-data will be ignored"); } - format!("create empty branch {}", new_branch) + format!("create empty branch {new_branch}") } else { let kind = if copy_data { "data" } else { "schema" }; diff --git a/src/branch/current.rs b/src/branch/current.rs index 400c8b694..40d9e2e54 100644 --- a/src/branch/current.rs +++ b/src/branch/current.rs @@ -12,7 +12,7 @@ pub async fn main( let current_branch = context.get_current_branch(connection).await?; if options.plain { - println!("{}", current_branch); + println!("{current_branch}"); } else { eprintln!("The current branch is '{}'", current_branch.green()); } diff --git a/src/branch/list.rs b/src/branch/list.rs index f440f20d5..be77c1795 100644 --- a/src/branch/list.rs +++ b/src/branch/list.rs @@ -21,7 +21,7 @@ pub async fn main( if current_branch == branch { println!("{} - Current", branch.green()); } else { - println!("{}", branch); + println!("{branch}"); } } diff --git a/src/branch/rebase.rs b/src/branch/rebase.rs index 92ebc032a..03ab8dbcf 100644 --- a/src/branch/rebase.rs +++ b/src/branch/rebase.rs @@ -87,7 +87,7 @@ async fn rebase( } // drop source branch - eprintln!("\nReplacing '{}' with rebased version...", current_branch); + eprintln!("\nReplacing '{current_branch}' with rebased version..."); let (status, _warnings) = target_connection .execute( &format!( diff --git a/src/cli/install.rs b/src/cli/install.rs index 037a29526..1f40f31f5 100644 --- a/src/cli/install.rs +++ b/src/cli/install.rs @@ -204,7 +204,7 @@ fn ensure_line(path: &PathBuf, line: &str) -> anyhow::Result<()> { .append(true) .open(path) .context("cannot open file for appending (writing)")?; - file.write(format!("{}\n", line).as_bytes()) + file.write(format!("{line}\n").as_bytes()) .context("cannot append to file")?; Ok(()) } @@ -362,7 +362,7 @@ pub fn main(options: &CliInstall) -> anyhow::Result<()> { { // This is needed so user can read the message if console // was open just for this process - eprintln!("edgedb error: {:#}", e); + eprintln!("edgedb error: {e:#}"); eprintln!("Press the Enter key to continue"); read_choice()?; exit(1); @@ -516,12 +516,11 @@ fn _main(options: &CliInstall) -> anyhow::Result<()> { fs::create_dir_all(&settings.installation_path) .with_context(|| format!("failed to create {:?}", settings.installation_path))?; if exe_path.parent() == path.parent() { - fs::rename(&exe_path, &path).with_context(|| format!("failed to rename {:?}", exe_path))?; + fs::rename(&exe_path, &path).with_context(|| format!("failed to rename {exe_path:?}"))?; } else { fs::remove_file(&tmp_path).ok(); - fs::copy(&exe_path, &tmp_path) - .with_context(|| format!("failed to write {:?}", tmp_path))?; - fs::rename(&tmp_path, &path).with_context(|| format!("failed to rename {:?}", tmp_path))?; + fs::copy(&exe_path, &tmp_path).with_context(|| format!("failed to write {tmp_path:?}"))?; + fs::rename(&tmp_path, &path).with_context(|| format!("failed to rename {tmp_path:?}"))?; } write_completions_home()?; @@ -551,10 +550,10 @@ fn _main(options: &CliInstall) -> anyhow::Result<()> { ); for path in &settings.rc_files { ensure_line(path, &line) - .with_context(|| format!("failed to update profile file {:?}", path))?; + .with_context(|| format!("failed to update profile file {path:?}"))?; } if let Some(dir) = settings.env_file.parent() { - fs::create_dir_all(dir).with_context(|| format!("failed to create {:?}", dir))?; + fs::create_dir_all(dir).with_context(|| format!("failed to create {dir:?}"))?; } fs::write(&settings.env_file, line + "\n") .with_context(|| format!("failed to write env file {:?}", settings.env_file))?; diff --git a/src/cli/migrate.rs b/src/cli/migrate.rs index 1cabfe83e..d2eed3208 100644 --- a/src/cli/migrate.rs +++ b/src/cli/migrate.rs @@ -78,9 +78,8 @@ fn move_file(src: &Path, dest: &Path, dry_run: bool) -> anyhow::Result<()> { return Ok(()); } let mut q = question::Choice::new(format!( - "Attempting to move {:?} -> {:?}, but \ - destination file exists. Do you want to overwrite?", - src, dest + "Attempting to move {src:?} -> {dest:?}, but \ + destination file exists. Do you want to overwrite?" )); q.option(Yes, &["y"], "overwrite the destination file"); q.option(Skip, &["s"], "skip, keep destination file, remove source"); @@ -114,9 +113,8 @@ fn move_dir(src: &Path, dest: &Path, dry_run: bool) -> anyhow::Result<()> { return Ok(()); } let mut q = question::Choice::new(format!( - "Attempting to move {:?} -> {:?}, but \ - destination directory exists. Do you want to overwrite?", - src, dest + "Attempting to move {src:?} -> {dest:?}, but \ + destination directory exists. Do you want to overwrite?" )); q.option(Yes, &["y"], "overwrite the destination dir"); q.option(Skip, &["s"], "skip, keep destination dir, remove source"); @@ -244,9 +242,9 @@ fn update_path(base: &Path, new_bin_path: &Path) -> anyhow::Result<()> { let cfg_dir = config_dir()?; let env_file = cfg_dir.join("env"); - fs::create_dir_all(&cfg_dir).with_context(|| format!("failed to create {:?}", cfg_dir))?; + fs::create_dir_all(&cfg_dir).with_context(|| format!("failed to create {cfg_dir:?}"))?; fs::write(&env_file, new_line + "\n") - .with_context(|| format!("failed to write env file {:?}", env_file))?; + .with_context(|| format!("failed to write env file {env_file:?}"))?; if modified && no_dir_in_path(new_bin_dir) { print::success(concatcp!( @@ -351,16 +349,14 @@ pub fn migrate(base: &Path, dry_run: bool) -> anyhow::Result<()> { if !dry_run && dir_is_non_empty(base)? { eprintln!( "\ - Directory {:?} is no longer used by {BRANDING} tools and must be \ + Directory {base:?} is no longer used by {BRANDING} tools and must be \ removed to finish migration, but some files or directories \ remain after all known files have moved. \ The files may have been left by a third party tool. \ - ", - base + " ); let q = question::Confirm::new(format!( - "Do you want to remove all files and directories within {:?}?", - base, + "Do you want to remove all files and directories within {base:?}?", )); if !q.ask()? { print::error("Canceled by user."); diff --git a/src/cli/upgrade.rs b/src/cli/upgrade.rs index e278f6817..b28473d97 100644 --- a/src/cli/upgrade.rs +++ b/src/cli/upgrade.rs @@ -198,7 +198,7 @@ fn _main(options: &CliUpgrade, path: PathBuf) -> anyhow::Result<()> { let down_dir = path .parent() .context("download path missing directory component")?; - fs::create_dir_all(down_dir).with_context(|| format!("failed to create {:?}", down_dir))?; + fs::create_dir_all(down_dir).with_context(|| format!("failed to create {down_dir:?}"))?; let down_path = path.with_extension("download"); let tmp_path = tmp_file_path(&path); diff --git a/src/cloud/auth.rs b/src/cloud/auth.rs index e72c6da8a..ac57fe521 100644 --- a/src/cloud/auth.rs +++ b/src/cloud/auth.rs @@ -88,7 +88,7 @@ pub async fn _do_login(client: &mut CloudClient) -> anyhow::Result<()> { } let deadline = Instant::now() + AUTHENTICATION_WAIT_TIME; while Instant::now() < deadline { - match client.get(format!("auth/sessions/{}", id)).await { + match client.get(format!("auth/sessions/{id}")).await { Ok(UserSession { id: _, auth_url: _, @@ -126,7 +126,7 @@ pub async fn _do_login(client: &mut CloudClient) -> anyhow::Result<()> { )); return Ok(()); } - Err(e) => print::warn(format!("Request failed: {:?}\nRetrying...", e)), + Err(e) => print::warn(format!("Request failed: {e:?}\nRetrying...")), _ => {} } sleep(AUTHENTICATION_POLL_INTERVAL).await; @@ -213,8 +213,7 @@ pub fn logout(c: &options::Logout, options: &CloudOptions) -> anyhow::Result<()> removed = true; fs::remove_file(cloud_creds.join(item.file_name()))?; print::success(format!( - "You are now logged out from {BRANDING_CLOUD} profile {:?}.", - profile + "You are now logged out from {BRANDING_CLOUD} profile {profile:?}." )); } } else { diff --git a/src/cloud/backups.rs b/src/cloud/backups.rs index 9c503cdef..bbc55b164 100644 --- a/src/cloud/backups.rs +++ b/src/cloud/backups.rs @@ -79,7 +79,7 @@ pub async fn list_cloud_instance_backups( name: &str, json: bool, ) -> anyhow::Result<()> { - let url = format!("orgs/{}/instances/{}/backups", org_slug, name); + let url = format!("orgs/{org_slug}/instances/{name}/backups"); let backups: Vec = client.get(url).await?; if json { diff --git a/src/cloud/client.rs b/src/cloud/client.rs index 08814adf0..db379494d 100644 --- a/src/cloud/client.rs +++ b/src/cloud/client.rs @@ -121,7 +121,7 @@ impl CloudClient { .context("malformed secret key: missing `iss` claim")?; let mut headers = header::HeaderMap::new(); - let auth_str = format!("Bearer {}", secret_key); + let auth_str = format!("Bearer {secret_key}"); let mut auth_value = header::HeaderValue::from_str(&auth_str)?; auth_value.set_sensitive(true); headers.insert(header::AUTHORIZATION, auth_value.clone()); @@ -323,7 +323,7 @@ y4u6fdOVhgIhAJ4pJLfdoWQsHPUOcnVG5fBgdSnoCJhGQyuGyp+NDu1q log::debug!("Response body: {}", full); ErrorResponse { code, - status: format!("error decoding response body: {:#}", e), + status: format!("error decoding response body: {e:#}"), error: Some(full), } }))) @@ -399,7 +399,7 @@ y4u6fdOVhgIhAJ4pJLfdoWQsHPUOcnVG5fBgdSnoCJhGQyuGyp+NDu1q impl fmt::Display for ErrorResponse { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { if let Some(error) = &self.error { - write!(f, "{}", error) + write!(f, "{error}") } else { write!(f, "HTTP error: [{:?}] {}", self.code, self.status) } diff --git a/src/cloud/ops.rs b/src/cloud/ops.rs index c497f0918..19c4057e6 100644 --- a/src/cloud/ops.rs +++ b/src/cloud/ops.rs @@ -140,7 +140,7 @@ pub enum CloudTier { impl fmt::Display for CloudTier { fn fmt(&self, f: &mut fmt::Formatter) -> std::fmt::Result { - write!(f, "{:?}", self) + write!(f, "{self:?}") } } @@ -240,7 +240,7 @@ pub async fn find_cloud_instance_by_name( client: &CloudClient, ) -> anyhow::Result> { client - .get(format!("orgs/{}/instances/{}", org, inst)) + .get(format!("orgs/{org}/instances/{inst}")) .await .map(Some) .or_else(|e| match e.downcast_ref::() { @@ -254,7 +254,7 @@ pub async fn find_cloud_instance_by_name( #[tokio::main(flavor = "current_thread")] pub async fn get_org(org: &str, client: &CloudClient) -> anyhow::Result { - client.get(format!("orgs/{}", org)).await + client.get(format!("orgs/{org}")).await } pub(crate) async fn wait_for_operation( @@ -275,7 +275,7 @@ pub(crate) async fn wait_for_operation( (OperationStatus::Failed, Some(subsequent_id)) => { original_error = original_error.or(Some(operation.message)); - url = format!("operations/{}", subsequent_id); + url = format!("operations/{subsequent_id}"); operation = client.get(&url).await?; } (OperationStatus::Failed, None) => { @@ -381,7 +381,7 @@ pub async fn restart_cloud_instance( client.ensure_authenticated()?; let operation: CloudOperation = client .post( - format!("orgs/{}/instances/{}/restart", org, name), + format!("orgs/{org}/instances/{name}/restart"), &CloudInstanceRestart {}, ) .await?; @@ -398,7 +398,7 @@ pub async fn destroy_cloud_instance( let client = CloudClient::new(options)?; client.ensure_authenticated()?; let operation: CloudOperation = client - .delete(format!("orgs/{}/instances/{}", org, name)) + .delete(format!("orgs/{org}/instances/{name}")) .await?; wait_for_operation(operation, &client).await?; Ok(()) diff --git a/src/cloud/secret_keys.rs b/src/cloud/secret_keys.rs index 1d7c0f68b..4712a72c0 100644 --- a/src/cloud/secret_keys.rs +++ b/src/cloud/secret_keys.rs @@ -140,7 +140,7 @@ pub async fn _do_create(c: &options::CreateSecretKey, client: &CloudClient) -> a .secret_key .context("no valid secret key returned from server")?; if c.non_interactive { - print!("{}", sk); + print!("{sk}"); } else { echo!( "\nYour new ", diff --git a/src/commands/backslash.rs b/src/commands/backslash.rs index 4de88de07..40a642967 100644 --- a/src/commands/backslash.rs +++ b/src/commands/backslash.rs @@ -582,7 +582,7 @@ pub async fn execute( }; match cmd { Help => { - print!("{}", HELP); + print!("{HELP}"); Ok(Skip) } Common(ref cmd) => { @@ -668,7 +668,7 @@ pub async fn execute( .try_connect(&c.database_name) .await .map_err(|e| { - print::error(format!("Cannot connect: {:#}", e)); + print::error(format!("Cannot connect: {e:#}")); }) .ok(); Ok(Skip) @@ -677,7 +677,7 @@ pub async fn execute( if let Some(ref err) = prompt.last_error { match err.downcast_ref::() { Some(e) => println!("{}", display_error_verbose(e)), - None => println!("{:#}", err), + None => println!("{err:#}"), } } else { eprintln!("== no previous error =="); @@ -702,7 +702,7 @@ pub async fn execute( .map(|c| c.get_state_as_value()) .unwrap_or_else(|| prompt.get_state_as_value())? }; - println!("Descriptor id: {}", desc_id); + println!("Descriptor id: {desc_id}"); print::native_to_stdout(tokio_stream::iter([Ok::<_, Error>(value)]), &prompt.print) .await?; println!(); diff --git a/src/commands/configure.rs b/src/commands/configure.rs index da4c3136e..c73911b57 100644 --- a/src/commands/configure.rs +++ b/src/commands/configure.rs @@ -50,7 +50,7 @@ pub async fn configure( .collect::>() .join(", "); if !users.is_empty() { - props.push(format!("user := {{ {} }}", users)) + props.push(format!("user := {{ {users} }}")) } if let Some(ref comment_text) = comment { props.push(format!("comment := {}", quote_string(comment_text))) diff --git a/src/commands/describe.rs b/src/commands/describe.rs index f0de04766..ae4920da0 100644 --- a/src/commands/describe.rs +++ b/src/commands/describe.rs @@ -23,9 +23,9 @@ pub async fn describe( if let Some(ref styler) = options.styler { let mut out = String::with_capacity(text.len()); highlight::edgeql(&mut out, &text, styler); - println!("{}", out); + println!("{out}"); } else { - println!("{}", text); + println!("{text}"); } } Ok(()) diff --git a/src/commands/describe_schema.rs b/src/commands/describe_schema.rs index 712cf3044..7db6ff456 100644 --- a/src/commands/describe_schema.rs +++ b/src/commands/describe_schema.rs @@ -9,9 +9,9 @@ pub async fn describe_schema(cli: &mut Connection, options: &Options) -> Result< if let Some(ref styler) = options.styler { let mut out = String::with_capacity(text.len()); highlight::edgeql(&mut out, &text, styler); - println!("{}", out); + println!("{out}"); } else { - println!("{}", text); + println!("{text}"); } Ok(()) } diff --git a/src/commands/list.rs b/src/commands/list.rs index c60946558..c0ec39a0f 100644 --- a/src/commands/list.rs +++ b/src/commands/list.rs @@ -6,13 +6,13 @@ pub async fn print( options: &Options, ) -> Result<(), anyhow::Error> { if !options.command_line { - println!("{}:", title); + println!("{title}:"); } for name in items { if options.command_line { - println!("{}", name); + println!("{name}"); } else { - println!(" {}", name); + println!(" {name}"); } } Ok(()) diff --git a/src/commands/list_aliases.rs b/src/commands/list_aliases.rs index f5aade744..ca600f667 100644 --- a/src/commands/list_aliases.rs +++ b/src/commands/list_aliases.rs @@ -54,8 +54,7 @@ pub async fn list_aliases( }} {filter} ORDER BY .name; - "###, - filter = filter + "### ); let items = filter::query::(cli, query, pattern, case_sensitive).await?; if !options.command_line || std::io::stdout().is_terminal() { @@ -91,7 +90,7 @@ pub async fn list_aliases( } if table.is_empty() { if let Some(pattern) = pattern { - eprintln!("No aliases found matching {:?}", pattern); + eprintln!("No aliases found matching {pattern:?}"); } else if !system { eprintln!("No user-defined expression aliases found."); } else { diff --git a/src/commands/list_branches.rs b/src/commands/list_branches.rs index 5687fd0cd..0cad622d9 100644 --- a/src/commands/list_branches.rs +++ b/src/commands/list_branches.rs @@ -13,8 +13,7 @@ pub async fn list_branches(cli: &mut Connection, options: &Options) -> Result<() if version.specific().major <= 4 { print::warn(format!( - "Branches are not supported in {BRANDING} {}, printing list of databases instead", - version + "Branches are not supported in {BRANDING} {version}, printing list of databases instead" )); return list_databases(cli, options).await; } diff --git a/src/commands/list_casts.rs b/src/commands/list_casts.rs index 1f031820e..2cfbe9648 100644 --- a/src/commands/list_casts.rs +++ b/src/commands/list_casts.rs @@ -44,8 +44,7 @@ pub async fn list_casts<'x>( }} {filter} ORDER BY .kind THEN .from_type.name THEN .to_type.name; - "###, - filter = filter + "### ); let items = filter::query::(cli, query, pattern, case_sensitive).await?; if !options.command_line || std::io::stdout().is_terminal() { @@ -67,7 +66,7 @@ pub async fn list_casts<'x>( } if table.is_empty() { if let Some(pattern) = pattern { - eprintln!("No casts found matching {:?}", pattern); + eprintln!("No casts found matching {pattern:?}"); } } else { table.printstd(); diff --git a/src/commands/list_databases.rs b/src/commands/list_databases.rs index 26475f04b..e44d12c73 100644 --- a/src/commands/list_databases.rs +++ b/src/commands/list_databases.rs @@ -20,8 +20,7 @@ pub async fn list_databases(cli: &mut Connection, options: &Options) -> Result<( if version.specific().major >= 5 { print::warn(format!( - "Databases are not supported in {BRANDING} {}, printing list of branches instead", - version + "Databases are not supported in {BRANDING} {version}, printing list of branches instead" )); return list_branches0(cli, options).await; } diff --git a/src/commands/list_indexes.rs b/src/commands/list_indexes.rs index 47d513ef2..9515cc310 100644 --- a/src/commands/list_indexes.rs +++ b/src/commands/list_indexes.rs @@ -70,8 +70,7 @@ pub async fn list_indexes( }} {filter} ORDER BY .subject_name; - "###, - filter = filter + "### ); let items = filter::query::(cli, query, pattern, case_sensitive).await?; if !options.command_line || std::io::stdout().is_terminal() { @@ -107,7 +106,7 @@ pub async fn list_indexes( } if table.is_empty() { if let Some(pattern) = pattern { - eprintln!("No indexes found matching {:?}", pattern); + eprintln!("No indexes found matching {pattern:?}"); } else if !verbose { if options.command_line { eprintln!("No explicit indexes found. Try --verbose"); diff --git a/src/commands/list_modules.rs b/src/commands/list_modules.rs index 6fa44503a..9df88fed2 100644 --- a/src/commands/list_modules.rs +++ b/src/commands/list_modules.rs @@ -19,8 +19,7 @@ pub async fn list_modules( SELECT name := schema::Module.name {filter} ORDER BY name - "###, - filter = filter + "### ); let items = filter::query(cli, &query, pattern, case_sensitive).await?; list::print(items, "List of modules", options).await?; diff --git a/src/commands/list_object_types.rs b/src/commands/list_object_types.rs index 5b92886e6..8b98ced6c 100644 --- a/src/commands/list_object_types.rs +++ b/src/commands/list_object_types.rs @@ -70,7 +70,7 @@ pub async fn list_object_types( } if table.is_empty() { if let Some(pattern) = pattern { - eprintln!("No object types found matching {:?}", pattern); + eprintln!("No object types found matching {pattern:?}"); } else if !system { eprintln!( "No user-defined object types found. {}", diff --git a/src/commands/list_roles.rs b/src/commands/list_roles.rs index 869d28930..7dddc5392 100644 --- a/src/commands/list_roles.rs +++ b/src/commands/list_roles.rs @@ -19,8 +19,7 @@ pub async fn list_roles<'x>( SELECT name := sys::Role.name {filter} ORDER BY name - "###, - filter = filter + "### ); let items = filter::query(cli, &query, pattern, case_sensitive).await?; list::print(items, "List of roles", options).await?; diff --git a/src/commands/list_scalar_types.rs b/src/commands/list_scalar_types.rs index 424de4415..c403c9e09 100644 --- a/src/commands/list_scalar_types.rs +++ b/src/commands/list_scalar_types.rs @@ -53,8 +53,7 @@ pub async fn list_scalar_types<'x>( }} {filter} ORDER BY .name; - "###, - filter = filter + "### ); let items = filter::query::(cli, query, pattern, case_sensitive).await?; @@ -78,7 +77,7 @@ pub async fn list_scalar_types<'x>( } if table.is_empty() { if let Some(pattern) = pattern { - eprintln!("No scalar types found matching {:?}", pattern); + eprintln!("No scalar types found matching {pattern:?}"); } else if !system { eprintln!( "No user-defined scalar types found. {}", diff --git a/src/commands/psql.rs b/src/commands/psql.rs index d01d4cf30..3eddd981a 100644 --- a/src/commands/psql.rs +++ b/src/commands/psql.rs @@ -26,7 +26,7 @@ pub async fn psql<'x>(cli: &mut Connection, _options: &Options) -> Result<(), an let npath = if let Some(path) = env::var_os("PATH") { env::join_paths(iter::once(PathBuf::from(dir)).chain(env::split_paths(&path))) .unwrap_or_else(|e| { - eprintln!("PSQL_DEFAULT_PATH error: {}", e); + eprintln!("PSQL_DEFAULT_PATH error: {e}"); path }) } else { diff --git a/src/commands/restore.rs b/src/commands/restore.rs index 01c343057..e4987cd56 100644 --- a/src/commands/restore.rs +++ b/src/commands/restore.rs @@ -83,10 +83,10 @@ async fn read_packet( let read = input .read_buf(buf) .await - .with_context(|| format!("Error reading block of {} bytes", len))?; + .with_context(|| format!("Error reading block of {len} bytes"))?; if read == 0 { return Err(io::Error::from(io::ErrorKind::UnexpectedEof)) - .with_context(|| format!("Error reading block of {} bytes", len))?; + .with_context(|| format!("Error reading block of {len} bytes"))?; } } Ok(Some( @@ -219,7 +219,7 @@ fn path_to_database_name(path: &Path) -> anyhow::Result { .and_then(|x| x.to_str()) .ok_or_else(|| anyhow::anyhow!("invalid dump filename {:?}", path))?; let decoded = urlencoding::decode(encoded) - .with_context(|| format!("failed to decode filename {:?}", path))?; + .with_context(|| format!("failed to decode filename {path:?}"))?; Ok(decoded.to_string()) } @@ -238,7 +238,7 @@ async fn apply_init(cli: &mut Connection, path: &Path) -> anyhow::Result<()> { log::trace!("Executing {:?}", stmt); cli.execute(stmt, &()) .await - .with_context(|| format!("failed statement {:?}", stmt))?; + .with_context(|| format!("failed statement {stmt:?}"))?; } } Ok(()) @@ -253,7 +253,7 @@ pub async fn restore_all<'x>( let filename = dir.join("init.edgeql"); apply_init(cli, filename.as_ref()) .await - .with_context(|| format!("error applying init file {:?}", filename))?; + .with_context(|| format!("error applying init file {filename:?}"))?; let mut conn_params = options.conn_params.clone(); conn_params.wait_until_available(Duration::from_secs(300)); @@ -274,17 +274,17 @@ pub async fn restore_all<'x>( let stmt = format!("CREATE DATABASE {}", quote_name(&database)); cli.execute(&stmt, &()) .await - .with_context(|| format!("error creating database {:?}", database))?; + .with_context(|| format!("error creating database {database:?}"))?; } conn_params.branch(&database)?; let mut db_conn = conn_params .connect() .await - .with_context(|| format!("cannot connect to database {:?}", database))?; + .with_context(|| format!("cannot connect to database {database:?}"))?; params.path = path; restore_db(&mut db_conn, options, ¶ms) .await - .with_context(|| format!("restoring database {:?}", database))?; + .with_context(|| format!("restoring database {database:?}"))?; } Ok(()) } diff --git a/src/commands/ui.rs b/src/commands/ui.rs index 7edcd3a17..632afef9a 100644 --- a/src/commands/ui.rs +++ b/src/commands/ui.rs @@ -33,15 +33,15 @@ pub fn show_ui(cmd: &UI, opts: &Options) -> anyhow::Result<()> { match open::that(&url) { Ok(_) => { print::success("Opening URL in browser:"); - println!("{}", url); + println!("{url}"); Ok(()) } Err(e) => { - print::error(format!("Cannot launch browser: {:#}", e)); + print::error(format!("Cannot launch browser: {e:#}")); print::prompt( "Please paste the URL below into your browser to launch the {BRANDING} UI:", ); - println!("{}", url); + println!("{url}"); Err(ExitCode::new(1).into()) } } @@ -75,7 +75,7 @@ fn get_local_ui_url(cmd: &UI, cfg: &edgedb_tokio::Config) -> anyhow::Result anyhow::Result { - print::error(format!("cannot connect to {}: {:#}", url, e,)); + print::error(format!("cannot connect to {url}: {e:#}",)); return Err(ExitCode::new(4).into()); } } @@ -265,7 +265,7 @@ mod jwt { let token = self.generate_token()?; if !self.legacy { - return Ok(format!("edbt_{}", token)); + return Ok(format!("edbt_{token}")); } self.generate_legacy_token(token) @@ -325,10 +325,9 @@ mod jwt { let protected = format!( "{{\ \"alg\":\"ECDH-ES\",\"enc\":\"A256GCM\",\"epk\":{{\ - \"crv\":\"P-256\",\"kty\":\"EC\",\"x\":\"{}\",\"y\":\"{}\"\ + \"crv\":\"P-256\",\"kty\":\"EC\",\"x\":\"{x}\",\"y\":\"{y}\"\ }}\ - }}", - x, y + }}" ); let protected = URL_SAFE_NO_PAD.encode(protected.as_bytes()); let mut nonce = vec![0; 96 / 8]; diff --git a/src/completion.rs b/src/completion.rs index 08c509f45..e3b682808 100644 --- a/src/completion.rs +++ b/src/completion.rs @@ -435,7 +435,7 @@ fn hint_setting_value(input: &str, val: &SettingValue) -> Option { }; if let Some(suggest) = suggest { return Some(Hint::new( - format!(" ← unknown boolean, did you mean: {}", suggest), + format!(" ← unknown boolean, did you mean: {suggest}"), 0, )); } diff --git a/src/connect.rs b/src/connect.rs index de43204ec..f1c9d63bb 100644 --- a/src/connect.rs +++ b/src/connect.rs @@ -182,22 +182,22 @@ impl Connector { Some(edgedb_tokio::InstanceName::Cloud { org_slug: org, name, - }) => format!("{BRANDING_CLOUD} instance '{}/{}'", org, name), + }) => format!("{BRANDING_CLOUD} instance '{org}/{name}'"), Some(edgedb_tokio::InstanceName::Local(name)) => { format!("{BRANDING} instance '{}' at {}", name, cfg.display_addr()) } _ => format!("{BRANDING} instance at {}", cfg.display_addr()), }; - format!("Connecting to {}...", desc) + format!("Connecting to {desc}...") } async fn print_warning(&self, cfg: &Config, interactive: bool) -> Result { sleep(Duration::new(1, 0)).await; let msg = self.warning_msg(cfg); if interactive { - eprint!("{}", msg); + eprint!("{msg}"); } else { - eprintln!("{}", msg); + eprintln!("{msg}"); } pending().await } diff --git a/src/credentials.rs b/src/credentials.rs index 781e7eadc..2a3b98d05 100644 --- a/src/credentials.rs +++ b/src/credentials.rs @@ -18,7 +18,7 @@ pub fn base_dir() -> anyhow::Result { } pub fn path(name: &str) -> anyhow::Result { - Ok(base_dir()?.join(format!("{}.json", name))) + Ok(base_dir()?.join(format!("{name}.json"))) } pub fn all_instance_names() -> anyhow::Result> { @@ -27,7 +27,7 @@ pub fn all_instance_names() -> anyhow::Result> { let dir_entries = match fs::read_dir(&dir) { Ok(d) => d, Err(e) if e.kind() == io::ErrorKind::NotFound => return Ok(result), - Err(e) => return Err(e).context(format!("error reading {:?}", dir)), + Err(e) => return Err(e).context(format!("error reading {dir:?}")), }; for item in dir_entries { let item = item?; diff --git a/src/error_display.rs b/src/error_display.rs index f6f873810..ae5a27e07 100644 --- a/src/error_display.rs +++ b/src/error_display.rs @@ -41,7 +41,7 @@ pub fn print_query_error( "{}{}", err.kind_name(), err.initial_message() - .map(|s| format!(": {}", s)) + .map(|s| format!(": {s}")) .unwrap_or("".into()) )) .with_labels(vec![Label { @@ -63,7 +63,7 @@ pub fn print_query_error( if let Some(traceback) = err.server_traceback() { eprintln!(" Server traceback:"); for line in traceback.lines() { - eprintln!(" {}", line); + eprintln!(" {line}"); } } } diff --git a/src/interactive.rs b/src/interactive.rs index ce33a7e84..38099322a 100644 --- a/src/interactive.rs +++ b/src/interactive.rs @@ -178,14 +178,14 @@ fn _check_json_limit(json: &serde_json::Value, path: &mut String, limit: usize) return false; } for (idx, item) in items.iter().enumerate() { - write!(path, "[{}]", idx).expect("formatting failed"); + write!(path, "[{idx}]").expect("formatting failed"); _check_json_limit(item, path, limit); path.truncate(level); } } Object(pairs) => { for (key, value) in pairs { - write!(path, ".{}", key).expect("formatting failed"); + write!(path, ".{key}").expect("formatting failed"); _check_json_limit(value, path, limit); path.truncate(level); } @@ -242,7 +242,7 @@ async fn execute_backslash(state: &mut repl::State, text: &str) -> anyhow::Resul // It's expected that command already printed all required // messages, so ignoring it is safe } else { - eprintln!("Error executing command: {:#}", e); + eprintln!("Error executing command: {e:#}"); // Quick-edit command on error state.initial_text = text.into(); state.last_error = Some(e); @@ -303,7 +303,7 @@ async fn execute_query( } if options.debug_print_codecs { let incodec = indesc.build_codec()?; - println!("Input Codec {:#?}", incodec); + println!("Input Codec {incodec:#?}"); } let input_start = Instant::now(); @@ -313,7 +313,7 @@ async fn execute_query( { Ok(input) => input, Err(e) => { - eprintln!("{:#}", e); + eprintln!("{e:#}"); state.last_error = Some(e); return Err(QueryError)?; } @@ -350,7 +350,7 @@ async fn execute_query( return Err(RetryStateError)?; } Err(e) => { - eprintln!("Error: {}", e); + eprintln!("Error: {e}"); state.last_error = Some(e.into()); return Err(QueryError)?; } @@ -388,7 +388,7 @@ async fn execute_query( let mut text = match tab_separated::format_row(&row) { Ok(text) => text, Err(e) => { - eprintln!("Error: {}", e); + eprintln!("Error: {e}"); // exhaust the iterator to get connection in the // consistent state items.complete().await?; @@ -411,7 +411,7 @@ async fn execute_query( } => { print_query_error(error, statement, state.verbose_errors, "")?; } - _ => eprintln!("{:#?}", e), + _ => eprintln!("{e:#?}"), } state.last_error = Some(e.into()); return Err(QueryError)?; @@ -478,7 +478,7 @@ async fn execute_query( let value: serde_json::Value = serde_json::from_str(&text).context("cannot decode json result")?; - let path = format!(".[{}]", index); + let path = format!(".[{index}]"); if let Some(limit) = state.implicit_limit { if index >= limit { print_json_limit_error(&path); diff --git a/src/migrations/context.rs b/src/migrations/context.rs index a71791c7f..9152f769b 100644 --- a/src/migrations/context.rs +++ b/src/migrations/context.rs @@ -32,7 +32,7 @@ impl Context { Ok(Context { schema_dir, quiet }) } pub fn for_watch(config_path: &Path) -> anyhow::Result { - let config = config::read(&config_path)?; + let config = config::read(config_path)?; Context::for_project(&config) } pub fn for_project(config: &config::Config) -> anyhow::Result { diff --git a/src/migrations/create.rs b/src/migrations/create.rs index d5022ecd7..627223277 100644 --- a/src/migrations/create.rs +++ b/src/migrations/create.rs @@ -215,7 +215,7 @@ fn print_statements(statements: impl IntoIterator>) { buf.truncate(0); highlight::edgeql(&mut buf, statement.as_ref(), &styler); for line in buf.lines() { - println!(" {}", line); + println!(" {line}"); } } } @@ -470,7 +470,7 @@ async fn non_interactive_populate( eprintln!("{BRANDING} intended to apply the following migration:"); for statement in proposal.statements { for line in statement.text.lines() { - eprintln!(" {}", line); + eprintln!(" {line}"); } } eprintln!( @@ -579,7 +579,7 @@ impl InteractiveMigration<'_> { println!("The following extra DDL statements will be applied:"); for statement in &proposal.statements { for line in statement.text.lines() { - println!(" {}", line); + println!(" {line}"); } } println!("(approved as part of an earlier prompt)"); @@ -672,7 +672,7 @@ impl InteractiveMigration<'_> { e.to_string().bold().white(), ); } else { - eprintln!("Error applying statement: {:#}", e); + eprintln!("Error applying statement: {e:#}"); } if self.cli.is_consistent() { eprintln!("Rolling back last operation..."); @@ -701,8 +701,7 @@ impl InteractiveMigration<'_> { Some(e) => format!( "{BRANDING} could not resolve migration with the provided answers. \ Please retry with different answers.\n\n \ - Debug info:\n\n {}", - e + Debug info:\n\n {e}" ), None => String::from( "{BRANDING} could not resolve migration with the \ @@ -768,14 +767,14 @@ where } fs::remove_file(&tmp_file).await.ok(); let mut file = io::BufWriter::new(fs::File::create(&tmp_file).await?); - file.write_all(format!("CREATE MIGRATION {}\n", id).as_bytes()) + file.write_all(format!("CREATE MIGRATION {id}\n").as_bytes()) .await?; file.write_all(format!(" ONTO {}\n", descr.parent()?).as_bytes()) .await?; file.write_all(b"{\n").await?; for statement in descr.statements() { for line in statement.lines() { - file.write_all(format!(" {}\n", line).as_bytes()).await?; + file.write_all(format!(" {line}\n").as_bytes()).await?; } } file.write_all(b"};\n").await?; @@ -928,7 +927,7 @@ fn get_input(req: &RequiredUserInput) -> Result { match expr::check(&value) { Ok(()) => {} Err(e) => { - println!("Invalid expression: {}", e); + println!("Invalid expression: {e}"); prev = value; continue; } @@ -973,7 +972,7 @@ fn substitute_placeholders<'x>( .ok_or_else(|| bug::error(format!("bad substitution token")))?; let expr = placeholders .get(name) - .ok_or_else(|| bug::error(format!("missing input for {:?} placeholder", name)))?; + .ok_or_else(|| bug::error(format!("missing input for {name:?} placeholder")))?; output.push_str(expr); start = token.span.end as usize; } diff --git a/src/migrations/db_migration.rs b/src/migrations/db_migration.rs index 2c42b417f..3bc200172 100644 --- a/src/migrations/db_migration.rs +++ b/src/migrations/db_migration.rs @@ -140,7 +140,7 @@ pub(crate) async fn find_by_prefix( } FILTER .name LIKE $0 "###, - &(format!("{}%", prefix),), + &(format!("{prefix}%"),), ) .await? } else { @@ -154,7 +154,7 @@ pub(crate) async fn find_by_prefix( } FILTER .name LIKE $0 "###, - &(format!("{}%", prefix),), + &(format!("{prefix}%"),), ) .await? }; diff --git a/src/migrations/edit.rs b/src/migrations/edit.rs index 7d21e841c..4e7a7a69f 100644 --- a/src/migrations/edit.rs +++ b/src/migrations/edit.rs @@ -45,12 +45,12 @@ fn print_diff(path1: &Path, data1: &str, path2: &Path, data2: &str) { let changeset = diff(data1, data2); let n1 = data1.split('\n').count(); let n2 = data2.split('\n').count(); - println!("@@ -1,{} +1,{}", n1, n2); + println!("@@ -1,{n1} +1,{n2}"); for item in &changeset { match item { Chunk::Equal(block) => { for line in block.split('\n') { - println!(" {}", line); + println!(" {line}"); } } Chunk::Insert(block) => { @@ -180,22 +180,19 @@ async fn _edit( echo!("Id", migration.id.emphasize(), "is already correct."); } } else { - let temp_path = path - .parent() - .unwrap() - .join(format!(".editing.{}.edgeql", n)); + let temp_path = path.parent().unwrap().join(format!(".editing.{n}.edgeql")); if cli.ping_while(fs::metadata(&temp_path)).await.is_ok() { loop { let mut q = Choice::new("Previously edited file exists. Restore?"); q.option( OldAction::Restore, &["y", "yes"], - format!("use previously edited {:?}", temp_path), + format!("use previously edited {temp_path:?}"), ); q.option( OldAction::Replace, &["n", "no"], - format!("use original {:?} instead", path), + format!("use original {path:?} instead"), ); q.option(OldAction::Diff, &["d", "diff"], "show diff"); match cli.ping_while(q.async_ask()).await? { diff --git a/src/migrations/log.rs b/src/migrations/log.rs index be9394647..bceafd270 100644 --- a/src/migrations/log.rs +++ b/src/migrations/log.rs @@ -61,11 +61,11 @@ async fn log_fs_async(_common: &Options, options: &MigrationLog) -> Result<(), a let limit = options.limit.unwrap_or(migrations.len()); if options.newest_first { for rev in migrations.keys().rev().take(limit) { - println!("{}", rev); + println!("{rev}"); } } else { for rev in migrations.keys().take(limit) { - println!("{}", rev); + println!("{rev}"); } } Ok(()) diff --git a/src/migrations/migrate.rs b/src/migrations/migrate.rs index 16d794099..07206f74f 100644 --- a/src/migrations/migrate.rs +++ b/src/migrations/migrate.rs @@ -259,15 +259,13 @@ async fn fixup( "Last recorded database migration is the result of \ a direct DDL statement. \ Consider running `edgedb migration extract` \ - to bring the history in {0:?} in sync with the database.", - migrations_dir + to bring the history in {migrations_dir:?} in sync with the database." ) } else { format!( "You might have a wrong or outdated source checkout. \ If you don't, consider running `edgedb migration extract` \ - to bring the history in {0:?} in sync with the database.", - migrations_dir + to bring the history in {migrations_dir:?} in sync with the database." ) } }))?; @@ -299,15 +297,13 @@ async fn fixup( "Last recorded database migration is the result of \ a direct DDL statement. \ Consider running `edgedb migration extract` \ - to bring the history in {0:?} in sync with the database.", - migrations_dir + to bring the history in {migrations_dir:?} in sync with the database." ) } else { format!( "You might have a wrong or outdated source checkout. \ If you don't, consider running `edgedb migration extract` \ - to bring the history in {0:?} in sync with the database.", - migrations_dir + to bring the history in {migrations_dir:?} in sync with the database." ) } }))?; @@ -323,8 +319,7 @@ async fn fixup( format!( "You might have a wrong or outdated source checkout. \ If you don't, consider running `edgedb migration extract` \ - to bring the history in {0:?} in sync with the database.", - migrations_dir, + to bring the history in {migrations_dir:?} in sync with the database.", ) }))?; } diff --git a/src/migrations/print_error.rs b/src/migrations/print_error.rs index 8dbb86a53..52d17416c 100644 --- a/src/migrations/print_error.rs +++ b/src/migrations/print_error.rs @@ -89,7 +89,7 @@ pub fn print_migration_error( if let Some(traceback) = err.server_traceback() { eprintln!(" Server traceback:"); for line in traceback.lines() { - eprintln!(" {}", line); + eprintln!(" {line}"); } } } diff --git a/src/migrations/prompt.rs b/src/migrations/prompt.rs index f76e777cb..d0901a047 100644 --- a/src/migrations/prompt.rs +++ b/src/migrations/prompt.rs @@ -79,7 +79,7 @@ pub fn expression( editor.bind_sequence(KeyEvent::new('\r', Modifiers::ALT), Cmd::AcceptLine); load_history(&mut editor, &history_name) .map_err(|e| { - eprintln!("Can't load history: {:#}", e); + eprintln!("Can't load history: {e:#}"); }) .ok(); editor.set_helper(Some(ExpressionHelper { diff --git a/src/migrations/rebase.rs b/src/migrations/rebase.rs index 8fe0a6691..1a7eb29cd 100644 --- a/src/migrations/rebase.rs +++ b/src/migrations/rebase.rs @@ -79,7 +79,7 @@ impl RebaseMigrations { } }; - eprintln!("Last common migration is {}", last_common); + eprintln!("Last common migration is {last_common}"); eprintln!( "Since then, there are:\n- {} new {} on the target branch,\n- {} {} to rebase", self.target_migrations.len().to_string().green(), diff --git a/src/migrations/squash.rs b/src/migrations/squash.rs index f05ef5194..54a00d0f5 100644 --- a/src/migrations/squash.rs +++ b/src/migrations/squash.rs @@ -208,7 +208,7 @@ impl TwoStageRemove<'_> { Ok(dir) => dir, Err(e) if e.kind() == io::ErrorKind::NotFound => return Ok(()), Err(e) => { - return Err(e).context(format!("cannot open {:?}", dir_path))?; + return Err(e).context(format!("cannot open {dir_path:?}"))?; } }; @@ -255,7 +255,7 @@ impl TwoStageRemove<'_> { Ok(dir) => dir, Err(e) if e.kind() == io::ErrorKind::NotFound => return Ok(()), Err(e) => { - return Err(e).context(format!("cannot open {:?}", dir_path))?; + return Err(e).context(format!("cannot open {dir_path:?}"))?; } }; while let Some(item) = dir.next_entry().await? { diff --git a/src/migrations/status.rs b/src/migrations/status.rs index 2d117bcf4..bdcd81287 100644 --- a/src/migrations/status.rs +++ b/src/migrations/status.rs @@ -60,7 +60,7 @@ pub async fn status( migration.bold().white(), ); } else { - eprintln!("Database is up to date. Last migration: {}.", migration,); + eprintln!("Database is up to date. Last migration: {migration}.",); } Ok(()) } @@ -102,8 +102,7 @@ pub async fn migrations_applied( )); } else { print::error(format!( - "Database revision {} not found in the filesystem.", - db_migration, + "Database revision {db_migration} not found in the filesystem.", )); eprintln!(" Consider updating sources."); } diff --git a/src/migrations/upgrade_format.rs b/src/migrations/upgrade_format.rs index 0c913886f..718e4c7de 100644 --- a/src/migrations/upgrade_format.rs +++ b/src/migrations/upgrade_format.rs @@ -29,10 +29,10 @@ async fn _upgrade_format(context: &Context) -> anyhow::Result<()> { if old_filename.captures(fname).is_some() { // migrate to new filename - eprintln!("Upgrading migration file layout for {}.edgeql...", fname); + eprintln!("Upgrading migration file layout for {fname}.edgeql..."); upgrade_format_of_file(&name, file_num(&name).unwrap()).await?; } else if new_filename.captures(fname).is_some() { - println!("Migration {} OK", fname) + println!("Migration {fname} OK") } else { print::warn(format!("Unknown migration file naming schema: {fname}",)) } diff --git a/src/options.rs b/src/options.rs index 54a6d1b4f..1a64d820c 100644 --- a/src/options.rs +++ b/src/options.rs @@ -643,9 +643,9 @@ fn update_help_branding(help: &str) -> String { ("BRANDING_CLOUD", BRANDING_CLOUD), ] { let value = cformat!("{}", value); - let pattern1 = format!("[{}]", placeholder); + let pattern1 = format!("[{placeholder}]"); help = help.replace(&pattern1, &value); - let pattern2 = format!("[`{}`]", placeholder); + let pattern2 = format!("[`{placeholder}`]"); help = help.replace(&pattern2, &value); } @@ -704,7 +704,7 @@ fn print_full_connection_options() { let help = &help[slice_from..]; color_print::cprintln!("Connection Options (full list):"); - println!("{}", help); + println!("{help}"); } fn term_width() -> usize { @@ -835,8 +835,7 @@ impl Options { \n \ Use '--no-cli-update-check' instead.\ \n\ - ", - error = error + " ); } @@ -882,7 +881,7 @@ impl Options { --unix-path or local instance name" ); } - let sock = runstate_dir(name)?.join(format!(".s.EDGEDB.admin.{}", port)); + let sock = runstate_dir(name)?.join(format!(".s.EDGEDB.admin.{port}")); cfg = cfg.with_unix_path(&sock); } (true, Some(_), None) => { diff --git a/src/portable/backup.rs b/src/portable/backup.rs index c8dc85416..b39a5cd4d 100644 --- a/src/portable/backup.rs +++ b/src/portable/backup.rs @@ -140,7 +140,7 @@ fn restore_cloud_cmd( org: org_slug.to_string(), backup_id: backup.backup_id.clone(), latest: backup.latest, - source_instance_id: source_inst.and_then(|i| Some(i.id)), + source_instance_id: source_inst.map(|i| i.id), }; cloud::backups::restore_cloud_instance(&client, &request)?; diff --git a/src/portable/config.rs b/src/portable/config.rs index 72332de45..ed681ead9 100644 --- a/src/portable/config.rs +++ b/src/portable/config.rs @@ -138,8 +138,7 @@ where } print::error(format!( - "Invalid {CONFIG_FILE_DISPLAY_NAME}: missing {}", - field_name + "Invalid {CONFIG_FILE_DISPLAY_NAME}: missing {field_name}" )); Err(ExitCode::new(exit_codes::INVALID_CONFIG).into()) } diff --git a/src/portable/control.rs b/src/portable/control.rs index 11dc7a759..36ffb381b 100644 --- a/src/portable/control.rs +++ b/src/portable/control.rs @@ -90,7 +90,7 @@ pub fn ensure_runstate_dir(name: &str) -> anyhow::Result { Ok(()) => Ok(runstate_dir), Err(e) if e.kind() == io::ErrorKind::PermissionDenied && cfg!(unix) => { Err(anyhow::Error::new(e) - .context(format!("failed to create runstate dir {:?}", runstate_dir)) + .context(format!("failed to create runstate dir {runstate_dir:?}")) .hint( "This may mean that `XDG_RUNTIME_DIR` \ is inherited from another user's environment. \ @@ -100,7 +100,7 @@ pub fn ensure_runstate_dir(name: &str) -> anyhow::Result { .into()) } Err(e) => Err(anyhow::Error::new(e) - .context(format!("failed to create runstate dir {:?}", runstate_dir))), + .context(format!("failed to create runstate dir {runstate_dir:?}"))), } } @@ -249,7 +249,7 @@ pub fn start(options: &Start) -> anyhow::Result<()> { } else { drop(try_write); let locked_by = fs_err::read_to_string(&lock_path) - .with_context(|| format!("cannot read lock file {:?}", lock_path))?; + .with_context(|| format!("cannot read lock file {lock_path:?}"))?; if options.managed_by.is_some() { log::warn!( "Process is already running by {}. \ @@ -353,11 +353,11 @@ pub fn read_pid(instance: &str) -> anyhow::Result> { let pid = pid_str .trim() .parse() - .with_context(|| format!("cannot parse pid file {:?}", pid_path))?; + .with_context(|| format!("cannot parse pid file {pid_path:?}"))?; Ok(Some(pid)) } Err(e) if e.kind() == io::ErrorKind::NotFound => Ok(None), - Err(e) => Err(e).context(format!("cannot read pid file {:?}", pid_path))?, + Err(e) => Err(e).context(format!("cannot read pid file {pid_path:?}"))?, } } diff --git a/src/portable/create.rs b/src/portable/create.rs index 7f6a019db..7d1f5741e 100644 --- a/src/portable/create.rs +++ b/src/portable/create.rs @@ -135,12 +135,11 @@ pub fn create(cmd: &Create, opts: &crate::options::Options) -> anyhow::Result<() let paths = Paths::get(&name)?; paths .check_exists() - .with_context(|| format!("instance {:?} detected", name)) + .with_context(|| format!("instance {name:?} detected")) .with_hint(|| { format!( - "Use `{BRANDING_CLI_CMD} instance destroy -I {}` \ - to remove rest of unused instance", - name + "Use `{BRANDING_CLI_CMD} instance destroy -I {name}` \ + to remove rest of unused instance" ) })?; @@ -284,12 +283,10 @@ fn create_cloud( let prices = cloud::ops::get_prices(client)?; let tier_prices = prices.get(&tier).context(format!( - "could not download pricing information for the {} tier", - tier + "could not download pricing information for the {tier} tier" ))?; let region_prices = tier_prices.get(®ion).context(format!( - "could not download pricing information for the {} region", - region + "could not download pricing information for the {region} region" ))?; let default_compute = region_prices .iter() @@ -462,7 +459,7 @@ pub fn bootstrap( let cert_path = tmp_data.join("edbtlscert.pem"); let cert = fs::read_to_string(&cert_path) - .with_context(|| format!("cannot read certificate: {:?}", cert_path))?; + .with_context(|| format!("cannot read certificate: {cert_path:?}"))?; write_json(&tmp_data.join("instance_info.json"), "metadata", &info)?; fs::rename(&tmp_data, &paths.data_dir) diff --git a/src/portable/destroy.rs b/src/portable/destroy.rs index 5fb943b7f..dc331f7c4 100644 --- a/src/portable/destroy.rs +++ b/src/portable/destroy.rs @@ -21,10 +21,7 @@ pub struct InstanceNotFound(#[source] pub anyhow::Error); pub fn print_warning(name: &str, project_dirs: &[PathBuf]) { project::print_instance_in_use_warning(name, project_dirs); eprintln!("If you really want to destroy the instance, run:"); - eprintln!( - " {BRANDING_CLI_CMD} instance destroy -I {:?} --force", - name - ); + eprintln!(" {BRANDING_CLI_CMD} instance destroy -I {name:?} --force"); } pub fn with_projects( @@ -55,8 +52,7 @@ pub fn destroy(options: &Destroy, opts: &Options) -> anyhow::Result<()> { with_projects(&name_str, options.force, print_warning, || { if !options.force && !options.non_interactive { let q = question::Confirm::new_dangerous(format!( - "Do you really want to delete instance {:?}?", - name_str + "Do you really want to delete instance {name_str:?}?" )); if !q.ask()? { print::error("Canceled."); @@ -155,7 +151,7 @@ fn do_destroy(options: &Destroy, opts: &Options, name: &InstanceName) -> anyhow: if let Err(e) = crate::cloud::ops::destroy_cloud_instance(inst_name, org_slug, &opts.cloud_options) { - let msg = format!("Could not destroy {BRANDING_CLOUD} instance: {:#}", e); + let msg = format!("Could not destroy {BRANDING_CLOUD} instance: {e:#}"); if options.force { print::warn(msg); } else { diff --git a/src/portable/extension.rs b/src/portable/extension.rs index 5448d4121..89bc6060f 100644 --- a/src/portable/extension.rs +++ b/src/portable/extension.rs @@ -38,24 +38,16 @@ fn get_local_instance(instance: &Option) -> Result Result<(), anyhow::Error> { "Found extension package: {} version {}", options.extension, pkg.version ); - let zip = download_package(&pkg)?; + let zip = download_package(pkg)?; let command = if options.reinstall { Some("--reinstall") } else { diff --git a/src/portable/info.rs b/src/portable/info.rs index 1c5f8e634..6057af88c 100644 --- a/src/portable/info.rs +++ b/src/portable/info.rs @@ -57,7 +57,7 @@ pub fn info(options: &Info) -> anyhow::Result<()> { if options.json { println!("{}", serde_json::to_string(version)?); } else { - println!("{}", version); + println!("{version}"); } } _ => unreachable!(), diff --git a/src/portable/install.rs b/src/portable/install.rs index 5f5acc6cb..1050cf4fb 100644 --- a/src/portable/install.rs +++ b/src/portable/install.rs @@ -180,8 +180,8 @@ pub fn specific(version: &ver::Specific) -> anyhow::Result { if target_dir.exists() { return InstallInfo::read(&target_dir); } - let pkg = get_specific_package(version)? - .with_context(|| format!("cannot find package {}", version))?; + let pkg = + get_specific_package(version)?.with_context(|| format!("cannot find package {version}"))?; package(&pkg) } @@ -213,7 +213,7 @@ pub fn package(pkg_info: &PackageInfo) -> anyhow::Result { }; write_json(&tmp_target.join("install_info.json"), "metadata", &info)?; fs::rename(&tmp_target, &target_dir) - .with_context(|| format!("cannot rename {:?} -> {:?}", tmp_target, target_dir))?; + .with_context(|| format!("cannot rename {tmp_target:?} -> {target_dir:?}"))?; unlink_cache(&cache_path); echo!("Successfully installed", pkg_info.version.emphasize()); INSTALLED_VERSIONS diff --git a/src/portable/link.rs b/src/portable/link.rs index b25b11f9d..e7215b288 100644 --- a/src/portable/link.rs +++ b/src/portable/link.rs @@ -95,15 +95,13 @@ impl ServerCertVerifier for InteractiveCertVerifier { if self.trust_tls_cert { if !self.quiet { print::warn(format!( - "Trusting unknown server certificate: {:?}", - fingerprint, + "Trusting unknown server certificate: {fingerprint:?}", )); } } else if self.non_interactive { return Err(e); } else if let Ok(answer) = question::Confirm::new(format!( - "Unknown server certificate: {:?}. Trust?", - fingerprint, + "Unknown server certificate: {fingerprint:?}. Trust?", )) .default(false) .ask() @@ -423,7 +421,7 @@ async fn prompt_conn_params( pub fn print_warning(name: &str, project_dirs: &[PathBuf]) { project::print_instance_in_use_warning(name, project_dirs); eprintln!("If you really want to unlink the instance, run:"); - eprintln!(" {BRANDING_CLI_CMD} instance unlink -I {:?} --force", name); + eprintln!(" {BRANDING_CLI_CMD} instance unlink -I {name:?} --force"); } pub fn unlink(options: &Unlink) -> anyhow::Result<()> { @@ -435,22 +433,14 @@ pub fn unlink(options: &Unlink) -> anyhow::Result<()> { inst_name )) .with_hint(|| { - format!( - "use `edgedb instance destroy -I {}` to remove the instance", - inst_name - ) + format!("use `edgedb instance destroy -I {inst_name}` to remove the instance") })?; } }; let inst = InstanceInfo::try_read(name)?; if inst.is_some() { return Err(anyhow::anyhow!("cannot unlink local instance {:?}.", name) - .with_hint(|| { - format!( - "use `edgedb instance destroy -I {}` to remove the instance", - name - ) - }) + .with_hint(|| format!("use `edgedb instance destroy -I {name}` to remove the instance")) .into()); } with_projects(name, options.force, print_warning, || { diff --git a/src/portable/linux.rs b/src/portable/linux.rs index f229fc8cb..095bd0549 100644 --- a/src/portable/linux.rs +++ b/src/portable/linux.rs @@ -21,11 +21,11 @@ pub fn unit_dir() -> anyhow::Result { } fn unit_name(name: &str) -> String { - format!("edgedb-server@{}.service", name) + format!("edgedb-server@{name}.service") } fn socket_name(name: &str) -> String { - format!("edgedb-server@{}.socket", name) + format!("edgedb-server@{name}.socket") } pub fn service_files(name: &str) -> anyhow::Result> { @@ -37,16 +37,16 @@ pub fn create_service(info: &InstanceInfo) -> anyhow::Result<()> { let name = &info.name; let unit_dir = unit_dir()?; fs::create_dir_all(&unit_dir) - .with_context(|| format!("cannot create directory {:?}", unit_dir))?; + .with_context(|| format!("cannot create directory {unit_dir:?}"))?; let unit_name = unit_name(name); let socket_name = socket_name(name); let unit_path = unit_dir.join(unit_name); let socket_unit_path = unit_dir.join(socket_name); fs::write(&unit_path, systemd_unit(name, info)?) - .with_context(|| format!("cannot write {:?}", unit_path))?; + .with_context(|| format!("cannot write {unit_path:?}"))?; if info.get_version()?.specific().major >= 2 { fs::write(&socket_unit_path, systemd_socket(name, info)?) - .with_context(|| format!("cannot write {:?}", socket_unit_path))?; + .with_context(|| format!("cannot write {socket_unit_path:?}"))?; } if preliminary_detect().is_some() { process::Native::new("systemctl", "systemctl", "systemctl") @@ -379,7 +379,7 @@ pub fn service_status(name: &str) -> Service { Ok(txt) => txt, Err(e) => { return Service::Inactive { - error: format!("cannot determine service status: {:#}", e), + error: format!("cannot determine service status: {e:#}"), } } }; @@ -437,7 +437,7 @@ pub fn logs(options: &Logs) -> anyhow::Result<()> { let mut cmd = process::Native::new("logs", "journalctl", "journalctl"); cmd.arg("--user-unit").arg(unit_name(name)); if let Some(n) = options.tail { - cmd.arg(format!("--lines={}", n)); + cmd.arg(format!("--lines={n}")); } if options.follow { cmd.arg("--follow"); diff --git a/src/portable/local.rs b/src/portable/local.rs index 84cf779c6..f0d6a6bf7 100644 --- a/src/portable/local.rs +++ b/src/portable/local.rs @@ -58,7 +58,7 @@ fn port_file() -> anyhow::Result { } pub fn log_file(instance: &str) -> anyhow::Result { - Ok(cache_dir()?.join(format!("logs/{}.log", instance))) + Ok(cache_dir()?.join(format!("logs/{instance}.log"))) } pub fn lock_file(instance: &str) -> anyhow::Result { @@ -76,14 +76,14 @@ pub fn open_lock(instance: &str) -> anyhow::Result> { .write(true) .read(true) .open(&lock_path) - .with_context(|| format!("cannot open lock file {:?}", lock_path))?; + .with_context(|| format!("cannot open lock file {lock_path:?}"))?; Ok(fd_lock::RwLock::new(lock_file)) } pub fn runstate_dir(instance: &str) -> anyhow::Result { if cfg!(target_os = "linux") { if let Some(dir) = dirs::runtime_dir() { - return Ok(dir.join(format!("edgedb-{}", instance))); + return Ok(dir.join(format!("edgedb-{instance}"))); } } Ok(cache_dir()?.join("run").join(instance)) @@ -196,7 +196,7 @@ pub fn write_json(path: &Path, title: &str, data: &T) -> an fn list_installed( dir: &Path, ) -> anyhow::Result> + '_> { - let err_ctx = move || format!("error reading directory {:?}", dir); + let err_ctx = move || format!("error reading directory {dir:?}"); let dir = fs::read_dir(dir).with_context(err_ctx)?; Ok(dir.filter_map(move |result| { let entry = match result { @@ -266,9 +266,9 @@ impl Paths { Ok(Paths { credentials: credentials::path(name)?, data_dir: base.join(name), - dump_path: base.join(format!("{}.dump", name)), - backup_dir: base.join(format!("{}.backup", name)), - upgrade_marker: base.join(format!("{}.UPGRADE_IN_PROGRESS", name)), + dump_path: base.join(format!("{name}.dump")), + backup_dir: base.join(format!("{name}.backup")), + upgrade_marker: base.join(format!("{name}.UPGRADE_IN_PROGRESS")), runstate_dir: runstate_dir(name)?, service_files: if cfg!(windows) { windows::service_files(name)? diff --git a/src/portable/macos.rs b/src/portable/macos.rs index bc5fbeac7..f436bd405 100644 --- a/src/portable/macos.rs +++ b/src/portable/macos.rs @@ -29,7 +29,7 @@ pub fn plist_dir() -> anyhow::Result { } fn plist_name(name: &str) -> String { - format!("com.edgedb.edgedb-server-{}.plist", name) + format!("com.edgedb.edgedb-server-{name}.plist") } fn plist_path(name: &str) -> anyhow::Result { @@ -223,7 +223,7 @@ fn _service_status(name: &str) -> Status { Ok(output) => output, Err(e) => { return Inactive { - error: format!("cannot determine service status: {:#}", e), + error: format!("cannot determine service status: {e:#}"), } } }; diff --git a/src/portable/options.rs b/src/portable/options.rs index 66ab84be7..377d7e769 100644 --- a/src/portable/options.rs +++ b/src/portable/options.rs @@ -873,7 +873,7 @@ impl fmt::Display for InstanceName { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { InstanceName::Local(name) => name.fmt(f), - InstanceName::Cloud { org_slug, name } => write!(f, "{}/{}", org_slug, name), + InstanceName::Cloud { org_slug, name } => write!(f, "{org_slug}/{name}"), } } } @@ -943,8 +943,7 @@ pub fn instance_arg<'x>( } warn(format_args!( "Specifying instance name as positional argument is \ - deprecated. Use `-I {}` instead.", - name + deprecated. Use `-I {name}` instead." )); return Ok(name); } diff --git a/src/portable/project.rs b/src/portable/project.rs index 211862d12..7b462c17e 100644 --- a/src/portable/project.rs +++ b/src/portable/project.rs @@ -352,7 +352,7 @@ fn ask_existing_instance_name(cloud_client: &mut CloudClient) -> anyhow::Result< if exists { return Ok(inst_name); } else { - print::error(format!("Instance {:?} does not exist", target_name)); + print::error(format!("Instance {target_name:?} does not exist")); } } } @@ -589,9 +589,8 @@ fn ask_name( }; if exists { let confirm = question::Confirm::new(format!( - "Do you want to use existing instance {:?} \ - for the project?", - target_name + "Do you want to use existing instance {target_name:?} \ + for the project?" )); if confirm.ask()? { return Ok((inst_name, true)); @@ -629,7 +628,7 @@ pub fn init_existing( let schema_dir_path = project_dir.join(&schema_dir); let schema_dir_path = if schema_dir_path.exists() { fs::canonicalize(&schema_dir_path) - .with_context(|| format!("failed to canonicalize dir {:?}", schema_dir_path))? + .with_context(|| format!("failed to canonicalize dir {schema_dir_path:?}"))? } else { schema_dir_path }; @@ -905,7 +904,7 @@ fn do_cloud_init( source_backup_id: None, }; crate::cloud::ops::create_cloud_instance(client, &request)?; - let full_name = format!("{}/{}", org, name); + let full_name = format!("{org}/{name}"); let handle = Handle { name: full_name.clone(), @@ -1505,7 +1504,7 @@ fn ask_local_version(options: &Init) -> anyhow::Result<(Query, PackageInfo)> { continue; } Err(e) => { - print::error(format!("Cannot find nightly version: {}", e)); + print::error(format!("Cannot find nightly version: {e}")); continue; } } @@ -1517,7 +1516,7 @@ fn ask_local_version(options: &Init) -> anyhow::Result<(Query, PackageInfo)> { continue; } Err(e) => { - print::error(format!("Cannot find testing version: {}", e)); + print::error(format!("Cannot find testing version: {e}")); continue; } } @@ -1591,7 +1590,7 @@ fn ask_cloud_version( match cloud::versions::get_version(&Query::nightly(), client) { Ok(v) => return Ok((Query::nightly(), v)), Err(e) => { - print::error(format!("{}", e)); + print::error(format!("{e}")); continue; } } @@ -1599,7 +1598,7 @@ fn ask_cloud_version( match cloud::versions::get_version(&Query::testing(), client) { Ok(v) => return Ok((Query::testing(), v)), Err(e) => { - print::error(format!("{}", e)); + print::error(format!("{e}")); continue; } } @@ -1660,7 +1659,7 @@ pub fn unlink(options: &Unlink, opts: &crate::options::Options) -> anyhow::Resul anyhow::bail!("`{CONFIG_FILE_DISPLAY_NAME}` not found, unable to unlink instance."); }; let canon = fs::canonicalize(&project_dir) - .with_context(|| format!("failed to canonicalize dir {:?}", project_dir))?; + .with_context(|| format!("failed to canonicalize dir {project_dir:?}"))?; let stash_path = get_stash_path(&canon)?; if stash_path.exists() { @@ -1669,8 +1668,7 @@ pub fn unlink(options: &Unlink, opts: &crate::options::Options) -> anyhow::Resul if !options.non_interactive { let q = question::Confirm::new_dangerous(format!( "Do you really want to unlink \ - and delete instance {}?", - inst + and delete instance {inst}?" )); if !q.ask()? { print::error("Canceled."); @@ -1696,7 +1694,7 @@ pub fn unlink(options: &Unlink, opts: &crate::options::Options) -> anyhow::Resul echo!("Unlinking instance", name.emphasize()); } Err(e) => { - print::error(format!("Cannot read instance name: {}", e)); + print::error(format!("Cannot read instance name: {e}")); eprintln!("Removing project configuration directory..."); } }; @@ -1753,14 +1751,14 @@ pub fn info(options: &Info) -> anyhow::Result<()> { if options.json { println!("{}", serde_json::to_string(&instance_name)?); } else { - println!("{}", instance_name); + println!("{instance_name}"); } } "cloud-profile" => { if options.json { println!("{}", serde_json::to_string(&cloud_profile)?); } else if let Some(profile) = cloud_profile { - println!("{}", profile); + println!("{profile}"); } } _ => unreachable!(), @@ -1980,9 +1978,8 @@ fn print_other_project_warning( } if !project_dirs.is_empty() { print::warn(format!( - "Warning: the instance {} is still used by the following \ - projects:", - name + "Warning: the instance {name} is still used by the following \ + projects:" )); for pd in &project_dirs { eprintln!(" {}", pd.display()); @@ -2147,7 +2144,7 @@ fn upgrade_cloud( let result = upgrade::upgrade_cloud(org, name, to_version, &client, cmd.force, |target_ver| { let target_ver_str = target_ver.to_string(); - let _inst_name = format!("{}/{}", org, name); + let _inst_name = format!("{org}/{name}"); let inst_name = _inst_name.emphasize(); if !cmd.non_interactive { question::Confirm::new(format!( @@ -2161,7 +2158,7 @@ fn upgrade_cloud( })?; if let upgrade::UpgradeAction::Upgraded = result.action { - let inst_name = format!("{}/{}", org, name); + let inst_name = format!("{org}/{name}"); echo!( "Instance", inst_name.emphasize(), diff --git a/src/portable/repository.rs b/src/portable/repository.rs index 3b57d06a5..25c682107 100644 --- a/src/portable/repository.rs +++ b/src/portable/repository.rs @@ -524,8 +524,8 @@ impl PackageHash { impl fmt::Display for PackageHash { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - PackageHash::Blake2b(val) => write!(f, "blake2b:{}", val), - PackageHash::Unknown(val) => write!(f, "{}", val), + PackageHash::Blake2b(val) => write!(f, "blake2b:{val}"), + PackageHash::Unknown(val) => write!(f, "{val}"), } } } @@ -858,10 +858,10 @@ impl fmt::Display for QueryDisplay<'_> { match ver.minor { None => "0".fmt(f), Some(Minor(m)) => m.fmt(f), - Some(Dev(v)) => write!(f, "0-dev.{}", v), - Some(Alpha(v)) => write!(f, "0-alpha.{}", v), - Some(Beta(v)) => write!(f, "0-beta.{}", v), - Some(Rc(v)) => write!(f, "0-rc.{}", v), + Some(Dev(v)) => write!(f, "0-dev.{v}"), + Some(Alpha(v)) => write!(f, "0-alpha.{v}"), + Some(Beta(v)) => write!(f, "0-beta.{v}"), + Some(Rc(v)) => write!(f, "0-rc.{v}"), } } } diff --git a/src/portable/reset_password.rs b/src/portable/reset_password.rs index 937055eb3..5de0506b3 100644 --- a/src/portable/reset_password.rs +++ b/src/portable/reset_password.rs @@ -179,11 +179,6 @@ fn test_verifier() { assert_eq!( verifier, - format!( - "SCRAM-SHA-256$4096:{salt}${stored_key}:{server_key}", - salt = salt, - stored_key = stored_key, - server_key = server_key - ) + format!("SCRAM-SHA-256$4096:{salt}${stored_key}:{server_key}") ); } diff --git a/src/portable/resize.rs b/src/portable/resize.rs index 830815193..8e882661b 100644 --- a/src/portable/resize.rs +++ b/src/portable/resize.rs @@ -95,8 +95,7 @@ fn resize_cloud_cmd( if storage_size.is_none() || compute_size.is_none() { let prices = cloud::ops::get_prices(&client)?; let tier_prices = prices.get(&tier).context(format!( - "could not download pricing information for the {} tier", - tier + "could not download pricing information for the {tier} tier" ))?; let region_prices = tier_prices.get(&inst.region).context(format!( "could not download pricing information for the {} region", diff --git a/src/portable/revert.rs b/src/portable/revert.rs index d1e53ad60..c77a5777b 100644 --- a/src/portable/revert.rs +++ b/src/portable/revert.rs @@ -91,7 +91,7 @@ pub fn revert(options: &Revert) -> anyhow::Result<()> { } if let Err(e) = control::do_stop(name) { - print::error(format!("Error stopping service: {:#}", e)); + print::error(format!("Error stopping service: {e:#}")); if !options.no_confirm { let q = question::Confirm::new("Do you want to proceed?"); if !q.ask()? { diff --git a/src/portable/status.rs b/src/portable/status.rs index c3270a6cd..24ad42e83 100644 --- a/src/portable/status.rs +++ b/src/portable/status.rs @@ -149,7 +149,7 @@ fn is_run_by_supervisor(name: &str) -> anyhow::Result> { Ok(s) if s == "launchctl" && cfg!(target_os = "macos") => Ok(Some(true)), Ok(_) => Ok(Some(false)), Err(e) if e.kind() == io::ErrorKind::NotFound => Ok(None), - Err(e) => Err(e).context(format!("cannot read {:?}", lock_path))?, + Err(e) => Err(e).context(format!("cannot read {lock_path:?}"))?, } } @@ -239,7 +239,7 @@ fn normal_status(cmd: &Status, opts: &crate::options::Options) -> anyhow::Result let paths = Paths::get(name)?; let status = status_from_meta(name, &paths, meta); if cmd.debug { - println!("{:#?}", status); + println!("{status:#?}"); Ok(()) } else if cmd.extended { status.print_extended_and_exit(); @@ -367,7 +367,7 @@ pub fn remote_status(options: &Status) -> anyhow::Result<()> { if options.service { println!("Remote instance"); } else if options.debug { - println!("{:#?}", status); + println!("{status:#?}"); } else if options.extended { status.print_extended(); } else if options.json { @@ -376,7 +376,7 @@ pub fn remote_status(options: &Status) -> anyhow::Result<()> { serde_json::to_string_pretty(&status.json()).expect("status is json-serializable"), ); } else if let Some(inst_status) = &status.instance_status { - println!("{}", inst_status); + println!("{inst_status}"); } else if let Some(ConnectionStatus::Error(e)) = &status.connection { print::error(e); } else if let Some(conn_status) = &status.connection { @@ -390,7 +390,7 @@ pub fn remote_status(options: &Status) -> anyhow::Result<()> { pub fn list_local( dir: &Path, ) -> anyhow::Result> + '_> { - let err_ctx = move || format!("error reading directory {:?}", dir); + let err_ctx = move || format!("error reading directory {dir:?}"); let dir = fs::read_dir(dir).with_context(err_ctx)?; Ok(dir.filter_map(move |result| { let entry = match result { @@ -433,7 +433,7 @@ async fn get_remote_async( Some(status) } Err(e) => { - errors.add(e.context(format!("probing {:?}", name))); + errors.add(e.context(format!("probing {name:?}"))); None } } @@ -499,10 +499,7 @@ async fn _get_remote( get_remote_and_cloud(instances, cloud_client, errors), || { if num > 0 { - format!( - "Checking {BRANDING_CLOUD} and {} remote instance(s)...", - num - ) + format!("Checking {BRANDING_CLOUD} and {num} remote instance(s)...") } else { format!("Checking {BRANDING_CLOUD} instances...") } @@ -511,7 +508,7 @@ async fn _get_remote( .await } else if num > 0 { intermediate_feedback(get_remote_async(instances, errors), || { - format!("Checking {} remote instance(s)...", num) + format!("Checking {num} remote instance(s)...") }) .await } else { @@ -580,10 +577,10 @@ pub fn list(options: &List, opts: &crate::options::Options) -> anyhow::Result<() } if options.debug { for status in local { - println!("{:#?}", status); + println!("{status:#?}"); } for status in remote { - println!("{:#?}", status); + println!("{status:#?}"); } } else if options.extended { for status in local { @@ -619,7 +616,7 @@ pub fn list(options: &List, opts: &crate::options::Options) -> anyhow::Result<() pub fn print_errors(errs: &[anyhow::Error], is_warning: bool) -> bool { for e in errs { if is_warning { - print::warn(format!("Warning: {:#}", e)); + print::warn(format!("Warning: {e:#}")); } else { print::error(e); } @@ -695,20 +692,20 @@ impl FullStatus { println!("ready in socket activation mode, not running"); } Service::Running { pid } => { - println!("running, pid {}", pid); - println!(" Pid: {}", pid); + println!("running, pid {pid}"); + println!(" Pid: {pid}"); } Service::Failed { exit_code: Some(code), } => { - println!("stopped, exit code {}", code); + println!("stopped, exit code {code}"); } Service::Failed { exit_code: None } => { println!("not running"); } Service::Inactive { error } => { println!("inactive"); - println!(" Inactivity assumed because: {}", error); + println!(" Inactivity assumed because: {error}"); } } println!( @@ -729,11 +726,11 @@ impl FullStatus { match &self.instance { Ok(inst) => { if let Ok(version) = inst.get_version() { - println!(" Version: {}", version); + println!(" Version: {version}"); } if let Some(port) = self.reserved_port { if inst.port == port { - println!(" Port: {}", port); + println!(" Port: {port}"); } else { println!(" Port: {} (but {} reserved)", inst.port, port); } @@ -743,7 +740,7 @@ impl FullStatus { } _ => { if let Some(port) = self.reserved_port { - println!(" Port: {} (reserved)", port); + println!(" Port: {port} (reserved)"); } } } @@ -754,7 +751,7 @@ impl FullStatus { match &self.data_status { DataDirectory::Absent => "NOT FOUND".into(), DataDirectory::NoMetadata => "METADATA ERROR".into(), - DataDirectory::Upgrading(Err(e)) => format!("upgrading ({:#})", e), + DataDirectory::Upgrading(Err(e)) => format!("upgrading ({e:#})"), DataDirectory::Upgrading(Ok(up)) => { format!( "upgrading {} -> {} for {}", @@ -774,7 +771,7 @@ impl FullStatus { backup_meta: Err(e), .. } => { - format!("present (error: {:#})", e) + format!("present (error: {e:#})") } BackupStatus::Exists { backup_meta: Ok(b), .. @@ -813,12 +810,12 @@ impl FullStatus { } Running { pid } => { eprint!("Running, pid "); - println!("{}", pid); + println!("{pid}"); } Failed { exit_code: Some(code), } => { - eprintln!("Stopped, exit code {}", code); + eprintln!("Stopped, exit code {code}"); } Failed { exit_code: None } => { eprintln!("Not running"); @@ -849,7 +846,7 @@ impl RemoteStatus { pub fn print_extended(&self) { println!("{}:", self.name); let is_cloud = if let RemoteType::Cloud { instance_id } = &self.type_ { - println!(" {BRANDING_CLOUD} Instance ID: {}", instance_id); + println!(" {BRANDING_CLOUD} Instance ID: {instance_id}"); true } else { false @@ -858,7 +855,7 @@ impl RemoteStatus { println!(" Connection status: {}", conn_status.as_str()); } if let Some(inst_status) = &self.instance_status { - println!(" Instance status: {}", inst_status); + println!(" Instance status: {inst_status}"); } if !is_cloud { println!(" Credentials: exist"); @@ -881,7 +878,7 @@ impl RemoteStatus { ); } if let Some(ConnectionStatus::Error(e)) = &self.connection { - println!(" Connection error: {:#}", e); + println!(" Connection error: {e:#}"); } } diff --git a/src/portable/upgrade.rs b/src/portable/upgrade.rs index ac60e83c1..31c6ae63c 100644 --- a/src/portable/upgrade.rs +++ b/src/portable/upgrade.rs @@ -64,7 +64,7 @@ pub fn print_project_upgrade_command( match version.channel { Channel::Stable => if let Some(filt) = &version.version { - format!("--to-version={}", filt) + format!("--to-version={filt}") } else { "--to-latest".into() }, @@ -182,7 +182,7 @@ fn upgrade_cloud_cmd( let client = cloud::client::CloudClient::new(&opts.cloud_options)?; client.ensure_authenticated()?; - let _inst_name = format!("{}/{}", org, name); + let _inst_name = format!("{org}/{name}"); let inst_name = _inst_name.emphasize(); let result = upgrade_cloud(org, name, &query, &client, cmd.force, |target_ver| { @@ -346,7 +346,7 @@ pub fn upgrade_incompatible( } reinit_and_restore(&inst, &paths).map_err(|e| { - print::error(format!("{:#}", e)); + print::error(format!("{e:#}")); eprintln!( "To undo run:\n {BRANDING_CLI_CMD} instance revert -I {:?}", inst.name diff --git a/src/portable/ver.rs b/src/portable/ver.rs index bd1566f26..bd0530bc9 100644 --- a/src/portable/ver.rs +++ b/src/portable/ver.rs @@ -323,10 +323,10 @@ impl fmt::Display for Specific { f.write_str(".")?; match self.minor { MinorVersion::Minor(m) => m.fmt(f), - MinorVersion::Alpha(v) => write!(f, "0-alpha.{}", v), - MinorVersion::Beta(v) => write!(f, "0-beta.{}", v), - MinorVersion::Rc(v) => write!(f, "0-rc.{}", v), - MinorVersion::Dev(v) => write!(f, "0-dev.{}", v), + MinorVersion::Alpha(v) => write!(f, "0-alpha.{v}"), + MinorVersion::Beta(v) => write!(f, "0-beta.{v}"), + MinorVersion::Rc(v) => write!(f, "0-rc.{v}"), + MinorVersion::Dev(v) => write!(f, "0-dev.{v}"), } } } diff --git a/src/portable/windows.rs b/src/portable/windows.rs index 00c4ef8c4..29d9a6dc8 100644 --- a/src/portable/windows.rs +++ b/src/portable/windows.rs @@ -145,7 +145,7 @@ impl Wsl { } fn credentials_linux(instance: &str) -> String { - format!("/home/edgedb/.config/edgedb/credentials/{}.json", instance) + format!("/home/edgedb/.config/edgedb/credentials/{instance}.json") } #[context("cannot convert to linux (WSL) path {:?}", path)] @@ -616,7 +616,7 @@ pub fn startup_dir() -> anyhow::Result { } fn service_file(instance: &str) -> anyhow::Result { - Ok(startup_dir()?.join(format!("edgedb-server-{}.cmd", instance))) + Ok(startup_dir()?.join(format!("edgedb-server-{instance}.cmd"))) } pub fn service_files(name: &str) -> anyhow::Result> { @@ -973,7 +973,7 @@ pub fn list(options: &options::List, opts: &crate::Options) -> anyhow::Result<() } if options.debug { for status in remote { - println!("{:#?}", status); + println!("{status:#?}"); } } else if options.extended { for status in remote { @@ -1037,7 +1037,7 @@ fn get_instance_data_dir(name: &str, wsl: &Wsl) -> anyhow::Result { Err(_) => "/home/edgedb/.local/share/edgedb/_localdev/".into(), } } else { - format!("/home/edgedb/.local/share/edgedb/data/{}/", name) + format!("/home/edgedb/.local/share/edgedb/data/{name}/") }; if !wsl.check_path_exist(&data_dir) { @@ -1068,8 +1068,7 @@ pub fn read_jose_keys_legacy(name: &str) -> anyhow::Result<(Vec, Vec)> { pub fn get_instance_info(name: &str) -> anyhow::Result { let wsl = try_get_wsl()?; wsl.read_text_file(format!( - "/home/edgedb/.local/share/edgedb/data/{}/instance_info.json", - name + "/home/edgedb/.local/share/edgedb/data/{name}/instance_info.json" )) } diff --git a/src/print/buffer.rs b/src/print/buffer.rs index b123bcb09..016b64359 100644 --- a/src/print/buffer.rs +++ b/src/print/buffer.rs @@ -102,7 +102,7 @@ impl Printer { return Err(Exception::DisableFlow); } if self.colors { - write!(&mut self.buffer, "{}", s).expect("formatting CString always succeeds"); + write!(&mut self.buffer, "{s}").expect("formatting CString always succeeds"); } else { self.buffer.push_str(&s.to_str()); } diff --git a/src/print/formatter.rs b/src/print/formatter.rs index f34dd5cd4..41b0f5ad3 100644 --- a/src/print/formatter.rs +++ b/src/print/formatter.rs @@ -96,7 +96,7 @@ where } fn typed(&mut self, typ: &str, s: S) -> Result { self.delimit()?; - self.write(self.styler.apply(Style::Cast, &format!("<{}>", typ)))?; + self.write(self.styler.apply(Style::Cast, &format!("<{typ}>")))?; self.write(self.styler.apply( Style::String, &format!("'{}'", s.to_string().escape_default()), @@ -104,7 +104,7 @@ where } fn error(&mut self, typ: &str, s: S) -> Result { self.delimit()?; - self.write(self.styler.apply(Style::Error, &format!("", typ)))?; + self.write(self.styler.apply(Style::Error, &format!("")))?; self.write(self.styler.apply( Style::Error, &format!("'{}'", s.to_string().escape_default()), @@ -212,8 +212,7 @@ where { self.delimit()?; self.block( - self.styler - .apply(Style::TupleLiteral, &format!("{}(", name)), + self.styler.apply(Style::TupleLiteral, &format!("{name}(")), f, self.styler.apply(Style::TupleLiteral, ")"), )?; diff --git a/src/print/mod.rs b/src/print/mod.rs index f79712d05..a4dd58ff9 100644 --- a/src/print/mod.rs +++ b/src/print/mod.rs @@ -387,7 +387,7 @@ pub fn prompt(line: impl fmt::Display) { if use_color() { println!("{}", line.to_string().bold().color(Color::Orange3),); } else { - println!("{}", line); + println!("{line}"); } } @@ -396,7 +396,7 @@ pub fn err_marker() -> impl fmt::Display { } pub fn error(line: impl fmt::Display) { - let text = format!("{:#}", line); + let text = format!("{line:#}"); if text.len() > 60 { echo!(err_marker(), text); } else { diff --git a/src/print/native.rs b/src/print/native.rs index e5c7f9be1..321fc2619 100644 --- a/src/print/native.rs +++ b/src/print/native.rs @@ -42,7 +42,7 @@ fn format_bytes(bytes: &[u8]) -> String { for b in bytes { match b { 0..=0x08 | 0x0B | 0x0C | 0x0E..=0x1F | 0x7F..=0xFF => { - write!(&mut buf, "\\x{:02x}", b).unwrap() + write!(&mut buf, "\\x{b:02x}").unwrap() } b'\'' => buf.push_str("\\'"), b'\r' => buf.push_str("\\r"), @@ -61,9 +61,9 @@ fn format_bigint(bint: BigInt) -> String { let no_zeros = txt.trim_end_matches('0'); let zeros = txt.len() - no_zeros.len(); if zeros > 5 { - format!("{}e{}n", no_zeros, zeros) + format!("{no_zeros}e{zeros}n") } else { - format!("{}n", txt) + format!("{txt}n") } } @@ -73,17 +73,17 @@ fn format_decimal(value: BigDecimal) -> String { if txt.starts_with("0.00000") { let no_zeros = txt[2..].trim_start_matches('0'); let zeros = txt.len() - 2 - no_zeros.len(); - format!("0.{}e-{}", no_zeros, zeros) + format!("0.{no_zeros}e-{zeros}") } else { - format!("{}n", txt) + format!("{txt}n") } } else { let no_zeros = txt.trim_end_matches('0'); let zeros = txt.len() - no_zeros.len(); if zeros > 5 { - format!("{}.0e{}n", no_zeros, zeros) + format!("{no_zeros}.0e{zeros}n") } else { - format!("{}.0n", txt) + format!("{txt}.0n") } } } @@ -105,14 +105,14 @@ impl FormatExt for Value { V::Decimal(v) => prn.const_number(format_decimal(v.into())), V::Bool(v) => prn.const_bool(v), V::ConfigMemory(t) => prn.typed("cfg::memory", t.to_string()), - V::Datetime(t) => prn.typed("datetime", format!("{:?}", t)), - V::LocalDatetime(t) => prn.typed("cal::local_datetime", format!("{:?}", t)), - V::LocalDate(d) => prn.typed("cal::local_date", format!("{:?}", d)), - V::LocalTime(t) => prn.typed("cal::local_time", format!("{:?}", t)), + V::Datetime(t) => prn.typed("datetime", format!("{t:?}")), + V::LocalDatetime(t) => prn.typed("cal::local_datetime", format!("{t:?}")), + V::LocalDate(d) => prn.typed("cal::local_date", format!("{d:?}")), + V::LocalTime(t) => prn.typed("cal::local_time", format!("{t:?}")), V::Duration(d) => prn.typed("duration", d.to_string()), V::RelativeDuration(d) => prn.typed("cal::relative_duration", d.to_string()), V::DateDuration(d) => prn.typed("cal::date_duration", d.to_string()), - V::Json(d) => prn.const_string(format!("{:?}", d)), + V::Json(d) => prn.const_string(format!("{d:?}")), V::Set(items) => prn.set(|prn| { if let Some(limit) = prn.max_items() { for item in &items[..min(limit, items.len())] { diff --git a/src/process.rs b/src/process.rs index 08714a27e..f7ddf1a8d 100644 --- a/src/process.rs +++ b/src/process.rs @@ -223,7 +223,7 @@ impl Native { .append(true) .create(true) .open(path) - .with_context(|| format!("cannot open log file {:?}", path))?; + .with_context(|| format!("cannot open log file {path:?}"))?; self.command .stdout(file.try_clone().context("cannot clone file")?); self.command.stderr(file); @@ -818,11 +818,11 @@ async fn stdout_loop( let mut lines = buf.lines(); while let Ok(Some(line)) = lines.next_line().await { let message = if cfg!(windows) { - format!("[{}] {}\r\n", marker, line) + format!("[{marker}] {line}\r\n") .color(Color::Grey37) .to_string() } else { - format!("[{}] {}\n", marker, line) + format!("[{marker}] {line}\n") .color(Color::Grey37) .to_string() }; diff --git a/src/prompt.rs b/src/prompt.rs index 3e37acaf7..09dd75f66 100644 --- a/src/prompt.rs +++ b/src/prompt.rs @@ -91,12 +91,12 @@ impl Highlighter for EdgeqlHelper { if prompt.ends_with("> ") { let content = &prompt[..prompt.len() - 2]; if content.ends_with(TX_MARKER) { - return format!( + format!( "{}{}> ", &content[..content.len() - TX_MARKER.len()], TX_MARKER.green() ) - .into(); + .into() } else if content.ends_with(FAILURE_MARKER) { return format!( "{}{}> ", @@ -108,7 +108,7 @@ impl Highlighter for EdgeqlHelper { return prompt.into(); } } else { - return prompt.into(); + prompt.into() } } fn highlight<'l>(&self, line: &'l str, _pos: usize) -> Cow<'l, str> { @@ -201,7 +201,7 @@ pub fn load_history( ) -> Result<(), anyhow::Error> { let dir = data_local_dir().context("cannot find local data dir")?; let app_dir = dir.join("edgedb"); - match ed.load_history(&app_dir.join(format!("{}.history", name))) { + match ed.load_history(&app_dir.join(format!("{name}.history"))) { Err(ReadlineError::Io(e)) if e.kind() == ErrorKind::NotFound => {} Err(e) => return Err(e).context("error loading history")?, Ok(()) => {} @@ -218,7 +218,7 @@ fn _save_history( if !app_dir.exists() { fs::create_dir_all(&app_dir).context("cannot create application dir")?; } - ed.save_history(&app_dir.join(format!("{}.history", name))) + ed.save_history(&app_dir.join(format!("{name}.history"))) .context("error writing history file")?; Ok(()) } @@ -284,7 +284,7 @@ pub fn edgeql_input( return Ok(()); } Err(e) => { - eprintln!("Readline error: {}", e); + eprintln!("Readline error: {e}"); return Ok(()); } }; @@ -375,7 +375,7 @@ pub fn main(mut control: Receiver) -> Result<(), anyhow::Error> { } } Err(e) => { - println!("Bad value: {}", e); + println!("Bad value: {e}"); initial = text; } } @@ -388,7 +388,7 @@ pub fn main(mut control: Receiver) -> Result<(), anyhow::Error> { match show_history(editor.history()) { Ok(()) => {} Err(e) => { - eprintln!("Error displaying history: {}", e); + eprintln!("Error displaying history: {e}"); } } ack.send(()).ok(); @@ -406,7 +406,7 @@ pub fn main(mut control: Receiver) -> Result<(), anyhow::Error> { e }; if normal < 0 { - eprintln!("No history entry {}", e); + eprintln!("No history entry {e}"); response.send(Input::Interrupt).ok(); continue; } @@ -416,14 +416,14 @@ pub fn main(mut control: Receiver) -> Result<(), anyhow::Error> { ) { value } else { - eprintln!("No history entry {}", e); + eprintln!("No history entry {e}"); response.send(Input::Interrupt).ok(); continue; }; let mut text = match spawn_editor(&value.entry) { Ok(text) => text, Err(e) => { - eprintln!("Error editing history entry: {}", e); + eprintln!("Error editing history entry: {e}"); response.send(Input::Interrupt).ok(); continue; } @@ -458,7 +458,7 @@ fn show_history(history: &dyn History) -> Result<(), anyhow::Error> { let prefix = format!("[-{}] ", history.len() - index); let mut lines = s.entry.lines(); if let Some(first) = lines.next() { - writeln!(childin, "{}{}", prefix, first)?; + writeln!(childin, "{prefix}{first}")?; } for next in lines { writeln!(childin, "{:1$}{2}", "", prefix.len(), next)?; diff --git a/src/prompt/variable.rs b/src/prompt/variable.rs index 0d9e0a49c..6aab48148 100644 --- a/src/prompt/variable.rs +++ b/src/prompt/variable.rs @@ -83,9 +83,9 @@ impl ParseError<&str> for ParsingError { fn from_char(input: &str, c: char) -> Self { let message = if !input.is_empty() { - format!("Expected '{}' in {:?}", c, input) + format!("Expected '{c}' in {input:?}") } else { - format!("Expected '{}'", c) + format!("Expected '{c}'") }; ParsingError::Mistake { kind: None, @@ -94,7 +94,7 @@ impl ParseError<&str> for ParsingError { } fn or(self, other: Self) -> Self { - let message = format!("{}, or: {}", self, other); + let message = format!("{self}, or: {other}"); ParsingError::Mistake { kind: None, description: message, @@ -104,7 +104,7 @@ impl ParseError<&str> for ParsingError { impl ContextError<&str> for ParsingError { fn add_context(_input: &str, ctx: &'static str, other: Self) -> Self { - let message = format!("{} -> {}", ctx, other); + let message = format!("{ctx} -> {other}"); ParsingError::Mistake { kind: None, description: message, @@ -116,7 +116,7 @@ impl FromExternalError<&str, String> for ParsingError { fn from_external_error(input: &str, kind: ErrorKind, e: String) -> Self { ParsingError::Mistake { kind: Some(kind), - description: format!("{} at {}", e, input), + description: format!("{e} at {input}"), } } } @@ -132,7 +132,7 @@ impl FromExternalError<&str, anyhow::Error> for ParsingError { ParsingError::External { error: e, kind: Some(kind), - description: format!("Failed at '{}'", input), + description: format!("Failed at '{input}'"), } } } @@ -211,7 +211,7 @@ fn quoted_str_parser<'a>(input: &'a str, quote: char) -> IResult<&'a str, String if !complete { return Err(Failure(ParsingError::Mistake { kind: None, - description: format!("Missing end quote in '{}'", str), + description: format!("Missing end quote in '{str}'"), })); } @@ -602,8 +602,7 @@ impl VariableInput for NamedTuple { return Err(ParsingError::Mistake { kind: None, description: format!( - "Duplicate named tuple element: {}", - name + "Duplicate named tuple element: {name}" ), }); } @@ -647,16 +646,16 @@ fn format_parsing_error(e: nom::Err) -> String { ParsingError::Mistake { kind: _kind, description, - } => format!("{}", description), + } => format!("{description}"), ParsingError::External { description, error, kind: _, - } => format!("External error occurred: {} {}", description, error), + } => format!("External error occurred: {description} {error}"), ParsingError::Incomplete { hint: description } => description.unwrap_or("Incomplete input".to_string()), }, - Incomplete(Needed::Size(sz)) => format!("Incomplete input, needing {} more chars", sz), + Incomplete(Needed::Size(sz)) => format!("Incomplete input, needing {sz} more chars"), Incomplete(_n) => "Incomplete input".to_string(), } ) diff --git a/src/question.rs b/src/question.rs index 98a80c9e0..972cf6ef8 100644 --- a/src/question.rs +++ b/src/question.rs @@ -72,7 +72,7 @@ impl<'a, T: Clone + 'a> Numeric<'a, T> { let choice = match value.parse::() { Ok(choice) => choice, Err(e) => { - print::error(format!("Error reading choice: {}", e)); + print::error(format!("Error reading choice: {e}")); print::prompt("Please enter a number"); continue; } @@ -257,7 +257,7 @@ impl<'a, T: Clone + 'a> Choice<'a, T> { pad = pad ) } - println!("{:pad$} - print help", HELP, pad = pad); + println!("{HELP:pad$} - print help"); continue; } for choice in &self.choices { @@ -268,8 +268,7 @@ impl<'a, T: Clone + 'a> Choice<'a, T> { } } print::error(format!( - "Invalid option {:?}, please use one of: [{}]", - val, options + "Invalid option {val:?}, please use one of: [{options}]" )); } } diff --git a/src/repl.rs b/src/repl.rs index cde6225bf..2f076b8c4 100644 --- a/src/repl.rs +++ b/src/repl.rs @@ -277,14 +277,14 @@ impl State { Some(edgedb_tokio::InstanceName::Cloud { org_slug: org, name, - }) => format!("{}/{}:{}", org, name, current_database,), + }) => format!("{org}/{name}:{current_database}",), Some(edgedb_tokio::InstanceName::Local(name)) => { - format!("{}:{}", name, current_database,) + format!("{name}:{current_database}",) } - _ => format!("{}", current_database), + _ => format!("{current_database}"), }; - let prompt = format!("{}{}> ", location, txstate); + let prompt = format!("{location}{txstate}> "); self.editor_cmd(|response| prompt::Control::EdgeqlInput { prompt, diff --git a/src/variables.rs b/src/variables.rs index e04070e42..64ee0a980 100644 --- a/src/variables.rs +++ b/src/variables.rs @@ -26,7 +26,7 @@ pub async fn input_variables( let mut val = Vec::with_capacity(tuple.element_types.len()); for (idx, el) in tuple.element_types.iter().enumerate() { val.push( - input_item(&format!("{}", idx), desc.get(*el)?, desc, state, false) + input_item(&format!("{idx}"), desc.get(*el)?, desc, state, false) .await? .expect("no optional"), ); diff --git a/src/watch/main.rs b/src/watch/main.rs index 1571f7682..919205de5 100644 --- a/src/watch/main.rs +++ b/src/watch/main.rs @@ -79,7 +79,7 @@ pub fn watch(options: &Options, _watch: &WatchCommand) -> anyhow::Result<()> { eprintln!("{BRANDING} Watch initialized."); eprintln!(" Hint: Use `{BRANDING_CLI_CMD} migration create` and `{BRANDING_CLI_CMD} migrate --dev-mode` to apply changes once done."); - eprintln!("Monitoring {:?}.", project_dir); + eprintln!("Monitoring {project_dir:?}."); let res = runtime.block_on(watch_loop(rx, &mut ctx)); runtime .block_on(ctx.try_connect_and_clear_error()) @@ -215,8 +215,7 @@ impl From for ErrorJson { kind: "WatchError", message: format!( "error when trying to update the schema.\n \ - Original error: {}", - err + Original error: {err}" ), hint: Some( concatcp!( diff --git a/tests/common/util.rs b/tests/common/util.rs index 6849d3072..0447e017b 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -18,9 +18,9 @@ impl OutputExt for Assert { fn context(mut self, name: &'static str, description: &'static str) -> Self { self = self.append_context(name, description); let out = self.get_output(); - println!("------ {}: {} (STDOUT) -----", name, description); + println!("------ {name}: {description} (STDOUT) -----"); println!("{}", String::from_utf8_lossy(&out.stdout)); - println!("------ {}: {} (STDERR) -----", name, description); + println!("------ {name}: {description} (STDERR) -----"); println!("{}", String::from_utf8_lossy(&out.stderr)); self }