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

let x = 2_32; // Noncompliant: Mistyped literal suffix
let y = 250_8; // Noncompliant: Mistyped literal suffix

Compliant solution

let x = 2_i32; // Compliant: Correct literal suffix
let y = 250_u8; // Compliant: Correct literal suffix

Resources

Documentation