@@ -155,30 +155,27 @@ where
155155 self . state = new_state;
156156 }
157157
158- /// Visit the items inside the [ExprCfgIf] and return the final
159- /// state after, which is conservatively the minimum of all branches
160- /// since the branches could have diverged in state.
161- fn visit_cfg_expr_if ( & mut self , cfg_expr_if : & ExprCfgIf ) -> State {
158+ /// Visit the items inside the [ExprCfgIf], restoring the state after
159+ /// each branch.
160+ fn visit_cfg_expr_if ( & mut self , cfg_expr_if : & ExprCfgIf ) {
162161 let initial_state = self . state ;
163162
164163 for item in & cfg_expr_if. then_branch {
165164 self . visit_item ( item) ;
166165 }
167- let then_end_state = self . state ;
168166 self . state = initial_state;
169167
170- match & cfg_expr_if. else_branch {
171- Some ( else_branch ) => match else_branch. deref ( ) {
168+ if let Some ( else_branch ) = & cfg_expr_if. else_branch {
169+ match else_branch. deref ( ) {
172170 ExprCfgElse :: Block ( items) => {
173171 for item in items {
174172 self . visit_item ( item) ;
175173 }
176- then_end_state. min ( self . state )
177174 }
178175 ExprCfgElse :: If ( cfg_expr_if) => self . visit_cfg_expr_if ( & cfg_expr_if) ,
179- } ,
180- None => then_end_state,
176+ }
181177 }
178+ self . state = initial_state;
182179 }
183180}
184181
@@ -236,8 +233,7 @@ where
236233 . parse_body ( )
237234 . expect ( "cfg_if! should be parsed since it compiled" ) ;
238235
239- let end_state = self . visit_cfg_expr_if ( & cfg_expr_if) ;
240- self . state = end_state;
236+ self . visit_cfg_expr_if ( & cfg_expr_if) ;
241237 } else {
242238 let new_state = if mac. path . is_ident ( "s" ) {
243239 // FIXME: see StyleChecker::set_state
0 commit comments