@@ -61,26 +61,6 @@ impl_lint_pass!(IfThenSomeElseNone => [IF_THEN_SOME_ELSE_NONE]);
6161
6262impl < ' tcx > LateLintPass < ' tcx > for IfThenSomeElseNone {
6363 fn check_expr ( & mut self , cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' tcx > ) {
64- if !self . msrv . meets ( msrvs:: BOOL_THEN ) {
65- return ;
66- }
67-
68- if in_external_macro ( cx. sess ( ) , expr. span ) {
69- return ;
70- }
71-
72- // We only care about the top-most `if` in the chain
73- if is_else_clause ( cx. tcx , expr) {
74- return ;
75- }
76-
77- // `bool::then()` and `bool::then_some()` are not const
78- if in_constant ( cx, expr. hir_id ) {
79- return ;
80- }
81-
82- let ctxt = expr. span . ctxt ( ) ;
83-
8464 if let Some ( higher:: If {
8565 cond,
8666 then,
@@ -89,9 +69,14 @@ impl<'tcx> LateLintPass<'tcx> for IfThenSomeElseNone {
8969 && let ExprKind :: Block ( then_block, _) = then. kind
9070 && let Some ( then_expr) = then_block. expr
9171 && let ExprKind :: Call ( then_call, [ then_arg] ) = then_expr. kind
72+ && let ctxt = expr. span . ctxt ( )
9273 && then_expr. span . ctxt ( ) == ctxt
9374 && is_res_lang_ctor ( cx, path_res ( cx, then_call) , OptionSome )
9475 && is_res_lang_ctor ( cx, path_res ( cx, peel_blocks ( els) ) , OptionNone )
76+ && !is_else_clause ( cx. tcx , expr)
77+ && !in_constant ( cx, expr. hir_id )
78+ && !in_external_macro ( cx. sess ( ) , expr. span )
79+ && self . msrv . meets ( msrvs:: BOOL_THEN )
9580 && !contains_return ( then_block. stmts )
9681 {
9782 let mut app = Applicability :: Unspecified ;
0 commit comments