Skip to content

Commit 8aa332d

Browse files
committed
Auto merge of #8495 - matthiaskrgr:clippy_v15, r=Eh2406
clippy cleanups Fixes a couple of clippy warnings. Ignores clippy::collapsible_if warnings in the future (iirc there were not desired) clippy::redundant_clone is enabled by default by clippy already.
2 parents b92636f + 833ad21 commit 8aa332d

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

src/cargo/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
#![allow(clippy::wrong_self_convention)] // perhaps `Rc` should be special-cased in Clippy?
1919
#![allow(clippy::write_with_newline)] // too pedantic
2020
#![allow(clippy::inefficient_to_string)] // this causes suggestions that result in `(*s).to_string()`
21+
#![allow(clippy::collapsible_if)] // too pedantic
2122
#![warn(clippy::needless_borrow)]
22-
#![warn(clippy::redundant_clone)]
2323
// Unit is now interned, and would probably be better as pass-by-copy, but
2424
// doing so causes a lot of & and * shenanigans that makes the code arguably
2525
// less clear and harder to read.
@@ -165,7 +165,7 @@ fn _display_error(err: &Error, shell: &mut Shell, as_err: bool) -> bool {
165165
drop(writeln!(shell.err(), "\nCaused by:"));
166166
for line in cause.to_string().lines() {
167167
if line.is_empty() {
168-
drop(writeln!(shell.err(), ""));
168+
drop(writeln!(shell.err()));
169169
} else {
170170
drop(writeln!(shell.err(), " {}", line));
171171
}

src/cargo/sources/git/source.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl<'cfg> Source for GitSource<'cfg> {
173173
.join("checkouts")
174174
.join(&self.ident)
175175
.join(short_id.as_str());
176-
db.copy_to(actual_rev.clone(), &checkout_path, self.config)?;
176+
db.copy_to(actual_rev, &checkout_path, self.config)?;
177177

178178
let source_id = self.source_id.with_precise(Some(actual_rev.to_string()));
179179
let path_source = PathSource::new_recursive(&checkout_path, source_id, self.config);

src/cargo/sources/git/utils.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl GitDatabase {
150150
) -> CargoResult<GitCheckout<'_>> {
151151
let mut checkout = None;
152152
if let Ok(repo) = git2::Repository::open(dest) {
153-
let mut co = GitCheckout::new(dest, self, rev.clone(), repo);
153+
let mut co = GitCheckout::new(dest, self, rev, repo);
154154
if !co.is_fresh() {
155155
// After a successful fetch operation the subsequent reset can
156156
// fail sometimes for corrupt repositories where the fetch
@@ -751,15 +751,15 @@ pub fn fetch(
751751
}
752752

753753
GitReference::DefaultBranch => {
754-
refspecs.push(format!("HEAD:refs/remotes/origin/HEAD"));
754+
refspecs.push(String::from("HEAD:refs/remotes/origin/HEAD"));
755755
}
756756

757757
// For `rev` dependencies we don't know what the rev will point to. To
758758
// handle this situation we fetch all branches and tags, and then we
759759
// pray it's somewhere in there.
760760
GitReference::Rev(_) => {
761-
refspecs.push(format!("refs/heads/*:refs/remotes/origin/*"));
762-
refspecs.push(format!("HEAD:refs/remotes/origin/HEAD"));
761+
refspecs.push(String::from("refs/heads/*:refs/remotes/origin/*"));
762+
refspecs.push(String::from("HEAD:refs/remotes/origin/HEAD"));
763763
tags = true;
764764
}
765765
}

src/cargo/sources/registry/remote.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use std::str;
2222

2323
fn make_crate_prefix(name: &str) -> String {
2424
match name.len() {
25-
1 => format!("1"),
26-
2 => format!("2"),
25+
1 => String::from("1"),
26+
2 => String::from("2"),
2727
3 => format!("3/{}", &name[..1]),
2828
_ => format!("{}/{}", &name[0..2], &name[2..4]),
2929
}

src/cargo/util/paths.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ pub fn create_dir_all_excluded_from_backups_atomic(p: impl AsRef<Path>) -> Cargo
487487
// easily sure that rename() will succeed (the new name needs to be on the same mount
488488
// point as the old one).
489489
let tempdir = TempFileBuilder::new().prefix(base).tempdir_in(parent)?;
490-
exclude_from_backups(&tempdir.path());
490+
exclude_from_backups(tempdir.path());
491491
// Previously std::fs::create_dir_all() (through paths::create_dir_all()) was used
492492
// here to create the directory directly and fs::create_dir_all() explicitly treats
493493
// the directory being created concurrently by another thread or process as success,

tests/testsuite/dep_info.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn assert_deps(project: &Project, fingerprint: &str, test_cb: impl Fn(&Path, &[(
3737
fn read_usize(bytes: &mut &[u8]) -> usize {
3838
let ret = &bytes[..4];
3939
*bytes = &bytes[4..];
40-
((ret[0] as usize) << 0)
40+
(ret[0] as usize)
4141
| ((ret[1] as usize) << 8)
4242
| ((ret[2] as usize) << 16)
4343
| ((ret[3] as usize) << 24)

0 commit comments

Comments
 (0)