mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 23:20:39 +00:00
Revert changes from accidentally running rustfmt
This commit is contained in:
parent
c922eb9db5
commit
31919aff3b
9 changed files with 28 additions and 36 deletions
|
@ -173,8 +173,6 @@ fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref
|
||||||
EXPL_IMPL_CLONE_ON_COPY,
|
EXPL_IMPL_CLONE_ON_COPY,
|
||||||
item.span,
|
item.span,
|
||||||
"you are implementing `Clone` explicitly on a `Copy` type",
|
"you are implementing `Clone` explicitly on a `Copy` type",
|
||||||
|db| {
|
|db| { db.span_note(item.span, "consider deriving `Clone` or removing `Copy`"); });
|
||||||
db.span_note(item.span, "consider deriving `Clone` or removing `Copy`");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use rustc::lint::*;
|
use rustc::lint::*;
|
||||||
use rustc::hir::*;
|
use rustc::hir::*;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use utils::{is_adjusted, match_path, match_trait_method, match_type, remove_blocks, paths, snippet,
|
use utils::{is_adjusted, match_path, match_trait_method, match_type, remove_blocks, paths, snippet, span_help_and_lint,
|
||||||
span_help_and_lint, walk_ptrs_ty, walk_ptrs_ty_depth, iter_input_pats};
|
walk_ptrs_ty, walk_ptrs_ty_depth, iter_input_pats};
|
||||||
|
|
||||||
/// **What it does:** Checks for mapping `clone()` over an iterator.
|
/// **What it does:** Checks for mapping `clone()` over an iterator.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1213,9 +1213,7 @@ fn lint_single_char_pattern(cx: &LateContext, expr: &hir::Expr, arg: &hir::Expr)
|
||||||
SINGLE_CHAR_PATTERN,
|
SINGLE_CHAR_PATTERN,
|
||||||
arg.span,
|
arg.span,
|
||||||
"single-character string constant used as pattern",
|
"single-character string constant used as pattern",
|
||||||
|db| {
|
|db| { db.span_suggestion(expr.span, "try using a char instead:", hint); });
|
||||||
db.span_suggestion(expr.span, "try using a char instead:", hint);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,9 +74,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBool {
|
||||||
NEEDLESS_BOOL,
|
NEEDLESS_BOOL,
|
||||||
e.span,
|
e.span,
|
||||||
"this if-then-else expression returns a bool literal",
|
"this if-then-else expression returns a bool literal",
|
||||||
|db| {
|
|db| { db.span_suggestion(e.span, "you can reduce it to", hint); });
|
||||||
db.span_suggestion(e.span, "you can reduce it to", hint);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
match (fetch_bool_block(then_block), fetch_bool_expr(else_expr)) {
|
match (fetch_bool_block(then_block), fetch_bool_expr(else_expr)) {
|
||||||
(RetBool(true), RetBool(true)) |
|
(RetBool(true), RetBool(true)) |
|
||||||
|
@ -123,9 +121,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoolComparison {
|
||||||
BOOL_COMPARISON,
|
BOOL_COMPARISON,
|
||||||
e.span,
|
e.span,
|
||||||
"equality checks against true are unnecessary",
|
"equality checks against true are unnecessary",
|
||||||
|db| {
|
|db| { db.span_suggestion(e.span, "try simplifying it as shown:", hint); });
|
||||||
db.span_suggestion(e.span, "try simplifying it as shown:", hint);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
(Other, Bool(true)) => {
|
(Other, Bool(true)) => {
|
||||||
let hint = snippet(cx, left_side.span, "..").into_owned();
|
let hint = snippet(cx, left_side.span, "..").into_owned();
|
||||||
|
@ -133,9 +129,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoolComparison {
|
||||||
BOOL_COMPARISON,
|
BOOL_COMPARISON,
|
||||||
e.span,
|
e.span,
|
||||||
"equality checks against true are unnecessary",
|
"equality checks against true are unnecessary",
|
||||||
|db| {
|
|db| { db.span_suggestion(e.span, "try simplifying it as shown:", hint); });
|
||||||
db.span_suggestion(e.span, "try simplifying it as shown:", hint);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
(Bool(false), Other) => {
|
(Bool(false), Other) => {
|
||||||
let hint = Sugg::hir(cx, right_side, "..");
|
let hint = Sugg::hir(cx, right_side, "..");
|
||||||
|
|
|
@ -120,9 +120,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
span_lint_and_then(cx, UNNECESSARY_OPERATION, stmt.span, "statement can be reduced", |db| {
|
span_lint_and_then(cx,
|
||||||
db.span_suggestion(stmt.span, "replace it with", snippet);
|
UNNECESSARY_OPERATION,
|
||||||
});
|
stmt.span,
|
||||||
|
"statement can be reduced",
|
||||||
|
|db| { db.span_suggestion(stmt.span, "replace it with", snippet); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,11 +36,12 @@ impl LintPass for Precedence {
|
||||||
impl EarlyLintPass for Precedence {
|
impl EarlyLintPass for Precedence {
|
||||||
fn check_expr(&mut self, cx: &EarlyContext, expr: &Expr) {
|
fn check_expr(&mut self, cx: &EarlyContext, expr: &Expr) {
|
||||||
if let ExprKind::Binary(Spanned { node: op, .. }, ref left, ref right) = expr.node {
|
if let ExprKind::Binary(Spanned { node: op, .. }, ref left, ref right) = expr.node {
|
||||||
let span_sugg = |expr: &Expr, sugg| {
|
let span_sugg =
|
||||||
span_lint_and_then(cx, PRECEDENCE, expr.span, "operator precedence can trip the unwary", |db| {
|
|expr: &Expr, sugg| {
|
||||||
db.span_suggestion(expr.span, "consider parenthesizing your expression", sugg);
|
span_lint_and_then(cx, PRECEDENCE, expr.span, "operator precedence can trip the unwary", |db| {
|
||||||
});
|
db.span_suggestion(expr.span, "consider parenthesizing your expression", sugg);
|
||||||
};
|
});
|
||||||
|
};
|
||||||
|
|
||||||
if !is_bit_op(op) {
|
if !is_bit_op(op) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -250,9 +250,7 @@ fn lint_shadow<'a, 'tcx: 'a>(
|
||||||
&format!("`{}` is shadowed by itself in `{}`",
|
&format!("`{}` is shadowed by itself in `{}`",
|
||||||
snippet(cx, pattern_span, "_"),
|
snippet(cx, pattern_span, "_"),
|
||||||
snippet(cx, expr.span, "..")),
|
snippet(cx, expr.span, "..")),
|
||||||
|db| {
|
|db| { db.span_note(prev_span, "previous binding is here"); });
|
||||||
db.span_note(prev_span, "previous binding is here");
|
|
||||||
});
|
|
||||||
} else if contains_self(cx, name, expr) {
|
} else if contains_self(cx, name, expr) {
|
||||||
span_lint_and_then(cx,
|
span_lint_and_then(cx,
|
||||||
SHADOW_REUSE,
|
SHADOW_REUSE,
|
||||||
|
@ -282,9 +280,7 @@ fn lint_shadow<'a, 'tcx: 'a>(
|
||||||
SHADOW_UNRELATED,
|
SHADOW_UNRELATED,
|
||||||
span,
|
span,
|
||||||
&format!("`{}` shadows a previous declaration", snippet(cx, pattern_span, "_")),
|
&format!("`{}` shadows a previous declaration", snippet(cx, pattern_span, "_")),
|
||||||
|db| {
|
|db| { db.span_note(prev_span, "previous binding is here"); });
|
||||||
db.span_note(prev_span, "previous binding is here");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -258,8 +258,9 @@ pub fn make_assoc(op: AssocOp, lhs: &Sugg, rhs: &Sugg) -> Sugg<'static> {
|
||||||
fn needs_paren(op: &AssocOp, other: &AssocOp, dir: Associativity) -> bool {
|
fn needs_paren(op: &AssocOp, other: &AssocOp, dir: Associativity) -> bool {
|
||||||
other.precedence() < op.precedence() ||
|
other.precedence() < op.precedence() ||
|
||||||
(other.precedence() == op.precedence() &&
|
(other.precedence() == op.precedence() &&
|
||||||
((op != other && associativity(op) != dir) || (op == other && associativity(op) != Associativity::Both))) ||
|
((op != other && associativity(op) != dir) ||
|
||||||
is_shift(op) && is_arith(other) || is_shift(other) && is_arith(op)
|
(op == other && associativity(op) != Associativity::Both))) || is_shift(op) && is_arith(other) ||
|
||||||
|
is_shift(other) && is_arith(op)
|
||||||
}
|
}
|
||||||
|
|
||||||
let lhs_paren = if let Sugg::BinOp(ref lop, _) = *lhs {
|
let lhs_paren = if let Sugg::BinOp(ref lop, _) = *lhs {
|
||||||
|
|
|
@ -81,9 +81,11 @@ fn check_vec_macro(cx: &LateContext, vec_args: &higher::VecArgs, span: Span) {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
span_lint_and_then(cx, USELESS_VEC, span, "useless use of `vec!`", |db| {
|
span_lint_and_then(cx,
|
||||||
db.span_suggestion(span, "you can use a slice directly", snippet);
|
USELESS_VEC,
|
||||||
});
|
span,
|
||||||
|
"useless use of `vec!`",
|
||||||
|
|db| { db.span_suggestion(span, "you can use a slice directly", snippet); });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the item type of the vector (ie. the `T` in `Vec<T>`).
|
/// Return the item type of the vector (ie. the `T` in `Vec<T>`).
|
||||||
|
|
Loading…
Reference in a new issue