Skip to content

Commit 61c1b1c

Browse files
committed
fix a bunch of clippy warnings
1 parent 60b7bf0 commit 61c1b1c

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

src/cargo/core/resolver/dep_cache.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,8 @@ fn build_requirements<'a, 'b: 'a>(
353353
}
354354
}
355355

356-
if opts.uses_default_features {
357-
if s.features().contains_key("default") {
358-
reqs.require_feature(InternedString::new("default"))?;
359-
}
356+
if opts.uses_default_features && s.features().contains_key("default") {
357+
reqs.require_feature(InternedString::new("default"))?;
360358
}
361359

362360
Ok(reqs)

src/cargo/core/resolver/encode.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ impl EncodableResolve {
193193
let mut map = HashMap::new();
194194
for (id, _) in live_pkgs.values() {
195195
map.entry(id.name().as_str())
196-
.or_insert(HashMap::new())
196+
.or_insert_with(HashMap::new)
197197
.entry(id.version().to_string())
198-
.or_insert(HashMap::new())
198+
.or_insert_with(HashMap::new)
199199
.insert(id.source_id(), *id);
200200
}
201201

@@ -317,7 +317,7 @@ impl EncodableResolve {
317317
// If `checksum` was listed in `[metadata]` but we were previously
318318
// listed as `V2` then assume some sort of bad git merge happened, so
319319
// discard all checksums and let's regenerate them later.
320-
if to_remove.len() > 0 && version == ResolveVersion::V2 {
320+
if !to_remove.is_empty() && version == ResolveVersion::V2 {
321321
checksums.drain();
322322
}
323323
for k in to_remove {
@@ -542,7 +542,7 @@ impl<'a> ser::Serialize for Resolve {
542542
dependencies: None,
543543
replace: None,
544544
checksum: match self.version() {
545-
ResolveVersion::V2 => self.checksums().get(&id).and_then(|x| x.clone()),
545+
ResolveVersion::V2 => self.checksums().get(id).and_then(|x| x.clone()),
546546
ResolveVersion::V1 => None,
547547
},
548548
})

src/cargo/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
#![allow(clippy::trivially_copy_pass_by_ref)]
2525
// exhaustively destructuring ensures future fields are handled
2626
#![allow(clippy::unneeded_field_pattern)]
27+
// false positives in target-specific code, for details see
28+
// https://github.com/rust-lang/cargo/pull/7251#pullrequestreview-274914270
29+
#![allow(clippy::identity_conversion)]
2730

2831
use std::fmt;
2932
use std::io;

src/cargo/sources/git/utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl GitRemote {
141141
fn fetch_into(&self, dst: &mut git2::Repository, cargo_config: &Config) -> CargoResult<()> {
142142
// Create a local anonymous remote in the repository to fetch the url
143143
let refspec = "refs/heads/*:refs/heads/*";
144-
fetch(dst, &self.url.as_str(), refspec, cargo_config)
144+
fetch(dst, self.url.as_str(), refspec, cargo_config)
145145
}
146146

147147
fn clone_into(&self, dst: &Path, cargo_config: &Config) -> CargoResult<git2::Repository> {
@@ -152,7 +152,7 @@ impl GitRemote {
152152
let mut repo = init(dst, true)?;
153153
fetch(
154154
&mut repo,
155-
&self.url.as_str(),
155+
self.url.as_str(),
156156
"refs/heads/*:refs/heads/*",
157157
cargo_config,
158158
)?;
@@ -395,7 +395,7 @@ impl<'a> GitCheckout<'a> {
395395
};
396396
// Fetch data from origin and reset to the head commit
397397
let refspec = "refs/heads/*:refs/heads/*";
398-
fetch(&mut repo, &url, refspec, cargo_config).chain_err(|| {
398+
fetch(&mut repo, url, refspec, cargo_config).chain_err(|| {
399399
internal(format!(
400400
"failed to fetch submodule `{}` from {}",
401401
child.name().unwrap_or(""),

tests/testsuite/support/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ impl Execs {
11571157
// hidden characters
11581158
let matcher = matcher.replace("\t", "<tab>");
11591159

1160-
return matcher;
1160+
matcher
11611161
}
11621162

11631163
fn match_std(
@@ -1410,7 +1410,7 @@ enum MatchKind {
14101410
/// - `[ROOT]` the path to the test directory's root
14111411
/// - `[CWD]` is the working directory of the process that was run.
14121412
pub fn lines_match(expected: &str, mut actual: &str) -> bool {
1413-
let expected = substitute_macros(&expected);
1413+
let expected = substitute_macros(expected);
14141414
for (i, part) in expected.split("[..]").enumerate() {
14151415
match actual.find(part) {
14161416
Some(j) => {

0 commit comments

Comments
 (0)