Skip to content

Commit b1ba2cd

Browse files
authored
Rollup merge of #142573 - lcnr:search_graph-3, r=lqd
`fn candidate_is_applicable` to method r? `@BoxyUwU`
2 parents a53c1d7 + 7fb9284 commit b1ba2cd

File tree

1 file changed

+6
-17
lines changed
  • compiler/rustc_type_ir/src/search_graph

1 file changed

+6
-17
lines changed

compiler/rustc_type_ir/src/search_graph/mod.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -842,9 +842,8 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
842842
/// evaluating this entry would not have ended up depending on either a goal
843843
/// already on the stack or a provisional cache entry.
844844
fn candidate_is_applicable(
845-
stack: &Stack<X>,
845+
&self,
846846
step_kind_from_parent: PathKind,
847-
provisional_cache: &HashMap<X::Input, Vec<ProvisionalCacheEntry<X>>>,
848847
nested_goals: &NestedGoals<X>,
849848
) -> bool {
850849
// If the global cache entry didn't depend on any nested goals, it always
@@ -855,7 +854,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
855854

856855
// If a nested goal of the global cache entry is on the stack, we would
857856
// definitely encounter a cycle.
858-
if stack.iter().any(|e| nested_goals.contains(e.input)) {
857+
if self.stack.iter().any(|e| nested_goals.contains(e.input)) {
859858
debug!("cache entry not applicable due to stack");
860859
return false;
861860
}
@@ -864,7 +863,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
864863
// would apply for any of its nested goals.
865864
#[allow(rustc::potential_query_instability)]
866865
for (input, path_from_global_entry) in nested_goals.iter() {
867-
let Some(entries) = provisional_cache.get(&input) else {
866+
let Some(entries) = self.provisional_cache.get(&input) else {
868867
continue;
869868
};
870869

@@ -890,7 +889,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
890889
// We check if any of the paths taken while computing the global goal
891890
// would end up with an applicable provisional cache entry.
892891
let head = heads.highest_cycle_head();
893-
let head_to_curr = Self::cycle_path_kind(stack, step_kind_from_parent, head);
892+
let head_to_curr = Self::cycle_path_kind(&self.stack, step_kind_from_parent, head);
894893
let full_paths = path_from_global_entry.extend_with(head_to_curr);
895894
if full_paths.contains(head_to_provisional.into()) {
896895
debug!(
@@ -918,12 +917,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
918917
cx.with_global_cache(|cache| {
919918
cache
920919
.get(cx, input, available_depth, |nested_goals| {
921-
Self::candidate_is_applicable(
922-
&self.stack,
923-
step_kind_from_parent,
924-
&self.provisional_cache,
925-
nested_goals,
926-
)
920+
self.candidate_is_applicable(step_kind_from_parent, nested_goals)
927921
})
928922
.map(|c| c.result)
929923
})
@@ -942,12 +936,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
942936
cx.with_global_cache(|cache| {
943937
let CacheData { result, required_depth, encountered_overflow, nested_goals } = cache
944938
.get(cx, input, available_depth, |nested_goals| {
945-
Self::candidate_is_applicable(
946-
&self.stack,
947-
step_kind_from_parent,
948-
&self.provisional_cache,
949-
nested_goals,
950-
)
939+
self.candidate_is_applicable(step_kind_from_parent, nested_goals)
951940
})?;
952941

953942
// We don't move cycle participants to the global cache, so the

0 commit comments

Comments
 (0)