From 2b8dabaae45174512e9e62fd926a3364564a012b Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Thu, 3 Nov 2022 21:14:41 -0700 Subject: [PATCH] Fixes suggested by new version of Clippy --- lib/src/git_backend.rs | 4 ++-- lib/src/index.rs | 6 +++--- lib/src/index_store.rs | 6 +++--- lib/src/stacked_table.rs | 4 ++-- testing/fake-diff-editor.rs | 4 ++-- testing/fake-editor.rs | 2 +- tests/test_git_clone.rs | 2 +- tests/test_git_push.rs | 2 +- tests/test_obslog_command.rs | 2 +- tests/test_rebase_command.rs | 2 +- tests/test_touchup_command.rs | 2 +- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/src/git_backend.rs b/lib/src/git_backend.rs index 612bb4d45..ba0ba7918 100644 --- a/lib/src/git_backend.rs +++ b/lib/src/git_backend.rs @@ -65,7 +65,7 @@ impl GitBackend { } pub fn init_internal(store_path: &Path) -> Self { - let git_repo = git2::Repository::init_bare(&store_path.join("git")).unwrap(); + let git_repo = git2::Repository::init_bare(store_path.join("git")).unwrap(); let extra_path = store_path.join("extra"); std::fs::create_dir(&extra_path).unwrap(); let mut git_target_file = File::create(store_path.join("git_target")).unwrap(); @@ -174,7 +174,7 @@ impl Backend for GitBackend { fn git_repo(&self) -> Option { let path = self.repo.lock().unwrap().path().to_owned(); - Some(git2::Repository::open(&path).unwrap()) + Some(git2::Repository::open(path).unwrap()) } fn read_file(&self, _path: &RepoPath, id: &FileId) -> BackendResult> { diff --git a/lib/src/index.rs b/lib/src/index.rs index 3b0994c52..799ba5610 100644 --- a/lib/src/index.rs +++ b/lib/src/index.rs @@ -280,7 +280,7 @@ impl HexPrefix { let bytes = hex::decode(&self.0).unwrap(); (CommitId::new(bytes.clone()), CommitId::new(bytes)) } else { - let min_bytes = hex::decode(&(self.0.clone() + "0")).unwrap(); + let min_bytes = hex::decode(self.0.clone() + "0").unwrap(); let prefix = min_bytes[0..min_bytes.len() - 1].to_vec(); (CommitId::new(prefix), CommitId::new(min_bytes)) } @@ -559,7 +559,7 @@ impl MutableIndex { let mut temp_file = NamedTempFile::new_in(&dir)?; let file = temp_file.as_file_mut(); file.write_all(&buf)?; - persist_content_addressed_temp_file(temp_file, &index_file_path)?; + persist_content_addressed_temp_file(temp_file, index_file_path)?; let mut cursor = Cursor::new(&buf); ReadonlyIndex::load_from(&mut cursor, dir, index_file_id_hex, hash_length).map_err(|err| { @@ -1307,7 +1307,7 @@ impl ReadonlyIndex { file.read_exact(&mut parent_filename_bytes)?; let parent_filename = String::from_utf8(parent_filename_bytes).unwrap(); let parent_file_path = dir.join(&parent_filename); - let mut index_file = File::open(&parent_file_path).unwrap(); + let mut index_file = File::open(parent_file_path).unwrap(); let parent_file = ReadonlyIndex::load_from(&mut index_file, dir, parent_filename, hash_length)?; num_parent_commits = parent_file.num_parent_commits + parent_file.num_local_commits; diff --git a/lib/src/index_store.rs b/lib/src/index_store.rs index 2d07e2283..b03487bdc 100644 --- a/lib/src/index_store.rs +++ b/lib/src/index_store.rs @@ -52,7 +52,7 @@ impl IndexStore { pub fn get_index_at_op(&self, op: &Operation, store: &Arc) -> Arc { let op_id_hex = op.id().hex(); - let op_id_file = self.dir.join("operations").join(&op_id_hex); + let op_id_file = self.dir.join("operations").join(op_id_hex); if op_id_file.exists() { match self.load_index_at_operation(store.hash_length(), op.id()) { Err(IndexLoadError::IndexCorrupt(_)) => { @@ -88,7 +88,7 @@ impl IndexStore { .unwrap(); let index_file_id_hex = String::from_utf8(buf).unwrap(); let index_file_path = self.dir.join(&index_file_id_hex); - let mut index_file = File::open(&index_file_path).unwrap(); + let mut index_file = File::open(index_file_path).unwrap(); ReadonlyIndex::load_from( &mut index_file, self.dir.clone(), @@ -164,7 +164,7 @@ impl IndexStore { file.write_all(index.name().as_bytes())?; persist_content_addressed_temp_file( temp_file, - &self.dir.join("operations").join(op_id.hex()), + self.dir.join("operations").join(op_id.hex()), )?; Ok(()) } diff --git a/lib/src/stacked_table.rs b/lib/src/stacked_table.rs index eb55f380b..5694c9fc4 100644 --- a/lib/src/stacked_table.rs +++ b/lib/src/stacked_table.rs @@ -335,7 +335,7 @@ impl MutableTable { let mut temp_file = NamedTempFile::new_in(&store.dir)?; let file = temp_file.as_file_mut(); file.write_all(&buf)?; - persist_content_addressed_temp_file(temp_file, &file_path)?; + persist_content_addressed_temp_file(temp_file, file_path)?; let mut cursor = Cursor::new(&buf); ReadonlyTable::load_from(&mut cursor, store, file_id_hex, store.key_size) @@ -442,7 +442,7 @@ impl TableStore { } } let table_file_path = self.dir.join(&name); - let mut table_file = File::open(&table_file_path)?; + let mut table_file = File::open(table_file_path)?; let table = ReadonlyTable::load_from(&mut table_file, self, name, self.key_size)?; { let mut write_locked_cache = self.cached_tables.write().unwrap(); diff --git a/testing/fake-diff-editor.rs b/testing/fake-diff-editor.rs index 2cb51f4fc..166dcd10c 100644 --- a/testing/fake-diff-editor.rs +++ b/testing/fake-diff-editor.rs @@ -49,7 +49,7 @@ fn files_recursively(dir: &Path) -> HashSet { fn main() { let args: Args = Args::parse(); let edit_script_path = PathBuf::from(std::env::var_os("DIFF_EDIT_SCRIPT").unwrap()); - let edit_script = String::from_utf8(std::fs::read(&edit_script_path).unwrap()).unwrap(); + let edit_script = String::from_utf8(std::fs::read(edit_script_path).unwrap()).unwrap(); for instruction in edit_script.split('\0') { let (command, payload) = instruction.split_once('\n').unwrap_or((instruction, "")); let parts = command.split(' ').collect_vec(); @@ -83,7 +83,7 @@ fn main() { } ["reset", file] => { if args.before.join(file).exists() { - std::fs::copy(&args.before.join(file), &args.after.join(file)).unwrap(); + std::fs::copy(args.before.join(file), args.after.join(file)).unwrap(); } else { std::fs::remove_file(args.after.join(file)).unwrap(); } diff --git a/testing/fake-editor.rs b/testing/fake-editor.rs index 937d61c5f..14f1e8cab 100644 --- a/testing/fake-editor.rs +++ b/testing/fake-editor.rs @@ -30,7 +30,7 @@ struct Args { fn main() { let args: Args = Args::parse(); let edit_script_path = PathBuf::from(std::env::var_os("EDIT_SCRIPT").unwrap()); - let edit_script = String::from_utf8(std::fs::read(&edit_script_path).unwrap()).unwrap(); + let edit_script = String::from_utf8(std::fs::read(edit_script_path).unwrap()).unwrap(); for instruction in edit_script.split('\0') { let (command, payload) = instruction.split_once('\n').unwrap_or((instruction, "")); let parts = command.split(' ').collect_vec(); diff --git a/tests/test_git_clone.rs b/tests/test_git_clone.rs index 28ad12f2e..3a0166ffe 100644 --- a/tests/test_git_clone.rs +++ b/tests/test_git_clone.rs @@ -20,7 +20,7 @@ pub mod common; fn test_git_clone() { let test_env = TestEnvironment::default(); let git_repo_path = test_env.env_root().join("source"); - let git_repo = git2::Repository::init(&git_repo_path).unwrap(); + let git_repo = git2::Repository::init(git_repo_path).unwrap(); // Clone an empty repo let stdout = test_env.jj_cmd_success(test_env.env_root(), &["git", "clone", "source", "empty"]); diff --git a/tests/test_git_push.rs b/tests/test_git_push.rs index 7b10c7cd8..becc2b923 100644 --- a/tests/test_git_push.rs +++ b/tests/test_git_push.rs @@ -21,7 +21,7 @@ pub mod common; fn set_up() -> (TestEnvironment, PathBuf) { let test_env = TestEnvironment::default(); let git_repo_path = test_env.env_root().join("git-repo"); - let git_repo = git2::Repository::init_bare(&git_repo_path).unwrap(); + let git_repo = git2::Repository::init_bare(git_repo_path).unwrap(); let signature = git2::Signature::new("Some One", "some.one@example.com", &git2::Time::new(0, 0)).unwrap(); let empty_tree_oid = git_repo.treebuilder(None).unwrap().write().unwrap(); diff --git a/tests/test_obslog_command.rs b/tests/test_obslog_command.rs index bb8542fe7..8b20cc3e1 100644 --- a/tests/test_obslog_command.rs +++ b/tests/test_obslog_command.rs @@ -131,7 +131,7 @@ fn test_obslog_squash() { std::fs::write(repo_path.join("file1"), "foo\nbar\n").unwrap(); let edit_script = test_env.set_up_fake_editor(); - std::fs::write(&edit_script, "write\nsquashed").unwrap(); + std::fs::write(edit_script, "write\nsquashed").unwrap(); test_env.jj_cmd_success(&repo_path, &["squash"]); let stdout = get_log_output(&test_env, &repo_path, &["obslog", "-p", "-r", "@-"]); diff --git a/tests/test_rebase_command.rs b/tests/test_rebase_command.rs index f6fba98ed..af4e7ce7c 100644 --- a/tests/test_rebase_command.rs +++ b/tests/test_rebase_command.rs @@ -28,7 +28,7 @@ fn create_commit(test_env: &TestEnvironment, repo_path: &Path, name: &str, paren args.extend(parents); test_env.jj_cmd_success(repo_path, &args); } - std::fs::write(repo_path.join(name), &format!("{name}\n")).unwrap(); + std::fs::write(repo_path.join(name), format!("{name}\n")).unwrap(); test_env.jj_cmd_success(repo_path, &["branch", "create", name]); test_env.jj_cmd_success(repo_path, &["close", "-m", name]); } diff --git a/tests/test_touchup_command.rs b/tests/test_touchup_command.rs index 0bb3adc47..1d0efddcc 100644 --- a/tests/test_touchup_command.rs +++ b/tests/test_touchup_command.rs @@ -120,7 +120,7 @@ fn test_touchup_merge() { // Remove file1. The conflict remains in the working copy on top of the merge. std::fs::write( - &edit_script, + edit_script, "files-before file1\0files-after JJ-INSTRUCTIONS file1 file3\0rm file1", ) .unwrap();