(from: Location, to: Location, body: &Body<'_>)
| 102 | } |
| 103 | |
| 104 | fn is_reachable(from: Location, to: Location, body: &Body<'_>) -> bool { |
| 105 | if from.block == to.block { |
| 106 | return from.statement_index <= to.statement_index; |
| 107 | } |
| 108 | let from_block = from.block; |
| 109 | let to_block = to.block; |
| 110 | let mut worklist = Vec::new(); |
| 111 | let mut visited = FxHashSet::default(); |
| 112 | worklist.push(from_block); |
| 113 | visited.insert(from_block); |
| 114 | while let Some(curr) = worklist.pop() { |
| 115 | if curr == to_block { |
| 116 | return true; |
| 117 | } |
| 118 | for succ in body.basic_blocks[curr].terminator().successors() { |
| 119 | if !visited.insert(succ) { |
| 120 | continue; |
| 121 | } |
| 122 | worklist.push(succ); |
| 123 | } |
| 124 | } |
| 125 | false |
| 126 | } |
no test coverage detected