Skip to content

Commit

Permalink
use sort_by_key() instead of comparing by keys manually
Browse files Browse the repository at this point in the history
replace format!() macro by String::from()
use eprintln() instead of manually writing to std::io::stderr
  • Loading branch information
matthiaskrgr committed Aug 3, 2020
1 parent 44e7946 commit f23b911
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
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 @@ -1233,7 +1233,7 @@ impl Execs {
None => failures.push(e_line),
}
}
if failures.len() > 0 {
if !failures.is_empty() {
return Err(format!(
"Did not find expected line(s):\n{}\n\
Remaining available output:\n{}\n",
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/resolver/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ pub(super) fn activation_error(
if let Err(e) = registry.query(&new_dep, &mut |s| candidates.push(s), true) {
return to_resolve_err(e);
};
candidates.sort_unstable_by(|a, b| a.name().cmp(&b.name()));
candidates.sort_unstable_by_key(|a| a.name());
candidates.dedup_by(|a, b| a.name() == b.name());
let mut candidates: Vec<_> = candidates
.iter()
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/sources/git/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ pub fn fetch(

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

Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1870,6 +1870,8 @@ fn long_file_names() {
test_path.mkdir_p();
let test_path = test_path.join(long_name);
if let Err(e) = File::create(&test_path) {
// write to stderr directly to avoid output from being captured
// and always display text, even without --nocapture
use std::io::Write;
writeln!(
std::io::stderr(),
Expand Down

0 comments on commit f23b911

Please sign in to comment.