@@ -434,6 +434,7 @@ fn get_switch_semantic_cases(
434434 /* default */ Option < BlockNodeId > ,
435435 /* exit */ Option < BlockNodeId > ,
436436) {
437+ let nodes = ctx. nodes ( ) ;
437438 let cfg = ctx. cfg ( ) ;
438439 let graph = cfg. graph ( ) ;
439440 let has_default = switch. cases . iter ( ) . any ( SwitchCase :: is_default_case) ;
@@ -459,7 +460,7 @@ fn get_switch_semantic_cases(
459460 . instructions ( )
460461 . first ( )
461462 . and_then ( |it| it. node_id )
462- . map ( |id| ctx . nodes ( ) . parent_kind ( id) )
463+ . map ( |id| nodes. parent_kind ( id) )
463464 . and_then ( |it| match it {
464465 AstKind :: SwitchCase ( case) => Some ( case) ,
465466 _ => None ,
@@ -482,6 +483,7 @@ fn get_switch_semantic_cases(
482483 } else {
483484 ( None , exit)
484485 } ;
486+ cfg_ids. sort_by_key ( |cfg_id| nodes. iter ( ) . position ( |it| it. cfg_id ( ) == * cfg_id ) ) ;
485487 ( cfg_ids, FxHashMap :: from_iter ( tests) , default, exit)
486488}
487489
@@ -535,6 +537,7 @@ fn test() {
535537 "switch (foo) { case 0: a(); \n // eslint-disable-next-line no-fallthrough\n case 1: }" ,
536538 None ,
537539 ) ,
540+ ( "switch(foo) { case 0: default: a(); break; case 1: b(); }" , None ) ,
538541 (
539542 "switch(foo) { case 0: a(); /* no break */ case 1: b(); }" ,
540543 Some ( serde_json:: json!( [ {
0 commit comments