Replace str path utils with new PathLookup type
This commit is contained in:
parent
ea13461967
commit
b768fbe4bc
70 changed files with 799 additions and 1400 deletions
|
|
@ -1,8 +1,6 @@
|
|||
if let StmtKind::Let(local) = stmt.kind
|
||||
&& let Some(init) = local.init
|
||||
&& let ExprKind::Cast(expr, cast_ty) = init.kind
|
||||
&& let TyKind::Path(ref qpath) = cast_ty.kind
|
||||
&& match_qpath(qpath, &["char"])
|
||||
&& let ExprKind::Lit(ref lit) = expr.kind
|
||||
&& let LitKind::Int(69, LitIntType::Unsuffixed) = lit.node
|
||||
&& let PatKind::Binding(BindingMode::NONE, _, name, None) = local.pat.kind
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@ if let ExprKind::Block(block, None) = expr.kind
|
|||
&& name1.as_str() == "_t"
|
||||
&& let StmtKind::Semi(e) = block.stmts[2].kind
|
||||
&& let ExprKind::Unary(UnOp::Neg, inner) = e.kind
|
||||
&& let ExprKind::Path(ref qpath) = inner.kind
|
||||
&& match_qpath(qpath, &["x"])
|
||||
&& block.expr.is_none()
|
||||
{
|
||||
// report your lint here
|
||||
|
|
@ -25,18 +23,14 @@ if let ExprKind::Block(block, None) = expr.kind
|
|||
&& let StmtKind::Let(local) = block.stmts[0].kind
|
||||
&& let Some(init) = local.init
|
||||
&& let ExprKind::Call(func, args) = init.kind
|
||||
&& let ExprKind::Path(ref qpath) = func.kind
|
||||
&& match_qpath(qpath, &["String", "new"])
|
||||
&& is_path_diagnostic_item(cx, func, sym::string_new)
|
||||
&& args.is_empty()
|
||||
&& let PatKind::Binding(BindingMode::NONE, _, name, None) = local.pat.kind
|
||||
&& name.as_str() == "expr"
|
||||
&& let Some(trailing_expr) = block.expr
|
||||
&& let ExprKind::Call(func1, args1) = trailing_expr.kind
|
||||
&& let ExprKind::Path(ref qpath1) = func1.kind
|
||||
&& match_qpath(qpath1, &["drop"])
|
||||
&& is_path_diagnostic_item(cx, func1, sym::mem_drop)
|
||||
&& args1.len() == 1
|
||||
&& let ExprKind::Path(ref qpath2) = args1[0].kind
|
||||
&& match_qpath(qpath2, &["expr"])
|
||||
{
|
||||
// report your lint here
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
if let StmtKind::Let(local) = stmt.kind
|
||||
&& let Some(init) = local.init
|
||||
&& let ExprKind::Call(func, args) = init.kind
|
||||
&& let ExprKind::Path(ref qpath) = func.kind
|
||||
&& match_qpath(qpath, &["{{root}}", "std", "cmp", "min"])
|
||||
&& is_path_diagnostic_item(cx, func, sym::cmp_min)
|
||||
&& args.len() == 2
|
||||
&& let ExprKind::Lit(ref lit) = args[0].kind
|
||||
&& let LitKind::Int(3, LitIntType::Unsuffixed) = lit.node
|
||||
|
|
|
|||
|
|
@ -31,10 +31,8 @@ if let StmtKind::Let(local) = stmt.kind
|
|||
if let ExprKind::If(cond, then, Some(else_expr)) = expr.kind
|
||||
&& let ExprKind::Let(let_expr) = cond.kind
|
||||
&& let PatKind::Expr(lit_expr) = let_expr.pat.kind
|
||||
&& let PatExprKind::Lit{ref lit, negated } = lit_expr.kind
|
||||
&& let PatExprKind::Lit { ref lit, negated } = lit_expr.kind
|
||||
&& let LitKind::Bool(true) = lit.node
|
||||
&& let ExprKind::Path(ref qpath) = let_expr.init.kind
|
||||
&& match_qpath(qpath, &["a"])
|
||||
&& let ExprKind::Block(block, None) = then.kind
|
||||
&& block.stmts.is_empty()
|
||||
&& block.expr.is_none()
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
if let StmtKind::Let(local) = stmt.kind
|
||||
&& let Some(init) = local.init
|
||||
&& let ExprKind::Call(func, args) = init.kind
|
||||
&& let ExprKind::Path(ref qpath) = func.kind
|
||||
&& match_qpath(qpath, &["std", "mem", "transmute"])
|
||||
&& is_path_diagnostic_item(cx, func, sym::transmute)
|
||||
&& args.len() == 1
|
||||
&& let ExprKind::Path(ref qpath1) = args[0].kind
|
||||
&& match_qpath(qpath1, &["ZPTR"])
|
||||
&& let PatKind::Wild = local.pat.kind
|
||||
{
|
||||
// report your lint here
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@ if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::Fo
|
|||
&& block.stmts.len() == 1
|
||||
&& let StmtKind::Let(local) = block.stmts[0].kind
|
||||
&& let Some(init) = local.init
|
||||
&& let ExprKind::Path(ref qpath1) = init.kind
|
||||
&& match_qpath(qpath1, &["y"])
|
||||
&& let PatKind::Binding(BindingMode::NONE, _, name1, None) = local.pat.kind
|
||||
&& name1.as_str() == "z"
|
||||
&& block.expr.is_none()
|
||||
|
|
@ -64,8 +62,6 @@ if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::Fo
|
|||
// report your lint here
|
||||
}
|
||||
if let Some(higher::While { condition: condition, body: body }) = higher::While::hir(expr)
|
||||
&& let ExprKind::Path(ref qpath) = condition.kind
|
||||
&& match_qpath(qpath, &["a"])
|
||||
&& let ExprKind::Block(block, None) = body.kind
|
||||
&& block.stmts.len() == 1
|
||||
&& let StmtKind::Semi(e) = block.stmts[0].kind
|
||||
|
|
@ -77,10 +73,8 @@ if let Some(higher::While { condition: condition, body: body }) = higher::While:
|
|||
}
|
||||
if let Some(higher::WhileLet { let_pat: let_pat, let_expr: let_expr, if_then: if_then }) = higher::WhileLet::hir(expr)
|
||||
&& let PatKind::Expr(lit_expr) = let_pat.kind
|
||||
&& let PatExprKind::Lit{ref lit, negated } = lit_expr.kind
|
||||
&& let PatExprKind::Lit { ref lit, negated } = lit_expr.kind
|
||||
&& let LitKind::Bool(true) = lit.node
|
||||
&& let ExprKind::Path(ref qpath) = let_expr.kind
|
||||
&& match_qpath(qpath, &["a"])
|
||||
&& let ExprKind::Block(block, None) = if_then.kind
|
||||
&& block.stmts.len() == 1
|
||||
&& let StmtKind::Semi(e) = block.stmts[0].kind
|
||||
|
|
|
|||
|
|
@ -7,12 +7,10 @@ if let StmtKind::Let(local) = stmt.kind
|
|||
&& block.stmts.len() == 1
|
||||
&& let StmtKind::Semi(e) = block.stmts[0].kind
|
||||
&& let ExprKind::Call(func, args) = e.kind
|
||||
&& let ExprKind::Path(ref qpath) = func.kind
|
||||
&& match_qpath(qpath, &["$crate", "io", "_print"])
|
||||
&& paths::STD_IO_STDIO__PRINT.matches_path(cx, func) // Add the path to `clippy_utils::paths` if needed
|
||||
&& args.len() == 1
|
||||
&& let ExprKind::Call(func1, args1) = args[0].kind
|
||||
&& let ExprKind::Path(ref qpath1) = func1.kind
|
||||
&& match_qpath(qpath1, &["format_arguments", "new_v1"])
|
||||
&& paths::CORE_FMT_ARGUMENTS_NEW_V1.matches_path(cx, func1) // Add the path to `clippy_utils::paths` if needed
|
||||
&& args1.len() == 2
|
||||
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner) = args1[0].kind
|
||||
&& let ExprKind::Array(elements) = inner.kind
|
||||
|
|
@ -27,12 +25,9 @@ if let StmtKind::Let(local) = stmt.kind
|
|||
&& let ExprKind::Array(elements1) = inner1.kind
|
||||
&& elements1.len() == 1
|
||||
&& let ExprKind::Call(func2, args2) = elements1[0].kind
|
||||
&& let ExprKind::Path(ref qpath2) = func2.kind
|
||||
&& match_qpath(qpath2, &["format_argument", "new_display"])
|
||||
&& paths::CORE_FMT_RT_ARGUMENT_NEW_DISPLAY.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed
|
||||
&& args2.len() == 1
|
||||
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner2) = args2[0].kind
|
||||
&& let ExprKind::Path(ref qpath3) = inner2.kind
|
||||
&& match_qpath(qpath3, &["x"])
|
||||
&& block.expr.is_none()
|
||||
&& let PatKind::Binding(BindingMode::NONE, _, name, None) = local.pat.kind
|
||||
&& name.as_str() == "print_text"
|
||||
|
|
|
|||
|
|
@ -17,12 +17,10 @@ if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::Fo
|
|||
&& block1.stmts.len() == 1
|
||||
&& let StmtKind::Semi(e1) = block1.stmts[0].kind
|
||||
&& let ExprKind::Call(func, args) = e1.kind
|
||||
&& let ExprKind::Path(ref qpath1) = func.kind
|
||||
&& match_qpath(qpath1, &["$crate", "io", "_print"])
|
||||
&& paths::STD_IO_STDIO__PRINT.matches_path(cx, func) // Add the path to `clippy_utils::paths` if needed
|
||||
&& args.len() == 1
|
||||
&& let ExprKind::Call(func1, args1) = args[0].kind
|
||||
&& let ExprKind::Path(ref qpath2) = func1.kind
|
||||
&& match_qpath(qpath2, &["format_arguments", "new_v1"])
|
||||
&& paths::CORE_FMT_ARGUMENTS_NEW_V1.matches_path(cx, func1) // Add the path to `clippy_utils::paths` if needed
|
||||
&& args1.len() == 2
|
||||
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner) = args1[0].kind
|
||||
&& let ExprKind::Array(elements) = inner.kind
|
||||
|
|
@ -37,12 +35,9 @@ if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::Fo
|
|||
&& let ExprKind::Array(elements1) = inner1.kind
|
||||
&& elements1.len() == 1
|
||||
&& let ExprKind::Call(func2, args2) = elements1[0].kind
|
||||
&& let ExprKind::Path(ref qpath3) = func2.kind
|
||||
&& match_qpath(qpath3, &["format_argument", "new_display"])
|
||||
&& paths::CORE_FMT_RT_ARGUMENT_NEW_DISPLAY.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed
|
||||
&& args2.len() == 1
|
||||
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner2) = args2[0].kind
|
||||
&& let ExprKind::Path(ref qpath4) = inner2.kind
|
||||
&& match_qpath(qpath4, &["i"])
|
||||
&& block1.expr.is_none()
|
||||
&& block.expr.is_none()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ if let StmtKind::Let(local) = stmt.kind
|
|||
&& let LitKind::Int(42, LitIntType::Unsuffixed) = lit.node
|
||||
&& arms.len() == 3
|
||||
&& let PatKind::Expr(lit_expr) = arms[0].pat.kind
|
||||
&& let PatExprKind::Lit{ref lit1, negated } = lit_expr.kind
|
||||
&& let PatExprKind::Lit { ref lit1, negated } = lit_expr.kind
|
||||
&& let LitKind::Int(16, LitIntType::Unsuffixed) = lit1.node
|
||||
&& arms[0].guard.is_none()
|
||||
&& let ExprKind::Lit(ref lit2) = arms[0].body.kind
|
||||
&& let LitKind::Int(5, LitIntType::Unsuffixed) = lit2.node
|
||||
&& let PatKind::Expr(lit_expr1) = arms[1].pat.kind
|
||||
&& let PatExprKind::Lit{ref lit3, negated1 } = lit_expr1.kind
|
||||
&& let PatExprKind::Lit { ref lit3, negated1 } = lit_expr1.kind
|
||||
&& let LitKind::Int(17, LitIntType::Unsuffixed) = lit3.node
|
||||
&& arms[1].guard.is_none()
|
||||
&& let ExprKind::Block(block, None) = arms[1].body.kind
|
||||
|
|
@ -23,8 +23,6 @@ if let StmtKind::Let(local) = stmt.kind
|
|||
&& let PatKind::Binding(BindingMode::NONE, _, name, None) = local1.pat.kind
|
||||
&& name.as_str() == "x"
|
||||
&& let Some(trailing_expr) = block.expr
|
||||
&& let ExprKind::Path(ref qpath) = trailing_expr.kind
|
||||
&& match_qpath(qpath, &["x"])
|
||||
&& let PatKind::Wild = arms[2].pat.kind
|
||||
&& arms[2].guard.is_none()
|
||||
&& let ExprKind::Lit(ref lit5) = arms[2].body.kind
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
if let ExprKind::Struct(qpath, fields, None) = expr.kind
|
||||
&& match_qpath(qpath, &["Test"])
|
||||
&& fields.len() == 1
|
||||
&& fields[0].ident.as_str() == "field"
|
||||
&& let ExprKind::If(cond, then, Some(else_expr)) = fields[0].expr.kind
|
||||
|
|
@ -20,11 +19,10 @@ if let ExprKind::Struct(qpath, fields, None) = expr.kind
|
|||
// report your lint here
|
||||
}
|
||||
if let PatKind::Struct(ref qpath, fields, false) = arm.pat.kind
|
||||
&& match_qpath(qpath, &["Test"])
|
||||
&& fields.len() == 1
|
||||
&& fields[0].ident.as_str() == "field"
|
||||
&& let PatKind::Expr(lit_expr) = fields[0].pat.kind
|
||||
&& let PatExprKind::Lit{ref lit, negated } = lit_expr.kind
|
||||
&& let PatExprKind::Lit { ref lit, negated } = lit_expr.kind
|
||||
&& let LitKind::Int(1, LitIntType::Unsuffixed) = lit.node
|
||||
&& arm.guard.is_none()
|
||||
&& let ExprKind::Block(block, None) = arm.body.kind
|
||||
|
|
@ -34,10 +32,9 @@ if let PatKind::Struct(ref qpath, fields, false) = arm.pat.kind
|
|||
// report your lint here
|
||||
}
|
||||
if let PatKind::TupleStruct(ref qpath, fields, None) = arm.pat.kind
|
||||
&& match_qpath(qpath, &["TestTuple"])
|
||||
&& fields.len() == 1
|
||||
&& let PatKind::Expr(lit_expr) = fields[0].kind
|
||||
&& let PatExprKind::Lit{ref lit, negated } = lit_expr.kind
|
||||
&& let PatExprKind::Lit { ref lit, negated } = lit_expr.kind
|
||||
&& let LitKind::Int(1, LitIntType::Unsuffixed) = lit.node
|
||||
&& arm.guard.is_none()
|
||||
&& let ExprKind::Block(block, None) = arm.body.kind
|
||||
|
|
@ -48,8 +45,6 @@ if let PatKind::TupleStruct(ref qpath, fields, None) = arm.pat.kind
|
|||
}
|
||||
if let ExprKind::MethodCall(method_name, receiver, args, _) = expr.kind
|
||||
&& method_name.ident.as_str() == "test"
|
||||
&& let ExprKind::Path(ref qpath) = receiver.kind
|
||||
&& match_qpath(qpath, &["test_method_call"])
|
||||
&& args.is_empty()
|
||||
{
|
||||
// report your lint here
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
#![allow(clippy::legacy_numeric_constants, unused_imports)]
|
||||
|
||||
use std::{i32, i128, u32, u128};
|
||||
|
||||
fn main() {
|
||||
let _ = 1u32.saturating_add(1);
|
||||
//~^ manual_saturating_arithmetic
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
#![allow(clippy::legacy_numeric_constants, unused_imports)]
|
||||
|
||||
use std::{i32, i128, u32, u128};
|
||||
|
||||
fn main() {
|
||||
let _ = 1u32.checked_add(1).unwrap_or(u32::max_value());
|
||||
//~^ manual_saturating_arithmetic
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:6:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:4:13
|
||||
|
|
||||
LL | let _ = 1u32.checked_add(1).unwrap_or(u32::max_value());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1u32.saturating_add(1)`
|
||||
|
|
@ -8,19 +8,19 @@ LL | let _ = 1u32.checked_add(1).unwrap_or(u32::max_value());
|
|||
= help: to override `-D warnings` add `#[allow(clippy::manual_saturating_arithmetic)]`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:8:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:6:13
|
||||
|
|
||||
LL | let _ = 1u32.checked_add(1).unwrap_or(u32::MAX);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1u32.saturating_add(1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:10:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:8:13
|
||||
|
|
||||
LL | let _ = 1u8.checked_add(1).unwrap_or(255);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1u8.saturating_add(1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:12:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:10:13
|
||||
|
|
||||
LL | let _ = 1u128
|
||||
| _____________^
|
||||
|
|
@ -30,49 +30,49 @@ LL | | .unwrap_or(340_282_366_920_938_463_463_374_607_431_768_211_455);
|
|||
| |_______________________________________________________________________^ help: consider using `saturating_add`: `1u128.saturating_add(1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:18:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:16:13
|
||||
|
|
||||
LL | let _ = 1u32.checked_mul(1).unwrap_or(u32::MAX);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_mul`: `1u32.saturating_mul(1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:21:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:19:13
|
||||
|
|
||||
LL | let _ = 1u32.checked_sub(1).unwrap_or(u32::min_value());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1u32.saturating_sub(1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:23:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:21:13
|
||||
|
|
||||
LL | let _ = 1u32.checked_sub(1).unwrap_or(u32::MIN);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1u32.saturating_sub(1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:25:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:23:13
|
||||
|
|
||||
LL | let _ = 1u8.checked_sub(1).unwrap_or(0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1u8.saturating_sub(1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:30:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:28:13
|
||||
|
|
||||
LL | let _ = 1i32.checked_add(1).unwrap_or(i32::max_value());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i32.saturating_add(1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:32:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:30:13
|
||||
|
|
||||
LL | let _ = 1i32.checked_add(1).unwrap_or(i32::MAX);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i32.saturating_add(1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:34:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:32:13
|
||||
|
|
||||
LL | let _ = 1i8.checked_add(1).unwrap_or(127);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i8.saturating_add(1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:36:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:34:13
|
||||
|
|
||||
LL | let _ = 1i128
|
||||
| _____________^
|
||||
|
|
@ -82,25 +82,25 @@ LL | | .unwrap_or(170_141_183_460_469_231_731_687_303_715_884_105_727);
|
|||
| |_______________________________________________________________________^ help: consider using `saturating_add`: `1i128.saturating_add(1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:40:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:38:13
|
||||
|
|
||||
LL | let _ = 1i32.checked_add(-1).unwrap_or(i32::min_value());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i32.saturating_add(-1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:42:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:40:13
|
||||
|
|
||||
LL | let _ = 1i32.checked_add(-1).unwrap_or(i32::MIN);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i32.saturating_add(-1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:44:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:42:13
|
||||
|
|
||||
LL | let _ = 1i8.checked_add(-1).unwrap_or(-128);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i8.saturating_add(-1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:46:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:44:13
|
||||
|
|
||||
LL | let _ = 1i128
|
||||
| _____________^
|
||||
|
|
@ -110,25 +110,25 @@ LL | | .unwrap_or(-170_141_183_460_469_231_731_687_303_715_884_105_728);
|
|||
| |________________________________________________________________________^ help: consider using `saturating_add`: `1i128.saturating_add(-1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:54:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:52:13
|
||||
|
|
||||
LL | let _ = 1i32.checked_sub(1).unwrap_or(i32::min_value());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i32.saturating_sub(1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:56:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:54:13
|
||||
|
|
||||
LL | let _ = 1i32.checked_sub(1).unwrap_or(i32::MIN);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i32.saturating_sub(1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:58:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:56:13
|
||||
|
|
||||
LL | let _ = 1i8.checked_sub(1).unwrap_or(-128);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i8.saturating_sub(1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:60:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:58:13
|
||||
|
|
||||
LL | let _ = 1i128
|
||||
| _____________^
|
||||
|
|
@ -138,25 +138,25 @@ LL | | .unwrap_or(-170_141_183_460_469_231_731_687_303_715_884_105_728);
|
|||
| |________________________________________________________________________^ help: consider using `saturating_sub`: `1i128.saturating_sub(1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:64:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:62:13
|
||||
|
|
||||
LL | let _ = 1i32.checked_sub(-1).unwrap_or(i32::max_value());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i32.saturating_sub(-1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:66:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:64:13
|
||||
|
|
||||
LL | let _ = 1i32.checked_sub(-1).unwrap_or(i32::MAX);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i32.saturating_sub(-1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:68:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:66:13
|
||||
|
|
||||
LL | let _ = 1i8.checked_sub(-1).unwrap_or(127);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i8.saturating_sub(-1)`
|
||||
|
||||
error: manual saturating arithmetic
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:70:13
|
||||
--> tests/ui/manual_saturating_arithmetic.rs:68:13
|
||||
|
|
||||
LL | let _ = 1i128
|
||||
| _____________^
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue