@@ -70,9 +70,9 @@ declare_clippy_lint! {
70
70
declare_lint_pass ! ( OptionIfLetElse => [ OPTION_IF_LET_ELSE ] ) ;
71
71
72
72
/// Returns true iff the given expression is the result of calling `Result::ok`
73
- fn is_result_ok ( cx : & LateContext < ' _ , ' _ > , expr : & ' _ Expr < ' _ > ) -> bool {
73
+ fn is_result_ok ( cx : & LateContext < ' _ > , expr : & ' _ Expr < ' _ > ) -> bool {
74
74
if let ExprKind :: MethodCall ( ref path, _, & [ ref receiver] , _) = & expr. kind {
75
- path. ident . name . to_ident_string ( ) == "ok" && match_type ( cx, & cx. tables . expr_ty ( & receiver) , & paths:: RESULT )
75
+ path. ident . name . to_ident_string ( ) == "ok" && match_type ( cx, & cx. tables ( ) . expr_ty ( & receiver) , & paths:: RESULT )
76
76
} else {
77
77
false
78
78
}
@@ -157,7 +157,7 @@ fn extract_body_from_arm<'a>(arm: &'a Arm<'a>) -> Option<&'a Expr<'a>> {
157
157
158
158
/// If this is the else body of an if/else expression, then we need to wrap
159
159
/// it in curcly braces. Otherwise, we don't.
160
- fn should_wrap_in_braces ( cx : & LateContext < ' _ , ' _ > , expr : & Expr < ' _ > ) -> bool {
160
+ fn should_wrap_in_braces ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > ) -> bool {
161
161
utils:: get_enclosing_block ( cx, expr. hir_id ) . map_or ( false , |parent| {
162
162
if let Some ( Expr {
163
163
kind :
@@ -181,7 +181,7 @@ fn should_wrap_in_braces(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> bool {
181
181
} )
182
182
}
183
183
184
- fn format_option_in_sugg ( cx : & LateContext < ' _ , ' _ > , cond_expr : & Expr < ' _ > , as_ref : bool , as_mut : bool ) -> String {
184
+ fn format_option_in_sugg ( cx : & LateContext < ' _ > , cond_expr : & Expr < ' _ > , as_ref : bool , as_mut : bool ) -> String {
185
185
format ! (
186
186
"{}{}" ,
187
187
Sugg :: hir( cx, cond_expr, ".." ) . maybe_par( ) ,
@@ -198,7 +198,7 @@ fn format_option_in_sugg(cx: &LateContext<'_, '_>, cond_expr: &Expr<'_>, as_ref:
198
198
/// If this expression is the option if let/else construct we're detecting, then
199
199
/// this function returns an `OptionIfLetElseOccurence` struct with details if
200
200
/// this construct is found, or None if this construct is not found.
201
- fn detect_option_if_let_else < ' a > ( cx : & LateContext < ' _ , ' a > , expr : & ' a Expr < ' a > ) -> Option < OptionIfLetElseOccurence > {
201
+ fn detect_option_if_let_else ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > ) -> Option < OptionIfLetElseOccurence > {
202
202
if_chain ! {
203
203
if !utils:: in_macro( expr. span) ; // Don't lint macros, because it behaves weirdly
204
204
if let ExprKind :: Match ( cond_expr, arms, MatchSource :: IfLetDesugar { contains_else_clause: true } ) = & expr. kind;
@@ -242,8 +242,8 @@ fn detect_option_if_let_else<'a>(cx: &LateContext<'_, 'a>, expr: &'a Expr<'a>) -
242
242
}
243
243
}
244
244
245
- impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for OptionIfLetElse {
246
- fn check_expr ( & mut self , cx : & LateContext < ' a , ' tcx > , expr : & ' tcx Expr < ' _ > ) {
245
+ impl < ' a > LateLintPass < ' a > for OptionIfLetElse {
246
+ fn check_expr ( & mut self , cx : & LateContext < ' a > , expr : & Expr < ' _ > ) {
247
247
if let Some ( detection) = detect_option_if_let_else ( cx, expr) {
248
248
span_lint_and_sugg (
249
249
cx,
0 commit comments