]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/minmax.rs
Auto merge of #3705 - matthiaskrgr:rustup, r=phansch
[rust.git] / clippy_lints / src / minmax.rs
index fa2c9fda731e5ef6fef36e4b36bebdaca1c570f9..19bede8a280657c307ebcdb2fe65d509f756d534 100644 (file)
@@ -1,7 +1,8 @@
 use crate::consts::{constant_simple, Constant};
 use crate::utils::{match_def_path, opt_def_id, paths, span_lint};
 use rustc::hir::*;
-use rustc::lint::*;
+use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
+use rustc::{declare_tool_lint, lint_array};
 use std::cmp::Ordering;
 
 /// **What it does:** Checks for expressions where `std::cmp::min` and `max` are
     "`min(_, max(_, _))` (or vice versa) with bounds clamping the result to a constant"
 }
 
-#[allow(missing_copy_implementations)]
 pub struct MinMaxPass;
 
 impl LintPass for MinMaxPass {
     fn get_lints(&self) -> LintArray {
         lint_array!(MIN_MAX)
     }
+
+    fn name(&self) -> &'static str {
+        "MinMax"
+    }
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MinMaxPass {
@@ -42,7 +46,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
                 }
                 match (
                     outer_max,
-                    Constant::partial_cmp(cx.tcx, &cx.tables.expr_ty(ie).sty, &outer_c, &inner_c),
+                    Constant::partial_cmp(cx.tcx, cx.tables.expr_ty(ie), &outer_c, &inner_c),
                 ) {
                     (_, None) | (MinMax::Max, Some(Ordering::Less)) | (MinMax::Min, Some(Ordering::Greater)) => (),
                     _ => {
@@ -65,7 +69,7 @@ enum MinMax {
     Max,
 }
 
-fn min_max<'a>(cx: &LateContext, expr: &'a Expr) -> Option<(MinMax, Constant, &'a Expr)> {
+fn min_max<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr) -> Option<(MinMax, Constant, &'a Expr)> {
     if let ExprKind::Call(ref path, ref args) = expr.node {
         if let ExprKind::Path(ref qpath) = path.node {
             opt_def_id(cx.tables.qpath_def(qpath, path.hir_id)).and_then(|def_id| {
@@ -85,7 +89,7 @@ fn min_max<'a>(cx: &LateContext, expr: &'a Expr) -> Option<(MinMax, Constant, &'
     }
 }
 
-fn fetch_const<'a>(cx: &LateContext, args: &'a [Expr], m: MinMax) -> Option<(MinMax, Constant, &'a Expr)> {
+fn fetch_const<'a>(cx: &LateContext<'_, '_>, args: &'a [Expr], m: MinMax) -> Option<(MinMax, Constant, &'a Expr)> {
     if args.len() != 2 {
         return None;
     }