]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/utils/comparisons.rs
Merge pull request #3465 from flip1995/rustfmt
[rust.git] / clippy_lints / src / utils / comparisons.rs
index 5cb9b50a79d2b0a1cbd1252925c2444c2bb27ad4..05636e3234b46f9251ff13c51f8e2d6f60f508fb 100644 (file)
@@ -1,8 +1,17 @@
+// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
 //! Utility functions about comparison operators.
 
-#![deny(missing_docs_in_private_items)]
+#![deny(clippy::missing_docs_in_private_items)]
 
-use rustc::hir::{BinOp_, Expr};
+use crate::rustc::hir::{BinOpKind, Expr};
 
 #[derive(PartialEq, Eq, Debug, Copy, Clone)]
 /// Represent a normalized comparison operator.
@@ -19,14 +28,14 @@ pub enum Rel {
 
 /// Put the expression in the form  `lhs < rhs`, `lhs <= rhs`, `lhs == rhs` or
 /// `lhs != rhs`.
-pub fn normalize_comparison<'a>(op: BinOp_, lhs: &'a Expr, rhs: &'a Expr) -> Option<(Rel, &'a Expr, &'a Expr)> {
+pub fn normalize_comparison<'a>(op: BinOpKind, lhs: &'a Expr, rhs: &'a Expr) -> Option<(Rel, &'a Expr, &'a Expr)> {
     match op {
-        BinOp_::BiLt => Some((Rel::Lt, lhs, rhs)),
-        BinOp_::BiLe => Some((Rel::Le, lhs, rhs)),
-        BinOp_::BiGt => Some((Rel::Lt, rhs, lhs)),
-        BinOp_::BiGe => Some((Rel::Le, rhs, lhs)),
-        BinOp_::BiEq => Some((Rel::Eq, rhs, lhs)),
-        BinOp_::BiNe => Some((Rel::Ne, rhs, lhs)),
+        BinOpKind::Lt => Some((Rel::Lt, lhs, rhs)),
+        BinOpKind::Le => Some((Rel::Le, lhs, rhs)),
+        BinOpKind::Gt => Some((Rel::Lt, rhs, lhs)),
+        BinOpKind::Ge => Some((Rel::Le, rhs, lhs)),
+        BinOpKind::Eq => Some((Rel::Eq, rhs, lhs)),
+        BinOpKind::Ne => Some((Rel::Ne, rhs, lhs)),
         _ => None,
     }
 }