cleanup: fix warnings from nightly clippy

This commit is contained in:
Martin von Zweigbergk 2023-08-14 20:18:52 -07:00 committed by Martin von Zweigbergk
parent 9a2a8f85a7
commit f1b817e8ca
12 changed files with 44 additions and 41 deletions

View file

@ -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(

View file

@ -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"]);

View file

@ -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])
}

View file

@ -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()

View file

@ -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])
}

View file

@ -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"]);

View file

@ -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.

View file

@ -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

View file

@ -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()"])
}

View file

@ -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.

View file

@ -918,9 +918,9 @@ fn collect_function_names(aliases_map: &RevsetAliasesMap) -> Vec<String> {
fn collect_similar(name: &str, candidates: &[impl AsRef<str>]) -> Vec<String> {
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()

View file

@ -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(|| {