diff options
| author | ljedrz <ljedrz@gmail.com> | 2018-12-19 13:14:03 +0100 |
|---|---|---|
| committer | ljedrz <ljedrz@gmail.com> | 2018-12-19 15:15:04 +0100 |
| commit | d7ca0758812daa1e796a6f58a1fb3fe98cf88fa6 (patch) | |
| tree | bc0bd767012fc3b268c11e779fe5673b05d44920 /src | |
| parent | 3294a69abb1749bba8769df867f65cd37a93a30c (diff) | |
| download | rust-d7ca0758812daa1e796a6f58a1fb3fe98cf88fa6.tar.gz rust-d7ca0758812daa1e796a6f58a1fb3fe98cf88fa6.zip | |
query: insert visited queries more eagerly
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/ty/query/job.rs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/librustc/ty/query/job.rs b/src/librustc/ty/query/job.rs index 2e6cd8e0ec3..559093b8f18 100644 --- a/src/librustc/ty/query/job.rs +++ b/src/librustc/ty/query/job.rs @@ -290,7 +290,7 @@ fn cycle_check<'tcx>(query: Lrc<QueryJob<'tcx>>, stack: &mut Vec<(Span, Lrc<QueryJob<'tcx>>)>, visited: &mut FxHashSet<*const QueryJob<'tcx>> ) -> Option<Option<Waiter<'tcx>>> { - if visited.contains(&query.as_ptr()) { + if !visited.insert(query.as_ptr()) { return if let Some(p) = stack.iter().position(|q| q.1.as_ptr() == query.as_ptr()) { // We detected a query cycle, fix up the initial span and return Some @@ -304,8 +304,7 @@ fn cycle_check<'tcx>(query: Lrc<QueryJob<'tcx>>, } } - // Mark this query is visited and add it to the stack - visited.insert(query.as_ptr()); + // Query marked as visited is added it to the stack stack.push((span, query.clone())); // Visit all the waiters @@ -330,7 +329,7 @@ fn connected_to_root<'tcx>( visited: &mut FxHashSet<*const QueryJob<'tcx>> ) -> bool { // We already visited this or we're deliberately ignoring it - if visited.contains(&query.as_ptr()) { + if !visited.insert(query.as_ptr()) { return false; } @@ -339,8 +338,6 @@ fn connected_to_root<'tcx>( return true; } - visited.insert(query.as_ptr()); - visit_waiters(query, |_, successor| { if connected_to_root(successor, visited) { Some(None) |
