diff options
| author | lcnr <rust@lcnr.de> | 2025-07-30 14:30:57 +0200 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2025-07-30 14:30:57 +0200 |
| commit | 2b065e7c0b453cc6de5e89bbab47df3bc4212940 (patch) | |
| tree | 9d291193825631403a4fb8c3e1aafb5b64ae6991 /compiler | |
| parent | df2e54376c4cf9009ba159a50a404e1483f52f67 (diff) | |
| download | rust-2b065e7c0b453cc6de5e89bbab47df3bc4212940.tar.gz rust-2b065e7c0b453cc6de5e89bbab47df3bc4212940.zip | |
extend comment
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_next_trait_solver/src/solve/mod.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_next_trait_solver/src/solve/mod.rs b/compiler/rustc_next_trait_solver/src/solve/mod.rs index 9d52dee3c65..aec9594b834 100644 --- a/compiler/rustc_next_trait_solver/src/solve/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/mod.rs @@ -389,6 +389,19 @@ pub struct GoalEvaluation<I: Interner> { /// The goal we've evaluated. This is the input goal, but potentially with its /// inference variables resolved. This never applies any inference constraints /// from evaluating the goal. + /// + /// We rely on this to check whether root goals in HIR typeck had an unresolved + /// type inference variable in the input. We must not resolve this after evaluating + /// the goal as even if the inference variable has been resolved by evaluating the + /// goal itself, this goal may still end up failing due to region uniquification + /// later on. + /// + /// This is used as a minor optimization to avoid re-resolving inference variables + /// when reevaluating ambiguous goals. E.g. if we've got a goal `?x: Trait` with `?x` + /// already being constrained to `Vec<?y>`, then the first evaluation resolves it to + /// `Vec<?y>: Trait`. If this goal is still ambiguous and we later resolve `?y` to `u32`, + /// then reevaluating this goal now only needs to resolve `?y` while it would otherwise + /// have to resolve both `?x` and `?y`, pub goal: Goal<I, I::Predicate>, pub certainty: Certainty, pub has_changed: HasChanged, |
