]> git.proxmox.com Git - rustc.git/blobdiff - src/tools/clippy/clippy_lints/src/overflow_check_conditional.rs
New upstream version 1.53.0+dfsg1
[rustc.git] / src / tools / clippy / clippy_lints / src / overflow_check_conditional.rs
index 3c041bac234a589f8034f1dd5ede89db0b6c1c8b..e222782c2cc8c597f2b7755b4098ff88ddd860e5 100644 (file)
@@ -1,4 +1,5 @@
-use crate::utils::{span_lint, SpanlessEq};
+use clippy_utils::diagnostics::span_lint;
+use clippy_utils::SpanlessEq;
 use if_chain::if_chain;
 use rustc_hir::{BinOpKind, Expr, ExprKind, QPath};
 use rustc_lint::{LateContext, LateLintPass};
@@ -30,11 +31,11 @@ impl<'tcx> LateLintPass<'tcx> for OverflowCheckConditional {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
         let eq = |l, r| SpanlessEq::new(cx).eq_path_segment(l, r);
         if_chain! {
-            if let ExprKind::Binary(ref op, ref first, ref second) = expr.kind;
-            if let ExprKind::Binary(ref op2, ref ident1, ref ident2) = first.kind;
-            if let ExprKind::Path(QPath::Resolved(_, ref path1)) = ident1.kind;
-            if let ExprKind::Path(QPath::Resolved(_, ref path2)) = ident2.kind;
-            if let ExprKind::Path(QPath::Resolved(_, ref path3)) = second.kind;
+            if let ExprKind::Binary(ref op, first, second) = expr.kind;
+            if let ExprKind::Binary(ref op2, ident1, ident2) = first.kind;
+            if let ExprKind::Path(QPath::Resolved(_, path1)) = ident1.kind;
+            if let ExprKind::Path(QPath::Resolved(_, path2)) = ident2.kind;
+            if let ExprKind::Path(QPath::Resolved(_, path3)) = second.kind;
             if eq(&path1.segments[0], &path3.segments[0]) || eq(&path2.segments[0], &path3.segments[0]);
             if cx.typeck_results().expr_ty(ident1).is_integral();
             if cx.typeck_results().expr_ty(ident2).is_integral();
@@ -55,11 +56,11 @@ impl<'tcx> LateLintPass<'tcx> for OverflowCheckConditional {
         }
 
         if_chain! {
-            if let ExprKind::Binary(ref op, ref first, ref second) = expr.kind;
-            if let ExprKind::Binary(ref op2, ref ident1, ref ident2) = second.kind;
-            if let ExprKind::Path(QPath::Resolved(_, ref path1)) = ident1.kind;
-            if let ExprKind::Path(QPath::Resolved(_, ref path2)) = ident2.kind;
-            if let ExprKind::Path(QPath::Resolved(_, ref path3)) = first.kind;
+            if let ExprKind::Binary(ref op, first, second) = expr.kind;
+            if let ExprKind::Binary(ref op2, ident1, ident2) = second.kind;
+            if let ExprKind::Path(QPath::Resolved(_, path1)) = ident1.kind;
+            if let ExprKind::Path(QPath::Resolved(_, path2)) = ident2.kind;
+            if let ExprKind::Path(QPath::Resolved(_, path3)) = first.kind;
             if eq(&path1.segments[0], &path3.segments[0]) || eq(&path2.segments[0], &path3.segments[0]);
             if cx.typeck_results().expr_ty(ident1).is_integral();
             if cx.typeck_results().expr_ty(ident2).is_integral();