27 lines
924 B
Plaintext
27 lines
924 B
Plaintext
== Why is this an issue?
|
|
|
|
Mistyped suffixes in numeric literals can lead to incorrect interpretations of the values intended by the developer. This is typically seen as a typo which could impact the functionality of the code. The rule does not however address integers that would not fit within the assumed type or specific valid groupings such as `_127` in decimal and octal numbers.
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,rust,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
let x = 2_32; // Noncompliant: Mistyped literal suffix
|
|
let y = 250_8; // Noncompliant: Mistyped literal suffix
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,rust,diff-id=1,diff-type=compliant]
|
|
----
|
|
let x = 2_i32; // Compliant: Correct literal suffix
|
|
let y = 250_u8; // Compliant: Correct literal suffix
|
|
----
|
|
|
|
== Resources
|
|
=== Documentation
|
|
|
|
* Clippy Lints - https://rust-lang.github.io/rust-clippy/master/index.html#mistyped_literal_suffixes
|