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

Resolve some clippy lint warnings #5884

Merged
merged 10 commits into from
Aug 14, 2018
4 changes: 2 additions & 2 deletions src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1010,8 +1010,8 @@ fn json_stderr(line: &str, package_id: &PackageId, target: &Target) -> CargoResu
.map_err(|_| internal(&format!("compiler produced invalid json: `{}`", line)))?;

machine_message::emit(&machine_message::FromCompiler {
package_id: package_id,
target: target,
package_id,
target,
message: compiler_message,
});
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/ops/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ fn rustfix_and_fix(fixes: &mut FixedCrate, rustc: &Path, filename: &Path, args:
filename,
output.status.code()
);
return Ok(Default::default());
return Ok(());
}

let fix_mode = env::var_os("__CARGO_FIX_YOLO")
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/util/lev_distance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn test_lev_distance() {
use std::char::{from_u32, MAX};
// Test bytelength agnosticity
for c in (0u32..MAX as u32)
.filter_map(|i| from_u32(i))
.filter_map(from_u32)
.map(|i| i.to_string())
{
assert_eq!(lev_distance(&c, &c), 0);
Expand Down
4 changes: 1 addition & 3 deletions tests/testsuite/build_script.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::env;
use std::fs::{self, File};
use std::io::prelude::*;
use std::path::PathBuf;
use std::io;
use std::thread;
use std::time::Duration;
Expand Down Expand Up @@ -3555,8 +3554,7 @@ fn rename_with_link_search_path() {
// the `p` project. On OSX the `libfoo.dylib` artifact references the
// original path in `p` so we want to make sure that it can't find it (hence
// the deletion).
let root = PathBuf::from(p.root());
let root = root.join("target").join("debug").join("deps");
let root = p.root().join("target").join("debug").join("deps");
let file = format!("{}foo{}", env::consts::DLL_PREFIX, env::consts::DLL_SUFFIX);
let src = root.join(&file);

Expand Down
8 changes: 4 additions & 4 deletions tests/testsuite/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,10 +651,10 @@ i64max = 9223372036854775807
("CARGO_EI64MAX", "9223372036854775807"),
]);

assert_eq!(config.get::<u64>("i64max").unwrap(), 9223372036854775807);
assert_eq!(config.get::<i64>("i64max").unwrap(), 9223372036854775807);
assert_eq!(config.get::<u64>("ei64max").unwrap(), 9223372036854775807);
assert_eq!(config.get::<i64>("ei64max").unwrap(), 9223372036854775807);
assert_eq!(config.get::<u64>("i64max").unwrap(), 9_223_372_036_854_775_807);
assert_eq!(config.get::<i64>("i64max").unwrap(), 9_223_372_036_854_775_807);
assert_eq!(config.get::<u64>("ei64max").unwrap(), 9_223_372_036_854_775_807);
assert_eq!(config.get::<i64>("ei64max").unwrap(), 9_223_372_036_854_775_807);

assert_error(
config.get::<u32>("nneg").unwrap_err(),
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,7 @@ fn doc_private_items() {
assert_that(&foo.root().join("target/doc/foo/private/index.html"), existing_file());
}

const BAD_INTRA_LINK_LIB: &'static str = r#"
const BAD_INTRA_LINK_LIB: &str = r#"
#![deny(intra_doc_link_resolution_failure)]

/// [bad_link]
Expand Down
30 changes: 14 additions & 16 deletions tests/testsuite/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,24 +218,22 @@ fn cargo_compile_offline_with_cached_git_dep() {
execs().with_stdout("hello from cached git repo rev2\n"),
);

drop(
File::create(&p.root().join("Cargo.toml"))
.unwrap()
.write_all(&format!(
r#"
[project]
name = "foo"
version = "0.5.0"
File::create(&p.root().join("Cargo.toml"))
.unwrap()
.write_all(&format!(
r#"
[project]
name = "foo"
version = "0.5.0"

[dependencies.dep1]
git = '{}'
rev = "{}"
[dependencies.dep1]
git = '{}'
rev = "{}"
"#,
git_project.url(),
rev1
).as_bytes())
.unwrap(),
);
git_project.url(),
rev1
).as_bytes())
.unwrap();

let _out = p
.cargo("build")
Expand Down
5 changes: 2 additions & 3 deletions tests/testsuite/support/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,8 @@ pub fn commit(repo: &git2::Repository) -> git2::Oid {
let tree_id = t!(t!(repo.index()).write_tree());
let sig = t!(repo.signature());
let mut parents = Vec::new();
match repo.head().ok().map(|h| h.target().unwrap()) {
Some(parent) => parents.push(t!(repo.find_commit(parent))),
None => {}
if let Some(parent) = repo.head().ok().map(|h| h.target().unwrap()) {
parents.push(t!(repo.find_commit(parent)))
}
let parents = parents.iter().collect::<Vec<_>>();
t!(repo.commit(
Expand Down
7 changes: 1 addition & 6 deletions tests/testsuite/support/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,7 @@ impl ProjectBuilder {
symlink.mk();
}

let ProjectBuilder {
root,
files: _,
symlinks: _,
..
} = self;
let ProjectBuilder { root, .. } = self;
root
}

Expand Down