mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-26 22:50:56 +00:00
More if_chain
This commit is contained in:
parent
48e6be42d7
commit
ed9cd1530d
1 changed files with 48 additions and 50 deletions
|
@ -2271,13 +2271,13 @@ impl<'a, 'tcx> Visitor<'tcx> for VarCollectorVisitor<'a, 'tcx> {
|
|||
const NEEDLESS_COLLECT_MSG: &str = "avoid using `collect()` when not needed";
|
||||
|
||||
fn check_needless_collect<'a, 'tcx>(expr: &'tcx Expr, cx: &LateContext<'a, 'tcx>) {
|
||||
if let ExprKind::MethodCall(ref method, _, ref args) = expr.node {
|
||||
if let ExprKind::MethodCall(ref chain_method, _, _) = args[0].node {
|
||||
if chain_method.ident.name == "collect" &&
|
||||
match_trait_method(cx, &args[0], &paths::ITERATOR) &&
|
||||
chain_method.args.is_some() {
|
||||
let generic_args = chain_method.args.as_ref().unwrap();
|
||||
if let Some(GenericArg::Type(ref ty)) = generic_args.args.get(0) {
|
||||
if_chain! {
|
||||
if let ExprKind::MethodCall(ref method, _, ref args) = expr.node;
|
||||
if let ExprKind::MethodCall(ref chain_method, _, _) = args[0].node;
|
||||
if chain_method.ident.name == "collect" && match_trait_method(cx, &args[0], &paths::ITERATOR);
|
||||
if let Some(ref generic_args) = chain_method.args;
|
||||
if let Some(GenericArg::Type(ref ty)) = generic_args.args.get(0);
|
||||
then {
|
||||
let ty = cx.tables.node_id_to_type(ty.hir_id);
|
||||
if match_type(cx, ty, &paths::VEC) ||
|
||||
match_type(cx, ty, &paths::VEC_DEQUE) ||
|
||||
|
@ -2323,8 +2323,6 @@ fn check_needless_collect<'a, 'tcx>(expr: &'tcx Expr, cx: &LateContext<'a, 'tcx>
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn shorten_needless_collect_span(expr: &Expr) -> Span {
|
||||
|
|
Loading…
Reference in a new issue