diff options
author | David Wood <david@davidtw.co> | 2018-05-29 19:38:04 +0100 |
---|---|---|
committer | David Wood <david@davidtw.co> | 2018-05-29 19:38:04 +0100 |
commit | 62b1e6532adce4847153f6b6ac197d5906d389d0 (patch) | |
tree | 987c1372ec1b139e52698f2e1b3fce849214b8cc | |
parent | add some debugging statements (diff) | |
download | grust-62b1e6532adce4847153f6b6ac197d5906d389d0.tar.gz grust-62b1e6532adce4847153f6b6ac197d5906d389d0.tar.bz2 grust-62b1e6532adce4847153f6b6ac197d5906d389d0.tar.xz |
Ensure that all statements in block are visited not just successors of a block.
-rw-r--r-- | src/librustc_mir/dataflow/impls/borrows.rs | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/librustc_mir/dataflow/impls/borrows.rs b/src/librustc_mir/dataflow/impls/borrows.rs index bd16e3ac5f..b8949e0ad0 100644 --- a/src/librustc_mir/dataflow/impls/borrows.rs +++ b/src/librustc_mir/dataflow/impls/borrows.rs | |||
@@ -66,8 +66,8 @@ fn precompute_borrows_out_of_scope<'a, 'tcx>( | |||
66 | let mut visited = FxHashSet(); | 66 | let mut visited = FxHashSet(); |
67 | visited.insert(location); | 67 | visited.insert(location); |
68 | 68 | ||
69 | debug!("borrow {:?} starts at {:?}", borrow_index, location); | 69 | debug!("borrow {:?} (region: {:?}) starts at {:?}", |
70 | 70 | borrow_index, borrow_region, location); | |
71 | while let Some(location) = stack.pop() { | 71 | while let Some(location) = stack.pop() { |
72 | // If region does not contain a point at the location, then add to list and skip | 72 | // If region does not contain a point at the location, then add to list and skip |
73 | // successor locations. | 73 | // successor locations. |
@@ -80,15 +80,25 @@ fn precompute_borrows_out_of_scope<'a, 'tcx>( | |||
80 | continue; | 80 | continue; |
81 | } | 81 | } |
82 | 82 | ||
83 | // Add successors to locations to visit, if not visited before. | ||
84 | let bb_data = &mir[location.block]; | 83 | let bb_data = &mir[location.block]; |
85 | if let Some(ref terminator) = bb_data.terminator { | 84 | // If this is the last statement in the block, then add the |
86 | for block in terminator.successors() { | 85 | // terminator successors next. |
87 | let loc = block.start_location(); | 86 | if location.statement_index == bb_data.statements.len() - 1 { |
88 | if visited.insert(loc) { | 87 | // Add successors to locations to visit, if not visited before. |
89 | stack.push(loc); | 88 | if let Some(ref terminator) = bb_data.terminator { |
89 | for block in terminator.successors() { | ||
90 | let loc = block.start_location(); | ||
91 | if visited.insert(loc) { | ||
92 | stack.push(loc); | ||
93 | } | ||
90 | } | 94 | } |
91 | } | 95 | } |
96 | } else { | ||
97 | // Visit next statement in block. | ||
98 | let loc = location.successor_within_block(); | ||
99 | if visited.insert(loc) { | ||
100 | stack.push(loc); | ||
101 | } | ||
92 | } | 102 | } |
93 | } | 103 | } |
94 | } | 104 | } |