Skip to main content

Lint clippy::redundant_closure_for_method_calls

warning clippy::redundant_closure_for_method_calls §

redundant closure

examples/../src/diagnostic/normalize.rs:103:51

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • update_lint_metadata (example)

Primary: examples/../src/diagnostic/normalize.rs:103:51

            kinds: message.target.kind.iter().map(|k| k.to_string()).collect(),

help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#redundant_closure_for_method_calls

note: `-W clippy::redundant-closure-for-method-calls` implied by `-W clippy::pedantic`

help: to override `-W clippy::pedantic` add `#[allow(clippy::redundant_closure_for_method_calls)]`

help: replace the closure with the method itself

Suggestion: replace the closure with the method itself

Diff unavailable: Source path cannot be represented safely in a patch

/home/runner/work/clippy-html/clippy-html/examples/../src/diagnostic/normalize.rs:103:51 · MachineApplicable

std::string::ToString::to_string
Rendered diagnostic (text)
warning: redundant closure
   --> examples/../src/diagnostic/normalize.rs:103:51
    |
103 |             kinds: message.target.kind.iter().map(|k| k.to_string()).collect(),
    |                                                   ^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::string::ToString::to_string`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#redundant_closure_for_method_calls
    = note: `-W clippy::redundant-closure-for-method-calls` implied by `-W clippy::pedantic`
    = help: to override `-W clippy::pedantic` add `#[allow(clippy::redundant_closure_for_method_calls)]`

warning clippy::redundant_closure_for_method_calls §

redundant closure

src/cargo.rs:48:42

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • cargo-clippy-html (bin)

Primary: src/cargo.rs:48:42

        build_dir: m.build_directory.map(|p| p.into_std_path_buf()),

help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#redundant_closure_for_method_calls

note: `-W clippy::redundant-closure-for-method-calls` implied by `-W clippy::pedantic`

help: to override `-W clippy::pedantic` add `#[allow(clippy::redundant_closure_for_method_calls)]`

help: replace the closure with the method itself

Suggestion: replace the closure with the method itself

MachineApplicable

--- "a/src/cargo.rs"
+++ "b/src/cargo.rs"
@@ -45,7 +45,7 @@
         .collect();
     Ok(ProjectInfo {
         workspace_root: m.workspace_root.into_std_path_buf(),
-        build_dir: m.build_directory.map(|p| p.into_std_path_buf()),
+        build_dir: m.build_directory.map(cargo_metadata::camino::Utf8PathBuf::into_std_path_buf),
         target_dir: ctx
             .target_dir_override
             .clone()
Rendered diagnostic (text)
warning: redundant closure
  --> src/cargo.rs:48:42
   |
48 |         build_dir: m.build_directory.map(|p| p.into_std_path_buf()),
   |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `cargo_metadata::camino::Utf8PathBuf::into_std_path_buf`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#redundant_closure_for_method_calls
   = note: `-W clippy::redundant-closure-for-method-calls` implied by `-W clippy::pedantic`
   = help: to override `-W clippy::pedantic` add `#[allow(clippy::redundant_closure_for_method_calls)]`

warning clippy::redundant_closure_for_method_calls §

redundant closure

src/cargo.rs:190:57

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • cargo-clippy-html (bin)

Primary: src/cargo.rs:190:57

                        kinds: m.target.kind.iter().map(|k| k.to_string()).collect(),

help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#redundant_closure_for_method_calls

help: replace the closure with the method itself

Suggestion: replace the closure with the method itself

MachineApplicable

--- "a/src/cargo.rs"
+++ "b/src/cargo.rs"
@@ -187,7 +187,7 @@
                     packages.insert(m.package_id.to_string());
                     targets.insert(TargetInfo {
                         name: m.target.name.clone(),
-                        kinds: m.target.kind.iter().map(|k| k.to_string()).collect(),
+                        kinds: m.target.kind.iter().map(std::string::ToString::to_string).collect(),
                         source: m.target.src_path.clone().into_std_path_buf(),
                     });
                     result.messages.push(m);
Rendered diagnostic (text)
warning: redundant closure
   --> src/cargo.rs:190:57
    |
190 |                         kinds: m.target.kind.iter().map(|k| k.to_string()).collect(),
    |                                                         ^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::string::ToString::to_string`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#redundant_closure_for_method_calls

warning clippy::redundant_closure_for_method_calls §

redundant closure

src/cargo.rs:199:57

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • cargo-clippy-html (bin)

Primary: src/cargo.rs:199:57

                        kinds: a.target.kind.iter().map(|k| k.to_string()).collect(),

help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#redundant_closure_for_method_calls

help: replace the closure with the method itself

Suggestion: replace the closure with the method itself

MachineApplicable

--- "a/src/cargo.rs"
+++ "b/src/cargo.rs"
@@ -196,7 +196,7 @@
                     packages.insert(a.package_id.to_string());
                     targets.insert(TargetInfo {
                         name: a.target.name.clone(),
-                        kinds: a.target.kind.iter().map(|k| k.to_string()).collect(),
+                        kinds: a.target.kind.iter().map(std::string::ToString::to_string).collect(),
                         source: a.target.src_path.into_std_path_buf(),
                     });
                 }
Rendered diagnostic (text)
warning: redundant closure
   --> src/cargo.rs:199:57
    |
199 |                         kinds: a.target.kind.iter().map(|k| k.to_string()).collect(),
    |                                                         ^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::string::ToString::to_string`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#redundant_closure_for_method_calls

warning clippy::redundant_closure_for_method_calls §

redundant closure

src/diagnostic/normalize.rs:103:51

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • cargo-clippy-html (bin)

Primary: src/diagnostic/normalize.rs:103:51

            kinds: message.target.kind.iter().map(|k| k.to_string()).collect(),

help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#redundant_closure_for_method_calls

help: replace the closure with the method itself

Suggestion: replace the closure with the method itself

MachineApplicable

--- "a/src/diagnostic/normalize.rs"
+++ "b/src/diagnostic/normalize.rs"
@@ -100,7 +100,7 @@
         package_id: message.package_id.to_string(),
         targets: vec![TargetInfo {
             name: message.target.name.clone(),
-            kinds: message.target.kind.iter().map(|k| k.to_string()).collect(),
+            kinds: message.target.kind.iter().map(std::string::ToString::to_string).collect(),
             source: message.target.src_path.clone().into_std_path_buf(),
         }],
         origin: origin.into(),
Rendered diagnostic (text)
warning: redundant closure
   --> src/diagnostic/normalize.rs:103:51
    |
103 |             kinds: message.target.kind.iter().map(|k| k.to_string()).collect(),
    |                                                   ^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::string::ToString::to_string`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#redundant_closure_for_method_calls