fix some clippy warnings

This commit is contained in:
Matthias Krüger 2020-01-17 12:19:12 +01:00
parent 4e0d2f1a16
commit a6a395c690
10 changed files with 12 additions and 12 deletions

View File

@ -1511,7 +1511,7 @@ fn find_json_mismatch_r<'a>(
l.values()
.zip(r.values())
.filter_map(|(l, r)| find_json_mismatch_r(l, r))
.nth(0)
.next()
}
(&Null, &Null) => None,
// Magic string literal `"{...}"` acts as wildcard for any sub-JSON.

View File

@ -937,7 +937,7 @@ fn build_deps_args<'a, 'cfg>(
cmd.arg("-Z").arg("unstable-options");
}
return Ok(());
Ok(())
}
/// Generates a list of `--extern` arguments.

View File

@ -349,7 +349,7 @@ impl EncodableResolve {
// To help fix this issue we special case here. If our lockfile only has
// one trailing newline, not two, *and* it only has one package, then
// this is actually the v2 format.
if original.ends_with("\n")
if original.ends_with('\n')
&& !original.ends_with("\n\n")
&& version == ResolveVersion::V1
&& g.iter().count() == 1

View File

@ -449,7 +449,7 @@ pub fn compile_ws<'a>(
// the target is a binary. Binary crates get their private items
// documented by default.
if rustdoc_document_private_items || unit.target.is_bin() {
let mut args = extra_args.take().unwrap_or(vec![]);
let mut args = extra_args.take().unwrap_or_else(|| vec![]);
args.push("--document-private-items".into());
extra_args = Some(args);
}

View File

@ -181,7 +181,7 @@ fn check_name(name: &str, opts: &NewOptions) -> CargoResult<()> {
)
}
if let Some(ref c) = name.chars().nth(0) {
if let Some(ref c) = name.chars().next() {
if c.is_digit(10) {
anyhow::bail!(
"Package names starting with a digit cannot be used as a crate name{}",

View File

@ -552,7 +552,7 @@ where
// version range, otherwise parse it as a specific version
let first = v
.chars()
.nth(0)
.next()
.ok_or_else(|| format_err!("no version provided for the `--vers` flag"))?;
let is_req = "<>=^~".contains(first) || v.contains('*');

View File

@ -823,7 +823,7 @@ impl Config {
let mut seen = HashSet::new();
let tmp_table = self
.load_includes(tmp_table, &mut seen)
.chain_err(|| format!("failed to load --config include"))?;
.chain_err(|| "failed to load --config include".to_string())?;
loaded_args
.merge(tmp_table, true)
.chain_err(|| format!("failed to merge --config argument `{}`", arg))?;
@ -1526,7 +1526,7 @@ pub fn save_credentials(cfg: &Config, token: String, registry: Option<String>) -
.insert("registry".into(), map.into());
}
if let Some(_) = registry {
if registry.is_some() {
if let Some(table) = toml.as_table_mut().unwrap().remove("registries") {
let v = CV::from_toml(Definition::Path(file.path().to_path_buf()), table)?;
value.merge(v, false)?;

View File

@ -72,7 +72,7 @@ mod imp {
let nice = next.nice - prev.nice;
let system = next.system - prev.system;
let idle = next.idle - prev.idle;
let iowait = next.iowait.checked_sub(prev.iowait).unwrap_or(0);
let iowait = next.iowait.saturating_sub(prev.iowait);
let irq = next.irq - prev.irq;
let softirq = next.softirq - prev.softirq;
let steal = next.steal - prev.steal;

View File

@ -635,11 +635,11 @@ impl TomlProfile {
}
if let Some(v) = &profile.inherits {
self.inherits = Some(v.clone());
self.inherits = Some(*v);
}
if let Some(v) = &profile.dir_name {
self.dir_name = Some(v.clone());
self.dir_name = Some(*v);
}
}
}

View File

@ -2258,7 +2258,7 @@ fn credentials_is_unreadable() {
let stat = fs::metadata(credentials.as_path()).unwrap();
let mut perms = stat.permissions();
perms.set_mode(0o000);
fs::set_permissions(credentials, perms.clone()).unwrap();
fs::set_permissions(credentials, perms).unwrap();
p.cargo("build").run();
}