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.
This commit is contained in:
Georg Brandl 2015-08-13 08:15:42 +02:00
parent 7aee04878f
commit a67e55f3f0
11 changed files with 20 additions and 18 deletions

View File

@ -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));
}
}
}

View File

@ -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))[..])
}
}

View File

@ -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, "..")));
}
}

View File

@ -59,7 +59,7 @@ fn check_trait_items(cx: &Context, item: &Item, trait_items: &[P<TraitItem>]) {
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<ImplItem>]) {
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;
}

View File

@ -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");
}
}
}

View File

@ -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, "..")))
}
}

View File

@ -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")
}
})
})

View File

@ -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 `&[...]`"))
}

View File

@ -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")
}
}
}

View File

@ -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, "..")));
}
}

View File

@ -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));
}
}
}