Skip to content

Commit 426fae5

Browse files
committed
Auto merge of #7808 - matthiaskrgr:clippy_v10, r=ehuss
fix some clippy warnings
2 parents 4e0d2f1 + a6a395c commit 426fae5

File tree

10 files changed

+12
-12
lines changed

10 files changed

+12
-12
lines changed

crates/cargo-test-support/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,7 @@ fn find_json_mismatch_r<'a>(
15111511
l.values()
15121512
.zip(r.values())
15131513
.filter_map(|(l, r)| find_json_mismatch_r(l, r))
1514-
.nth(0)
1514+
.next()
15151515
}
15161516
(&Null, &Null) => None,
15171517
// Magic string literal `"{...}"` acts as wildcard for any sub-JSON.

src/cargo/core/compiler/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ fn build_deps_args<'a, 'cfg>(
937937
cmd.arg("-Z").arg("unstable-options");
938938
}
939939

940-
return Ok(());
940+
Ok(())
941941
}
942942

943943
/// Generates a list of `--extern` arguments.

src/cargo/core/resolver/encode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ impl EncodableResolve {
349349
// To help fix this issue we special case here. If our lockfile only has
350350
// one trailing newline, not two, *and* it only has one package, then
351351
// this is actually the v2 format.
352-
if original.ends_with("\n")
352+
if original.ends_with('\n')
353353
&& !original.ends_with("\n\n")
354354
&& version == ResolveVersion::V1
355355
&& g.iter().count() == 1

src/cargo/ops/cargo_compile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ pub fn compile_ws<'a>(
449449
// the target is a binary. Binary crates get their private items
450450
// documented by default.
451451
if rustdoc_document_private_items || unit.target.is_bin() {
452-
let mut args = extra_args.take().unwrap_or(vec![]);
452+
let mut args = extra_args.take().unwrap_or_else(|| vec![]);
453453
args.push("--document-private-items".into());
454454
extra_args = Some(args);
455455
}

src/cargo/ops/cargo_new.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ fn check_name(name: &str, opts: &NewOptions) -> CargoResult<()> {
181181
)
182182
}
183183

184-
if let Some(ref c) = name.chars().nth(0) {
184+
if let Some(ref c) = name.chars().next() {
185185
if c.is_digit(10) {
186186
anyhow::bail!(
187187
"Package names starting with a digit cannot be used as a crate name{}",

src/cargo/ops/common_for_install_and_uninstall.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ where
552552
// version range, otherwise parse it as a specific version
553553
let first = v
554554
.chars()
555-
.nth(0)
555+
.next()
556556
.ok_or_else(|| format_err!("no version provided for the `--vers` flag"))?;
557557

558558
let is_req = "<>=^~".contains(first) || v.contains('*');

src/cargo/util/config/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ impl Config {
823823
let mut seen = HashSet::new();
824824
let tmp_table = self
825825
.load_includes(tmp_table, &mut seen)
826-
.chain_err(|| format!("failed to load --config include"))?;
826+
.chain_err(|| "failed to load --config include".to_string())?;
827827
loaded_args
828828
.merge(tmp_table, true)
829829
.chain_err(|| format!("failed to merge --config argument `{}`", arg))?;
@@ -1526,7 +1526,7 @@ pub fn save_credentials(cfg: &Config, token: String, registry: Option<String>) -
15261526
.insert("registry".into(), map.into());
15271527
}
15281528

1529-
if let Some(_) = registry {
1529+
if registry.is_some() {
15301530
if let Some(table) = toml.as_table_mut().unwrap().remove("registries") {
15311531
let v = CV::from_toml(Definition::Path(file.path().to_path_buf()), table)?;
15321532
value.merge(v, false)?;

src/cargo/util/cpu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ mod imp {
7272
let nice = next.nice - prev.nice;
7373
let system = next.system - prev.system;
7474
let idle = next.idle - prev.idle;
75-
let iowait = next.iowait.checked_sub(prev.iowait).unwrap_or(0);
75+
let iowait = next.iowait.saturating_sub(prev.iowait);
7676
let irq = next.irq - prev.irq;
7777
let softirq = next.softirq - prev.softirq;
7878
let steal = next.steal - prev.steal;

src/cargo/util/toml/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,11 +635,11 @@ impl TomlProfile {
635635
}
636636

637637
if let Some(v) = &profile.inherits {
638-
self.inherits = Some(v.clone());
638+
self.inherits = Some(*v);
639639
}
640640

641641
if let Some(v) = &profile.dir_name {
642-
self.dir_name = Some(v.clone());
642+
self.dir_name = Some(*v);
643643
}
644644
}
645645
}

tests/testsuite/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2258,7 +2258,7 @@ fn credentials_is_unreadable() {
22582258
let stat = fs::metadata(credentials.as_path()).unwrap();
22592259
let mut perms = stat.permissions();
22602260
perms.set_mode(0o000);
2261-
fs::set_permissions(credentials, perms.clone()).unwrap();
2261+
fs::set_permissions(credentials, perms).unwrap();
22622262

22632263
p.cargo("build").run();
22642264
}

0 commit comments

Comments
 (0)