diff --git a/cli/src/config.rs b/cli/src/config.rs index 2ad5599dc..bd151d244 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -943,7 +943,7 @@ mod tests { let (want_existing, want_new) = match self.want { Want::None => (None, None), Want::New(want) => (None, Some(want)), - Want::ExistingAndNew(want) => (Some(want.clone()), Some(want)), + Want::ExistingAndNew(want) => (Some(want), Some(want)), }; check( diff --git a/cli/tests/test_config_command.rs b/cli/tests/test_config_command.rs index f07d6374a..1ca7a2de1 100644 --- a/cli/tests/test_config_command.rs +++ b/cli/tests/test_config_command.rs @@ -23,10 +23,10 @@ pub mod common; fn test_config_list_single() { let test_env = TestEnvironment::default(); test_env.add_config( - r###" + r#" [test-table] somekey = "some value" - "###, + "#, ); let stdout = test_env.jj_cmd_success( @@ -55,12 +55,12 @@ fn test_config_list_nonexistent() { fn test_config_list_table() { let test_env = TestEnvironment::default(); test_env.add_config( - r###" + r#" [test-table] x = true y.foo = "abc" y.bar = 123 - "###, + "#, ); let stdout = test_env.jj_cmd_success(test_env.env_root(), &["config", "list", "test-table"]); insta::assert_snapshot!( @@ -76,9 +76,9 @@ fn test_config_list_table() { fn test_config_list_array() { let test_env = TestEnvironment::default(); test_env.add_config( - r###" + r#" test-array = [1, "b", 3.4] - "###, + "#, ); let stdout = test_env.jj_cmd_success(test_env.env_root(), &["config", "list", "test-array"]); insta::assert_snapshot!(stdout, @r###" @@ -90,12 +90,12 @@ fn test_config_list_array() { fn test_config_list_inline_table() { let test_env = TestEnvironment::default(); test_env.add_config( - r###" + r#" [[test-table]] x = 1 [[test-table]] y = ["z"] - "###, + "#, ); let stdout = test_env.jj_cmd_success(test_env.env_root(), &["config", "list", "test-table"]); insta::assert_snapshot!(stdout, @r###" @@ -107,13 +107,13 @@ fn test_config_list_inline_table() { fn test_config_list_all() { let test_env = TestEnvironment::default(); test_env.add_config( - r###" + r#" test-val = [1, 2, 3] [test-table] x = true y.foo = "abc" y.bar = 123 - "###, + "#, ); let stdout = test_env.jj_cmd_success(test_env.env_root(), &["config", "list"]); insta::assert_snapshot!( @@ -439,19 +439,19 @@ fn test_config_edit_repo_outside_repo() { fn test_config_get() { let test_env = TestEnvironment::default(); test_env.add_config( - r###" + r#" [table] string = "some value 1" int = 123 list = ["list", "value"] overridden = "foo" - "###, + "#, ); test_env.add_config( - r###" + r#" [table] overridden = "bar" - "###, + "#, ); let stdout = test_env.jj_cmd_failure(test_env.env_root(), &["config", "get", "nonexistent"]); diff --git a/cli/tests/test_duplicate_command.rs b/cli/tests/test_duplicate_command.rs index 8acf180fc..0f5e61752 100644 --- a/cli/tests/test_duplicate_command.rs +++ b/cli/tests/test_duplicate_command.rs @@ -328,8 +328,8 @@ fn get_log_output(test_env: &TestEnvironment, repo_path: &Path) -> String { } fn get_log_output_with_ts(test_env: &TestEnvironment, repo_path: &Path) -> String { - let template = r###" + let template = r#" commit_id.short() ++ " " ++ description.first_line() ++ " @ " ++ committer.timestamp() - "###; + "#; test_env.jj_cmd_success(repo_path, &["log", "-T", template]) } diff --git a/cli/tests/test_git_clone.rs b/cli/tests/test_git_clone.rs index 260e40963..be0621886 100644 --- a/cli/tests/test_git_clone.rs +++ b/cli/tests/test_git_clone.rs @@ -198,6 +198,8 @@ fn test_git_clone_colocate() { .symbolic_target() ); // ".jj" directory should be ignored at Git side. + #[allow(unknown_lints)] // Needed for clippy <=1.71 + #[allow(clippy::format_collect)] let git_statuses: String = jj_git_repo .statuses(None) .unwrap() diff --git a/cli/tests/test_git_colocated.rs b/cli/tests/test_git_colocated.rs index 4a86c0f49..eb73e687b 100644 --- a/cli/tests/test_git_colocated.rs +++ b/cli/tests/test_git_colocated.rs @@ -378,7 +378,7 @@ fn test_git_colocated_squash_undo() { } fn get_log_output_divergence(test_env: &TestEnvironment, repo_path: &Path) -> String { - let template = r###" + let template = r#" separate(" ", change_id.short(), commit_id.short(), @@ -387,7 +387,7 @@ fn get_log_output_divergence(test_env: &TestEnvironment, repo_path: &Path) -> St git_head, if(divergent, "!divergence!"), ) - "###; + "#; test_env.jj_cmd_success(repo_path, &["log", "-T", template]) } diff --git a/cli/tests/test_log_command.rs b/cli/tests/test_log_command.rs index 52cf81186..dd2eb9d2d 100644 --- a/cli/tests/test_log_command.rs +++ b/cli/tests/test_log_command.rs @@ -328,10 +328,10 @@ fn test_log_shortest_accessors() { ) }; test_env.add_config( - r###" + r#" [template-aliases] 'format_id(id)' = 'id.shortest(12).prefix() ++ "[" ++ id.shortest(12).rest() ++ "]"' - "###, + "#, ); std::fs::write(repo_path.join("file"), "original file\n").unwrap(); @@ -561,15 +561,15 @@ fn test_log_prefix_highlight_counts_hidden_commits() { test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]); let repo_path = test_env.env_root().join("repo"); test_env.add_config( - r###" + r#" [revsets] short-prefixes = "" # Disable short prefixes [template-aliases] 'format_id(id)' = 'id.shortest(12).prefix() ++ "[" ++ id.shortest(12).rest() ++ "]"' - "###, + "#, ); - let prefix_format = r###" + let prefix_format = r#" separate(" ", "Change", format_id(change_id), @@ -577,7 +577,7 @@ fn test_log_prefix_highlight_counts_hidden_commits() { format_id(commit_id), branches, ) - "###; + "#; std::fs::write(repo_path.join("file"), "original file\n").unwrap(); test_env.jj_cmd_success(&repo_path, &["describe", "-m", "initial"]); diff --git a/cli/tests/test_revset_output.rs b/cli/tests/test_revset_output.rs index 0476833dd..7e659f5b4 100644 --- a/cli/tests/test_revset_output.rs +++ b/cli/tests/test_revset_output.rs @@ -374,12 +374,12 @@ fn test_bad_alias_decl() { let repo_path = test_env.env_root().join("repo"); test_env.add_config( - r###" + r#" [revset-aliases] 'my-root' = 'root' '"bad"' = 'root' 'badfn(a, a)' = 'root' - "###, + "#, ); // Invalid declaration should be warned and ignored. diff --git a/cli/tests/test_templater.rs b/cli/tests/test_templater.rs index 70fdb8c2c..583a8c8f3 100644 --- a/cli/tests/test_templater.rs +++ b/cli/tests/test_templater.rs @@ -429,11 +429,11 @@ fn test_templater_timestamp_method() { let render_err = |template| test_env.jj_cmd_failure(&repo_path, &["log", "-T", template]); test_env.add_config( - r###" + r#" [template-aliases] 'time_format' = '"%Y-%m-%d"' 'bad_time_format' = '"%_"' - "###, + "#, ); insta::assert_snapshot!( @@ -815,10 +815,10 @@ fn test_templater_alias_override() { let repo_path = test_env.env_root().join("repo"); test_env.add_config( - r###" + r#" [template-aliases] 'f(x)' = '"user"' - "###, + "#, ); // 'f(x)' should be overridden by --config-toml 'f(a)'. If aliases were sorted diff --git a/cli/tests/test_workspaces.rs b/cli/tests/test_workspaces.rs index adb7b70ad..33cdcb570 100644 --- a/cli/tests/test_workspaces.rs +++ b/cli/tests/test_workspaces.rs @@ -412,12 +412,12 @@ fn test_workspaces_root() { } fn get_log_output(test_env: &TestEnvironment, cwd: &Path) -> String { - let template = r###" + let template = r#" separate(" ", commit_id, working_copies, if(divergent, "(divergent)"), ) - "###; + "#; test_env.jj_cmd_success(cwd, &["log", "-T", template, "-r", "all()"]) } diff --git a/lib/src/git.rs b/lib/src/git.rs index 163f15d5a..4180827f6 100644 --- a/lib/src/git.rs +++ b/lib/src/git.rs @@ -572,7 +572,8 @@ pub fn remove_remote( .view() .git_refs() .keys() - .filter_map(|r| r.starts_with(&prefix).then(|| r.clone())) + .filter(|&r| r.starts_with(&prefix)) + .cloned() .collect_vec(); for branch in branches_to_delete { mut_repo.set_remote_branch_target(&branch, remote_name, RefTarget::absent()); @@ -679,7 +680,8 @@ pub fn fetch( .view() .branches() .iter() - .filter_map(|(branch, target)| target.local_target.is_present().then(|| branch.to_owned())) + .filter(|&(_branch, target)| target.local_target.is_present()) + .map(|(branch, _target)| branch.to_owned()) .collect(); // TODO: Inform the user if the export failed? In most cases, export is not // essential for fetch to work. diff --git a/lib/src/revset.rs b/lib/src/revset.rs index b854844f9..2e3af26af 100644 --- a/lib/src/revset.rs +++ b/lib/src/revset.rs @@ -918,9 +918,9 @@ fn collect_function_names(aliases_map: &RevsetAliasesMap) -> Vec { fn collect_similar(name: &str, candidates: &[impl AsRef]) -> Vec { candidates .iter() - .filter_map(|cand| { + .filter(|cand| { // The parameter is borrowed from clap f5540d26 - (strsim::jaro(name, cand.as_ref()) > 0.7).then_some(cand) + strsim::jaro(name, cand.as_ref()) > 0.7 }) .map(|s| s.as_ref().to_owned()) .collect_vec() diff --git a/lib/src/working_copy.rs b/lib/src/working_copy.rs index ae85663aa..d799ab882 100644 --- a/lib/src/working_copy.rs +++ b/lib/src/working_copy.rs @@ -666,11 +666,10 @@ impl TreeState { trace_span!("collecting existing files").in_scope(|| { self.file_states .iter() - .filter_map(|(path, state)| { - (fsmonitor_matcher.matches(path) - && state.file_type != FileType::GitSubmodule) - .then(|| path.clone()) + .filter(|&(path, state)| { + fsmonitor_matcher.matches(path) && state.file_type != FileType::GitSubmodule }) + .map(|(path, _state)| path.clone()) .collect() }); trace_span!("process tree entries").in_scope(|| {