Skip to content

Commit 8214f66

Browse files
committed
Ran cargo fmt
1 parent 5a6aaec commit 8214f66

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

clippy_lints/src/map_identity.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use crate::utils::{
33
};
44
use if_chain::if_chain;
55
use rustc_errors::Applicability;
6-
use rustc_lint::{LateLintPass, LateContext};
6+
use rustc_hir::{def, Body, Expr, ExprKind, Pat, PatKind, Path, QPath, StmtKind};
7+
use rustc_lint::{LateContext, LateLintPass};
78
use rustc_session::{declare_lint_pass, declare_tool_lint};
8-
use rustc_hir::{Body, Expr, ExprKind, Pat, PatKind, Path, QPath, StmtKind, def};
99

1010
declare_clippy_lint! {
1111
/// **What it does:** Checks for instances of `map(f)` where `f` is the identity function.
@@ -57,15 +57,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MapIdentity {
5757
}
5858
}
5959

60-
6160
/// Returns the arguments passed into map() if the expression is a method call to
6261
/// map(). Otherwise, returns None.
6362
fn get_map_argument<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr<'a>) -> Option<&'a [Expr<'a>]> {
6463
if_chain! {
6564
if let ExprKind::MethodCall(ref method, _, ref args) = expr.kind;
6665
if args.len() == 2 && method.ident.as_str() == "map";
6766
let caller_ty = cx.tables.expr_ty(&args[0]);
68-
if match_trait_method(cx, expr, &paths::ITERATOR)
67+
if match_trait_method(cx, expr, &paths::ITERATOR)
6968
|| is_type_diagnostic_item(cx, caller_ty, sym!(result_type))
7069
|| is_type_diagnostic_item(cx, caller_ty, sym!(option_type));
7170
then {
@@ -100,8 +99,8 @@ fn is_identity_function(cx: &LateContext<'_, '_>, func: &Body<'_>) -> bool {
10099
false
101100
}
102101
}
103-
}
104-
_ => false
102+
},
103+
_ => false,
105104
}
106105
}
107106

@@ -110,14 +109,15 @@ fn get_body<'a>(cx: &LateContext<'a, '_>, expr: &'a Expr<'a>) -> Option<&'a Body
110109
match expr.kind {
111110
ExprKind::Closure(_, _, body_id, _, _) => Some(cx.tcx.hir().body(body_id)),
112111
ExprKind::Path(QPath::Resolved(_, ref path)) => path_to_body(cx, path),
113-
_ => None
112+
_ => None,
114113
}
115114
}
116115

117116
/// Returns the function body associated with a path
118117
fn path_to_body<'a>(cx: &LateContext<'a, '_>, path: &'a Path<'a>) -> Option<&'a Body<'a>> {
119118
if let def::Res::Def(_, def_id) = path.res {
120-
def_id.as_local()
119+
def_id
120+
.as_local()
121121
.and_then(|local_id| cx.tcx.hir().opt_local_def_id_to_hir_id(local_id))
122122
.and_then(|hir_id| cx.tcx.hir().maybe_body_owned_by(hir_id))
123123
.map(|body_id| cx.tcx.hir().body(body_id))

0 commit comments

Comments
 (0)