Skip to content

Commit ae97799

Browse files
committed
Auto merge of #5876 - matthiaskrgr:clippy_2, r=alexcrichton
fix a bunch of clippy warnings (invocation: cargo clippy --all-targets --all-features -- --cap-lints warn )
2 parents 972ccba + 8798bf0 commit ae97799

File tree

25 files changed

+89
-88
lines changed

25 files changed

+89
-88
lines changed

src/cargo/core/compiler/custom_build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes
322322
} else {
323323
state.running(&cmd);
324324
let output = if extra_verbose {
325-
state.capture_output(cmd, true)
325+
state.capture_output(&cmd, true)
326326
} else {
327327
cmd.exec_with_output()
328328
};

src/cargo/core/compiler/job_queue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl<'a> JobState<'a> {
110110

111111
pub fn capture_output(
112112
&self,
113-
cmd: ProcessBuilder,
113+
cmd: &ProcessBuilder,
114114
print_output: bool,
115115
) -> CargoResult<Output> {
116116
cmd.exec_with_streaming(

src/cargo/core/compiler/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl Executor for DefaultExecutor {
118118
_mode: CompileMode,
119119
state: &job_queue::JobState<'_>,
120120
) -> CargoResult<()> {
121-
state.capture_output(cmd, false).map(drop)
121+
state.capture_output(&cmd, false).map(drop)
122122
}
123123
}
124124

@@ -643,7 +643,7 @@ fn rustdoc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoResult
643643
false,
644644
).map(drop)
645645
} else if should_capture_output {
646-
state.capture_output(rustdoc, false).map(drop)
646+
state.capture_output(&rustdoc, false).map(drop)
647647
} else {
648648
rustdoc.exec()
649649
};

src/cargo/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl fmt::Display for VersionInfo {
110110
if let Some(channel) = self.cfg_info.as_ref().map(|ci| &ci.release_channel) {
111111
if channel != "stable" {
112112
write!(f, "-{}", channel)?;
113-
let empty = String::from("");
113+
let empty = String::new();
114114
write!(f, "{}", self.pre_release.as_ref().unwrap_or(&empty))?;
115115
}
116116
};

src/cargo/ops/fix.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ fn rustfix_crate(lock_addr: &str, rustc: &Path, filename: &Path, args: &FixArgs)
270270
rustfix_and_fix(&mut fixes, rustc, filename, args)?;
271271
let mut progress_yet_to_be_made = false;
272272
for (path, file) in fixes.files.iter_mut() {
273-
if file.errors_applying_fixes.len() == 0 {
273+
if file.errors_applying_fixes.is_empty() {
274274
continue
275275
}
276276
// If anything was successfully fixed *and* there's at least one
@@ -523,7 +523,7 @@ impl FixArgs {
523523
ret.prepare_for_edition = PrepareFor::Next;
524524
}
525525
ret.idioms = env::var(IDIOMS_ENV).is_ok();
526-
return ret
526+
ret
527527
}
528528

529529
fn apply(&self, cmd: &mut Command) {
@@ -535,10 +535,7 @@ impl FixArgs {
535535
if let Some(edition) = &self.enabled_edition {
536536
cmd.arg("--edition").arg(edition);
537537
if self.idioms {
538-
match &edition[..] {
539-
"2018" => { cmd.arg("-Wrust-2018-idioms"); }
540-
_ => {}
541-
}
538+
if edition == "2018" { cmd.arg("-Wrust-2018-idioms"); }
542539
}
543540
}
544541
match &self.prepare_for_edition {

src/cargo/util/diagnostic_server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ guide can be found at
199199
file,
200200
match edition {
201201
Some(s) => format!("with the {} edition", s),
202-
None => format!("without an edition"),
202+
None => "without an edition".to_string(),
203203
},
204204
))?;
205205
Ok(())

tests/testsuite/build.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,12 +1024,12 @@ fn cargo_compile_with_downloaded_dependency_with_offline() {
10241024
p2.cargo("build")
10251025
.masquerade_as_nightly_cargo()
10261026
.arg("-Zoffline"),
1027-
execs().with_stderr(format!(
1027+
execs().with_stderr(
10281028
"\
10291029
[COMPILING] present_dep v1.2.3
10301030
[COMPILING] bar v0.1.0 ([..])
10311031
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]"
1032-
)),
1032+
),
10331033
);
10341034
}
10351035

@@ -4439,7 +4439,7 @@ fn target_edition_feature_gated() {
44394439

44404440
assert_that(
44414441
p.cargo("build").arg("-v").masquerade_as_nightly_cargo(),
4442-
execs().with_status(101).with_stderr(format!(
4442+
execs().with_status(101).with_stderr(
44434443
"\
44444444
error: failed to parse manifest at `[..]`
44454445
@@ -4451,7 +4451,7 @@ Caused by:
44514451
44524452
consider adding `cargo-features = [\"edition\"]` to the manifest
44534453
"
4454-
)),
4454+
),
44554455
);
44564456
}
44574457

tests/testsuite/concurrent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn multiple_installs() {
5252

5353
#[test]
5454
fn concurrent_installs() {
55-
const LOCKED_BUILD: &'static str = "waiting for file lock on build directory";
55+
const LOCKED_BUILD: &str = "waiting for file lock on build directory";
5656

5757
pkg("foo", "0.0.1");
5858
pkg("bar", "0.0.1");

tests/testsuite/config.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use cargo::util::toml::{self, VecStringOrBool as VSOB};
44
use cargo::CargoError;
55
use support::{execs, lines_match, paths, project};
66
use support::hamcrest::assert_that;
7+
use std::borrow::Borrow;
78
use std::collections;
89
use std::fs;
910

@@ -68,8 +69,9 @@ fn new_config(env: &[(&str, &str)]) -> Config {
6869
config
6970
}
7071

71-
fn assert_error(error: CargoError, msgs: &str) {
72+
fn assert_error<E: Borrow<CargoError>>(error: E, msgs: &str) {
7273
let causes = error
74+
.borrow()
7375
.iter_chain()
7476
.map(|e| e.to_string())
7577
.collect::<Vec<_>>()

tests/testsuite/corrupt_git.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn deleting_database_files() {
3838

3939
let mut files = Vec::new();
4040
find_files(&paths::home().join(".cargo/git/db"), &mut files);
41-
assert!(files.len() > 0);
41+
assert!(!files.is_empty());
4242

4343
let log = "cargo::sources::git=trace";
4444
for file in files {
@@ -120,7 +120,7 @@ fn deleting_checkout_files() {
120120
.join(".git");
121121
let mut files = Vec::new();
122122
find_files(&dir, &mut files);
123-
assert!(files.len() > 0);
123+
assert!(!files.is_empty());
124124

125125
let log = "cargo::sources::git=trace";
126126
for file in files {

0 commit comments

Comments
 (0)