mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 05:33:27 +00:00
s/cx.span_lint/span_lint(cx, /
This commit is contained in:
parent
2d5e3f3118
commit
e7158dc8f1
2 changed files with 23 additions and 18 deletions
22
src/misc.rs
22
src/misc.rs
|
@ -312,7 +312,7 @@ impl LateLintPass for ModuloOne {
|
|||
if let ExprBinary(ref cmp, _, ref right) = expr.node {
|
||||
if let Spanned {node: BinOp_::BiRem, ..} = *cmp {
|
||||
if is_integer_literal(right, 1) {
|
||||
cx.span_lint(MODULO_ONE, expr.span, "any number modulo 1 will be 0");
|
||||
span_lint(cx, MODULO_ONE, expr.span, "any number modulo 1 will be 0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -347,11 +347,12 @@ impl LateLintPass for PatternPass {
|
|||
fn check_pat(&mut self, cx: &LateContext, pat: &Pat) {
|
||||
if let PatKind::Ident(_, ref ident, Some(ref right)) = pat.node {
|
||||
if right.node == PatKind::Wild {
|
||||
cx.span_lint(REDUNDANT_PATTERN,
|
||||
pat.span,
|
||||
&format!("the `{} @ _` pattern can be written as just `{}`",
|
||||
ident.node.name,
|
||||
ident.node.name));
|
||||
span_lint(cx,
|
||||
REDUNDANT_PATTERN,
|
||||
pat.span,
|
||||
&format!("the `{} @ _` pattern can be written as just `{}`",
|
||||
ident.node.name,
|
||||
ident.node.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -408,10 +409,11 @@ impl LateLintPass for UsedUnderscoreBinding {
|
|||
_ => false,
|
||||
};
|
||||
if needs_lint {
|
||||
cx.span_lint(USED_UNDERSCORE_BINDING,
|
||||
expr.span,
|
||||
"used binding which is prefixed with an underscore. A leading underscore signals that a \
|
||||
binding will not be used.");
|
||||
span_lint(cx,
|
||||
USED_UNDERSCORE_BINDING,
|
||||
expr.span,
|
||||
"used binding which is prefixed with an underscore. A leading underscore signals that a \
|
||||
binding will not be used.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use rustc::lint::*;
|
||||
use rustc_front::hir::*;
|
||||
use syntax::codemap::Spanned;
|
||||
use utils::{is_integer_literal, match_type, snippet, unsugar_range, UnsugaredRange};
|
||||
use utils::{is_integer_literal, match_type, snippet, span_lint, unsugar_range, UnsugaredRange};
|
||||
|
||||
/// **What it does:** This lint checks for iterating over ranges with a `.step_by(0)`, which never terminates.
|
||||
///
|
||||
|
@ -41,10 +41,11 @@ impl LateLintPass for StepByZero {
|
|||
// Range with step_by(0).
|
||||
if name.as_str() == "step_by" && args.len() == 2 && is_range(cx, &args[0]) &&
|
||||
is_integer_literal(&args[1], 0) {
|
||||
cx.span_lint(RANGE_STEP_BY_ZERO,
|
||||
expr.span,
|
||||
"Range::step_by(0) produces an infinite iterator. Consider using `std::iter::repeat()` \
|
||||
instead")
|
||||
span_lint(cx,
|
||||
RANGE_STEP_BY_ZERO,
|
||||
expr.span,
|
||||
"Range::step_by(0) produces an infinite iterator. Consider using `std::iter::repeat()` \
|
||||
instead");
|
||||
} else if name.as_str() == "zip" && args.len() == 2 {
|
||||
let iter = &args[0].node;
|
||||
let zip_arg = &args[1];
|
||||
|
@ -64,9 +65,11 @@ impl LateLintPass for StepByZero {
|
|||
let ExprPath(_, Path { segments: ref len_path, .. }) = len_args[0].node,
|
||||
iter_path == len_path
|
||||
], {
|
||||
cx.span_lint(RANGE_ZIP_WITH_LEN, expr.span,
|
||||
&format!("It is more idiomatic to use {}.iter().enumerate()",
|
||||
snippet(cx, iter_args[0].span, "_")));
|
||||
span_lint(cx,
|
||||
RANGE_ZIP_WITH_LEN,
|
||||
expr.span,
|
||||
&format!("It is more idiomatic to use {}.iter().enumerate()",
|
||||
snippet(cx, iter_args[0].span, "_")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue