@@ -224,8 +224,7 @@ impl QuestionMark {
224224 ///
225225 /// If it matches, it will suggest to use the question mark operator instead
226226 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)
229228 && !is_else_clause ( cx. tcx , expr)
230229 && let ExprKind :: MethodCall ( segment, caller, ..) = & cond. kind
231230 && let caller_ty = cx. typeck_results ( ) . expr_ty ( caller)
@@ -259,8 +258,7 @@ impl QuestionMark {
259258 }
260259
261260 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 {
264262 let_pat,
265263 let_expr,
266264 if_then,
@@ -324,13 +322,13 @@ impl<'tcx> LateLintPass<'tcx> for QuestionMark {
324322 return ;
325323 }
326324
327- if !in_constant ( cx, stmt. hir_id ) {
325+ if !self . inside_try_block ( ) && ! in_constant ( cx, stmt. hir_id ) {
328326 check_let_some_else_return_none ( cx, stmt) ;
329327 }
330328 self . check_manual_let_else ( cx, stmt) ;
331329 }
332330 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 ) {
334332 self . check_is_none_or_err_and_early_return ( cx, expr) ;
335333 self . check_if_let_some_or_err_and_early_return ( cx, expr) ;
336334 }
0 commit comments