authorJakub Beránek <berykubik@gmail.com> 2025-06-16 17:54:37 UTC
committerGitHub <noreply@github.com> 2025-06-16 17:54:37 UTC
logb1ba2cdf41da538fa2195ff439cc6b82723b9474
treee876174d258caa3d3ab3233f3e6a0697b9601157
parenta53c1d7c991be1ce9046af21d9f7426c585a7e9b
parent7fb9284fb3e54db29919c3f2f8bd4212ac6b090d

Rollup merge of #142573 - lcnr:search_graph-3, r=lqd

`fn candidate_is_applicable` to method r? `@BoxyUwU`

1 files changed, 6 insertions(+), 17 deletions(-)

compiler/rustc_type_ir/src/search_graph/mod.rs+6-17
......@@ -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