aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/infer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/infer.rs')
-rw-r--r--crates/hir_ty/src/infer.rs34
1 files changed, 11 insertions, 23 deletions
diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs
index efe9198cc..7c6c3600b 100644
--- a/crates/hir_ty/src/infer.rs
+++ b/crates/hir_ty/src/infer.rs
@@ -42,7 +42,7 @@ use super::{
42}; 42};
43use crate::{ 43use crate::{
44 db::HirDatabase, infer::diagnostics::InferenceDiagnostic, lower::ImplTraitLoweringMode, 44 db::HirDatabase, infer::diagnostics::InferenceDiagnostic, lower::ImplTraitLoweringMode,
45 to_assoc_type_id, AliasEq, AliasTy, Interner, TyBuilder, TyExt, TyKind, 45 to_assoc_type_id, AliasEq, AliasTy, Canonical, Interner, TyBuilder, TyExt, TyKind,
46}; 46};
47 47
48// This lint has a false positive here. See the link below for details. 48// This lint has a false positive here. See the link below for details.
@@ -342,11 +342,18 @@ impl<'a> InferenceContext<'a> {
342 self.db.trait_solve(self.resolver.krate().unwrap(), canonicalized.value.clone()); 342 self.db.trait_solve(self.resolver.krate().unwrap(), canonicalized.value.clone());
343 343
344 match solution { 344 match solution {
345 Some(Solution::Unique(substs)) => { 345 Some(Solution::Unique(canonical_subst)) => {
346 canonicalized.apply_solution(self, substs.0); 346 canonicalized.apply_solution(
347 self,
348 Canonical {
349 binders: canonical_subst.binders,
350 // FIXME: handle constraints
351 value: canonical_subst.value.subst,
352 },
353 );
347 } 354 }
348 Some(Solution::Ambig(Guidance::Definite(substs))) => { 355 Some(Solution::Ambig(Guidance::Definite(substs))) => {
349 canonicalized.apply_solution(self, substs.0); 356 canonicalized.apply_solution(self, substs);
350 self.obligations.push(obligation); 357 self.obligations.push(obligation);
351 } 358 }
352 Some(_) => { 359 Some(_) => {
@@ -683,25 +690,6 @@ impl<'a> InferenceContext<'a> {
683 } 690 }
684} 691}
685 692
686/// The kinds of placeholders we need during type inference. There's separate
687/// values for general types, and for integer and float variables. The latter
688/// two are used for inference of literal values (e.g. `100` could be one of
689/// several integer types).
690#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
691pub struct InferenceVar {
692 index: u32,
693}
694
695impl InferenceVar {
696 fn to_inner(self) -> unify::TypeVarId {
697 unify::TypeVarId(self.index)
698 }
699
700 fn from_inner(unify::TypeVarId(index): unify::TypeVarId) -> Self {
701 InferenceVar { index }
702 }
703}
704
705/// When inferring an expression, we propagate downward whatever type hint we 693/// When inferring an expression, we propagate downward whatever type hint we
706/// are able in the form of an `Expectation`. 694/// are able in the form of an `Expectation`.
707#[derive(Clone, PartialEq, Eq, Debug)] 695#[derive(Clone, PartialEq, Eq, Debug)]