ok/jj
1
0
Fork 0
forked from mirrors/jj

style: add semicolon at the end of expressions used as statements

This commit is contained in:
Samuel Tardieu 2024-10-02 21:55:56 +02:00
parent 46e2723464
commit 3f2ef2ee04
35 changed files with 50 additions and 49 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -553,7 +553,7 @@ impl<W: Write> Formatter for ColorFormatter<W> {
fn pop_label(&mut self) -> io::Result<()> {
self.labels.pop();
if self.labels.is_empty() {
self.write_new_style()?
self.write_new_style()?;
}
Ok(())
}

View file

@ -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)),
}),
)
);
}
}
}

View file

@ -109,7 +109,7 @@ impl Direction {
write!(formatter, "Working copy parent: ")?;
}
template.format(commit, formatter)
})
});
});
cmd_err

View file

@ -206,7 +206,7 @@ pub struct ConcatTemplate<T>(pub Vec<T>);
impl<T: Template> Template for ConcatTemplate<T> {
fn format(&self, formatter: &mut TemplateFormatter) -> io::Result<()> {
for template in &self.0 {
template.format(formatter)?
template.format(formatter)?;
}
Ok(())
}

View file

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

View file

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

View file

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

View file

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

View file

@ -34,7 +34,7 @@ fn test_util_config_schema() {
[...]
}
}
"###)
"###);
});
}

View file

@ -197,7 +197,7 @@ int main(int argc, char **argv)
}
"##,
])
})
});
});
}

View file

@ -72,7 +72,7 @@ impl PartialOrd for Commit {
impl Hash for Commit {
fn hash<H: Hasher>(&self, state: &mut H) {
self.id.hash(state)
self.id.hash(state);
}
}

View file

@ -81,7 +81,7 @@ impl<T: ContentHash> ContentHash for [T] {
impl<T: ContentHash> ContentHash for Vec<T> {
fn hash(&self, state: &mut impl DigestUpdate) {
self.as_slice().hash(state)
self.as_slice().hash(state);
}
}
@ -97,7 +97,7 @@ impl<T: ContentHash> ContentHash for Option<T> {
None => state.update(&0u32.to_le_bytes()),
Some(x) => {
state.update(&1u32.to_le_bytes());
x.hash(state)
x.hash(state);
}
}
}

View file

@ -73,7 +73,7 @@ impl Eq for IndexEntry<'_> {}
impl Hash for IndexEntry<'_> {
fn hash<H: Hasher>(&self, state: &mut H) {
self.pos.hash(state)
self.pos.hash(state);
}
}

View file

@ -183,7 +183,7 @@ impl<'a> RevsetGraphWalk<'a> {
parent_edges
.iter()
.filter(|edge| known_ancestors.insert(edge.target)),
)
);
}
}
}

View file

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

View file

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

View file

@ -328,7 +328,7 @@ fn build_union_matcher(expressions: &[FilesetExpression]) -> Box<dyn Matcher> {
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;

View file

@ -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());
}
_ => (),
};

View file

@ -85,7 +85,7 @@ where
reverse_edges.entry(target).or_default().push(GraphEdge {
target: node.clone(),
edge_type,
})
});
}
entries.push(node);
}

View file

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

View file

@ -424,7 +424,7 @@ impl<T> FromIterator<T> for MergeBuilder<T> {
impl<T> Extend<T> for MergeBuilder<T> {
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
self.values.extend(iter)
self.values.extend(iter);
}
}
@ -512,7 +512,7 @@ impl<T> Merge<Merge<T>> {
impl<T: ContentHash> ContentHash for Merge<T> {
fn hash(&self, state: &mut impl DigestUpdate) {
self.values.hash(state)
self.values.hash(state);
}
}

View file

@ -67,7 +67,7 @@ impl PartialOrd for Operation {
impl Hash for Operation {
fn hash<H: Hasher>(&self, state: &mut H) {
self.id.hash(state)
self.id.hash(state);
}
}

View file

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

View file

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

View file

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

View file

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

View file

@ -541,7 +541,7 @@ fn test_resolve_with_conflict() {
vec![expected_base1],
vec![expected_side1, expected_side2]
))
)
);
}
#[test]