From 3f2ef2ee044f68b5336527c49afb0aa1f8e3ff3d Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Wed, 2 Oct 2024 21:55:56 +0200 Subject: [PATCH] style: add semicolon at the end of expressions used as statements --- Cargo.toml | 1 + cli/src/cli_util.rs | 2 +- cli/src/commands/config/set.rs | 2 +- cli/src/commands/init.rs | 2 +- cli/src/commands/operation/abandon.rs | 2 +- cli/src/commands/status.rs | 2 +- cli/src/config.rs | 4 ++-- cli/src/diff_util.rs | 4 ++-- cli/src/formatter.rs | 2 +- cli/src/merge_tools/builtin.rs | 10 +++++----- cli/src/movement_util.rs | 2 +- cli/src/templater.rs | 2 +- cli/tests/test_git_colocated.rs | 2 +- cli/tests/test_log_command.rs | 2 +- cli/tests/test_next_prev_commands.rs | 2 +- cli/tests/test_parallelize_command.rs | 2 +- cli/tests/test_util_command.rs | 2 +- lib/benches/diff_bench.rs | 2 +- lib/src/commit.rs | 2 +- lib/src/content_hash.rs | 4 ++-- lib/src/default_index/entry.rs | 2 +- lib/src/default_index/revset_graph_iterator.rs | 2 +- lib/src/default_index/store.rs | 2 +- lib/src/diff.rs | 2 +- lib/src/fileset.rs | 2 +- lib/src/git.rs | 4 ++-- lib/src/graph.rs | 2 +- lib/src/local_backend.rs | 4 ++-- lib/src/merge.rs | 4 ++-- lib/src/operation.rs | 2 +- lib/src/simple_op_heads_store.rs | 2 +- lib/tests/test_bad_locking.rs | 2 +- lib/tests/test_conflicts.rs | 12 ++++++------ lib/tests/test_index.rs | 2 +- lib/tests/test_merged_tree.rs | 2 +- 35 files changed, 50 insertions(+), 49 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7f4a09b35..5ea1bcb9d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -134,6 +134,7 @@ testutils = { path = "lib/testutils" } [workspace.lints.clippy] explicit_iter_loop = "warn" +semicolon_if_nothing_returned = "warn" uninlined_format_args = "warn" # Insta suggests compiling these packages in opt mode for faster testing. diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index 7183e9bb7..c283b2b7b 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -254,7 +254,7 @@ impl TracingSubscription { .modify(|filter| { *filter = tracing_subscriber::EnvFilter::builder() .with_default_directive(tracing::metadata::LevelFilter::DEBUG.into()) - .from_env_lossy() + .from_env_lossy(); }) .map_err(|err| internal_error_with_message("failed to enable debug logging", err))?; tracing::info!("debug logging enabled"); diff --git a/cli/src/commands/config/set.rs b/cli/src/commands/config/set.rs index 088f1939a..e4a9106ed 100644 --- a/cli/src/commands/config/set.rs +++ b/cli/src/commands/config/set.rs @@ -100,7 +100,7 @@ fn check_wc_author( AuthorChange::Email => &author.email, }; if new_value.as_str() != Some(orig_value) { - warn_wc_author(ui, &author.name, &author.email)? + warn_wc_author(ui, &author.name, &author.email)?; } } Ok(()) diff --git a/cli/src/commands/init.rs b/cli/src/commands/init.rs index ad2b39efb..d6665bc10 100644 --- a/cli/src/commands/init.rs +++ b/cli/src/commands/init.rs @@ -74,7 +74,7 @@ pub(crate) fn cmd_init( ui.warning_default(), "`--git` and `--git-repo` are deprecated. Use `jj git init` instead" - )? + )?; } else { if !command.settings().allow_native_backend() { return Err(user_error_with_hint( diff --git a/cli/src/commands/operation/abandon.rs b/cli/src/commands/operation/abandon.rs index 89e3142b5..4a8e9ddc0 100644 --- a/cli/src/commands/operation/abandon.rs +++ b/cli/src/commands/operation/abandon.rs @@ -134,7 +134,7 @@ pub fn cmd_op_abandon( let mut locked_ws = workspace.start_working_copy_mutation()?; let old_op_id = locked_ws.locked_wc().old_operation_id(); if let Some((_, new_id)) = reparented_head_ops().find(|(old, _)| old.id() == old_op_id) { - locked_ws.finish(new_id.clone())? + locked_ws.finish(new_id.clone())?; } else { writeln!( ui.warning_default(), diff --git a/cli/src/commands/status.rs b/cli/src/commands/status.rs index 7945294b5..25d0e87e7 100644 --- a/cli/src/commands/status.rs +++ b/cli/src/commands/status.rs @@ -93,7 +93,7 @@ pub(crate) fn cmd_status( formatter.labeled("conflict"), "There are unresolved conflicts at these paths:" )?; - print_conflicted_paths(&conflicts, formatter, &workspace_command)? + print_conflicted_paths(&conflicts, formatter, &workspace_command)?; } let template = workspace_command.commit_summary_template(); diff --git a/cli/src/config.rs b/cli/src/config.rs index 0bf45f2e5..1075cd6ff 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -499,10 +499,10 @@ pub fn default_config() -> config::Config { .add_source(from_toml!("config/revsets.toml")) .add_source(from_toml!("config/templates.toml")); if cfg!(unix) { - builder = builder.add_source(from_toml!("config/unix.toml")) + builder = builder.add_source(from_toml!("config/unix.toml")); } if cfg!(windows) { - builder = builder.add_source(from_toml!("config/windows.toml")) + builder = builder.add_source(from_toml!("config/windows.toml")); } builder.build().unwrap() } diff --git a/cli/src/diff_util.rs b/cli/src/diff_util.rs index 8fcae42d2..48c6dfcb4 100644 --- a/cli/src/diff_util.rs +++ b/cli/src/diff_util.rs @@ -1282,7 +1282,7 @@ fn show_diff_line_tokens( match token_type { DiffTokenType::Matching => formatter.write_all(content)?, DiffTokenType::Different => { - formatter.with_label("token", |formatter| formatter.write_all(content))? + formatter.with_label("token", |formatter| formatter.write_all(content))?; } } } @@ -1402,7 +1402,7 @@ pub fn show_diff_summary( CopyOperation::Rename => ("renamed", "R"), }; let path = path_converter.format_copied_path(before_path, after_path); - writeln!(formatter.labeled(label), "{sigil} {path}")? + writeln!(formatter.labeled(label), "{sigil} {path}")?; } else { let path = path_converter.format_file_path(after_path); match (before.is_present(), after.is_present()) { diff --git a/cli/src/formatter.rs b/cli/src/formatter.rs index 7df6915ae..86db6e56a 100644 --- a/cli/src/formatter.rs +++ b/cli/src/formatter.rs @@ -553,7 +553,7 @@ impl Formatter for ColorFormatter { fn pop_label(&mut self) -> io::Result<()> { self.labels.pop(); if self.labels.is_empty() { - self.write_new_style()? + self.write_new_style()?; } Ok(()) } diff --git a/cli/src/merge_tools/builtin.rs b/cli/src/merge_tools/builtin.rs index 4c10a8c0e..14c7e6171 100644 --- a/cli/src/merge_tools/builtin.rs +++ b/cli/src/merge_tools/builtin.rs @@ -265,7 +265,7 @@ fn make_diff_sections( .split_inclusive('\n') .map(|line| Cow::Owned(line.to_owned())) .collect(), - }) + }); } DiffHunk::Different(sides) => { assert_eq!(sides.len(), 2, "only two inputs were provided to the diff"); @@ -285,7 +285,7 @@ fn make_diff_sections( make_section_changed_lines(right_side, scm_record::ChangeType::Added), ] .concat(), - }) + }); } } } @@ -361,7 +361,7 @@ pub fn make_diff_files( is_checked: false, old_description: None, new_description: Some(Cow::Owned(describe_binary(hash.as_deref(), num_bytes))), - }) + }); } ( @@ -426,7 +426,7 @@ pub fn make_diff_files( is_checked: false, old_description: Some(Cow::Owned(describe_binary(hash.as_deref(), num_bytes))), new_description: None, - }) + }); } } @@ -507,7 +507,7 @@ pub fn apply_diff_builtin( executable: file.get_file_mode() == Some(scm_record::FileMode(mode::EXECUTABLE)), }), - ) + ); } } } diff --git a/cli/src/movement_util.rs b/cli/src/movement_util.rs index ce197f7e6..eadc059a3 100644 --- a/cli/src/movement_util.rs +++ b/cli/src/movement_util.rs @@ -109,7 +109,7 @@ impl Direction { write!(formatter, "Working copy parent: ")?; } template.format(commit, formatter) - }) + }); }); cmd_err diff --git a/cli/src/templater.rs b/cli/src/templater.rs index a8332fd9a..2dd28e27c 100644 --- a/cli/src/templater.rs +++ b/cli/src/templater.rs @@ -206,7 +206,7 @@ pub struct ConcatTemplate(pub Vec); impl Template for ConcatTemplate { fn format(&self, formatter: &mut TemplateFormatter) -> io::Result<()> { for template in &self.0 { - template.format(formatter)? + template.format(formatter)?; } Ok(()) } diff --git a/cli/tests/test_git_colocated.rs b/cli/tests/test_git_colocated.rs index 5d3f9725e..1fc33b3ac 100644 --- a/cli/tests/test_git_colocated.rs +++ b/cli/tests/test_git_colocated.rs @@ -618,7 +618,7 @@ fn test_git_colocated_external_checkout() { let git_check_out_ref = |name| { git_repo .set_head_detached(git_repo.find_reference(name).unwrap().target().unwrap()) - .unwrap() + .unwrap(); }; test_env.jj_cmd_ok(&repo_path, &["git", "init", "--git-repo=."]); diff --git a/cli/tests/test_log_command.rs b/cli/tests/test_log_command.rs index 63413846b..dd17b13f8 100644 --- a/cli/tests/test_log_command.rs +++ b/cli/tests/test_log_command.rs @@ -328,7 +328,7 @@ fn test_log_null_terminate_multiline_descriptions() { insta::assert_debug_snapshot!( stdout, @r###""commit 3 line 1\n\ncommit 3 line 2\n\0commit 2 line 1\n\ncommit 2 line 2\n\0commit 1 line 1\n\ncommit 1 line 2\n\0""### - ) + ); } #[test] diff --git a/cli/tests/test_next_prev_commands.rs b/cli/tests/test_next_prev_commands.rs index 6d7f8b5b1..cda696f98 100644 --- a/cli/tests/test_next_prev_commands.rs +++ b/cli/tests/test_next_prev_commands.rs @@ -610,7 +610,7 @@ fn test_prev_prompts_on_multiple_parents() { Hint: Working copy parent: mzvwutvl bc4f4fe3 (empty) third Hint: Working copy parent: kkmpptxz b0d21db3 (empty) second Hint: Working copy parent: qpvuntsm fa15625b (empty) first - "###) + "###); } #[test] diff --git a/cli/tests/test_parallelize_command.rs b/cli/tests/test_parallelize_command.rs index 214cc8578..8928437b7 100644 --- a/cli/tests/test_parallelize_command.rs +++ b/cli/tests/test_parallelize_command.rs @@ -628,7 +628,7 @@ fn test_parallelize_complex_nonlinear_target() { │ ○ 14ca4df576b3 4 parents: ├─╯ ◆ 000000000000 parents: - "###) + "###); } fn get_log_output(test_env: &TestEnvironment, cwd: &Path) -> String { diff --git a/cli/tests/test_util_command.rs b/cli/tests/test_util_command.rs index 5c9a5e4f3..dc3f3563c 100644 --- a/cli/tests/test_util_command.rs +++ b/cli/tests/test_util_command.rs @@ -34,7 +34,7 @@ fn test_util_config_schema() { [...] } } - "###) + "###); }); } diff --git a/lib/benches/diff_bench.rs b/lib/benches/diff_bench.rs index 2987760be..d0cddebb3 100644 --- a/lib/benches/diff_bench.rs +++ b/lib/benches/diff_bench.rs @@ -197,7 +197,7 @@ int main(int argc, char **argv) } "##, ]) - }) + }); }); } diff --git a/lib/src/commit.rs b/lib/src/commit.rs index ae03c8b23..9d5f210b3 100644 --- a/lib/src/commit.rs +++ b/lib/src/commit.rs @@ -72,7 +72,7 @@ impl PartialOrd for Commit { impl Hash for Commit { fn hash(&self, state: &mut H) { - self.id.hash(state) + self.id.hash(state); } } diff --git a/lib/src/content_hash.rs b/lib/src/content_hash.rs index 7ab11dcfc..68ad1d56a 100644 --- a/lib/src/content_hash.rs +++ b/lib/src/content_hash.rs @@ -81,7 +81,7 @@ impl ContentHash for [T] { impl ContentHash for Vec { fn hash(&self, state: &mut impl DigestUpdate) { - self.as_slice().hash(state) + self.as_slice().hash(state); } } @@ -97,7 +97,7 @@ impl ContentHash for Option { None => state.update(&0u32.to_le_bytes()), Some(x) => { state.update(&1u32.to_le_bytes()); - x.hash(state) + x.hash(state); } } } diff --git a/lib/src/default_index/entry.rs b/lib/src/default_index/entry.rs index b6ea98457..a598b0d65 100644 --- a/lib/src/default_index/entry.rs +++ b/lib/src/default_index/entry.rs @@ -73,7 +73,7 @@ impl Eq for IndexEntry<'_> {} impl Hash for IndexEntry<'_> { fn hash(&self, state: &mut H) { - self.pos.hash(state) + self.pos.hash(state); } } diff --git a/lib/src/default_index/revset_graph_iterator.rs b/lib/src/default_index/revset_graph_iterator.rs index fd5c2e5ad..fc807cffa 100644 --- a/lib/src/default_index/revset_graph_iterator.rs +++ b/lib/src/default_index/revset_graph_iterator.rs @@ -183,7 +183,7 @@ impl<'a> RevsetGraphWalk<'a> { parent_edges .iter() .filter(|edge| known_ancestors.insert(edge.target)), - ) + ); } } } diff --git a/lib/src/default_index/store.rs b/lib/src/default_index/store.rs index 28a50af5f..8c516a0de 100644 --- a/lib/src/default_index/store.rs +++ b/lib/src/default_index/store.rs @@ -233,7 +233,7 @@ impl DefaultIndexStore { change_id_length, )?; maybe_parent_file = Some(parent_file.clone()); - mutable_index = DefaultMutableIndex::incremental(parent_file) + mutable_index = DefaultMutableIndex::incremental(parent_file); } } diff --git a/lib/src/diff.rs b/lib/src/diff.rs index 48a20d353..5eab27eff 100644 --- a/lib/src/diff.rs +++ b/lib/src/diff.rs @@ -745,7 +745,7 @@ mod tests { #[test] fn test_find_word_ranges_multibyte() { - assert_eq!(find_word_ranges("⊢".as_bytes()), vec![0..3]) + assert_eq!(find_word_ranges("⊢".as_bytes()), vec![0..3]); } #[test] diff --git a/lib/src/fileset.rs b/lib/src/fileset.rs index a7136b037..dae932a6f 100644 --- a/lib/src/fileset.rs +++ b/lib/src/fileset.rs @@ -328,7 +328,7 @@ fn build_union_matcher(expressions: &[FilesetExpression]) -> Box { FilePattern::FilePath(path) => file_paths.push(path), FilePattern::PrefixPath(path) => prefix_paths.push(path), FilePattern::FileGlob { dir, pattern } => { - file_globs.push((dir, pattern.clone())) + file_globs.push((dir, pattern.clone())); } } continue; diff --git a/lib/src/git.rs b/lib/src/git.rs index 5de8c695f..1517456a5 100644 --- a/lib/src/git.rs +++ b/lib/src/git.rs @@ -1782,10 +1782,10 @@ pub fn parse_gitmodules( // TODO Git warns when a duplicate config entry is found, we should // consider doing the same. ("path", PartialSubmoduleConfig { path: None, .. }) => { - map_entry.path = Some(config_value.to_string()) + map_entry.path = Some(config_value.to_string()); } ("url", PartialSubmoduleConfig { url: None, .. }) => { - map_entry.url = Some(config_value.to_string()) + map_entry.url = Some(config_value.to_string()); } _ => (), }; diff --git a/lib/src/graph.rs b/lib/src/graph.rs index e68c952d4..9b1067ab0 100644 --- a/lib/src/graph.rs +++ b/lib/src/graph.rs @@ -85,7 +85,7 @@ where reverse_edges.entry(target).or_default().push(GraphEdge { target: node.clone(), edge_type, - }) + }); } entries.push(node); } diff --git a/lib/src/local_backend.rs b/lib/src/local_backend.rs index 49ca108f7..36020f00c 100644 --- a/lib/src/local_backend.rs +++ b/lib/src/local_backend.rs @@ -513,10 +513,10 @@ fn conflict_to_proto(conflict: &Conflict) -> crate::protos::local_store::Conflic fn conflict_from_proto(proto: crate::protos::local_store::Conflict) -> Conflict { let mut conflict = Conflict::default(); for term in proto.removes { - conflict.removes.push(conflict_term_from_proto(term)) + conflict.removes.push(conflict_term_from_proto(term)); } for term in proto.adds { - conflict.adds.push(conflict_term_from_proto(term)) + conflict.adds.push(conflict_term_from_proto(term)); } conflict } diff --git a/lib/src/merge.rs b/lib/src/merge.rs index dd9fd51cb..286dac1f4 100644 --- a/lib/src/merge.rs +++ b/lib/src/merge.rs @@ -424,7 +424,7 @@ impl FromIterator for MergeBuilder { impl Extend for MergeBuilder { fn extend>(&mut self, iter: I) { - self.values.extend(iter) + self.values.extend(iter); } } @@ -512,7 +512,7 @@ impl Merge> { impl ContentHash for Merge { fn hash(&self, state: &mut impl DigestUpdate) { - self.values.hash(state) + self.values.hash(state); } } diff --git a/lib/src/operation.rs b/lib/src/operation.rs index 9ab588dcb..9e916f3c9 100644 --- a/lib/src/operation.rs +++ b/lib/src/operation.rs @@ -67,7 +67,7 @@ impl PartialOrd for Operation { impl Hash for Operation { fn hash(&self, state: &mut H) { - self.id.hash(state) + self.id.hash(state); } } diff --git a/lib/src/simple_op_heads_store.rs b/lib/src/simple_op_heads_store.rs index e4b05a1c1..72bc4e6c8 100644 --- a/lib/src/simple_op_heads_store.rs +++ b/lib/src/simple_op_heads_store.rs @@ -87,7 +87,7 @@ impl OpHeadsStore for SimpleOpHeadsStore { assert!(!old_ids.contains(new_id)); self.add_op_head(new_id); for old_id in old_ids { - self.remove_op_head(old_id) + self.remove_op_head(old_id); } } diff --git a/lib/tests/test_bad_locking.rs b/lib/tests/test_bad_locking.rs index 9e43ddb2b..2fb3ca487 100644 --- a/lib/tests/test_bad_locking.rs +++ b/lib/tests/test_bad_locking.rs @@ -32,7 +32,7 @@ fn copy_directory(src: &Path, dst: &Path) { let base_name = child_src.file_name().unwrap(); let child_dst = dst.join(base_name); if child_src.is_dir() { - copy_directory(&child_src, &child_dst) + copy_directory(&child_src, &child_dst); } else { std::fs::copy(&child_src, &child_dst).unwrap(); } diff --git a/lib/tests/test_conflicts.rs b/lib/tests/test_conflicts.rs index e5d23a530..75066a94e 100644 --- a/lib/tests/test_conflicts.rs +++ b/lib/tests/test_conflicts.rs @@ -535,7 +535,7 @@ line 5 2 ), None - ) + ); } #[test] @@ -631,7 +631,7 @@ fn test_parse_conflict_simple() { 2 ), @"None" - ) + ); } #[test] @@ -746,7 +746,7 @@ fn test_parse_conflict_wrong_arity() { 3 ), None - ) + ); } #[test] @@ -767,7 +767,7 @@ fn test_parse_conflict_malformed_missing_removes() { 2 ), None - ) + ); } #[test] @@ -790,7 +790,7 @@ fn test_parse_conflict_malformed_marker() { 2 ), None - ) + ); } #[test] @@ -814,7 +814,7 @@ fn test_parse_conflict_malformed_diff() { 2 ), None - ) + ); } #[test] diff --git a/lib/tests/test_index.rs b/lib/tests/test_index.rs index ed68d3420..a5d8891e4 100644 --- a/lib/tests/test_index.rs +++ b/lib/tests/test_index.rs @@ -650,7 +650,7 @@ fn test_reindex_corrupt_segment_files() { // u32: number of local change ids // u32: number of overflow parent entries // u32: number of overflow change id positions - fs::write(entry.path(), b"\0".repeat(24)).unwrap() + fs::write(entry.path(), b"\0".repeat(24)).unwrap(); } let repo = load_repo_at_head(&settings, test_repo.repo_path()); diff --git a/lib/tests/test_merged_tree.rs b/lib/tests/test_merged_tree.rs index 4ba8a55f5..8ef86e88b 100644 --- a/lib/tests/test_merged_tree.rs +++ b/lib/tests/test_merged_tree.rs @@ -541,7 +541,7 @@ fn test_resolve_with_conflict() { vec![expected_base1], vec![expected_side1, expected_side2] )) - ) + ); } #[test]