From a67e55f3f07d552233248a63d256535e095c7975 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Thu, 13 Aug 2015 08:15:42 +0200 Subject: [PATCH] lint messages: remove trailing period Since lint messages often are suffixed by ", #[warn(xxx)] on by default" this trailing period produces an ugly clash with the comma. --- src/approx_const.rs | 2 +- src/eta_reduction.rs | 2 +- src/identity_op.rs | 2 +- src/len_zero.rs | 4 ++-- src/methods.rs | 4 ++-- src/misc.rs | 10 ++++++---- src/mut_mut.rs | 2 +- src/ptr_arg.rs | 4 ++-- src/strings.rs | 2 +- src/types.rs | 2 +- src/unicode.rs | 4 ++-- 11 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/approx_const.rs b/src/approx_const.rs index 594348bf93f..377c7e66ebd 100644 --- a/src/approx_const.rs +++ b/src/approx_const.rs @@ -53,7 +53,7 @@ fn check_known_consts(cx: &Context, span: Span, str: &str, module: &str) { for &(constant, name) in KNOWN_CONSTS { if within_epsilon(constant, value) { span_lint(cx, APPROX_CONSTANT, span, &format!( - "approximate value of `{}::{}` found. Consider using it directly.", module, &name)); + "approximate value of `{}::{}` found. Consider using it directly", module, &name)); } } } diff --git a/src/eta_reduction.rs b/src/eta_reduction.rs index 00c5a523981..eda38419d4d 100644 --- a/src/eta_reduction.rs +++ b/src/eta_reduction.rs @@ -51,7 +51,7 @@ impl LintPass for EtaPass { } } span_lint(cx, REDUNDANT_CLOSURE, expr.span, - &format!("redundant closure found. Consider using `{}` in its place.", + &format!("redundant closure found. Consider using `{}` in its place", expr_to_string(caller))[..]) } } diff --git a/src/identity_op.rs b/src/identity_op.rs index e043ac63026..8c6940e3df4 100644 --- a/src/identity_op.rs +++ b/src/identity_op.rs @@ -49,7 +49,7 @@ impl LintPass for IdentityOp { fn check(cx: &Context, e: &Expr, m: i8, span: Span, arg: Span) { if have_lit(cx, e, m) { span_lint(cx, IDENTITY_OP, span, &format!( - "the operation is ineffective. Consider reducing it to `{}`.", + "the operation is ineffective. Consider reducing it to `{}`", snippet(cx, arg, ".."))); } } diff --git a/src/len_zero.rs b/src/len_zero.rs index 298522ed24c..da230c1d28a 100644 --- a/src/len_zero.rs +++ b/src/len_zero.rs @@ -59,7 +59,7 @@ fn check_trait_items(cx: &Context, item: &Item, trait_items: &[P]) { if is_named_self(i, "len") { span_lint(cx, LEN_WITHOUT_IS_EMPTY, i.span, &format!("trait `{}` has a `.len(_: &Self)` method, but no \ - `.is_empty(_: &Self)` method. Consider adding one.", + `.is_empty(_: &Self)` method. Consider adding one", item.ident.name)); } }; @@ -79,7 +79,7 @@ fn check_impl_items(cx: &Context, item: &Item, impl_items: &[P]) { span_lint(cx, LEN_WITHOUT_IS_EMPTY, Span{ lo: s.lo, hi: s.lo, expn_id: s.expn_id }, &format!("item `{}` has a `.len(_: &Self)` method, but no \ - `.is_empty(_: &Self)` method. Consider adding one.", + `.is_empty(_: &Self)` method. Consider adding one", item.ident.name)); return; } diff --git a/src/methods.rs b/src/methods.rs index a5b12e52bdf..403845771a9 100644 --- a/src/methods.rs +++ b/src/methods.rs @@ -30,12 +30,12 @@ impl LintPass for MethodsPass { span_lint(cx, OPTION_UNWRAP_USED, expr.span, "used unwrap() on an Option value. If you don't want \ to handle the None case gracefully, consider using - expect() to provide a better panic message."); + expect() to provide a better panic message"); } else if match_def_path(cx, did.did, &["core", "result", "Result"]) { span_lint(cx, RESULT_UNWRAP_USED, expr.span, "used unwrap() on a Result value. Graceful handling \ - of Err values is preferred."); + of Err values is preferred"); } } } diff --git a/src/misc.rs b/src/misc.rs index d5e1efe2cc3..82754820f8b 100644 --- a/src/misc.rs +++ b/src/misc.rs @@ -129,7 +129,8 @@ impl LintPass for FloatCmp { let op = cmp.node; if (op == BiEq || op == BiNe) && (is_float(cx, left) || is_float(cx, right)) { span_lint(cx, FLOAT_CMP, expr.span, &format!( - "{}-comparison of f32 or f64 detected. Consider changing this to `abs({} - {}) < epsilon` for some suitable value of epsilon.", + "{}-comparison of f32 or f64 detected. Consider changing this to \ + `abs({} - {}) < epsilon` for some suitable value of epsilon", binop_to_string(op), snippet(cx, left.span, ".."), snippet(cx, right.span, ".."))); } @@ -160,7 +161,8 @@ impl LintPass for Precedence { if let ExprBinary(Spanned { node: op, ..}, ref left, ref right) = expr.node { if is_bit_op(op) && (is_arith_expr(left) || is_arith_expr(right)) { span_lint(cx, PRECEDENCE, expr.span, - "operator precedence can trip the unwary. Consider adding parenthesis to the subexpression."); + "operator precedence can trip the unwary. Consider adding parenthesis \ + to the subexpression"); } } } @@ -216,7 +218,7 @@ fn check_to_owned(cx: &Context, expr: &Expr, other_span: Span) { name == "to_owned" && is_str_arg(cx, args) { span_lint(cx, CMP_OWNED, expr.span, &format!( "this creates an owned instance just for comparison. \ - Consider using `{}.as_slice()` to compare without allocation.", + Consider using `{}.as_slice()` to compare without allocation", snippet(cx, other_span, ".."))) } }, @@ -226,7 +228,7 @@ fn check_to_owned(cx: &Context, expr: &Expr, other_span: Span) { match_path(path, &["String", "from"]) { span_lint(cx, CMP_OWNED, expr.span, &format!( "this creates an owned instance just for comparison. \ - Consider using `{}.as_slice()` to compare without allocation.", + Consider using `{}.as_slice()` to compare without allocation", snippet(cx, other_span, ".."))) } } diff --git a/src/mut_mut.rs b/src/mut_mut.rs index 469a14a9452..a2055bb655f 100644 --- a/src/mut_mut.rs +++ b/src/mut_mut.rs @@ -46,7 +46,7 @@ fn check_expr_expd(cx: &Context, expr: &Expr, info: Option<&ExpnInfo>) { cx.tcx.expr_ty(e).sty { span_lint(cx, MUT_MUT, expr.span, "this expression mutably borrows a mutable reference. \ - Consider reborrowing.") + Consider reborrowing") } }) }) diff --git a/src/ptr_arg.rs b/src/ptr_arg.rs index ed37c112040..3868854c7a1 100644 --- a/src/ptr_arg.rs +++ b/src/ptr_arg.rs @@ -61,9 +61,9 @@ fn check_ptr_subtype(cx: &Context, span: Span, ty: &Ty) { &["String"]).map_or((), |_| { span_lint(cx, PTR_ARG, span, "writing `&String` instead of `&str` involves a new object \ - where a slice will do. Consider changing the type to `&str`.") + where a slice will do. Consider changing the type to `&str`") }), |_| span_lint(cx, PTR_ARG, span, "writing `&Vec<_>` instead of \ `&[_]` involves one more reference and cannot be used with \ - non-Vec-based slices. Consider changing the type to `&[...]`.")) + non-Vec-based slices. Consider changing the type to `&[...]`")) } diff --git a/src/strings.rs b/src/strings.rs index 97016f36268..afc444dd67f 100644 --- a/src/strings.rs +++ b/src/strings.rs @@ -30,7 +30,7 @@ impl LintPass for StringAdd { if is_string(cx, target) && is_add(src, target) { span_lint(cx, STRING_ADD_ASSIGN, e.span, "you assign the result of adding something to this string. \ - Consider using `String::push_str()` instead.") + Consider using `String::push_str()` instead") } } } diff --git a/src/types.rs b/src/types.rs index 4980046e01b..c22d088ce5b 100644 --- a/src/types.rs +++ b/src/types.rs @@ -90,7 +90,7 @@ fn check_let_unit(cx: &Context, decl: &Decl, info: Option<&ExpnInfo>) { let bindtype = &cx.tcx.pat_ty(&*local.pat).sty; if *bindtype == ty::TyTuple(vec![]) { span_lint(cx, LET_UNIT_VALUE, decl.span, &format!( - "this let-binding has unit value. Consider omitting `let {} =`.", + "this let-binding has unit value. Consider omitting `let {} =`", snippet(cx, local.pat.span, ".."))); } } diff --git a/src/unicode.rs b/src/unicode.rs index ca6abaf01b4..161e90d0f64 100644 --- a/src/unicode.rs +++ b/src/unicode.rs @@ -27,11 +27,11 @@ fn check_str(cx: &Context, string: &str, span: Span) { for (i, c) in string.char_indices() { if c == '\u{200B}' { str_pos_lint(cx, ZERO_WIDTH_SPACE, span, i, - "zero-width space detected. Consider using `\\u{200B}`."); + "zero-width space detected. Consider using `\\u{200B}`"); } if c as u32 > 0x7F { str_pos_lint(cx, NON_ASCII_LITERAL, span, i, &format!( - "literal non-ASCII character detected. Consider using `\\u{{{:X}}}`.", c as u32)); + "literal non-ASCII character detected. Consider using `\\u{{{:X}}}`", c as u32)); } } }