Skip to content

Commit 3d4004c

Browse files
committed
Fix clippy warnings.
1 parent 61cf771 commit 3d4004c

File tree

6 files changed

+15
-16
lines changed

6 files changed

+15
-16
lines changed

src/cargo.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ pub enum Subcommand {
1919
}
2020

2121
impl Subcommand {
22-
pub fn needs_docker(&self) -> bool {
23-
match *self {
22+
pub fn needs_docker(self) -> bool {
23+
match self {
2424
Subcommand::Other => false,
2525
_ => true,
2626
}
2727
}
2828

29-
pub fn needs_interpreter(&self) -> bool {
30-
match *self {
29+
pub fn needs_interpreter(self) -> bool {
30+
match self {
3131
Subcommand::Run | Subcommand::Test | Subcommand::Bench => true,
3232
_ => false,
3333
}

src/cli.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ pub fn parse(target_list: &TargetList) -> Args {
3636
}
3737

3838
Args {
39-
all: all,
39+
all,
4040
subcommand: sc,
41-
target: target,
41+
target,
4242
}
4343
}

src/docker.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ pub fn run(target: &Target,
134134
}
135135

136136
if let Ok(value) = env::var("DOCKER_OPTS") {
137-
let opts: Vec<&str> = value.split(" ").collect();
137+
let opts: Vec<&str> = value.split(' ').collect();
138138
docker.args(&opts);
139139
}
140140

141141
docker
142-
.args(&["-e", &format!("CROSS_RUNNER={}", runner.unwrap_or_else(|| String::new()))])
142+
.args(&["-e", &format!("CROSS_RUNNER={}", runner.unwrap_or_else(String::new))])
143143
.args(&["-v", &format!("{}:/xargo:Z", xargo_dir.display())])
144144
.args(&["-v", &format!("{}:/cargo:Z", cargo_dir.display())])
145145
// Prevent `bin` from being mounted inside the Docker container.

src/interpreter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::Target;
77
/// Checks if the interpreters have been registered in the host system
88
pub fn is_registered(target: &Target) -> Result<bool> {
99
if file::read("/proc/sys/fs/binfmt_misc/status")?.trim() != "enabled" {
10-
Err("host system doesn't have binfmt_misc support")?
10+
return Err("host system doesn't have binfmt_misc support".into());
1111
}
1212

1313
let ok = if target.is_windows() {

src/main.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ fn run() -> Result<ExitStatus> {
225225

226226
if host.is_supported(args.target.as_ref()) {
227227
let target = args.target
228-
.unwrap_or(Target::from(host.triple(), &target_list));
228+
.unwrap_or_else(|| Target::from(host.triple(), &target_list));
229229
let toml = toml(&root)?;
230230

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

257-
if args.subcommand.map(|sc| sc == Subcommand::Clippy).unwrap_or(false) {
258-
if !rustup::component_is_installed("clippy", toolchain, verbose)? {
259-
rustup::install_component("clippy", toolchain, verbose)?;
260-
}
257+
if args.subcommand.map(|sc| sc == Subcommand::Clippy).unwrap_or(false) &&
258+
!rustup::component_is_installed("clippy", toolchain, verbose)? {
259+
rustup::install_component("clippy", toolchain, verbose)?;
261260
}
262261

263262
let needs_interpreter = args.subcommand.map(|sc| sc.needs_interpreter()).unwrap_or(false);

src/rustc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ impl VersionMetaExt for VersionMeta {
2828
}
2929

3030
fn needs_interpreter(&self) -> bool {
31-
!(self.semver >= Version {
31+
self.semver < Version {
3232
major: 1,
3333
minor: 19,
3434
patch: 0,
3535
pre: vec![],
3636
build: vec![],
37-
})
37+
}
3838
}
3939
}
4040

0 commit comments

Comments
 (0)