Skip to content

Commit e31a9ae

Browse files
committed
Fix clippy::needless_pass_by_ref_mut warning
``` warning: this argument is a mutable reference, but not used mutably --> src/process.rs:125:23 | 125 | pub(crate) fn run(&mut self) -> Result<()> { | ^^^^^^^^^ help: consider changing to: `&self` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut = note: `-W clippy::needless-pass-by-ref-mut` implied by `-W clippy::nursery` = help: to override `-W clippy::nursery` add `#[allow(clippy::needless_pass_by_ref_mut)]` warning: this argument is a mutable reference, but not used mutably --> src/process.rs:142:35 | 142 | pub(crate) fn run_with_output(&mut self) -> Result<Output> { | ^^^^^^^^^ help: consider changing to: `&self` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut ```
1 parent ab1c50c commit e31a9ae

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ fn exec_on_package(
480480
match kind {
481481
Kind::Normal => {
482482
// only run with default features
483-
return exec_cargo(cx, id, &mut line, progress, keep_going);
483+
return exec_cargo(cx, id, &line, progress, keep_going);
484484
}
485485
Kind::Each { .. } | Kind::Powerset { .. } => {}
486486
}
@@ -510,7 +510,7 @@ fn exec_on_package(
510510
// run with all features
511511
// https://github.com/taiki-e/cargo-hack/issues/42
512512
line.arg("--all-features");
513-
exec_cargo(cx, id, &mut line, progress, keep_going)?;
513+
exec_cargo(cx, id, &line, progress, keep_going)?;
514514
}
515515

516516
if !cx.no_default_features {
@@ -524,7 +524,7 @@ fn exec_on_package(
524524

525525
if !cx.exclude_no_default_features {
526526
// run with no default features if the package has other features
527-
exec_cargo(cx, id, &mut line, progress, keep_going)?;
527+
exec_cargo(cx, id, &line, progress, keep_going)?;
528528
}
529529

530530
match kind {
@@ -567,7 +567,7 @@ fn exec_cargo_with_features(
567567
) -> Result<()> {
568568
let mut line = line.clone();
569569
line.append_features(features);
570-
exec_cargo(cx, id, &mut line, progress, keep_going)
570+
exec_cargo(cx, id, &line, progress, keep_going)
571571
}
572572

573573
#[derive(Default)]
@@ -643,7 +643,7 @@ impl FromStr for LogGroup {
643643
fn exec_cargo(
644644
cx: &Context,
645645
id: &PackageId,
646-
line: &mut ProcessBuilder<'_>,
646+
line: &ProcessBuilder<'_>,
647647
progress: &mut Progress,
648648
keep_going: &mut KeepGoing,
649649
) -> Result<()> {
@@ -667,7 +667,7 @@ fn exec_cargo(
667667
fn exec_cargo_inner(
668668
cx: &Context,
669669
id: &PackageId,
670-
line: &mut ProcessBuilder<'_>,
670+
line: &ProcessBuilder<'_>,
671671
progress: &mut Progress,
672672
) -> Result<()> {
673673
if progress.count != 0 && !cx.print_command_list && cx.log_group == LogGroup::None {

src/process.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl<'a> ProcessBuilder<'a> {
121121

122122
/// Executes a process, waiting for completion, and mapping non-zero exit
123123
/// status to an error.
124-
pub(crate) fn run(&mut self) -> Result<()> {
124+
pub(crate) fn run(&self) -> Result<()> {
125125
let status = self.build().status().with_context(|| {
126126
process_error(format!("could not execute process {self:#}"), None, None)
127127
})?;
@@ -138,7 +138,7 @@ impl<'a> ProcessBuilder<'a> {
138138

139139
/// Executes a process, captures its stdio output, returning the captured
140140
/// output, or an error if non-zero exit status.
141-
pub(crate) fn run_with_output(&mut self) -> Result<Output> {
141+
pub(crate) fn run_with_output(&self) -> Result<Output> {
142142
let output = self.build().output().with_context(|| {
143143
process_error(format!("could not execute process {self:#}"), None, None)
144144
})?;
@@ -155,7 +155,7 @@ impl<'a> ProcessBuilder<'a> {
155155

156156
/// Executes a process, captures its stdio output, returning the captured
157157
/// standard output as a `String`.
158-
pub(crate) fn read(&mut self) -> Result<String> {
158+
pub(crate) fn read(&self) -> Result<String> {
159159
let mut output = String::from_utf8(self.run_with_output()?.stdout)
160160
.with_context(|| format!("failed to parse output from {self:#}"))?;
161161
while output.ends_with('\n') || output.ends_with('\r') {

src/rustup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pub(crate) fn install_toolchain(
160160
}
161161

162162
fn minor_version() -> Result<u32> {
163-
let mut cmd = cmd!("rustup", "--version");
163+
let cmd = cmd!("rustup", "--version");
164164
let output = cmd.read()?;
165165

166166
let version = (|| {

0 commit comments

Comments
 (0)