]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/eq_op.rs
update to the rust-PR that unblocks clippy
[rust.git] / clippy_lints / src / eq_op.rs
index fb06639853cd5b648b78117ce650cc9af6487152..c43dfe6e27ca260a49f69e6fd331ce4f74af8c14 100644 (file)
@@ -2,15 +2,21 @@
 use rustc::lint::*;
 use utils::{SpanlessEq, span_lint};
 
-/// **What it does:** This lint checks for equal operands to comparison, logical and bitwise,
-/// difference and division binary operators (`==`, `>`, etc., `&&`, `||`, `&`, `|`, `^`, `-` and
-/// `/`).
+/// **What it does:** Checks for equal operands to comparison, logical and
+/// bitwise, difference and division binary operators (`==`, `>`, etc., `&&`,
+/// `||`, `&`, `|`, `^`, `-` and `/`).
 ///
 /// **Why is this bad?** This is usually just a typo or a copy and paste error.
 ///
-/// **Known problems:** False negatives: We had some false positives regarding calls (notably [racer](https://github.com/phildawes/racer) had one instance of `x.pop() && x.pop()`), so we removed matching any function or method calls. We may introduce a whitelist of known pure functions in the future.
+/// **Known problems:** False negatives: We had some false positives regarding
+/// calls (notably [racer](https://github.com/phildawes/racer) had one instance
+/// of `x.pop() && x.pop()`), so we removed matching any function or method
+/// calls. We may introduce a whitelist of known pure functions in the future.
 ///
-/// **Example:** `x + 1 == x + 1`
+/// **Example:**
+/// ```rust
+/// x + 1 == x + 1
+/// ```
 declare_lint! {
     pub EQ_OP,
     Warn,
@@ -26,8 +32,8 @@ fn get_lints(&self) -> LintArray {
     }
 }
 
-impl LateLintPass for EqOp {
-    fn check_expr(&mut self, cx: &LateContext, e: &Expr) {
+impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
+    fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
         if let ExprBinary(ref op, ref left, ref right) = e.node {
             if is_valid_operator(op) && SpanlessEq::new(cx).ignore_fn().eq_expr(left, right) {
                 span_lint(cx,