diff options
| author | David Wood <david@davidtw.co> | 2018-06-29 22:17:35 +0100 |
|---|---|---|
| committer | David Wood <david@davidtw.co> | 2018-07-01 16:14:26 +0100 |
| commit | 15aad8356083e6098f7e8aefa1293b68201ec43c (patch) | |
| tree | e4978d38e33cae4db23fdd5239c39f83753e8e43 | |
| parent | f334a9e8dd3438fb2f827b8f3932b18ae50e76ce (diff) | |
| download | rust-15aad8356083e6098f7e8aefa1293b68201ec43c.tar.gz rust-15aad8356083e6098f7e8aefa1293b68201ec43c.zip | |
Fix infinite loops when regions are self-referential.
| -rw-r--r-- | src/librustc_mir/borrow_check/nll/region_infer/error_reporting.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting.rs index f3372f6be70..970652d8872 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting.rs @@ -63,12 +63,15 @@ impl<'tcx> RegionInferenceContext<'tcx> { // Regions that have been visited. let mut visited = FxHashSet(); // Ends of paths. - let mut end_regions: Vec<RegionVid> = Vec::new(); + let mut end_regions = FxHashSet(); // When we've still got points to visit... while let Some(current) = next.pop() { // ...take the next point... - debug!("find_constraint_paths_from_region: current={:?} next={:?}", current, next); + debug!("find_constraint_paths_from_region: current={:?} visited={:?} next={:?}", + current, visited, next); + // ...but make sure not to visit this point again... + visited.insert(current); // ...find the edges containing it... let mut upcoming = Vec::new(); @@ -93,16 +96,13 @@ impl<'tcx> RegionInferenceContext<'tcx> { if upcoming.is_empty() { // If we didn't find any edges then this is the end of a path... debug!("find_constraint_paths_from_region: new end region current={:?}", current); - end_regions.push(current); + end_regions.insert(current); } else { - // ...but, if we did find edges, then add these to the regions yet to visit... + // ...but, if we did find edges, then add these to the regions yet to visit. debug!("find_constraint_paths_from_region: extend next upcoming={:?}", upcoming); next.extend(upcoming); } - // ...and don't visit it again. - visited.insert(current.clone()); - debug!("find_constraint_paths_from_region: next={:?} visited={:?}", next, visited); } // Now we've visited each point, compute the final paths. |
