diff --git a/Cargo.toml b/Cargo.toml index a861becdbd..67fb5f5a8a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -134,6 +134,7 @@ testutils = { path = "lib/testutils" } [workspace.lints.clippy] explicit_iter_loop = "deny" +uninlined_format_args = "deny" # Insta suggests compiling these packages in opt mode for faster testing. # See https://docs.rs/insta/latest/insta/#optional-faster-runs. diff --git a/cli/build.rs b/cli/build.rs index a7e599b92f..dbe485faed 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -33,9 +33,9 @@ fn main() -> std::io::Result<()> { println!("cargo:rerun-if-env-changed=NIX_JJ_GIT_HASH"); if let Some(git_hash) = get_git_hash() { - println!("cargo:rustc-env=JJ_VERSION={}-{}", version, git_hash); + println!("cargo:rustc-env=JJ_VERSION={version}-{git_hash}"); } else { - println!("cargo:rustc-env=JJ_VERSION={}", version); + println!("cargo:rustc-env=JJ_VERSION={version}"); } Ok(()) diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index 273acc4faa..31be7eaa92 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -3311,7 +3311,7 @@ impl CliRunner { .flatten() .map(|path| format!("- {}", path.display())) .join("\n"); - e.hinted(format!("Check the following config files:\n{}", paths)) + e.hinted(format!("Check the following config files:\n{paths}")) })?; let string_args = expand_args(ui, &self.app, env::args_os(), &config)?; diff --git a/cli/src/command_error.rs b/cli/src/command_error.rs index 489ad8db93..7ebe1f4ad2 100644 --- a/cli/src/command_error.rs +++ b/cli/src/command_error.rs @@ -352,7 +352,7 @@ impl From for CommandError { size_diff, max_size.0, max_size, ) } else { - format!("it is {}; the maximum size allowed is ~{}.", size, max_size,) + format!("it is {size}; the maximum size allowed is ~{max_size}.",) }; user_error(format!( diff --git a/cli/src/commands/git/push.rs b/cli/src/commands/git/push.rs index bcfd04702c..6b7d019035 100644 --- a/cli/src/commands/git/push.rs +++ b/cli/src/commands/git/push.rs @@ -123,7 +123,7 @@ pub struct GitPushArgs { fn make_bookmark_term(bookmark_names: &[impl fmt::Display]) -> String { match bookmark_names { - [bookmark_name] => format!("bookmark {}", bookmark_name), + [bookmark_name] => format!("bookmark {bookmark_name}"), bookmark_names => format!("bookmarks {}", bookmark_names.iter().join(", ")), } } diff --git a/cli/src/commands/operation/diff.rs b/cli/src/commands/operation/diff.rs index c2c0b3ee3e..955647f343 100644 --- a/cli/src/commands/operation/diff.rs +++ b/cli/src/commands/operation/diff.rs @@ -282,7 +282,7 @@ pub fn show_op_diff( })?; for (name, (from_target, to_target)) in changed_local_bookmarks { with_content_format.write(formatter, |formatter| { - writeln!(formatter, "{}:", name)?; + writeln!(formatter, "{name}:")?; write_ref_target_summary( formatter, current_repo, @@ -310,7 +310,7 @@ pub fn show_op_diff( with_content_format.write(formatter, |formatter| writeln!(formatter, "Changed tags:"))?; for (name, (from_target, to_target)) in changed_tags { with_content_format.write(formatter, |formatter| { - writeln!(formatter, "{}:", name)?; + writeln!(formatter, "{name}:")?; write_ref_target_summary( formatter, current_repo, @@ -351,7 +351,7 @@ pub fn show_op_diff( }; for ((name, remote_name), (from_ref, to_ref)) in changed_remote_bookmarks { with_content_format.write(formatter, |formatter| { - writeln!(formatter, "{}@{}:", name, remote_name)?; + writeln!(formatter, "{name}@{remote_name}:")?; write_ref_target_summary( formatter, current_repo, @@ -422,7 +422,7 @@ fn write_ref_target_summary( })?; write!(formatter, " ")?; if let Some(prefix) = prefix { - write!(formatter, "{} ", prefix)?; + write!(formatter, "{prefix} ")?; } Ok(()) }; diff --git a/cli/src/commands/sparse.rs b/cli/src/commands/sparse.rs index 84c31d1a35..44c8282f61 100644 --- a/cli/src/commands/sparse.rs +++ b/cli/src/commands/sparse.rs @@ -177,7 +177,7 @@ fn edit_sparse( workspace_relative_sparse_path.display() )) })?; - writeln!(&mut content, "{}", path_string).unwrap(); + writeln!(&mut content, "{path_string}").unwrap(); } let content = edit_temp_file( diff --git a/cli/src/description_util.rs b/cli/src/description_util.rs index 3178646276..e44fa542fb 100644 --- a/cli/src/description_util.rs +++ b/cli/src/description_util.rs @@ -39,10 +39,9 @@ pub fn edit_description( settings: &UserSettings, ) -> Result { let description = format!( - r#"{} + r#"{description} JJ: Lines starting with "JJ: " (like this one) will be removed. -"#, - description +"# ); let description = edit_temp_file( diff --git a/cli/src/formatter.rs b/cli/src/formatter.rs index f487df84da..7df6915ae9 100644 --- a/cli/src/formatter.rs +++ b/cli/src/formatter.rs @@ -395,7 +395,7 @@ impl ColorFormatter { } if let Some(d) = new_debug { if !d.is_empty() { - write!(self.output, "<<{}::", d)?; + write!(self.output, "<<{d}::")?; } self.current_debug = Some(d); } @@ -471,7 +471,7 @@ fn color_for_name_or_hex(name_or_hex: &str) -> Result Ok(Color::Cyan), "bright white" => Ok(Color::White), _ => color_for_hex(name_or_hex) - .ok_or_else(|| config::ConfigError::Message(format!("invalid color: {}", name_or_hex))), + .ok_or_else(|| config::ConfigError::Message(format!("invalid color: {name_or_hex}"))), } } @@ -786,7 +786,7 @@ mod tests { for [label, color] in labels_and_colors { // Use the color name as the label. config_builder = config_builder - .set_override(format!("colors.{}", label), color) + .set_override(format!("colors.{label}"), color) .unwrap(); } let mut output: Vec = vec![]; diff --git a/cli/src/ui.rs b/cli/src/ui.rs index be604b87d0..5b5b85d87f 100644 --- a/cli/src/ui.rs +++ b/cli/src/ui.rs @@ -632,7 +632,7 @@ impl Ui { let default_choice = default.map(|c| if c { "Y" } else { "N" }); let choice = self.prompt_choice( - &format!("{} {}", prompt, default_str), + &format!("{prompt} {default_str}"), &["y", "n", "yes", "no", "Yes", "No", "YES", "NO"], default_choice, )?; diff --git a/cli/testing/fake-formatter.rs b/cli/testing/fake-formatter.rs index f0fa6852c3..952f87a3d3 100644 --- a/cli/testing/fake-formatter.rs +++ b/cli/testing/fake-formatter.rs @@ -70,7 +70,7 @@ fn main() -> ExitCode { let args: Args = Args::parse(); // Code formatters tend to print errors before printing the result. if let Some(data) = args.stderr { - eprint!("{}", data); + eprint!("{data}"); } let stdout = if let Some(data) = args.stdout { // Other content-altering flags don't apply to --stdout. @@ -106,14 +106,14 @@ fn main() -> ExitCode { } stdout }; - print!("{}", stdout); + print!("{stdout}"); if let Some(path) = args.tee { let mut file = OpenOptions::new() .create(true) .append(true) .open(path) .unwrap(); - write!(file, "{}", stdout).unwrap(); + write!(file, "{stdout}").unwrap(); } if args.fail { ExitCode::FAILURE diff --git a/cli/tests/test_diff_command.rs b/cli/tests/test_diff_command.rs index 2c7ae86e0d..f8311d4f23 100644 --- a/cli/tests/test_diff_command.rs +++ b/cli/tests/test_diff_command.rs @@ -433,8 +433,8 @@ fn test_diff_types() { &[ "diff", "--types", - &format!(r#"--from=description("{}")"#, from), - &format!(r#"--to=description("{}")"#, to), + &format!(r#"--from=description("{from}")"#), + &format!(r#"--to=description("{to}")"#), ], ) }; diff --git a/lib/src/default_index/store.rs b/lib/src/default_index/store.rs index df37d421a7..a1dd785bc6 100644 --- a/lib/src/default_index/store.rs +++ b/lib/src/default_index/store.rs @@ -355,8 +355,7 @@ impl IndexStore for DefaultIndexStore { } ReadonlyIndexLoadError::Other { name: _, error } => { eprintln!( - "{err} (maybe the format has changed): {source}. Reindexing...", - source = error + "{err} (maybe the format has changed): {error}. Reindexing..." ); } } diff --git a/lib/src/repo.rs b/lib/src/repo.rs index 0e4220d621..1d89b600ff 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -762,7 +762,7 @@ impl RepoLoader { tx.repo_mut().rebase_descendants(settings)?; } let tx_description = tx_description.map_or_else( - || format!("merge {} operations", num_operations), + || format!("merge {num_operations} operations"), |tx_description| tx_description.to_string(), ); let merged_repo = tx.write(tx_description).leave_unpublished();