aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/infer/expr.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/infer/expr.rs')
-rw-r--r--crates/hir_ty/src/infer/expr.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs
index 6966d26e7..185a2dfc3 100644
--- a/crates/hir_ty/src/infer/expr.rs
+++ b/crates/hir_ty/src/infer/expr.rs
@@ -22,8 +22,8 @@ use crate::{
22 to_chalk_trait_id, 22 to_chalk_trait_id,
23 traits::{chalk::from_chalk, FnTrait}, 23 traits::{chalk::from_chalk, FnTrait},
24 utils::{generics, variant_data, Generics}, 24 utils::{generics, variant_data, Generics},
25 AdtId, Binders, CallableDefId, FnPointer, FnSig, InEnvironment, Interner, Rawness, Scalar, 25 AdtId, Binders, CallableDefId, FnPointer, FnSig, InEnvironment, Interner, ProjectionTyExt,
26 Substitution, TraitRef, Ty, TyBuilder, TyKind, 26 Rawness, Scalar, Substitution, TraitRef, Ty, TyBuilder, TyKind,
27}; 27};
28 28
29use super::{ 29use super::{
@@ -180,7 +180,8 @@ impl<'a> InferenceContext<'a> {
180 let inner_ty = self.infer_expr(*body, &Expectation::none()); 180 let inner_ty = self.infer_expr(*body, &Expectation::none());
181 let impl_trait_id = crate::ImplTraitId::AsyncBlockTypeImplTrait(self.owner, *body); 181 let impl_trait_id = crate::ImplTraitId::AsyncBlockTypeImplTrait(self.owner, *body);
182 let opaque_ty_id = self.db.intern_impl_trait_id(impl_trait_id).into(); 182 let opaque_ty_id = self.db.intern_impl_trait_id(impl_trait_id).into();
183 TyKind::OpaqueType(opaque_ty_id, Substitution::single(inner_ty)).intern(&Interner) 183 TyKind::OpaqueType(opaque_ty_id, Substitution::from1(&Interner, inner_ty))
184 .intern(&Interner)
184 } 185 }
185 Expr::Loop { body, label } => { 186 Expr::Loop { body, label } => {
186 self.breakables.push(BreakableContext { 187 self.breakables.push(BreakableContext {
@@ -266,7 +267,8 @@ impl<'a> InferenceContext<'a> {
266 .intern(&Interner); 267 .intern(&Interner);
267 let closure_id = self.db.intern_closure((self.owner, tgt_expr)).into(); 268 let closure_id = self.db.intern_closure((self.owner, tgt_expr)).into();
268 let closure_ty = 269 let closure_ty =
269 TyKind::Closure(closure_id, Substitution::single(sig_ty)).intern(&Interner); 270 TyKind::Closure(closure_id, Substitution::from1(&Interner, sig_ty))
271 .intern(&Interner);
270 272
271 // Eagerly try to relate the closure type with the expected 273 // Eagerly try to relate the closure type with the expected
272 // type, otherwise we often won't have enough information to 274 // type, otherwise we often won't have enough information to
@@ -962,8 +964,10 @@ impl<'a> InferenceContext<'a> {
962 if let AssocContainerId::TraitId(trait_) = f.lookup(self.db.upcast()).container 964 if let AssocContainerId::TraitId(trait_) = f.lookup(self.db.upcast()).container
963 { 965 {
964 // construct a TraitRef 966 // construct a TraitRef
965 let substs = 967 let substs = crate::subst_prefix(
966 parameters.prefix(generics(self.db.upcast(), trait_.into()).len()); 968 &*parameters,
969 generics(self.db.upcast(), trait_.into()).len(),
970 );
967 self.push_obligation( 971 self.push_obligation(
968 TraitRef { trait_id: to_chalk_trait_id(trait_), substitution: substs } 972 TraitRef { trait_id: to_chalk_trait_id(trait_), substitution: substs }
969 .cast(&Interner), 973 .cast(&Interner),