@@ -234,72 +234,73 @@ impl GetterReturn {
234234 break ' returns true ;
235235 }
236236 }
237- let output = set_depth_first_search ( graph, Some ( node. cfg_id ( ) ) , |event| {
238- match event {
239- // We only need to check paths that are normal or jump.
240- DfsEvent :: TreeEdge ( a, b) => {
241- let edges = graph. edges_connecting ( a, b) . collect :: < Vec < _ > > ( ) ;
242- if edges. iter ( ) . any ( |e| {
243- matches ! (
244- e. weight( ) ,
245- EdgeType :: Normal
246- | EdgeType :: Jump
247- | EdgeType :: Error ( ErrorEdgeKind :: Explicit )
248- )
249- } ) {
250- Control :: Continue
251- } else {
252- Control :: Prune
237+ let output =
238+ set_depth_first_search ( graph, Some ( ctx. nodes ( ) . cfg_id ( node. id ( ) ) ) , |event| {
239+ match event {
240+ // We only need to check paths that are normal or jump.
241+ DfsEvent :: TreeEdge ( a, b) => {
242+ let edges = graph. edges_connecting ( a, b) . collect :: < Vec < _ > > ( ) ;
243+ if edges. iter ( ) . any ( |e| {
244+ matches ! (
245+ e. weight( ) ,
246+ EdgeType :: Normal
247+ | EdgeType :: Jump
248+ | EdgeType :: Error ( ErrorEdgeKind :: Explicit )
249+ )
250+ } ) {
251+ Control :: Continue
252+ } else {
253+ Control :: Prune
254+ }
253255 }
254- }
255- DfsEvent :: Discover ( basic_block_id, _) => {
256- let return_instruction =
257- cfg. basic_block ( basic_block_id) . instructions ( ) . iter ( ) . find ( |it| {
258- match it. kind {
259- // Throws are classified as returning.
260- InstructionKind :: Return ( _) | InstructionKind :: Throw => true ,
261-
262- // Ignore irrelevant elements.
263- InstructionKind :: ImplicitReturn
264- | InstructionKind :: Break ( _)
265- | InstructionKind :: Continue ( _)
266- | InstructionKind :: Iteration ( _)
267- | InstructionKind :: Unreachable
268- | InstructionKind :: Condition
269- | InstructionKind :: Statement => false ,
270- }
256+ DfsEvent :: Discover ( basic_block_id, _) => {
257+ let return_instruction =
258+ cfg. basic_block ( basic_block_id) . instructions ( ) . iter ( ) . find ( |it| {
259+ match it. kind {
260+ // Throws are classified as returning.
261+ InstructionKind :: Return ( _) | InstructionKind :: Throw => true ,
262+
263+ // Ignore irrelevant elements.
264+ InstructionKind :: ImplicitReturn
265+ | InstructionKind :: Break ( _)
266+ | InstructionKind :: Continue ( _)
267+ | InstructionKind :: Iteration ( _)
268+ | InstructionKind :: Unreachable
269+ | InstructionKind :: Condition
270+ | InstructionKind :: Statement => false ,
271+ }
272+ } ) ;
273+
274+ let does_return = return_instruction. is_some_and ( |ret| {
275+ !matches ! ( ret. kind,
276+ InstructionKind :: Return ( ReturnInstructionKind :: ImplicitUndefined )
277+ if !self . allow_implicit
278+ )
271279 } ) ;
272280
273- let does_return = return_instruction. is_some_and ( |ret| {
274- !matches ! ( ret. kind,
275- InstructionKind :: Return ( ReturnInstructionKind :: ImplicitUndefined )
276- if !self . allow_implicit
277- )
278- } ) ;
279-
280- // Return true as the second argument to signify we should
281- // continue walking this branch, as we haven't seen anything
282- // that will signify to us that this path of the program will
283- // definitely return or throw.
284- if graph. edges_directed ( basic_block_id, Direction :: Outgoing ) . any ( |e| {
285- matches ! (
286- e. weight( ) ,
287- EdgeType :: Jump
288- | EdgeType :: Normal
289- | EdgeType :: Backedge
290- | EdgeType :: Error ( ErrorEdgeKind :: Explicit )
291- )
292- } ) {
293- Control :: Continue
294- } else if does_return {
295- Control :: Prune
296- } else {
297- Control :: Break ( ( ) )
281+ // Return true as the second argument to signify we should
282+ // continue walking this branch, as we haven't seen anything
283+ // that will signify to us that this path of the program will
284+ // definitely return or throw.
285+ if graph. edges_directed ( basic_block_id, Direction :: Outgoing ) . any ( |e| {
286+ matches ! (
287+ e. weight( ) ,
288+ EdgeType :: Jump
289+ | EdgeType :: Normal
290+ | EdgeType :: Backedge
291+ | EdgeType :: Error ( ErrorEdgeKind :: Explicit )
292+ )
293+ } ) {
294+ Control :: Continue
295+ } else if does_return {
296+ Control :: Prune
297+ } else {
298+ Control :: Break ( ( ) )
299+ }
298300 }
301+ _ => Control :: Continue ,
299302 }
300- _ => Control :: Continue ,
301- }
302- } ) ;
303+ } ) ;
303304
304305 output. break_value ( ) . is_none ( )
305306 } ;
0 commit comments