Skip to main content

Lint clippy::needless_pass_by_value

warning clippy::needless_pass_by_value §

this argument is passed by value, but not consumed in the function body

examples/../src/diagnostic/normalize.rs:41:39

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • update_lint_metadata (example)

Primary: examples/../src/diagnostic/normalize.rs:41:39

fn note(v: &Value, root: &Path, path: Vec<usize>, suggestions: &mut Vec<Suggestion>) -> Note {

Primary: examples/../src/diagnostic/normalize.rs:64:25

            child_path: path.clone(),

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

note: `-W clippy::needless-pass-by-value` implied by `-W clippy::pedantic`

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

help: consider changing the type to

help: change `path.clone()` to

Suggestion: consider changing the type to

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

/home/runner/work/clippy-html/clippy-html/examples/../src/diagnostic/normalize.rs:41:39 · Unspecified

&[usize]
Suggestion: change `path.clone()` to

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

/home/runner/work/clippy-html/clippy-html/examples/../src/diagnostic/normalize.rs:64:25 · Unspecified

path.to_owned()
Rendered diagnostic (text)
warning: this argument is passed by value, but not consumed in the function body
  --> examples/../src/diagnostic/normalize.rs:41:39
   |
41 | fn note(v: &Value, root: &Path, path: Vec<usize>, suggestions: &mut Vec<Suggestion>) -> Note {
   |                                       ^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#needless_pass_by_value
   = note: `-W clippy::needless-pass-by-value` implied by `-W clippy::pedantic`
   = help: to override `-W clippy::pedantic` add `#[allow(clippy::needless_pass_by_value)]`
help: consider changing the type to
   |
41 - fn note(v: &Value, root: &Path, path: Vec<usize>, suggestions: &mut Vec<Suggestion>) -> Note {
41 + fn note(v: &Value, root: &Path, path: &[usize], suggestions: &mut Vec<Suggestion>) -> Note {
   |
help: change `path.clone()` to
   |
64 -             child_path: path.clone(),
64 +             child_path: path.to_owned(),
   |

warning clippy::needless_pass_by_value §

this argument is passed by value, but not consumed in the function body

src/diagnostic/normalize.rs:41:39

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

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

Primary: src/diagnostic/normalize.rs:41:39

fn note(v: &Value, root: &Path, path: Vec<usize>, suggestions: &mut Vec<Suggestion>) -> Note {

Primary: src/diagnostic/normalize.rs:64:25

            child_path: path.clone(),

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

note: `-W clippy::needless-pass-by-value` implied by `-W clippy::pedantic`

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

help: consider changing the type to

help: change `path.clone()` to

Suggestion: consider changing the type to

Unspecified

--- "a/src/diagnostic/normalize.rs"
+++ "b/src/diagnostic/normalize.rs"
@@ -38,7 +38,7 @@
         })
         .collect()
 }
-fn note(v: &Value, root: &Path, path: Vec<usize>, suggestions: &mut Vec<Suggestion>) -> Note {
+fn note(v: &Value, root: &Path, path: &[usize], suggestions: &mut Vec<Suggestion>) -> Note {
     let normalized = spans(v, root);
     let replacements: Vec<_> = v["spans"]
         .as_array()
Suggestion: change `path.clone()` to

Unspecified

--- "a/src/diagnostic/normalize.rs"
+++ "b/src/diagnostic/normalize.rs"
@@ -61,7 +61,7 @@
     if !replacements.is_empty() {
         suggestions.push(Suggestion {
             message: string(v, "message"),
-            child_path: path.clone(),
+            child_path: path.to_owned(),
             replacements,
         });
     }
Rendered diagnostic (text)
warning: this argument is passed by value, but not consumed in the function body
  --> src/diagnostic/normalize.rs:41:39
   |
41 | fn note(v: &Value, root: &Path, path: Vec<usize>, suggestions: &mut Vec<Suggestion>) -> Note {
   |                                       ^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#needless_pass_by_value
   = note: `-W clippy::needless-pass-by-value` implied by `-W clippy::pedantic`
   = help: to override `-W clippy::pedantic` add `#[allow(clippy::needless_pass_by_value)]`
help: consider changing the type to
   |
41 - fn note(v: &Value, root: &Path, path: Vec<usize>, suggestions: &mut Vec<Suggestion>) -> Note {
41 + fn note(v: &Value, root: &Path, path: &[usize], suggestions: &mut Vec<Suggestion>) -> Note {
   |
help: change `path.clone()` to
   |
64 -             child_path: path.clone(),
64 +             child_path: path.to_owned(),
   |

warning clippy::needless_pass_by_value §

this argument is passed by value, but not consumed in the function body

src/main.rs:10:14

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

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

Primary: src/main.rs:10:14

fn run(opts: cli::RunOptions) -> Result<i32, String> {

Primary: src/main.rs:10:14

fn run(opts: cli::RunOptions) -> Result<i32, String> {

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

help: consider taking a reference instead

Suggestion: consider taking a reference instead

MaybeIncorrect

--- "a/src/main.rs"
+++ "b/src/main.rs"
@@ -7,7 +7,7 @@
 mod render;
 mod source;
 use diagnostic::model::*;
-fn run(opts: cli::RunOptions) -> Result<i32, String> {
+fn run(opts: &cli::RunOptions) -> Result<i32, String> {
     let cwd = std::env::current_dir().map_err(|e| e.to_string())?;
     let ctx = cli::cargo_context(
         &opts,
Rendered diagnostic (text)
warning: this argument is passed by value, but not consumed in the function body
  --> src/main.rs:10:14
   |
10 | fn run(opts: cli::RunOptions) -> Result<i32, String> {
   |              ^^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#needless_pass_by_value
help: consider taking a reference instead
   |
10 | fn run(opts: &cli::RunOptions) -> Result<i32, String> {
   |              +

warning clippy::needless_pass_by_value §

this argument is passed by value, but not consumed in the function body

src/render/pages.rs:289:54

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

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

Primary: src/render/pages.rs:289:54

fn write_page(destination: &Path, path: &Path, page: Page<'_>) -> Result<(), String> {

Primary: src/render/pages.rs:289:54

fn write_page(destination: &Path, path: &Path, page: Page<'_>) -> Result<(), String> {

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

help: consider taking a reference instead

Suggestion: consider taking a reference instead

MaybeIncorrect

--- "a/src/render/pages.rs"
+++ "b/src/render/pages.rs"
@@ -286,7 +286,7 @@
 fn render(t: &impl Template) -> Result<String, String> {
     t.render().map_err(|e| e.to_string())
 }
-fn write_page(destination: &Path, path: &Path, page: Page<'_>) -> Result<(), String> {
+fn write_page(destination: &Path, path: &Path, page: &Page<'_>) -> Result<(), String> {
     if let Some(parent) = path.parent() {
         std::fs::create_dir_all(destination.join(parent)).map_err(|e| e.to_string())?;
     }
Rendered diagnostic (text)
warning: this argument is passed by value, but not consumed in the function body
   --> src/render/pages.rs:289:54
    |
289 | fn write_page(destination: &Path, path: &Path, page: Page<'_>) -> Result<(), String> {
    |                                                      ^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#needless_pass_by_value
help: consider taking a reference instead
    |
289 | fn write_page(destination: &Path, path: &Path, page: &Page<'_>) -> Result<(), String> {
    |                                                      +