aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/lower.rs
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-02-20 17:51:42 +0000
committerLukas Wirth <[email protected]>2021-02-20 18:08:20 +0000
commit9e5192d917e998d78fd25c4013eb8117f7401068 (patch)
tree7b086dc1856824008099a1f4533bf4987383b076 /crates/hir_ty/src/lower.rs
parentba3a5c518a4e20ddacad05d7a8a67704ca2b2a9a (diff)
Don't lower TypeBound::Lifetime as GenericPredicate::Error
Diffstat (limited to 'crates/hir_ty/src/lower.rs')
-rw-r--r--crates/hir_ty/src/lower.rs34
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
671impl GenericPredicate { 660impl 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