Skip to content

Commit c1a9ee8

Browse files
committed
fix clippy
1 parent 174bf23 commit c1a9ee8

16 files changed

+91
-93
lines changed

src/bin/commands/containers.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,9 @@ fn get_cross_volumes(
322322
use cross::docker::remote::VOLUME_PREFIX;
323323
let stdout = docker::subcommand(engine, "volume")
324324
.arg("list")
325-
.args(&["--format", "{{.Name}}"])
325+
.args(["--format", "{{.Name}}"])
326326
// handles simple regex: ^ for start of line.
327-
.args(&["--filter", &format!("name=^{VOLUME_PREFIX}")])
327+
.args(["--filter", &format!("name=^{VOLUME_PREFIX}")])
328328
.run_and_get_stdout(msg_info)?;
329329

330330
let mut volumes: Vec<String> = stdout.lines().map(|s| s.to_string()).collect();
@@ -371,7 +371,7 @@ pub fn prune_volumes(
371371
msg_info: &mut MessageInfo,
372372
) -> cross::Result<()> {
373373
let mut command = docker::subcommand(engine, "volume");
374-
command.args(&["prune", "--force"]);
374+
command.args(["prune", "--force"]);
375375
if execute {
376376
command.run(msg_info, false).map_err(Into::into)
377377
} else {
@@ -405,7 +405,7 @@ pub fn create_persistent_volume(
405405
}
406406

407407
docker::subcommand(engine, "volume")
408-
.args(&["create", &volume])
408+
.args(["create", &volume])
409409
.run_and_get_status(msg_info, false)?;
410410

411411
// stop the container if it's already running
@@ -422,9 +422,9 @@ pub fn create_persistent_volume(
422422
// create a dummy running container to copy data over
423423
let mount_prefix = docker::remote::MOUNT_PREFIX;
424424
let mut docker = docker::subcommand(engine, "run");
425-
docker.args(&["--name", &container]);
425+
docker.args(["--name", &container]);
426426
docker.arg("--rm");
427-
docker.args(&["-v", &format!("{}:{}", volume, mount_prefix)]);
427+
docker.args(["-v", &format!("{}:{}", volume, mount_prefix)]);
428428
docker.arg("-d");
429429
let is_tty = io::Stdin::is_atty() && io::Stdout::is_atty() && io::Stderr::is_atty();
430430
if is_tty {
@@ -437,7 +437,7 @@ pub fn create_persistent_volume(
437437
// a TTY. this has a few issues though: now, the
438438
// container no longer responds to signals, so the
439439
// container will need to be sig-killed.
440-
docker.args(&["sh", "-c", "sleep infinity"]);
440+
docker.args(["sh", "-c", "sleep infinity"]);
441441
}
442442
// store first, since failing to non-existing container is fine
443443
docker::remote::create_container_deleter(engine.clone(), container.clone());
@@ -501,9 +501,9 @@ fn get_cross_containers(
501501
use cross::docker::remote::VOLUME_PREFIX;
502502
let stdout = docker::subcommand(engine, "ps")
503503
.arg("-a")
504-
.args(&["--format", "{{.Names}}: {{.State}}"])
504+
.args(["--format", "{{.Names}}: {{.State}}"])
505505
// handles simple regex: ^ for start of line.
506-
.args(&["--filter", &format!("name=^{VOLUME_PREFIX}")])
506+
.args(["--filter", &format!("name=^{VOLUME_PREFIX}")])
507507
.run_and_get_stdout(msg_info)?;
508508

509509
let mut containers: Vec<String> = stdout.lines().map(|s| s.to_string()).collect();

src/bin/commands/images.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ fn get_cross_images(
167167
local: bool,
168168
) -> cross::Result<Vec<Image>> {
169169
let mut images: BTreeSet<_> = cross::docker::subcommand(engine, "images")
170-
.args(&["--format", "{{.Repository}}:{{.Tag}} {{.ID}}"])
171-
.args(&[
170+
.args(["--format", "{{.Repository}}:{{.Tag}} {{.ID}}"])
171+
.args([
172172
"--filter",
173173
&format!("label={}.for-cross-target", cross::CROSS_LABEL_DOMAIN),
174174
])
@@ -178,7 +178,7 @@ fn get_cross_images(
178178
.collect();
179179

180180
let stdout = cross::docker::subcommand(engine, "images")
181-
.args(&["--format", "{{.Repository}}:{{.Tag}} {{.ID}}"])
181+
.args(["--format", "{{.Repository}}:{{.Tag}} {{.ID}}"])
182182
.run_and_get_stdout(msg_info)?;
183183
let ids: Vec<_> = images.iter().map(|i| i.id.to_string()).collect();
184184
images.extend(
@@ -239,7 +239,7 @@ fn get_image_target(
239239
}
240240
}
241241
let mut command = cross::docker::subcommand(engine, "inspect");
242-
command.args(&[
242+
command.args([
243243
"--format",
244244
&format!(
245245
r#"{{{{index .Config.Labels "{}.for-cross-target"}}}}"#,

src/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn commit_info() -> String {
3939

4040
fn commit_hash() -> Result<String, Some> {
4141
let output = Command::new("git")
42-
.args(&["rev-parse", "--short", "HEAD"])
42+
.args(["rev-parse", "--short", "HEAD"])
4343
.output()?;
4444

4545
if output.status.success() {
@@ -51,7 +51,7 @@ fn commit_hash() -> Result<String, Some> {
5151

5252
fn commit_date() -> Result<String, Some> {
5353
let output = Command::new("git")
54-
.args(&["log", "-1", "--date=short", "--pretty=format:%cd"])
54+
.args(["log", "-1", "--date=short", "--pretty=format:%cd"])
5555
.output()?;
5656

5757
if output.status.success() {

src/cargo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ pub fn cargo_metadata_with_args(
132132
if let Some(channel) = args.and_then(|x| x.channel.as_deref()) {
133133
command.arg(format!("+{channel}"));
134134
}
135-
command.arg("metadata").args(&["--format-version", "1"]);
135+
command.arg("metadata").args(["--format-version", "1"]);
136136
if let Some(cd) = cd {
137137
command.current_dir(cd);
138138
}

src/docker/custom.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ impl<'a> Dockerfile<'a> {
151151
opts.contains("--load") || opts.contains("--output")
152152
});
153153
if options.engine.kind.is_docker() && !has_output {
154-
docker_build.args(&["--output", "type=docker"]);
154+
docker_build.args(["--output", "type=docker"]);
155155
};
156156

157157
if let Some(context) = self.context() {
158-
docker_build.arg(&context);
158+
docker_build.arg(context);
159159
} else {
160160
docker_build.arg(paths.host_root());
161161
}

src/docker/image.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ impl ImagePlatform {
374374
&& Some(&self.os) == engine.os.as_ref()
375375
{
376376
} else {
377-
cmd.args(&["--platform", &self.docker_platform()]);
377+
cmd.args(["--platform", &self.docker_platform()]);
378378
}
379379
}
380380
}

src/docker/local.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use eyre::Context;
1212
// NOTE: host path must be absolute
1313
fn mount(docker: &mut Command, host_path: &Path, absolute_path: &Path, prefix: &str) -> Result<()> {
1414
let mount_path = absolute_path.as_posix_absolute()?;
15-
docker.args(&[
15+
docker.args([
1616
"-v",
1717
&format!("{}:{prefix}{}:z", host_path.to_utf8()?, mount_path),
1818
]);
@@ -62,36 +62,36 @@ pub(crate) fn run(
6262
docker_user_id(&mut docker, engine.kind);
6363

6464
docker
65-
.args(&[
65+
.args([
6666
"-v",
6767
&format!("{}:{}:z", dirs.xargo.to_utf8()?, dirs.xargo_mount_path()),
6868
])
69-
.args(&[
69+
.args([
7070
"-v",
7171
&format!("{}:{}:z", dirs.cargo.to_utf8()?, dirs.cargo_mount_path()),
7272
])
7373
// Prevent `bin` from being mounted inside the Docker container.
74-
.args(&["-v", &format!("{}/bin", dirs.cargo_mount_path())]);
75-
docker.args(&[
74+
.args(["-v", &format!("{}/bin", dirs.cargo_mount_path())]);
75+
docker.args([
7676
"-v",
7777
&format!("{}:{}:z", dirs.host_root.to_utf8()?, dirs.mount_root),
7878
]);
7979
docker
80-
.args(&[
80+
.args([
8181
"-v",
8282
&format!(
8383
"{}:{}:z,ro",
8484
dirs.get_sysroot().to_utf8()?,
8585
dirs.sysroot_mount_path()
8686
),
8787
])
88-
.args(&["-v", &format!("{}:/target:z", dirs.target.to_utf8()?)]);
88+
.args(["-v", &format!("{}:/target:z", dirs.target.to_utf8()?)]);
8989
docker_cwd(&mut docker, &paths)?;
9090

9191
// When running inside NixOS or using Nix packaging we need to add the Nix
9292
// Store to the running container so it can load the needed binaries.
9393
if let Some(ref nix_store) = dirs.nix_store {
94-
docker.args(&[
94+
docker.args([
9595
"-v",
9696
&format!(
9797
"{}:{}:z",
@@ -113,7 +113,7 @@ pub(crate) fn run(
113113

114114
docker
115115
.arg(&image_name)
116-
.args(&["sh", "-c", &build_command(dirs, &cmd)])
116+
.args(["sh", "-c", &build_command(dirs, &cmd)])
117117
.run_and_get_status(msg_info, false)
118118
.map_err(Into::into)
119119
}

src/docker/remote.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ fn create_volume_dir(
160160
// make our parent directory if needed
161161
subcommand_or_exit(engine, "exec")?
162162
.arg(container)
163-
.args(&[
163+
.args([
164164
"sh",
165165
"-c",
166166
&format!("mkdir -p '{}'", dir.as_posix_absolute()?),
@@ -210,7 +210,7 @@ fn container_path_exists(
210210
) -> Result<bool> {
211211
Ok(subcommand_or_exit(engine, "exec")?
212212
.arg(container)
213-
.args(&[
213+
.args([
214214
"bash",
215215
"-c",
216216
&format!("[[ -d '{}' ]]", path.as_posix_absolute()?),
@@ -659,7 +659,7 @@ rm \"{PATH}\"
659659

660660
subcommand_or_exit(engine, "exec")?
661661
.arg(container)
662-
.args(&["sh", "-c", &script.join("\n")])
662+
.args(["sh", "-c", &script.join("\n")])
663663
.run_and_get_status(msg_info, true)
664664
}
665665

@@ -812,9 +812,9 @@ pub fn container_state(
812812
msg_info: &mut MessageInfo,
813813
) -> Result<ContainerState> {
814814
let stdout = command(engine)
815-
.args(&["ps", "-a"])
816-
.args(&["--filter", &format!("name={container}")])
817-
.args(&["--format", "{{.State}}"])
815+
.args(["ps", "-a"])
816+
.args(["--filter", &format!("name={container}")])
817+
.args(["--format", "{{.State}}"])
818818
.run_and_get_stdout(msg_info)?;
819819
ContainerState::new(stdout.trim())
820820
}
@@ -946,13 +946,13 @@ pub(crate) fn run(
946946
.image
947947
.platform
948948
.specify_platform(&options.engine, &mut docker);
949-
docker.args(&["--name", &container]);
949+
docker.args(["--name", &container]);
950950
docker.arg("--rm");
951951
let volume_mount = match volume {
952952
VolumeId::Keep(ref id) => format!("{id}:{mount_prefix}"),
953953
VolumeId::Discard => mount_prefix.to_owned(),
954954
};
955-
docker.args(&["-v", &volume_mount]);
955+
docker.args(["-v", &volume_mount]);
956956

957957
let mut volumes = vec![];
958958
docker_mount(
@@ -968,7 +968,7 @@ pub(crate) fn run(
968968
.wrap_err("when copying seccomp profile")?;
969969

970970
// Prevent `bin` from being mounted inside the Docker container.
971-
docker.args(&["-v", &format!("{mount_prefix}/cargo/bin")]);
971+
docker.args(["-v", &format!("{mount_prefix}/cargo/bin")]);
972972

973973
// When running inside NixOS or using Nix packaging we need to add the Nix
974974
// Store to the running container so it can load the needed binaries.
@@ -999,7 +999,7 @@ pub(crate) fn run(
999999
// a TTY. this has a few issues though: now, the
10001000
// container no longer responds to signals, so the
10011001
// container will need to be sig-killed.
1002-
docker.args(&["sh", "-c", "sleep infinity"]);
1002+
docker.args(["sh", "-c", "sleep infinity"]);
10031003
}
10041004

10051005
// store first, since failing to non-existing container is fine
@@ -1202,7 +1202,7 @@ symlink_recurse \"${{prefix}}\"
12021202
}
12031203
subcommand_or_exit(engine, "exec")?
12041204
.arg(&container)
1205-
.args(&["sh", "-c", &symlink.join("\n")])
1205+
.args(["sh", "-c", &symlink.join("\n")])
12061206
.run_and_get_status(msg_info, false)
12071207
.wrap_err("when creating symlinks to provide consistent host/mount paths")?;
12081208

@@ -1219,7 +1219,7 @@ symlink_recurse \"${{prefix}}\"
12191219
)?;
12201220
docker_cwd(&mut docker, &paths)?;
12211221
docker.arg(&container);
1222-
docker.args(&["sh", "-c", &build_command(dirs, &cmd)]);
1222+
docker.args(["sh", "-c", &build_command(dirs, &cmd)]);
12231223
bail_container_exited!();
12241224
let status = docker
12251225
.run_and_get_status(msg_info, false)
@@ -1236,8 +1236,7 @@ symlink_recurse \"${{prefix}}\"
12361236
.arg("-a")
12371237
.arg(&format!("{container}:{}", target_dir.as_posix_absolute()?))
12381238
.arg(
1239-
&dirs
1240-
.target
1239+
dirs.target
12411240
.parent()
12421241
.expect("target directory should have a parent"),
12431242
)

0 commit comments

Comments
 (0)