Skip to content

Commit f23b911

Browse files
committed
use sort_by_key() instead of comparing by keys manually
replace format!() macro by String::from() use eprintln() instead of manually writing to std::io::stderr
1 parent 44e7946 commit f23b911

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ impl Execs {
12331233
None => failures.push(e_line),
12341234
}
12351235
}
1236-
if failures.len() > 0 {
1236+
if !failures.is_empty() {
12371237
return Err(format!(
12381238
"Did not find expected line(s):\n{}\n\
12391239
Remaining available output:\n{}\n",

src/cargo/core/resolver/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ pub(super) fn activation_error(
254254
if let Err(e) = registry.query(&new_dep, &mut |s| candidates.push(s), true) {
255255
return to_resolve_err(e);
256256
};
257-
candidates.sort_unstable_by(|a, b| a.name().cmp(&b.name()));
257+
candidates.sort_unstable_by_key(|a| a.name());
258258
candidates.dedup_by(|a, b| a.name() == b.name());
259259
let mut candidates: Vec<_> = candidates
260260
.iter()

src/cargo/sources/git/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ pub fn fetch(
901901

902902
GitReference::DefaultBranch => {
903903
// See the module docs for why we're fetching `master` here.
904-
refspecs.push(format!("refs/heads/master:refs/remotes/origin/master"));
904+
refspecs.push(String::from("refs/heads/master:refs/remotes/origin/master"));
905905
refspecs.push(String::from("HEAD:refs/remotes/origin/HEAD"));
906906
}
907907

tests/testsuite/package.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,6 +1870,8 @@ fn long_file_names() {
18701870
test_path.mkdir_p();
18711871
let test_path = test_path.join(long_name);
18721872
if let Err(e) = File::create(&test_path) {
1873+
// write to stderr directly to avoid output from being captured
1874+
// and always display text, even without --nocapture
18731875
use std::io::Write;
18741876
writeln!(
18751877
std::io::stderr(),

0 commit comments

Comments
 (0)