]> git.lizzy.rs Git - rust.git/commitdiff
Improve the lint message
authorZaki Manian <zaki@manian.org>
Sun, 3 Sep 2017 16:52:28 +0000 (09:52 -0700)
committerZaki Manian <zaki@manian.org>
Sun, 3 Sep 2017 16:52:28 +0000 (09:52 -0700)
clippy_lints/src/is_unit_expr.rs

index 82460f82fa126881a908ba2c7d3257998b1b2083..9db045ccd9125675fa5a2928a4f6318be70a1525 100644 (file)
@@ -2,7 +2,7 @@
 use syntax::ast::*;
 use std::ops::Deref;
 use syntax::ext::quote::rt::Span;
-
+use utils::span_note_and_lint;
 
 /// **What it does:** Checks for
 ///  - () being assigned to a variable
@@ -39,20 +39,20 @@ impl EarlyLintPass for UnitExpr {
     fn check_expr(&mut self, cx: &EarlyContext, expr: &Expr) {
         if let ExprKind::Assign(ref _left, ref right) = expr.node {
             if let Some(span) = is_unit_expr(right) {
-                cx.span_lint(UNIT_EXPR, span, "Consider removing the trailing semicolon");
+                span_note_and_lint(cx, UNIT_EXPR, expr.span,"This expression assigns the Unit type ()",span,"Consider removing the trailing semicolon");
             }
         }
         if let ExprKind::MethodCall(ref _left, ref args) = expr.node {
             for ref arg in args {
                 if let Some(span) = is_unit_expr(arg) {
-                    cx.span_lint(UNIT_EXPR, span, "Consider removing the trailing semicolon");
+                span_note_and_lint(cx, UNIT_EXPR, expr.span,"This expression assigns the Unit type ()",span,"Consider removing the trailing semicolon");
                 }
             }
         }
         if let ExprKind::Call(_, ref args) = expr.node {
             for ref arg in args {
                 if let Some(span) = is_unit_expr(arg) {
-                    cx.span_lint(UNIT_EXPR, span, "Consider removing the trailing semicolon");
+                span_note_and_lint(cx, UNIT_EXPR, expr.span,"This expression assigns the Unit type ()",span,"Consider removing the trailing semicolon");
                 }
             }
         }
@@ -65,7 +65,7 @@ fn check_stmt(&mut self, cx: &EarlyContext, stmt: &Stmt) {
             }
             if let Some(ref expr) = local.init {
                 if let Some(span) = is_unit_expr(expr) {
-                    cx.span_lint(UNIT_EXPR, span, "Consider removing the trailing semicolon");
+                span_note_and_lint(cx, UNIT_EXPR, expr.span,"This expression assigns the Unit type ()",span,"Consider removing the trailing semicolon");
                 }
             }
         }