about summary refs log tree commit diff
diff options
context:
space:
mode:
authorlcnr <rust@lcnr.de>2025-08-14 16:02:47 +0200
committerlcnr <rust@lcnr.de>2025-08-14 16:07:24 +0200
commit8afe306c381416d151f955981e7b4e47867e9d97 (patch)
tree1f63cc140ecaf42ed62cd79b5d840a934ad935ed
parentaa3691ea0857e0a26a372be3a84f239e775c24aa (diff)
downloadrust-8afe306c381416d151f955981e7b4e47867e9d97.tar.gz
rust-8afe306c381416d151f955981e7b4e47867e9d97.zip
update comment
-rw-r--r--compiler/rustc_next_trait_solver/src/solve/trait_goals.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs
index 03f7bc1f49e..04ede365a21 100644
--- a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs
@@ -1384,6 +1384,18 @@ where
                     // If there's an always applicable candidate, the result of all
                     // other candidates does not matter. This means we can ignore
                     // them when checking whether we've reached a fixpoint.
+                    //
+                    // We always prefer the first always applicable candidate, even if a
+                    // later candidate is also always applicable and would result in fewer
+                    // reruns. We could slightly improve this by e.g. searching for another
+                    // always applicable candidate which doesn't depend on any cycle heads.
+                    //
+                    // NOTE: This is optimization is observable in case there is an always
+                    // applicable global candidate and another non-global candidate which only
+                    // applies because of a provisional result. I can't even think of a test
+                    // case where this would occur and even then, this would not be unsound.
+                    // Supporting this makes the code more involved, so I am just going to
+                    // ignore this for now.
                     MergeCandidateInfo::AlwaysApplicable(i) => {
                         for (j, c) in where_bounds.into_iter().enumerate() {
                             if i != j {