Skip to main content

Source examples/../src/diagnostic/normalize.rs

1//! Preserve diagnostic trees and multipart suggestions as units.2use super::model::*; warning: clippy::wildcard_imports3use serde_json::Value;4use std::path::Path;5fn string(v: &Value, key: &str) -> String {6    v[key].as_str().unwrap_or_default().to_owned()7}8fn spans(v: &Value, root: &Path) -> Vec<Span> {9    v["spans"]10        .as_array()11        .into_iter()12        .flatten()13        .map(|s| Span {14            path: root.join(string(s, "file_name")),15            byte_start: s["byte_start"].as_u64().unwrap_or(0) as usize, warning: clippy::cast_possible_truncation16            byte_end: s["byte_end"].as_u64().unwrap_or(0) as usize, warning: clippy::cast_possible_truncation17            line_start: s["line_start"].as_u64().unwrap_or(0) as usize, warning: clippy::cast_possible_truncation18            line_end: s["line_end"].as_u64().unwrap_or(0) as usize, warning: clippy::cast_possible_truncation19            column_start: s["column_start"].as_u64().unwrap_or(0) as usize, warning: clippy::cast_possible_truncation20            column_end: s["column_end"].as_u64().unwrap_or(0) as usize, warning: clippy::cast_possible_truncation21            primary: s["is_primary"].as_bool().unwrap_or(false),22            label: s["label"].as_str().map(str::to_owned),23            text: s["text"]24                .as_array()25                .into_iter()26                .flatten()27                .map(|t| SnippetLine {28                    text: string(t, "text"),29                    highlight_start: t["highlight_start"].as_u64().unwrap_or(0) as usize, warning: clippy::cast_possible_truncation30                    highlight_end: t["highlight_end"].as_u64().unwrap_or(0) as usize, warning: clippy::cast_possible_truncation31                })32                .collect(),33            expansion: if s["expansion"].is_null() {34                None35            } else {36                Some(s["expansion"].clone())37            },38        })39        .collect()40}41fn note(v: &Value, root: &Path, path: Vec<usize>, suggestions: &mut Vec<Suggestion>) -> Note { warning: clippy::needless_pass_by_value42    let normalized = spans(v, root);43    let replacements: Vec<_> = v["spans"]44        .as_array()45        .into_iter()46        .flatten()47        .zip(&normalized)48        .filter_map(|(raw, span)| {49            raw["suggested_replacement"]50                .as_str()51                .map(|text| Replacement {52                    span: span.clone(),53                    text: text.into(),54                    applicability: raw["suggestion_applicability"]55                        .as_str()56                        .unwrap_or("Unspecified")57                        .into(),58                })59        })60        .collect();61    if !replacements.is_empty() {62        suggestions.push(Suggestion {63            message: string(v, "message"),64            child_path: path.clone(), warning: clippy::needless_pass_by_value65            replacements,66        });67    }68    let children = v["children"]69        .as_array()70        .into_iter()71        .flatten()72        .enumerate()73        .map(|(i, c)| {74            let mut p = path.clone();75            p.push(i);76            note(c, root, p, suggestions)77        })78        .collect();79    Note {80        level: string(v, "level"),81        message: string(v, "message"),82        spans: normalized,83        children,84    }85}86pub fn normalize(message: &cargo_metadata::CompilerMessage, root: &Path) -> Finding {87    let v = serde_json::to_value(&message.message).expect("Cargo diagnostic is JSON serializable");88    let mut suggestions = vec![];89    let n = note(&v, root, vec![], &mut suggestions);90    let code = v["code"]["code"].as_str().map(str::to_owned);91    let origin = if code.as_deref().is_some_and(|s| s.starts_with("clippy::")) {92        "Clippy"93    } else if code.is_some() {94        "Rust compiler"95    } else {96        "General"97    };98    Finding {99        id: String::new(),100        package_id: message.package_id.to_string(),101        targets: vec![TargetInfo {102            name: message.target.name.clone(),103            kinds: message.target.kind.iter().map(|k| k.to_string()).collect(), warning: clippy::redundant_closure_for_method_calls104            source: message.target.src_path.clone().into_std_path_buf(),105        }],106        origin: origin.into(),107        code,108        level: n.level,109        category: None,110        message: n.message,111        spans: n.spans,112        children: n.children,113        suggestions,114        rendered: v["rendered"].as_str().map(str::to_owned),115    }116}117#[cfg(test)]118mod tests {119    use super::*;120    pub fn finding() -> Finding {121        let msg: cargo_metadata::Message = serde_json::from_value(super::super::sample()).unwrap();122        let cargo_metadata::Message::CompilerMessage(m) = msg else {123            panic!()124        };125        normalize(&m, Path::new("/demo"))126    }127    #[test]128    fn preserves_diagnostic_kind_and_level() {129        let f = finding();130        assert_eq!(f.origin, "Clippy");131        assert_eq!(f.level, "warning");132        assert_eq!(f.spans.len(), 1);133    }134    #[test]135    fn multipart_replacements_stay_grouped() {136        let mut v = super::super::sample();137        let mut span = v["message"]["spans"][0].clone();138        span["suggested_replacement"] = "fixed".into();139        span["suggestion_applicability"] = "MachineApplicable".into();140        v["message"]["children"] = serde_json::json!([{"message":"replace both","level":"help","spans":[span.clone(),span],"children":[],"code":null,"rendered":null}]);141        let cargo_metadata::Message::CompilerMessage(m) = serde_json::from_value(v).unwrap() else {142            panic!()143        };144        let f = normalize(&m, Path::new("/demo"));145        assert_eq!(f.suggestions.len(), 1);146        assert_eq!(f.suggestions[0].replacements.len(), 2);147        assert_eq!(f.children.len(), 1);148    }149}150

Findings in this file§

warning clippy::wildcard_imports §

usage of wildcard import

examples/../src/diagnostic/normalize.rs:2:5

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • update_lint_metadata (example)

Primary: examples/../src/diagnostic/normalize.rs:2:5

use super::model::*;

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

note: `-W clippy::wildcard-imports` implied by `-W clippy::pedantic`

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

help: try

Suggestion: try

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

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

super::model::{Span, SnippetLine, Suggestion, Note, Replacement, Finding, TargetInfo}
Rendered diagnostic (text)
warning: usage of wildcard import
 --> examples/../src/diagnostic/normalize.rs:2:5
  |
2 | use super::model::*;
  |     ^^^^^^^^^^^^^^^ help: try: `super::model::{Span, SnippetLine, Suggestion, Note, Replacement, Finding, TargetInfo}`
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#wildcard_imports
  = note: `-W clippy::wildcard-imports` implied by `-W clippy::pedantic`
  = help: to override `-W clippy::pedantic` add `#[allow(clippy::wildcard_imports)]`

warning clippy::cast_possible_truncation §

casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers

examples/../src/diagnostic/normalize.rs:15:25

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • update_lint_metadata (example)

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

            byte_start: s["byte_start"].as_u64().unwrap_or(0) as usize,

help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...

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

note: `-W clippy::cast-possible-truncation` implied by `-W clippy::pedantic`

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

help: ... or use `try_from` and handle the error accordingly

Suggestion: ... or use `try_from` and handle the error accordingly

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

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

usize::try_from(s["byte_start"].as_u64().unwrap_or(0))
Rendered diagnostic (text)
warning: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
  --> examples/../src/diagnostic/normalize.rs:15:25
   |
15 |             byte_start: s["byte_start"].as_u64().unwrap_or(0) as usize,
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
   = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#cast_possible_truncation
   = note: `-W clippy::cast-possible-truncation` implied by `-W clippy::pedantic`
   = help: to override `-W clippy::pedantic` add `#[allow(clippy::cast_possible_truncation)]`
help: ... or use `try_from` and handle the error accordingly
   |
15 -             byte_start: s["byte_start"].as_u64().unwrap_or(0) as usize,
15 +             byte_start: usize::try_from(s["byte_start"].as_u64().unwrap_or(0)),
   |

warning clippy::cast_possible_truncation §

casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers

examples/../src/diagnostic/normalize.rs:16:23

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • update_lint_metadata (example)

Primary: examples/../src/diagnostic/normalize.rs:16:23

            byte_end: s["byte_end"].as_u64().unwrap_or(0) as usize,

help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...

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

help: ... or use `try_from` and handle the error accordingly

Suggestion: ... or use `try_from` and handle the error accordingly

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

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

usize::try_from(s["byte_end"].as_u64().unwrap_or(0))
Rendered diagnostic (text)
warning: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
  --> examples/../src/diagnostic/normalize.rs:16:23
   |
16 |             byte_end: s["byte_end"].as_u64().unwrap_or(0) as usize,
   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
   = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#cast_possible_truncation
help: ... or use `try_from` and handle the error accordingly
   |
16 -             byte_end: s["byte_end"].as_u64().unwrap_or(0) as usize,
16 +             byte_end: usize::try_from(s["byte_end"].as_u64().unwrap_or(0)),
   |

warning clippy::cast_possible_truncation §

casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers

examples/../src/diagnostic/normalize.rs:17:25

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • update_lint_metadata (example)

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

            line_start: s["line_start"].as_u64().unwrap_or(0) as usize,

help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...

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

help: ... or use `try_from` and handle the error accordingly

Suggestion: ... or use `try_from` and handle the error accordingly

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

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

usize::try_from(s["line_start"].as_u64().unwrap_or(0))
Rendered diagnostic (text)
warning: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
  --> examples/../src/diagnostic/normalize.rs:17:25
   |
17 |             line_start: s["line_start"].as_u64().unwrap_or(0) as usize,
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
   = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#cast_possible_truncation
help: ... or use `try_from` and handle the error accordingly
   |
17 -             line_start: s["line_start"].as_u64().unwrap_or(0) as usize,
17 +             line_start: usize::try_from(s["line_start"].as_u64().unwrap_or(0)),
   |

warning clippy::cast_possible_truncation §

casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers

examples/../src/diagnostic/normalize.rs:18:23

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • update_lint_metadata (example)

Primary: examples/../src/diagnostic/normalize.rs:18:23

            line_end: s["line_end"].as_u64().unwrap_or(0) as usize,

help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...

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

help: ... or use `try_from` and handle the error accordingly

Suggestion: ... or use `try_from` and handle the error accordingly

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

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

usize::try_from(s["line_end"].as_u64().unwrap_or(0))
Rendered diagnostic (text)
warning: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
  --> examples/../src/diagnostic/normalize.rs:18:23
   |
18 |             line_end: s["line_end"].as_u64().unwrap_or(0) as usize,
   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
   = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#cast_possible_truncation
help: ... or use `try_from` and handle the error accordingly
   |
18 -             line_end: s["line_end"].as_u64().unwrap_or(0) as usize,
18 +             line_end: usize::try_from(s["line_end"].as_u64().unwrap_or(0)),
   |

warning clippy::cast_possible_truncation §

casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers

examples/../src/diagnostic/normalize.rs:19:27

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • update_lint_metadata (example)

Primary: examples/../src/diagnostic/normalize.rs:19:27

            column_start: s["column_start"].as_u64().unwrap_or(0) as usize,

help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...

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

help: ... or use `try_from` and handle the error accordingly

Suggestion: ... or use `try_from` and handle the error accordingly

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

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

usize::try_from(s["column_start"].as_u64().unwrap_or(0))
Rendered diagnostic (text)
warning: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
  --> examples/../src/diagnostic/normalize.rs:19:27
   |
19 |             column_start: s["column_start"].as_u64().unwrap_or(0) as usize,
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
   = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#cast_possible_truncation
help: ... or use `try_from` and handle the error accordingly
   |
19 -             column_start: s["column_start"].as_u64().unwrap_or(0) as usize,
19 +             column_start: usize::try_from(s["column_start"].as_u64().unwrap_or(0)),
   |

warning clippy::cast_possible_truncation §

casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers

examples/../src/diagnostic/normalize.rs:20:25

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • update_lint_metadata (example)

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

            column_end: s["column_end"].as_u64().unwrap_or(0) as usize,

help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...

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

help: ... or use `try_from` and handle the error accordingly

Suggestion: ... or use `try_from` and handle the error accordingly

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

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

usize::try_from(s["column_end"].as_u64().unwrap_or(0))
Rendered diagnostic (text)
warning: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
  --> examples/../src/diagnostic/normalize.rs:20:25
   |
20 |             column_end: s["column_end"].as_u64().unwrap_or(0) as usize,
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
   = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#cast_possible_truncation
help: ... or use `try_from` and handle the error accordingly
   |
20 -             column_end: s["column_end"].as_u64().unwrap_or(0) as usize,
20 +             column_end: usize::try_from(s["column_end"].as_u64().unwrap_or(0)),
   |

warning clippy::cast_possible_truncation §

casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers

examples/../src/diagnostic/normalize.rs:29:38

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • update_lint_metadata (example)

Primary: examples/../src/diagnostic/normalize.rs:29:38

                    highlight_start: t["highlight_start"].as_u64().unwrap_or(0) as usize,

help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...

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

help: ... or use `try_from` and handle the error accordingly

Suggestion: ... or use `try_from` and handle the error accordingly

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

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

usize::try_from(t["highlight_start"].as_u64().unwrap_or(0))
Rendered diagnostic (text)
warning: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
  --> examples/../src/diagnostic/normalize.rs:29:38
   |
29 |                     highlight_start: t["highlight_start"].as_u64().unwrap_or(0) as usize,
   |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
   = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#cast_possible_truncation
help: ... or use `try_from` and handle the error accordingly
   |
29 -                     highlight_start: t["highlight_start"].as_u64().unwrap_or(0) as usize,
29 +                     highlight_start: usize::try_from(t["highlight_start"].as_u64().unwrap_or(0)),
   |

warning clippy::cast_possible_truncation §

casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers

examples/../src/diagnostic/normalize.rs:30:36

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • update_lint_metadata (example)

Primary: examples/../src/diagnostic/normalize.rs:30:36

                    highlight_end: t["highlight_end"].as_u64().unwrap_or(0) as usize,

help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...

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

help: ... or use `try_from` and handle the error accordingly

Suggestion: ... or use `try_from` and handle the error accordingly

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

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

usize::try_from(t["highlight_end"].as_u64().unwrap_or(0))
Rendered diagnostic (text)
warning: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
  --> examples/../src/diagnostic/normalize.rs:30:36
   |
30 |                     highlight_end: t["highlight_end"].as_u64().unwrap_or(0) as usize,
   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
   = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#cast_possible_truncation
help: ... or use `try_from` and handle the error accordingly
   |
30 -                     highlight_end: t["highlight_end"].as_u64().unwrap_or(0) as usize,
30 +                     highlight_end: usize::try_from(t["highlight_end"].as_u64().unwrap_or(0)),
   |

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::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)]`