Merge commit 'b7f3f7f608' into clippyup
This commit is contained in:
parent
87bb18e7c2
commit
5cf4984872
147 changed files with 4288 additions and 2969 deletions
|
|
@ -1284,8 +1284,9 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// ### Why is this bad?
|
||||
/// It looks suspicious. Maybe `map` was confused with `filter`.
|
||||
/// If the `map` call is intentional, this should be rewritten. Or, if you intend to
|
||||
/// drive the iterator to completion, you can just use `for_each` instead.
|
||||
/// If the `map` call is intentional, this should be rewritten
|
||||
/// using `inspect`. Or, if you intend to drive the iterator to
|
||||
/// completion, you can just use `for_each` instead.
|
||||
///
|
||||
/// ### Example
|
||||
/// ```rust
|
||||
|
|
|
|||
|
|
@ -178,15 +178,15 @@ pub(super) fn check<'tcx>(
|
|||
hir::ExprKind::Index(..) | hir::ExprKind::MethodCall(..) => {
|
||||
check_general_case(cx, name, method_span, &args[0], &args[1], expr.span, None);
|
||||
},
|
||||
hir::ExprKind::Block(block, _) => {
|
||||
if let BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided) = block.rules {
|
||||
if let Some(block_expr) = block.expr {
|
||||
if let hir::ExprKind::MethodCall(..) = block_expr.kind {
|
||||
check_general_case(cx, name, method_span, &args[0], &args[1], expr.span, None);
|
||||
}
|
||||
hir::ExprKind::Block(block, _)
|
||||
if block.rules == BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided) =>
|
||||
{
|
||||
if let Some(block_expr) = block.expr {
|
||||
if let hir::ExprKind::MethodCall(..) = block_expr.kind {
|
||||
check_general_case(cx, name, method_span, &args[0], &args[1], expr.span, None);
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ pub fn check<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, count_recv: &hi
|
|||
expr.span,
|
||||
"this call to `map()` won't have an effect on the call to `count()`",
|
||||
None,
|
||||
"make sure you did not confuse `map` with `filter` or `for_each`",
|
||||
"make sure you did not confuse `map` with `filter`, `for_each` or `inspect`",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,8 +35,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, arg: &hir::Expr<
|
|||
let in_ty = cx.typeck_results().node_type(body.params[0].hir_id);
|
||||
match cx.typeck_results().expr_ty(&body.value).kind() {
|
||||
ty::Adt(adt, subst)
|
||||
if cx.tcx.is_diagnostic_item(sym::Option, adt.did)
|
||||
&& TyS::same_type(in_ty, subst.type_at(0)) =>
|
||||
if cx.tcx.is_diagnostic_item(sym::Option, adt.did) && TyS::same_type(in_ty, subst.type_at(0)) =>
|
||||
{
|
||||
"filter"
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue