]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/modulo_arithmetic.rs
Merge commit '3ae8faff4d46ad92f194c2a4b941c3152a701b31' into clippyup
[rust.git] / clippy_lints / src / modulo_arithmetic.rs
index 59ccc6333fdcd838dc28da84c89ba7062a7c32b4..1414fdc1b114d6fcccc2a93a9e1ae2eb97b3e5ac 100644 (file)
@@ -1,14 +1,15 @@
-use crate::consts::{constant, Constant};
-use crate::utils::{sext, span_lint_and_then};
+use clippy_utils::consts::{constant, Constant};
+use clippy_utils::diagnostics::span_lint_and_then;
+use clippy_utils::sext;
 use if_chain::if_chain;
 use rustc_hir::{BinOpKind, Expr, ExprKind};
 use rustc_lint::{LateContext, LateLintPass};
-use rustc_middle::ty::{self};
+use rustc_middle::ty;
 use rustc_session::{declare_lint_pass, declare_tool_lint};
 use std::fmt::Display;
 
 declare_clippy_lint! {
-    /// **What it does:** Checks for modulo arithemtic.
+    /// **What it does:** Checks for modulo arithmetic.
     ///
     /// **Why is this bad?** The results of modulo (%) operation might differ
     /// depending on the language, when negative numbers are involved.
@@ -37,8 +38,8 @@ struct OperandInfo {
 }
 
 fn analyze_operand(operand: &Expr<'_>, cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<OperandInfo> {
-    match constant(cx, cx.tables(), operand) {
-        Some((Constant::Int(v), _)) => match cx.tables().expr_ty(expr).kind {
+    match constant(cx, cx.typeck_results(), operand) {
+        Some((Constant::Int(v), _)) => match *cx.typeck_results().expr_ty(expr).kind() {
             ty::Int(ity) => {
                 let value = sext(cx.tcx, v, ity);
                 return Some(OperandInfo {
@@ -106,7 +107,7 @@ fn check_const_operands<'tcx>(
 }
 
 fn check_non_const_operands<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, operand: &Expr<'_>) {
-    let operand_type = cx.tables().expr_ty(operand);
+    let operand_type = cx.typeck_results().expr_ty(operand);
     if might_have_negative_value(operand_type) {
         span_lint_and_then(
             cx,