@@ -224,8 +224,7 @@ impl QuestionMark {
224
224
///
225
225
/// If it matches, it will suggest to use the question mark operator instead
226
226
fn check_is_none_or_err_and_early_return < ' tcx > ( & self , cx : & LateContext < ' tcx > , expr : & Expr < ' tcx > ) {
227
- if !self . inside_try_block ( )
228
- && let Some ( higher:: If { cond, then, r#else } ) = higher:: If :: hir ( expr)
227
+ if let Some ( higher:: If { cond, then, r#else } ) = higher:: If :: hir ( expr)
229
228
&& !is_else_clause ( cx. tcx , expr)
230
229
&& let ExprKind :: MethodCall ( segment, caller, ..) = & cond. kind
231
230
&& let caller_ty = cx. typeck_results ( ) . expr_ty ( caller)
@@ -259,8 +258,7 @@ impl QuestionMark {
259
258
}
260
259
261
260
fn check_if_let_some_or_err_and_early_return < ' tcx > ( & self , cx : & LateContext < ' tcx > , expr : & Expr < ' tcx > ) {
262
- if !self . inside_try_block ( )
263
- && let Some ( higher:: IfLet {
261
+ if let Some ( higher:: IfLet {
264
262
let_pat,
265
263
let_expr,
266
264
if_then,
@@ -324,13 +322,13 @@ impl<'tcx> LateLintPass<'tcx> for QuestionMark {
324
322
return ;
325
323
}
326
324
327
- if !in_constant ( cx, stmt. hir_id ) {
325
+ if !self . inside_try_block ( ) && ! in_constant ( cx, stmt. hir_id ) {
328
326
check_let_some_else_return_none ( cx, stmt) ;
329
327
}
330
328
self . check_manual_let_else ( cx, stmt) ;
331
329
}
332
330
fn check_expr ( & mut self , cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' _ > ) {
333
- if !in_constant ( cx, expr. hir_id ) && is_lint_allowed ( cx, QUESTION_MARK_USED , expr. hir_id ) {
331
+ if !self . inside_try_block ( ) && ! in_constant ( cx, expr. hir_id ) && is_lint_allowed ( cx, QUESTION_MARK_USED , expr. hir_id ) {
334
332
self . check_is_none_or_err_and_early_return ( cx, expr) ;
335
333
self . check_if_let_some_or_err_and_early_return ( cx, expr) ;
336
334
}
0 commit comments