From 0b528eb587b92785792dd9155cd6f27b304312fe Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Tue, 22 Nov 2022 20:47:53 -0800 Subject: [PATCH] Fix some `cargo +nightly clippy` warnings --- lib/src/file_util.rs | 2 +- lib/src/git.rs | 2 +- lib/src/simple_op_store.rs | 4 ++-- src/ui.rs | 2 +- tests/test_commit_command.rs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/src/file_util.rs b/lib/src/file_util.rs index 42502f527..51bdb0b03 100644 --- a/lib/src/file_util.rs +++ b/lib/src/file_util.rs @@ -112,7 +112,7 @@ mod tests { let target = temp_dir.path().join("file"); let mut temp_file = NamedTempFile::new_in(&temp_dir).unwrap(); temp_file.write_all(b"contents").unwrap(); - assert!(persist_content_addressed_temp_file(temp_file, &target).is_ok()); + assert!(persist_content_addressed_temp_file(temp_file, target).is_ok()); } #[test_case(false ; "existing file open")] diff --git a/lib/src/git.rs b/lib/src/git.rs index 56190c0d2..617a5efd1 100644 --- a/lib/src/git.rs +++ b/lib/src/git.rs @@ -303,7 +303,7 @@ fn upgrade_old_export_state(repo: &Arc) { if let Ok(mut last_export_file) = OpenOptions::new() .write(true) .create(true) - .open(&repo.repo_path().join("git_export_view")) + .open(repo.repo_path().join("git_export_view")) { let thrift_view = simple_op_store_model::View::from(&last_export_store_view); simple_op_store::write_thrift(&thrift_view, &mut last_export_file) diff --git a/lib/src/simple_op_store.rs b/lib/src/simple_op_store.rs index 98f61ae16..ea2902f33 100644 --- a/lib/src/simple_op_store.rs +++ b/lib/src/simple_op_store.rs @@ -122,7 +122,7 @@ fn upgrade_to_thrift(store_path: PathBuf) -> std::io::Result<()> { fs::write(tmp_store_path.join("thrift_store"), "")?; let backup_store_path = store_path.parent().unwrap().join("op_store_old"); - fs::rename(&store_path, &backup_store_path)?; + fs::rename(&store_path, backup_store_path)?; fs::rename(&tmp_store_path, &store_path)?; // Update the pointers to the head(s) of the operation log @@ -157,7 +157,7 @@ fn upgrade_to_thrift(store_path: PathBuf) -> std::io::Result<()> { // Update the pointer to the last operation exported to Git let git_export_path = store_path.parent().unwrap().join("git_export_operation_id"); if let Ok(op_id_string) = fs::read_to_string(&git_export_path) { - if let Ok(op_id_bytes) = hex::decode(&op_id_string) { + if let Ok(op_id_bytes) = hex::decode(op_id_string) { let old_op_id = OperationId::new(op_id_bytes); let new_op_id = converted.get(&old_op_id).unwrap(); fs::write(&git_export_path, new_op_id.hex())?; diff --git a/src/ui.rs b/src/ui.rs index 02dd21daf..0e3280efd 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -228,7 +228,7 @@ impl Ui { "Cannot prompt for input since the output is not connected to a terminal", )); } - rpassword::prompt_password(&format!("{}: ", prompt)) + rpassword::prompt_password(format!("{prompt}: ")) } pub fn size(&self) -> Option<(u16, u16)> { diff --git a/tests/test_commit_command.rs b/tests/test_commit_command.rs index 0979c9279..c9fd97175 100644 --- a/tests/test_commit_command.rs +++ b/tests/test_commit_command.rs @@ -44,7 +44,7 @@ fn test_commit_with_editor() { test_env.jj_cmd_success(&workspace_path, &["describe", "-m=initial"]); let edit_script = test_env.set_up_fake_editor(); std::fs::write( - &edit_script, + edit_script, "expect initial JJ: Lines starting with \"JJ: \" (like this one) will be removed.