We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
manual_range_patterns
1 parent 5cc0c04 commit c927912Copy full SHA for c927912
clippy_lints/src/manual_range_patterns.rs
@@ -20,6 +20,10 @@ declare_clippy_lint! {
20
/// ### Why is this bad?
21
/// Using an explicit range is more concise and easier to read.
22
///
23
+ /// ### Known issues
24
+ /// This lint intentionally does not handle numbers greater than `i128::MAX` for `u128` literals
25
+ /// in order to support negative numbers.
26
+ ///
27
/// ### Example
28
/// ```rust
29
/// let x = 6;
@@ -43,7 +47,8 @@ fn expr_as_i128(expr: &Expr<'_>) -> Option<i128> {
43
47
} else if let ExprKind::Lit(lit) = expr.kind
44
48
&& let LitKind::Int(num, _) = lit.node
45
49
{
46
- Some(num as i128)
50
+ // Intentionally not handling numbers greater than i128::MAX (for u128 literals) for now.
51
+ num.try_into().ok()
52
} else {
53
None
54
}
0 commit comments