From 289eddd9beeffeb57ca3ae9f55380dd05996c23a Mon Sep 17 00:00:00 2001 From: extrawurst Date: Sat, 10 Dec 2022 11:27:59 +0100 Subject: [PATCH] fix nightly clippy --- asyncgit/src/sync/blame.rs | 9 +++---- asyncgit/src/sync/commit.rs | 16 ++++++------ asyncgit/src/sync/commit_details.rs | 2 +- asyncgit/src/sync/commit_files.rs | 10 ++++---- asyncgit/src/sync/commits_info.rs | 8 +++--- asyncgit/src/sync/diff.rs | 21 +++++++--------- asyncgit/src/sync/hunks.rs | 2 +- asyncgit/src/sync/ignore.rs | 16 ++++++------ asyncgit/src/sync/logwalker.rs | 15 ++++++------ asyncgit/src/sync/remotes/push.rs | 3 +-- asyncgit/src/sync/reset.rs | 38 ++++++++++++++--------------- asyncgit/src/sync/stash.rs | 10 ++++---- asyncgit/src/sync/utils.rs | 20 +++++++-------- src/app.rs | 3 +-- src/components/blame_file.rs | 11 ++------- src/components/branchlist.rs | 6 +---- src/components/commit.rs | 9 +++---- src/components/diff.rs | 3 +-- src/components/revision_files.rs | 6 +---- src/components/status_tree.rs | 5 +--- src/components/syntax_text.rs | 3 +-- src/strings.rs | 11 +++------ src/tabs/status.rs | 6 ++--- 23 files changed, 98 insertions(+), 135 deletions(-) diff --git a/asyncgit/src/sync/blame.rs b/asyncgit/src/sync/blame.rs index eba952fcb7..92edc991d0 100644 --- a/asyncgit/src/sync/blame.rs +++ b/asyncgit/src/sync/blame.rs @@ -172,8 +172,7 @@ mod tests { assert!(matches!(blame_file(repo_path, "foo", None), Err(_))); - File::create(&root.join(file_path))? - .write_all(b"line 1\n")?; + File::create(root.join(file_path))?.write_all(b"line 1\n")?; stage_add_file(repo_path, file_path)?; commit(repo_path, "first commit")?; @@ -195,7 +194,7 @@ mod tests { let mut file = OpenOptions::new() .append(true) - .open(&root.join(file_path))?; + .open(root.join(file_path))?; file.write(b"line 2\n")?; @@ -251,9 +250,9 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - std::fs::create_dir(&root.join("bar")).unwrap(); + std::fs::create_dir(root.join("bar")).unwrap(); - File::create(&root.join(file_path)) + File::create(root.join(file_path)) .unwrap() .write_all(b"line 1\n") .unwrap(); diff --git a/asyncgit/src/sync/commit.rs b/asyncgit/src/sync/commit.rs index 07d98feb30..d1af74d85d 100644 --- a/asyncgit/src/sync/commit.rs +++ b/asyncgit/src/sync/commit.rs @@ -151,7 +151,7 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path)) + File::create(root.join(file_path)) .unwrap() .write_all(b"test\nfoo") .unwrap(); @@ -177,7 +177,7 @@ mod tests { assert_eq!(get_statuses(repo_path), (0, 0)); - File::create(&root.join(file_path)) + File::create(root.join(file_path)) .unwrap() .write_all(b"test\nfoo") .unwrap(); @@ -202,14 +202,14 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path1))?.write_all(b"test1")?; + File::create(root.join(file_path1))?.write_all(b"test1")?; stage_add_file(repo_path, file_path1)?; let id = commit(repo_path, "commit msg")?; assert_eq!(count_commits(&repo, 10), 1); - File::create(&root.join(file_path2))?.write_all(b"test2")?; + File::create(root.join(file_path2))?.write_all(b"test2")?; stage_add_file(repo_path, file_path2)?; @@ -239,7 +239,7 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path))? + File::create(root.join(file_path))? .write_all(b"test\nfoo")?; stage_add_file(repo_path, file_path)?; @@ -281,7 +281,7 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path))? + File::create(root.join(file_path))? .write_all(b"test\nfoo")?; stage_add_file(repo_path, file_path)?; @@ -315,7 +315,7 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path))? + File::create(root.join(file_path))? .write_all(b"test\nfoo")?; stage_add_file(repo_path, file_path)?; @@ -351,7 +351,7 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path))? + File::create(root.join(file_path))? .write_all(b"test\nfoo")?; stage_add_file(repo_path, file_path)?; diff --git a/asyncgit/src/sync/commit_details.rs b/asyncgit/src/sync/commit_details.rs index e3cc4810e4..8de0894b71 100644 --- a/asyncgit/src/sync/commit_details.rs +++ b/asyncgit/src/sync/commit_details.rs @@ -140,7 +140,7 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path))?.write_all(b"a")?; + File::create(root.join(file_path))?.write_all(b"a")?; stage_add_file(repo_path, file_path).unwrap(); let msg = invalidstring::invalid_utf8("test msg"); diff --git a/asyncgit/src/sync/commit_files.rs b/asyncgit/src/sync/commit_files.rs index d7fbf7fcbf..7702670af7 100644 --- a/asyncgit/src/sync/commit_files.rs +++ b/asyncgit/src/sync/commit_files.rs @@ -167,7 +167,7 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path))? + File::create(root.join(file_path))? .write_all(b"test file1 content")?; stage_add_file(repo_path, file_path)?; @@ -190,7 +190,7 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path))? + File::create(root.join(file_path))? .write_all(b"test file1 content")?; let id = stash_save(repo_path, None, true, false)?; @@ -212,13 +212,13 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path1))?.write_all(b"test")?; + File::create(root.join(file_path1))?.write_all(b"test")?; stage_add_file(repo_path, file_path1)?; commit(repo_path, "c1")?; - File::create(&root.join(file_path1))? + File::create(root.join(file_path1))? .write_all(b"modified")?; - File::create(&root.join(file_path2))?.write_all(b"new")?; + File::create(root.join(file_path2))?.write_all(b"new")?; assert_eq!(get_statuses(repo_path), (2, 0)); diff --git a/asyncgit/src/sync/commits_info.rs b/asyncgit/src/sync/commits_info.rs index 2c877b9a87..b71ac3f177 100644 --- a/asyncgit/src/sync/commits_info.rs +++ b/asyncgit/src/sync/commits_info.rs @@ -157,10 +157,10 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path))?.write_all(b"a")?; + File::create(root.join(file_path))?.write_all(b"a")?; stage_add_file(repo_path, file_path).unwrap(); let c1 = commit(repo_path, "commit1").unwrap(); - File::create(&root.join(file_path))?.write_all(b"a")?; + File::create(root.join(file_path))?.write_all(b"a")?; stage_add_file(repo_path, file_path).unwrap(); let c2 = commit(repo_path, "commit2").unwrap(); @@ -182,7 +182,7 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path))?.write_all(b"a")?; + File::create(root.join(file_path))?.write_all(b"a")?; stage_add_file(repo_path, file_path).unwrap(); let c1 = commit(repo_path, "subject\nbody").unwrap(); @@ -202,7 +202,7 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path))?.write_all(b"a")?; + File::create(root.join(file_path))?.write_all(b"a")?; stage_add_file(repo_path, file_path).unwrap(); let msg = invalidstring::invalid_utf8("test msg"); diff --git a/asyncgit/src/sync/diff.rs b/asyncgit/src/sync/diff.rs index 64a0aee4d2..77bd5886ea 100644 --- a/asyncgit/src/sync/diff.rs +++ b/asyncgit/src/sync/diff.rs @@ -439,8 +439,8 @@ mod tests { assert_eq!(get_statuses(repo_path), (0, 0)); - fs::create_dir(&root.join("foo")).unwrap(); - File::create(&root.join("foo/bar.txt")) + fs::create_dir(root.join("foo")).unwrap(); + File::create(root.join("foo/bar.txt")) .unwrap() .write_all(b"test\nfoo") .unwrap(); @@ -464,7 +464,7 @@ mod tests { assert_eq!(get_statuses(repo_path), (0, 0)); - File::create(&root.join(file_path)) + File::create(root.join(file_path)) .unwrap() .write_all(b"test\nfoo") .unwrap(); @@ -563,7 +563,7 @@ mod tests { let sub_path = root.join("foo/"); fs::create_dir_all(&sub_path).unwrap(); - File::create(&root.join(file_path)) + File::create(root.join(file_path)) .unwrap() .write_all(b"test") .unwrap(); @@ -587,14 +587,13 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path))?.write_all(b"\x00")?; + File::create(root.join(file_path))?.write_all(b"\x00")?; stage_add_file(repo_path, file_path).unwrap(); commit(repo_path, "commit").unwrap(); - File::create(&root.join(file_path))? - .write_all(b"\x00\x02")?; + File::create(root.join(file_path))?.write_all(b"\x00\x02")?; let diff = get_diff( repo_path, @@ -619,8 +618,7 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path))? - .write_all(b"\x00\xc7")?; + File::create(root.join(file_path))?.write_all(b"\x00\xc7")?; let diff = get_diff( repo_path, @@ -645,14 +643,13 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path))?.write_all(b"\x00")?; + File::create(root.join(file_path))?.write_all(b"\x00")?; stage_add_file(repo_path, file_path).unwrap(); commit(repo_path, "").unwrap(); - File::create(&root.join(file_path))? - .write_all(b"\x00\x02")?; + File::create(root.join(file_path))?.write_all(b"\x00\x02")?; stage_add_file(repo_path, file_path).unwrap(); diff --git a/asyncgit/src/sync/hunks.rs b/asyncgit/src/sync/hunks.rs index 786c1c9079..d5d8960112 100644 --- a/asyncgit/src/sync/hunks.rs +++ b/asyncgit/src/sync/hunks.rs @@ -168,7 +168,7 @@ mod tests { let sub_path = root.join("foo/"); fs::create_dir_all(&sub_path)?; - File::create(&root.join(file_path))?.write_all(b"test")?; + File::create(root.join(file_path))?.write_all(b"test")?; let sub_path: &RepoPath = &sub_path.to_str().unwrap().into(); let diff = get_diff( diff --git a/asyncgit/src/sync/ignore.rs b/asyncgit/src/sync/ignore.rs index ba9916a9c0..011873bbc4 100644 --- a/asyncgit/src/sync/ignore.rs +++ b/asyncgit/src/sync/ignore.rs @@ -77,7 +77,7 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path))?.write_all(b"test")?; + File::create(root.join(file_path))?.write_all(b"test")?; assert_eq!(root.join(ignore_file_path).exists(), false); add_to_ignore(repo_path, file_path.to_str().unwrap())?; @@ -105,14 +105,14 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path))?.write_all(b"test")?; - File::create(&root.join(ignore_file_path))? + File::create(root.join(file_path))?.write_all(b"test")?; + File::create(root.join(ignore_file_path))? .write_all(b"foo\n")?; add_to_ignore(repo_path, file_path.to_str().unwrap())?; let mut lines = - read_lines(&root.join(ignore_file_path)).unwrap(); + read_lines(root.join(ignore_file_path)).unwrap(); assert_eq!(&lines.nth(1).unwrap().unwrap(), "foo.txt"); Ok(()) @@ -127,14 +127,14 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path))?.write_all(b"test")?; - File::create(&root.join(ignore_file_path))? + File::create(root.join(file_path))?.write_all(b"test")?; + File::create(root.join(ignore_file_path))? .write_all(b"foo")?; add_to_ignore(repo_path, file_path.to_str().unwrap())?; let mut lines = - read_lines(&root.join(ignore_file_path)).unwrap(); + read_lines(root.join(ignore_file_path)).unwrap(); assert_eq!(&lines.nth(1).unwrap().unwrap(), "foo.txt"); Ok(()) @@ -153,7 +153,7 @@ mod tests { let res = add_to_ignore(repo_path, ".gitignore"); assert!(res.is_err()); - let lines = read_lines(&root.join(ignore_file_path)).unwrap(); + let lines = read_lines(root.join(ignore_file_path)).unwrap(); assert_eq!(lines.count(), 1); } } diff --git a/asyncgit/src/sync/logwalker.rs b/asyncgit/src/sync/logwalker.rs index 3f9110b1d9..f7fbca5a5d 100644 --- a/asyncgit/src/sync/logwalker.rs +++ b/asyncgit/src/sync/logwalker.rs @@ -150,10 +150,10 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path))?.write_all(b"a")?; + File::create(root.join(file_path))?.write_all(b"a")?; stage_add_file(repo_path, file_path).unwrap(); commit(repo_path, "commit1").unwrap(); - File::create(&root.join(file_path))?.write_all(b"a")?; + File::create(root.join(file_path))?.write_all(b"a")?; stage_add_file(repo_path, file_path).unwrap(); let oid2 = commit(repo_path, "commit2").unwrap(); @@ -175,10 +175,10 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path))?.write_all(b"a")?; + File::create(root.join(file_path))?.write_all(b"a")?; stage_add_file(repo_path, file_path).unwrap(); commit(repo_path, "commit1").unwrap(); - File::create(&root.join(file_path))?.write_all(b"a")?; + File::create(root.join(file_path))?.write_all(b"a")?; stage_add_file(repo_path, file_path).unwrap(); let oid2 = commit(repo_path, "commit2").unwrap(); @@ -209,18 +209,17 @@ mod tests { let repo_path: RepoPath = root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path))?.write_all(b"a")?; + File::create(root.join(file_path))?.write_all(b"a")?; stage_add_file(&repo_path, file_path).unwrap(); let _first_commit_id = commit(&repo_path, "commit1").unwrap(); - File::create(&root.join(second_file_path))? - .write_all(b"a")?; + File::create(root.join(second_file_path))?.write_all(b"a")?; stage_add_file(&repo_path, second_file_path).unwrap(); let second_commit_id = commit(&repo_path, "commit2").unwrap(); - File::create(&root.join(file_path))?.write_all(b"b")?; + File::create(root.join(file_path))?.write_all(b"b")?; stage_add_file(&repo_path, file_path).unwrap(); let _third_commit_id = commit(&repo_path, "commit3").unwrap(); diff --git a/asyncgit/src/sync/remotes/push.rs b/asyncgit/src/sync/remotes/push.rs index 5e75eda8f9..37cdd4a9ca 100644 --- a/asyncgit/src/sync/remotes/push.rs +++ b/asyncgit/src/sync/remotes/push.rs @@ -171,8 +171,7 @@ pub fn push_raw( callbacks.get_stats()?.push_rejected_msg { return Err(Error::Generic(format!( - "push to '{}' rejected: {}", - reference, msg + "push to '{reference}' rejected: {msg}" ))); } diff --git a/asyncgit/src/sync/reset.rs b/asyncgit/src/sync/reset.rs index 76e12b69e2..e4ba87ebb1 100644 --- a/asyncgit/src/sync/reset.rs +++ b/asyncgit/src/sync/reset.rs @@ -136,8 +136,8 @@ mod tests { &root.as_os_str().to_str().unwrap().into(); { - fs::create_dir(&root.join("foo")).unwrap(); - File::create(&root.join("foo/bar.txt")) + fs::create_dir(root.join("foo")).unwrap(); + File::create(root.join("foo/bar.txt")) .unwrap() .write_all(b"test\nfoo") .unwrap(); @@ -162,12 +162,12 @@ mod tests { &root.as_os_str().to_str().unwrap().into(); { - fs::create_dir(&root.join("foo"))?; - File::create(&root.join("foo/file1.txt"))? + fs::create_dir(root.join("foo"))?; + File::create(root.join("foo/file1.txt"))? .write_all(b"file1")?; - File::create(&root.join("foo/file2.txt"))? + File::create(root.join("foo/file2.txt"))? .write_all(b"file1")?; - File::create(&root.join("file3.txt"))? + File::create(root.join("file3.txt"))? .write_all(b"file3")?; } @@ -175,14 +175,14 @@ mod tests { commit(repo_path, "msg").unwrap(); { - File::create(&root.join("foo/file1.txt"))? + File::create(root.join("foo/file1.txt"))? .write_all(b"file1\nadded line")?; - fs::remove_file(&root.join("foo/file2.txt"))?; - File::create(&root.join("foo/file4.txt"))? + fs::remove_file(root.join("foo/file2.txt"))?; + File::create(root.join("foo/file4.txt"))? .write_all(b"file4")?; - File::create(&root.join("foo/file5.txt"))? + File::create(root.join("foo/file5.txt"))? .write_all(b"file5")?; - File::create(&root.join("file3.txt"))? + File::create(root.join("file3.txt"))? .write_all(b"file3\nadded line")?; } @@ -209,8 +209,8 @@ mod tests { let file = "foo/bar.txt"; { - fs::create_dir(&root.join("foo")).unwrap(); - File::create(&root.join(file)) + fs::create_dir(root.join("foo")).unwrap(); + File::create(root.join(file)) .unwrap() .write_all(b"test\nfoo") .unwrap(); @@ -223,7 +223,7 @@ mod tests { debug_cmd_print(repo_path, "git status"); { - File::create(&root.join(file)) + File::create(root.join(file)) .unwrap() .write_all(b"test\nfoo\nnewend") .unwrap(); @@ -248,7 +248,7 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path)) + File::create(root.join(file_path)) .unwrap() .write_all(b"test\nfoo") .unwrap(); @@ -272,8 +272,8 @@ mod tests { &root.as_os_str().to_str().unwrap().into(); { - fs::create_dir(&root.join("foo")).unwrap(); - File::create(&root.join("foo/bar.txt")) + fs::create_dir(root.join("foo")).unwrap(); + File::create(root.join("foo/bar.txt")) .unwrap() .write_all(b"test\nfoo") .unwrap(); @@ -302,8 +302,8 @@ mod tests { &root.as_os_str().to_str().unwrap().into(); { - fs::create_dir_all(&root.join("foo/bar")).unwrap(); - File::create(&root.join("foo/bar/baz.txt")) + fs::create_dir_all(root.join("foo/bar")).unwrap(); + File::create(root.join("foo/bar/baz.txt")) .unwrap() .write_all(b"test\nfoo") .unwrap(); diff --git a/asyncgit/src/sync/stash.rs b/asyncgit/src/sync/stash.rs index 9a269db0f0..f95f2f53b1 100644 --- a/asyncgit/src/sync/stash.rs +++ b/asyncgit/src/sync/stash.rs @@ -170,7 +170,7 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join("foo.txt"))? + File::create(root.join("foo.txt"))? .write_all(b"test\nfoo")?; assert_eq!(get_statuses(repo_path), (1, 0)); @@ -189,7 +189,7 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join("foo.txt"))? + File::create(root.join("foo.txt"))? .write_all(b"test\nfoo")?; stash_save(repo_path, Some("foo"), true, false)?; @@ -213,7 +213,7 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join("foo.txt"))? + File::create(root.join("foo.txt"))? .write_all(b"test\nfoo")?; assert!( @@ -231,11 +231,11 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path1))?.write_all(b"test")?; + File::create(root.join(file_path1))?.write_all(b"test")?; stage_add_file(repo_path, file_path1)?; commit(repo_path, "c1")?; - File::create(&root.join(file_path1))? + File::create(root.join(file_path1))? .write_all(b"modified")?; //NOTE: apparently `libgit2` works differently to git stash in diff --git a/asyncgit/src/sync/utils.rs b/asyncgit/src/sync/utils.rs index e977d6da7e..fff6feccc9 100644 --- a/asyncgit/src/sync/utils.rs +++ b/asyncgit/src/sync/utils.rs @@ -256,12 +256,12 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - File::create(&root.join(file_path)) + File::create(root.join(file_path)) .unwrap() .write_all(b"test file1 content") .unwrap(); - File::create(&root.join(Path::new("file2.txt"))) + File::create(root.join(Path::new("file2.txt"))) .unwrap() .write_all(b"test file2 content") .unwrap(); @@ -284,12 +284,12 @@ mod tests { get_status(repo_path, s, None).unwrap().len() }; - fs::create_dir_all(&root.join("a/d"))?; - File::create(&root.join(Path::new("a/d/f1.txt")))? + fs::create_dir_all(root.join("a/d"))?; + File::create(root.join(Path::new("a/d/f1.txt")))? .write_all(b"foo")?; - File::create(&root.join(Path::new("a/d/f2.txt")))? + File::create(root.join(Path::new("a/d/f2.txt")))? .write_all(b"foo")?; - File::create(&root.join(Path::new("a/f3.txt")))? + File::create(root.join(Path::new("a/f3.txt")))? .write_all(b"foo")?; assert_eq!(status_count(StatusType::WorkingDir), 3); @@ -346,12 +346,12 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - fs::create_dir_all(&root.join("a/d"))?; - File::create(&root.join(Path::new("a/d/f1.txt")))? + fs::create_dir_all(root.join("a/d"))?; + File::create(root.join(Path::new("a/d/f1.txt")))? .write_all(b"foo")?; - File::create(&root.join(Path::new("a/d/f2.txt")))? + File::create(root.join(Path::new("a/d/f2.txt")))? .write_all(b"foo")?; - File::create(&root.join(Path::new("f3.txt")))? + File::create(root.join(Path::new("f3.txt")))? .write_all(b"foo")?; assert_eq!(get_statuses(repo_path), (3, 0)); diff --git a/src/app.rs b/src/app.rs index 1d634fec8c..be0cc9172f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -985,8 +985,7 @@ impl App { branch_ref.rsplit('/').next().map_or_else( || { InternalEvent::ShowErrorMsg(format!( - "Failed to find the branch name in {}", - branch_ref + "Failed to find the branch name in {branch_ref}" )) }, |name| { diff --git a/src/components/blame_file.rs b/src/components/blame_file.rs index 7125aca4b0..9f41df88f8 100644 --- a/src/components/blame_file.rs +++ b/src/components/blame_file.rs @@ -454,10 +454,7 @@ impl BlameFileComponent { let line_number_width = self.get_line_number_width(); cells.push( Cell::from(format!( - "{:>line_number_width$}{}", - line_number, - VERTICAL, - line_number_width = line_number_width, + "{line_number:>line_number_width$}{VERTICAL}", )) .style(self.theme.text(true, false)), ); @@ -483,11 +480,7 @@ impl BlameFileComponent { || NO_AUTHOR.into(), |hunk| string_width_align(&hunk.author, author_width), ); - let author = format!( - "{:author_width$}", - truncated_author, - author_width = MAX_AUTHOR_WIDTH - ); + let author = format!("{truncated_author:MAX_AUTHOR_WIDTH$}"); let time = blame_hunk.map_or_else(String::new, |hunk| { utils::time_to_string(hunk.time, true) }); diff --git a/src/components/branchlist.rs b/src/components/branchlist.rs index b27600a850..2657725a14 100644 --- a/src/components/branchlist.rs +++ b/src/components/branchlist.rs @@ -624,11 +624,7 @@ impl BranchListComponent { theme.text(true, selected), ); let span_name = Span::styled( - format!( - "{:w$} ", - branch_name, - w = branch_name_length - ), + format!("{branch_name:branch_name_length$} "), theme.branch(selected, is_head), ); diff --git a/src/components/commit.rs b/src/components/commit.rs index 399f22e700..74343ec22f 100644 --- a/src/components/commit.rs +++ b/src/components/commit.rs @@ -241,8 +241,7 @@ impl CommitComponent { { log::error!("pre-commit hook error: {}", e); self.queue.push(InternalEvent::ShowErrorMsg(format!( - "pre-commit hook error:\n{}", - e + "pre-commit hook error:\n{e}" ))); return Ok(CommitResult::Aborted); } @@ -252,8 +251,7 @@ impl CommitComponent { { log::error!("commit-msg hook error: {}", e); self.queue.push(InternalEvent::ShowErrorMsg(format!( - "commit-msg hook error:\n{}", - e + "commit-msg hook error:\n{e}" ))); return Ok(CommitResult::Aborted); } @@ -276,8 +274,7 @@ impl CommitComponent { { log::error!("post-commit hook error: {}", e); self.queue.push(InternalEvent::ShowErrorMsg(format!( - "post-commit hook error:\n{}", - e + "post-commit hook error:\n{e}" ))); } diff --git a/src/components/diff.rs b/src/components/diff.rs index 95d46e7419..cbc27e8737 100644 --- a/src/components/diff.rs +++ b/src/components/diff.rs @@ -326,8 +326,7 @@ impl DiffComponent { Span::raw(Cow::from(" (")), Span::styled( Cow::from(format!( - "{}{:}", - sign, delta_byte_size + "{sign}{delta_byte_size:}" )), self.theme.diff_line( if is_positive { diff --git a/src/components/revision_files.rs b/src/components/revision_files.rs index ac5ff44da7..33b0fb3d2b 100644 --- a/src/components/revision_files.rs +++ b/src/components/revision_files.rs @@ -199,11 +199,7 @@ impl RevisionFilesComponent { width.saturating_sub(indent_str.len() + path_arrow.len()); let path = format!( - "{}{}{:w$}", - indent_str, - path_arrow, - path, - w = available_width + "{indent_str}{path_arrow}{path:available_width$}" ); Span::styled(path, theme.file_tree_item(is_path, selected)) diff --git a/src/components/status_tree.rs b/src/components/status_tree.rs index 49cd306efe..f4c2f837a7 100644 --- a/src/components/status_tree.rs +++ b/src/components/status_tree.rs @@ -215,10 +215,7 @@ impl StatusTreeComponent { w = width as usize ) } else { - format!( - " {}{}{}", - indent_str, collapse_char, string, - ) + format!(" {indent_str}{collapse_char}{string}",) }; Some(Span::styled( diff --git a/src/components/syntax_text.rs b/src/components/syntax_text.rs index 8bfc48a995..bb0b39f886 100644 --- a/src/components/syntax_text.rs +++ b/src/components/syntax_text.rs @@ -132,8 +132,7 @@ impl SyntaxTextComponent { self.current_file = Some(( path, Either::Right(format!( - "error loading file: {}", - e + "error loading file: {e}" )), )); } diff --git a/src/strings.rs b/src/strings.rs index a096a9d98d..c7cf5d79e5 100644 --- a/src/strings.rs +++ b/src/strings.rs @@ -193,8 +193,7 @@ pub fn confirm_msg_reset() -> String { } pub fn confirm_msg_reset_lines(lines: usize) -> String { format!( - "are you sure you want to discard {} selected lines?", - lines + "are you sure you want to discard {lines} selected lines?" ) } pub fn confirm_msg_stashdrop( @@ -273,8 +272,7 @@ pub fn confirm_msg_force_push( branch_ref: &str, ) -> String { format!( - "Confirm force push to branch '{}' ? This may rewrite history.", - branch_ref + "Confirm force push to branch '{branch_ref}' ? This may rewrite history." ) } pub fn log_title(_key_config: &SharedKeyConfig) -> String { @@ -285,10 +283,7 @@ pub fn file_log_title( selected: usize, revisions: usize, ) -> String { - format!( - "Revisions of '{}' ({}/{})", - file_path, selected, revisions - ) + format!("Revisions of '{file_path}' ({selected}/{revisions})") } pub fn blame_title(_key_config: &SharedKeyConfig) -> String { "Blame".to_string() diff --git a/src/tabs/status.rs b/src/tabs/status.rs index 765ae1c4c2..cd544b4b09 100644 --- a/src/tabs/status.rs +++ b/src/tabs/status.rs @@ -232,8 +232,7 @@ impl Status { }); let w = Paragraph::new(format!( - "{}{{{}}}", - ahead_behind, branch_name + "{ahead_behind}{{{branch_name}}}" )) .alignment(Alignment::Right); @@ -560,8 +559,7 @@ impl Status { item.path.as_str(), ) { self.queue.push(InternalEvent::ShowErrorMsg(format!( - "reset failed:\n{}", - e + "reset failed:\n{e}" ))); false