Skip to main content

Lint clippy::cast_possible_truncation

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::cast_possible_truncation §

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

src/diagnostic/normalize.rs:15:25

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

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

Primary: 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

Unspecified

--- "a/src/diagnostic/normalize.rs"
+++ "b/src/diagnostic/normalize.rs"
@@ -12,7 +12,7 @@
         .flatten()
         .map(|s| Span {
             path: root.join(string(s, "file_name")),
-            byte_start: s["byte_start"].as_u64().unwrap_or(0) as usize,
+            byte_start: usize::try_from(s["byte_start"].as_u64().unwrap_or(0)),
             byte_end: s["byte_end"].as_u64().unwrap_or(0) as usize,
             line_start: s["line_start"].as_u64().unwrap_or(0) as usize,
             line_end: s["line_end"].as_u64().unwrap_or(0) as usize,
Rendered diagnostic (text)
warning: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
  --> 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

src/diagnostic/normalize.rs:16:23

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

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

Primary: 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

Unspecified

--- "a/src/diagnostic/normalize.rs"
+++ "b/src/diagnostic/normalize.rs"
@@ -13,7 +13,7 @@
         .map(|s| Span {
             path: root.join(string(s, "file_name")),
             byte_start: s["byte_start"].as_u64().unwrap_or(0) as usize,
-            byte_end: s["byte_end"].as_u64().unwrap_or(0) as usize,
+            byte_end: usize::try_from(s["byte_end"].as_u64().unwrap_or(0)),
             line_start: s["line_start"].as_u64().unwrap_or(0) as usize,
             line_end: s["line_end"].as_u64().unwrap_or(0) as usize,
             column_start: s["column_start"].as_u64().unwrap_or(0) as usize,
Rendered diagnostic (text)
warning: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
  --> 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

src/diagnostic/normalize.rs:17:25

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

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

Primary: 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

Unspecified

--- "a/src/diagnostic/normalize.rs"
+++ "b/src/diagnostic/normalize.rs"
@@ -14,7 +14,7 @@
             path: root.join(string(s, "file_name")),
             byte_start: s["byte_start"].as_u64().unwrap_or(0) as usize,
             byte_end: s["byte_end"].as_u64().unwrap_or(0) as usize,
-            line_start: s["line_start"].as_u64().unwrap_or(0) as usize,
+            line_start: usize::try_from(s["line_start"].as_u64().unwrap_or(0)),
             line_end: s["line_end"].as_u64().unwrap_or(0) as usize,
             column_start: s["column_start"].as_u64().unwrap_or(0) as usize,
             column_end: s["column_end"].as_u64().unwrap_or(0) as usize,
Rendered diagnostic (text)
warning: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
  --> 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

src/diagnostic/normalize.rs:18:23

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

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

Primary: 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

Unspecified

--- "a/src/diagnostic/normalize.rs"
+++ "b/src/diagnostic/normalize.rs"
@@ -15,7 +15,7 @@
             byte_start: s["byte_start"].as_u64().unwrap_or(0) as usize,
             byte_end: s["byte_end"].as_u64().unwrap_or(0) as usize,
             line_start: s["line_start"].as_u64().unwrap_or(0) as usize,
-            line_end: s["line_end"].as_u64().unwrap_or(0) as usize,
+            line_end: usize::try_from(s["line_end"].as_u64().unwrap_or(0)),
             column_start: s["column_start"].as_u64().unwrap_or(0) as usize,
             column_end: s["column_end"].as_u64().unwrap_or(0) as usize,
             primary: s["is_primary"].as_bool().unwrap_or(false),
Rendered diagnostic (text)
warning: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
  --> 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

src/diagnostic/normalize.rs:19:27

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

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

Primary: 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

Unspecified

--- "a/src/diagnostic/normalize.rs"
+++ "b/src/diagnostic/normalize.rs"
@@ -16,7 +16,7 @@
             byte_end: s["byte_end"].as_u64().unwrap_or(0) as usize,
             line_start: s["line_start"].as_u64().unwrap_or(0) as usize,
             line_end: s["line_end"].as_u64().unwrap_or(0) as usize,
-            column_start: s["column_start"].as_u64().unwrap_or(0) as usize,
+            column_start: usize::try_from(s["column_start"].as_u64().unwrap_or(0)),
             column_end: s["column_end"].as_u64().unwrap_or(0) as usize,
             primary: s["is_primary"].as_bool().unwrap_or(false),
             label: s["label"].as_str().map(str::to_owned),
Rendered diagnostic (text)
warning: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
  --> 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

src/diagnostic/normalize.rs:20:25

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

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

Primary: 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

Unspecified

--- "a/src/diagnostic/normalize.rs"
+++ "b/src/diagnostic/normalize.rs"
@@ -17,7 +17,7 @@
             line_start: s["line_start"].as_u64().unwrap_or(0) as usize,
             line_end: s["line_end"].as_u64().unwrap_or(0) as usize,
             column_start: s["column_start"].as_u64().unwrap_or(0) as usize,
-            column_end: s["column_end"].as_u64().unwrap_or(0) as usize,
+            column_end: usize::try_from(s["column_end"].as_u64().unwrap_or(0)),
             primary: s["is_primary"].as_bool().unwrap_or(false),
             label: s["label"].as_str().map(str::to_owned),
             text: s["text"]
Rendered diagnostic (text)
warning: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
  --> 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

src/diagnostic/normalize.rs:29:38

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

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

Primary: 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

Unspecified

--- "a/src/diagnostic/normalize.rs"
+++ "b/src/diagnostic/normalize.rs"
@@ -26,7 +26,7 @@
                 .flatten()
                 .map(|t| SnippetLine {
                     text: string(t, "text"),
-                    highlight_start: t["highlight_start"].as_u64().unwrap_or(0) as usize,
+                    highlight_start: usize::try_from(t["highlight_start"].as_u64().unwrap_or(0)),
                     highlight_end: t["highlight_end"].as_u64().unwrap_or(0) as usize,
                 })
                 .collect(),
Rendered diagnostic (text)
warning: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
  --> 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

src/diagnostic/normalize.rs:30:36

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

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

Primary: 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

Unspecified

--- "a/src/diagnostic/normalize.rs"
+++ "b/src/diagnostic/normalize.rs"
@@ -27,7 +27,7 @@
                 .map(|t| SnippetLine {
                     text: string(t, "text"),
                     highlight_start: t["highlight_start"].as_u64().unwrap_or(0) as usize,
-                    highlight_end: t["highlight_end"].as_u64().unwrap_or(0) as usize,
+                    highlight_end: usize::try_from(t["highlight_end"].as_u64().unwrap_or(0)),
                 })
                 .collect(),
             expansion: if s["expansion"].is_null() {
Rendered diagnostic (text)
warning: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
  --> 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)),
   |