diff options
Diffstat (limited to 'crates/hir_ty/src/autoderef.rs')
-rw-r--r-- | crates/hir_ty/src/autoderef.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/crates/hir_ty/src/autoderef.rs b/crates/hir_ty/src/autoderef.rs index be1fd1f13..56c6b92d4 100644 --- a/crates/hir_ty/src/autoderef.rs +++ b/crates/hir_ty/src/autoderef.rs | |||
@@ -12,9 +12,10 @@ use log::{info, warn}; | |||
12 | 12 | ||
13 | use crate::{ | 13 | use crate::{ |
14 | db::HirDatabase, | 14 | db::HirDatabase, |
15 | to_assoc_type_id, | ||
15 | traits::{InEnvironment, Solution}, | 16 | traits::{InEnvironment, Solution}, |
16 | utils::generics, | 17 | utils::generics, |
17 | BoundVar, Canonical, DebruijnIndex, Obligation, Substs, TraitRef, Ty, | 18 | BoundVar, Canonical, DebruijnIndex, Interner, Obligation, Substs, TraitRef, Ty, TyKind, |
18 | }; | 19 | }; |
19 | 20 | ||
20 | const AUTODEREF_RECURSION_LIMIT: usize = 10; | 21 | const AUTODEREF_RECURSION_LIMIT: usize = 10; |
@@ -81,8 +82,12 @@ fn deref_by_trait( | |||
81 | 82 | ||
82 | // Now do the assoc type projection | 83 | // Now do the assoc type projection |
83 | let projection = super::traits::ProjectionPredicate { | 84 | let projection = super::traits::ProjectionPredicate { |
84 | ty: Ty::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, ty.value.kinds.len())), | 85 | ty: TyKind::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, ty.value.kinds.len())) |
85 | projection_ty: super::ProjectionTy { associated_ty: target, parameters }, | 86 | .intern(&Interner), |
87 | projection_ty: super::ProjectionTy { | ||
88 | associated_ty_id: to_assoc_type_id(target), | ||
89 | substitution: parameters, | ||
90 | }, | ||
86 | }; | 91 | }; |
87 | 92 | ||
88 | let obligation = super::Obligation::Projection(projection); | 93 | let obligation = super::Obligation::Projection(projection); |
@@ -114,8 +119,8 @@ fn deref_by_trait( | |||
114 | // new variables in that case | 119 | // new variables in that case |
115 | 120 | ||
116 | for i in 1..vars.0.kinds.len() { | 121 | for i in 1..vars.0.kinds.len() { |
117 | if vars.0.value[i - 1] | 122 | if vars.0.value[i - 1].interned(&Interner) |
118 | != Ty::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, i - 1)) | 123 | != &TyKind::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, i - 1)) |
119 | { | 124 | { |
120 | warn!("complex solution for derefing {:?}: {:?}, ignoring", ty.value, solution); | 125 | warn!("complex solution for derefing {:?}: {:?}, ignoring", ty.value, solution); |
121 | return None; | 126 | return None; |