@@ -146,7 +146,7 @@ impl CodeFlags {
146146#[ derive( Serialize , Debug , Deserialize , Clone , Copy , PartialEq , Eq , Hash , Ord , PartialOrd ) ]
147147#[ repr( transparent) ]
148148// XXX: if you add a new instruction that stores a Label, make sure to add it in
149- // compile::CodeInfo::finalize_code
149+ // compile::CodeInfo::finalize_code and CodeObject::label_targets
150150pub struct Label ( pub usize ) ;
151151impl fmt:: Display for Label {
152152 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
@@ -598,25 +598,38 @@ impl<C: Constant> CodeObject<C> {
598598 pub fn label_targets ( & self ) -> BTreeSet < Label > {
599599 let mut label_targets = BTreeSet :: new ( ) ;
600600 for instruction in & self . instructions {
601- let label = match instruction {
602- Jump { target } => target,
603- JumpIfTrue { target } => target,
604- JumpIfFalse { target } => target,
605- JumpIfTrueOrPop { target } => target,
606- JumpIfFalseOrPop { target } => target,
607- ForIter { target } => target,
601+ match instruction {
602+ Jump { target : l }
603+ | JumpIfTrue { target : l }
604+ | JumpIfFalse { target : l }
605+ | JumpIfTrueOrPop { target : l }
606+ | JumpIfFalseOrPop { target : l }
607+ | ForIter { target : l }
608+ | SetupFinally { handler : l }
609+ | SetupExcept { handler : l }
610+ | SetupWith { end : l }
611+ | SetupAsyncWith { end : l } => {
612+ label_targets. insert ( * l) ;
613+ }
608614 SetupLoop { start, end } => {
609615 label_targets. insert ( * start) ;
610616 label_targets. insert ( * end) ;
611- continue ;
612617 }
613- SetupFinally { handler } => handler,
614- SetupExcept { handler } => handler,
615- SetupWith { end } => end,
616- SetupAsyncWith { end } => end,
617- _ => continue ,
618- } ;
619- label_targets. insert ( * label) ;
618+
619+ #[ rustfmt:: skip]
620+ Import { .. } | ImportStar | ImportFrom { .. } | LoadName { .. } | StoreName { .. }
621+ | DeleteName { .. } | Subscript | StoreSubscript | DeleteSubscript
622+ | StoreAttr { .. } | DeleteAttr { .. } | LoadConst { .. } | UnaryOperation { .. }
623+ | BinaryOperation { .. } | LoadAttr { .. } | CompareOperation { .. } | Pop
624+ | Rotate { .. } | Duplicate | GetIter | Continue | Break | MakeFunction
625+ | CallFunction { .. } | ReturnValue | YieldValue | YieldFrom | SetupAnnotation
626+ | EnterFinally | EndFinally | WithCleanupStart | WithCleanupFinish | PopBlock
627+ | Raise { .. } | BuildString { .. } | BuildTuple { .. } | BuildList { .. }
628+ | BuildSet { .. } | BuildMap { .. } | BuildSlice { .. } | ListAppend { .. }
629+ | SetAdd { .. } | MapAdd { .. } | PrintExpr | LoadBuildClass | UnpackSequence { .. }
630+ | UnpackEx { .. } | FormatValue { .. } | PopException | Reverse { .. }
631+ | GetAwaitable | BeforeAsyncWith | GetAIter | GetANext | MapAddRev { .. } => { }
632+ }
620633 }
621634 label_targets
622635 }
0 commit comments