diff options
| author | lcnr <rust@lcnr.de> | 2025-08-14 16:02:47 +0200 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2025-08-14 16:07:24 +0200 |
| commit | 8afe306c381416d151f955981e7b4e47867e9d97 (patch) | |
| tree | 1f63cc140ecaf42ed62cd79b5d840a934ad935ed | |
| parent | aa3691ea0857e0a26a372be3a84f239e775c24aa (diff) | |
| download | rust-8afe306c381416d151f955981e7b4e47867e9d97.tar.gz rust-8afe306c381416d151f955981e7b4e47867e9d97.zip | |
update comment
| -rw-r--r-- | compiler/rustc_next_trait_solver/src/solve/trait_goals.rs | 12 |
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 { |
