Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some clippy warnings #7808

Merged
merged 1 commit into from
Jan 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/cargo-test-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/resolver/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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{}",
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/ops/common_for_install_and_uninstall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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('*');
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/util/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))?;
Expand Down Expand Up @@ -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)?;
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/util/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down