diff options
Diffstat (limited to 'crates/ra_hir_ty/src/infer.rs')
-rw-r--r-- | crates/ra_hir_ty/src/infer.rs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs index 98ba05fc2..bbbc391c4 100644 --- a/crates/ra_hir_ty/src/infer.rs +++ b/crates/ra_hir_ty/src/infer.rs | |||
@@ -363,14 +363,26 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
363 | } | 363 | } |
364 | 364 | ||
365 | fn resolve_associated_type(&mut self, inner_ty: Ty, assoc_ty: Option<TypeAliasId>) -> Ty { | 365 | fn resolve_associated_type(&mut self, inner_ty: Ty, assoc_ty: Option<TypeAliasId>) -> Ty { |
366 | self.resolve_associated_type_with_params(inner_ty, assoc_ty, &[]) | ||
367 | } | ||
368 | |||
369 | fn resolve_associated_type_with_params( | ||
370 | &mut self, | ||
371 | inner_ty: Ty, | ||
372 | assoc_ty: Option<TypeAliasId>, | ||
373 | params: &[Ty], | ||
374 | ) -> Ty { | ||
366 | match assoc_ty { | 375 | match assoc_ty { |
367 | Some(res_assoc_ty) => { | 376 | Some(res_assoc_ty) => { |
368 | let ty = self.table.new_type_var(); | 377 | let ty = self.table.new_type_var(); |
378 | let builder = Substs::build_for_def(self.db, res_assoc_ty) | ||
379 | .push(inner_ty) | ||
380 | .fill(params.iter().cloned()); | ||
369 | let projection = ProjectionPredicate { | 381 | let projection = ProjectionPredicate { |
370 | ty: ty.clone(), | 382 | ty: ty.clone(), |
371 | projection_ty: ProjectionTy { | 383 | projection_ty: ProjectionTy { |
372 | associated_ty: res_assoc_ty, | 384 | associated_ty: res_assoc_ty, |
373 | parameters: Substs::single(inner_ty), | 385 | parameters: builder.build(), |
374 | }, | 386 | }, |
375 | }; | 387 | }; |
376 | self.obligations.push(Obligation::Projection(projection)); | 388 | self.obligations.push(Obligation::Projection(projection)); |
@@ -517,6 +529,12 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
517 | let struct_ = self.resolver.resolve_known_struct(self.db, &path)?; | 529 | let struct_ = self.resolver.resolve_known_struct(self.db, &path)?; |
518 | Some(struct_.into()) | 530 | Some(struct_.into()) |
519 | } | 531 | } |
532 | |||
533 | fn resolve_ops_index_output(&self) -> Option<TypeAliasId> { | ||
534 | let path = path![std::ops::Index]; | ||
535 | let trait_ = self.resolver.resolve_known_trait(self.db, &path)?; | ||
536 | self.db.trait_data(trait_).associated_type_by_name(&name![Output]) | ||
537 | } | ||
520 | } | 538 | } |
521 | 539 | ||
522 | /// The kinds of placeholders we need during type inference. There's separate | 540 | /// The kinds of placeholders we need during type inference. There's separate |