diff options
Diffstat (limited to 'crates/hir_ty/src/lower.rs')
-rw-r--r-- | crates/hir_ty/src/lower.rs | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index f9dc832bd..99b0ecf3b 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs | |||
@@ -655,17 +655,6 @@ impl TraitRef { | |||
655 | ) -> Substs { | 655 | ) -> Substs { |
656 | substs_from_path_segment(ctx, segment, Some(resolved.into()), false) | 656 | substs_from_path_segment(ctx, segment, Some(resolved.into()), false) |
657 | } | 657 | } |
658 | |||
659 | pub(crate) fn from_type_bound( | ||
660 | ctx: &TyLoweringContext<'_>, | ||
661 | bound: &TypeBound, | ||
662 | self_ty: Ty, | ||
663 | ) -> Option<TraitRef> { | ||
664 | match bound { | ||
665 | TypeBound::Path(path) => TraitRef::from_path(ctx, path, Some(self_ty)), | ||
666 | TypeBound::Lifetime(_) | TypeBound::Error => None, | ||
667 | } | ||
668 | } | ||
669 | } | 658 | } |
670 | 659 | ||
671 | impl GenericPredicate { | 660 | impl GenericPredicate { |
@@ -705,13 +694,22 @@ impl GenericPredicate { | |||
705 | bound: &'a TypeBound, | 694 | bound: &'a TypeBound, |
706 | self_ty: Ty, | 695 | self_ty: Ty, |
707 | ) -> impl Iterator<Item = GenericPredicate> + 'a { | 696 | ) -> impl Iterator<Item = GenericPredicate> + 'a { |
708 | let trait_ref = TraitRef::from_type_bound(ctx, bound, self_ty); | 697 | let mut bindings = None; |
709 | iter::once(trait_ref.clone().map_or(GenericPredicate::Error, GenericPredicate::Implemented)) | 698 | let trait_ref = match bound { |
710 | .chain( | 699 | TypeBound::Path(path) => { |
711 | trait_ref | 700 | bindings = TraitRef::from_path(ctx, path, Some(self_ty)); |
712 | .into_iter() | 701 | Some( |
713 | .flat_map(move |tr| assoc_type_bindings_from_type_bound(ctx, bound, tr)), | 702 | bindings.clone().map_or(GenericPredicate::Error, GenericPredicate::Implemented), |
714 | ) | 703 | ) |
704 | } | ||
705 | TypeBound::Lifetime(_) => None, | ||
706 | TypeBound::Error => Some(GenericPredicate::Error), | ||
707 | }; | ||
708 | trait_ref.into_iter().chain( | ||
709 | bindings | ||
710 | .into_iter() | ||
711 | .flat_map(move |tr| assoc_type_bindings_from_type_bound(ctx, bound, tr)), | ||
712 | ) | ||
715 | } | 713 | } |
716 | } | 714 | } |
717 | 715 | ||