From 98ec8657e4b85229b1472b1caf8421e88a575097 Mon Sep 17 00:00:00 2001 From: Zaki Manian Date: Sun, 3 Sep 2017 09:52:28 -0700 Subject: [PATCH] Improve the lint message --- clippy_lints/src/is_unit_expr.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/clippy_lints/src/is_unit_expr.rs b/clippy_lints/src/is_unit_expr.rs index 82460f82fa1..9db045ccd91 100644 --- a/clippy_lints/src/is_unit_expr.rs +++ b/clippy_lints/src/is_unit_expr.rs @@ -2,7 +2,7 @@ use rustc::lint::*; 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 @@ impl EarlyLintPass for UnitExpr { } 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"); } } }