diff --git a/src/cargo/core/resolver/dep_cache.rs b/src/cargo/core/resolver/dep_cache.rs index e20a78a66ae..ccfde1adec1 100644 --- a/src/cargo/core/resolver/dep_cache.rs +++ b/src/cargo/core/resolver/dep_cache.rs @@ -353,10 +353,8 @@ fn build_requirements<'a, 'b: 'a>( } } - if opts.uses_default_features { - if s.features().contains_key("default") { - reqs.require_feature(InternedString::new("default"))?; - } + if opts.uses_default_features && s.features().contains_key("default") { + reqs.require_feature(InternedString::new("default"))?; } Ok(reqs) diff --git a/src/cargo/core/resolver/encode.rs b/src/cargo/core/resolver/encode.rs index b60b3a20797..04d9ebd38b4 100644 --- a/src/cargo/core/resolver/encode.rs +++ b/src/cargo/core/resolver/encode.rs @@ -193,9 +193,9 @@ impl EncodableResolve { let mut map = HashMap::new(); for (id, _) in live_pkgs.values() { map.entry(id.name().as_str()) - .or_insert(HashMap::new()) + .or_insert_with(HashMap::new) .entry(id.version().to_string()) - .or_insert(HashMap::new()) + .or_insert_with(HashMap::new) .insert(id.source_id(), *id); } @@ -317,7 +317,7 @@ impl EncodableResolve { // If `checksum` was listed in `[metadata]` but we were previously // listed as `V2` then assume some sort of bad git merge happened, so // discard all checksums and let's regenerate them later. - if to_remove.len() > 0 && version == ResolveVersion::V2 { + if !to_remove.is_empty() && version == ResolveVersion::V2 { checksums.drain(); } for k in to_remove { @@ -542,7 +542,7 @@ impl<'a> ser::Serialize for Resolve { dependencies: None, replace: None, checksum: match self.version() { - ResolveVersion::V2 => self.checksums().get(&id).and_then(|x| x.clone()), + ResolveVersion::V2 => self.checksums().get(id).and_then(|x| x.clone()), ResolveVersion::V1 => None, }, }) diff --git a/src/cargo/core/shell.rs b/src/cargo/core/shell.rs index c0c9b13907a..0e1d878f518 100644 --- a/src/cargo/core/shell.rs +++ b/src/cargo/core/shell.rs @@ -377,6 +377,8 @@ mod imp { pub fn stderr_width() -> Option { unsafe { let mut winsize: libc::winsize = mem::zeroed(); + // The .into() here is needed for FreeBSD which defines TIOCGWINSZ + // as c_uint but ioctl wants c_ulong. if libc::ioctl(libc::STDERR_FILENO, libc::TIOCGWINSZ.into(), &mut winsize) < 0 { return None; } diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index 64e1ea2eae5..ac36549a8d6 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -24,6 +24,9 @@ #![allow(clippy::trivially_copy_pass_by_ref)] // exhaustively destructuring ensures future fields are handled #![allow(clippy::unneeded_field_pattern)] +// false positives in target-specific code, for details see +// https://github.com/rust-lang/cargo/pull/7251#pullrequestreview-274914270 +#![allow(clippy::identity_conversion)] use std::fmt; use std::io; diff --git a/src/cargo/sources/git/utils.rs b/src/cargo/sources/git/utils.rs index 48933a8fd00..fc4b7e10ef9 100644 --- a/src/cargo/sources/git/utils.rs +++ b/src/cargo/sources/git/utils.rs @@ -141,7 +141,7 @@ impl GitRemote { fn fetch_into(&self, dst: &mut git2::Repository, cargo_config: &Config) -> CargoResult<()> { // Create a local anonymous remote in the repository to fetch the url let refspec = "refs/heads/*:refs/heads/*"; - fetch(dst, &self.url.as_str(), refspec, cargo_config) + fetch(dst, self.url.as_str(), refspec, cargo_config) } fn clone_into(&self, dst: &Path, cargo_config: &Config) -> CargoResult { @@ -152,7 +152,7 @@ impl GitRemote { let mut repo = init(dst, true)?; fetch( &mut repo, - &self.url.as_str(), + self.url.as_str(), "refs/heads/*:refs/heads/*", cargo_config, )?; @@ -395,7 +395,7 @@ impl<'a> GitCheckout<'a> { }; // Fetch data from origin and reset to the head commit let refspec = "refs/heads/*:refs/heads/*"; - fetch(&mut repo, &url, refspec, cargo_config).chain_err(|| { + fetch(&mut repo, url, refspec, cargo_config).chain_err(|| { internal(format!( "failed to fetch submodule `{}` from {}", child.name().unwrap_or(""), diff --git a/tests/testsuite/support/mod.rs b/tests/testsuite/support/mod.rs index f1da02e255c..063f82fae10 100644 --- a/tests/testsuite/support/mod.rs +++ b/tests/testsuite/support/mod.rs @@ -1157,7 +1157,7 @@ impl Execs { // hidden characters let matcher = matcher.replace("\t", ""); - return matcher; + matcher } fn match_std( @@ -1410,7 +1410,7 @@ enum MatchKind { /// - `[ROOT]` the path to the test directory's root /// - `[CWD]` is the working directory of the process that was run. pub fn lines_match(expected: &str, mut actual: &str) -> bool { - let expected = substitute_macros(&expected); + let expected = substitute_macros(expected); for (i, part) in expected.split("[..]").enumerate() { match actual.find(part) { Some(j) => {