Skip to content

Commit

Permalink
Fix clippy warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Nov 16, 2019
1 parent 61cf771 commit 3d4004c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ pub enum Subcommand {
}

impl Subcommand {
pub fn needs_docker(&self) -> bool {
match *self {
pub fn needs_docker(self) -> bool {
match self {
Subcommand::Other => false,
_ => true,
}
}

pub fn needs_interpreter(&self) -> bool {
match *self {
pub fn needs_interpreter(self) -> bool {
match self {
Subcommand::Run | Subcommand::Test | Subcommand::Bench => true,
_ => false,
}
Expand Down
4 changes: 2 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ pub fn parse(target_list: &TargetList) -> Args {
}

Args {
all: all,
all,
subcommand: sc,
target: target,
target,
}
}
4 changes: 2 additions & 2 deletions src/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ pub fn run(target: &Target,
}

if let Ok(value) = env::var("DOCKER_OPTS") {
let opts: Vec<&str> = value.split(" ").collect();
let opts: Vec<&str> = value.split(' ').collect();
docker.args(&opts);
}

docker
.args(&["-e", &format!("CROSS_RUNNER={}", runner.unwrap_or_else(|| String::new()))])
.args(&["-e", &format!("CROSS_RUNNER={}", runner.unwrap_or_else(String::new))])
.args(&["-v", &format!("{}:/xargo:Z", xargo_dir.display())])
.args(&["-v", &format!("{}:/cargo:Z", cargo_dir.display())])
// Prevent `bin` from being mounted inside the Docker container.
Expand Down
2 changes: 1 addition & 1 deletion src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::Target;
/// Checks if the interpreters have been registered in the host system
pub fn is_registered(target: &Target) -> Result<bool> {
if file::read("/proc/sys/fs/binfmt_misc/status")?.trim() != "enabled" {
Err("host system doesn't have binfmt_misc support")?
return Err("host system doesn't have binfmt_misc support".into());
}

let ok = if target.is_windows() {
Expand Down
9 changes: 4 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ fn run() -> Result<ExitStatus> {

if host.is_supported(args.target.as_ref()) {
let target = args.target
.unwrap_or(Target::from(host.triple(), &target_list));
.unwrap_or_else(|| Target::from(host.triple(), &target_list));
let toml = toml(&root)?;

let sysroot = rustc::sysroot(&host, &target, verbose)?;
Expand Down Expand Up @@ -254,10 +254,9 @@ fn run() -> Result<ExitStatus> {
rustup::install_component("rust-src", toolchain, verbose)?;
}

if args.subcommand.map(|sc| sc == Subcommand::Clippy).unwrap_or(false) {
if !rustup::component_is_installed("clippy", toolchain, verbose)? {
rustup::install_component("clippy", toolchain, verbose)?;
}
if args.subcommand.map(|sc| sc == Subcommand::Clippy).unwrap_or(false) &&
!rustup::component_is_installed("clippy", toolchain, verbose)? {
rustup::install_component("clippy", toolchain, verbose)?;
}

let needs_interpreter = args.subcommand.map(|sc| sc.needs_interpreter()).unwrap_or(false);
Expand Down
4 changes: 2 additions & 2 deletions src/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ impl VersionMetaExt for VersionMeta {
}

fn needs_interpreter(&self) -> bool {
!(self.semver >= Version {
self.semver < Version {
major: 1,
minor: 19,
patch: 0,
pre: vec![],
build: vec![],
})
}
}
}

Expand Down

0 comments on commit 3d4004c

Please sign in to comment.