Skip to content

Commit 06f6b36

Browse files
author
Michael Wright
committed
rustfmt
1 parent efdc739 commit 06f6b36

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

clippy_lints/src/methods/unnecessary_filter_map.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
1-
use crate::rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
2-
use crate::rustc::lint::LateContext;
31
use crate::rustc::hir;
42
use crate::rustc::hir::def::Def;
3+
use crate::rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
4+
use crate::rustc::lint::LateContext;
55
use crate::syntax::ast;
6-
use crate::utils::{match_qpath, match_trait_method, span_lint};
76
use crate::utils::paths;
87
use crate::utils::usage::mutated_variables;
8+
use crate::utils::{match_qpath, match_trait_method, span_lint};
99

1010
use if_chain::if_chain;
1111

1212
use super::UNNECESSARY_FILTER_MAP;
1313

1414
pub(super) fn lint(cx: &LateContext<'_, '_>, expr: &hir::Expr, args: &[hir::Expr]) {
15-
1615
if !match_trait_method(cx, expr, &paths::ITERATOR) {
1716
return;
1817
}
1918

2019
if let hir::ExprKind::Closure(_, _, body_id, ..) = args[1].node {
21-
2220
let body = cx.tcx.hir.body(body_id);
2321
let arg_id = body.arguments[0].pat.id;
2422
let mutates_arg = match mutated_variables(&body.value, cx) {
25-
Some(used_mutably) => used_mutably.contains(&arg_id),
26-
None => true,
23+
Some(used_mutably) => used_mutably.contains(&arg_id),
24+
None => true,
2725
};
2826

2927
let (mut found_mapping, mut found_filtering) = check_expression(&cx, arg_id, &body.value);
@@ -56,7 +54,11 @@ pub(super) fn lint(cx: &LateContext<'_, '_>, expr: &hir::Expr, args: &[hir::Expr
5654
}
5755

5856
// returns (found_mapping, found_filtering)
59-
fn check_expression<'a, 'tcx: 'a>(cx: &'a LateContext<'a, 'tcx>, arg_id: ast::NodeId, expr: &'tcx hir::Expr) -> (bool, bool) {
57+
fn check_expression<'a, 'tcx: 'a>(
58+
cx: &'a LateContext<'a, 'tcx>,
59+
arg_id: ast::NodeId,
60+
expr: &'tcx hir::Expr,
61+
) -> (bool, bool) {
6062
match &expr.node {
6163
hir::ExprKind::Call(ref func, ref args) => {
6264
if_chain! {
@@ -105,7 +107,7 @@ fn check_expression<'a, 'tcx: 'a>(cx: &'a LateContext<'a, 'tcx>, arg_id: ast::No
105107
(found_mapping, found_filtering)
106108
},
107109
hir::ExprKind::Path(path) if match_qpath(path, &paths::OPTION_NONE) => (false, true),
108-
_ => (true, true)
110+
_ => (true, true),
109111
}
110112
}
111113

0 commit comments

Comments
 (0)