@@ -61,26 +61,6 @@ impl_lint_pass!(IfThenSomeElseNone => [IF_THEN_SOME_ELSE_NONE]);
61
61
62
62
impl < ' tcx > LateLintPass < ' tcx > for IfThenSomeElseNone {
63
63
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
-
84
64
if let Some ( higher:: If {
85
65
cond,
86
66
then,
@@ -89,9 +69,14 @@ impl<'tcx> LateLintPass<'tcx> for IfThenSomeElseNone {
89
69
&& let ExprKind :: Block ( then_block, _) = then. kind
90
70
&& let Some ( then_expr) = then_block. expr
91
71
&& let ExprKind :: Call ( then_call, [ then_arg] ) = then_expr. kind
72
+ && let ctxt = expr. span . ctxt ( )
92
73
&& then_expr. span . ctxt ( ) == ctxt
93
74
&& is_res_lang_ctor ( cx, path_res ( cx, then_call) , OptionSome )
94
75
&& 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 )
95
80
&& !contains_return ( then_block. stmts )
96
81
{
97
82
let mut app = Applicability :: Unspecified ;
0 commit comments