@@ -189,7 +189,10 @@ impl<'a> TyLoweringContext<'a> {
189
189
let self_ty =
190
190
TyKind :: BoundVar ( BoundVar :: new ( DebruijnIndex :: INNERMOST , 0 ) ) . intern ( & Interner ) ;
191
191
let predicates = self . with_shifted_in ( DebruijnIndex :: ONE , |ctx| {
192
- bounds. iter ( ) . flat_map ( |b| ctx. lower_type_bound ( b, self_ty. clone ( ) ) ) . collect ( )
192
+ bounds
193
+ . iter ( )
194
+ . flat_map ( |b| ctx. lower_type_bound ( b, self_ty. clone ( ) , false ) )
195
+ . collect ( )
193
196
} ) ;
194
197
TyKind :: Dyn ( predicates) . intern ( & Interner )
195
198
}
@@ -666,6 +669,7 @@ impl<'a> TyLoweringContext<'a> {
666
669
pub ( crate ) fn lower_where_predicate (
667
670
& ' a self ,
668
671
where_predicate : & ' a WherePredicate ,
672
+ ignore_bindings : bool ,
669
673
) -> impl Iterator < Item = WhereClause > + ' a {
670
674
match where_predicate {
671
675
WherePredicate :: ForLifetime { target, bound, .. }
@@ -688,7 +692,9 @@ impl<'a> TyLoweringContext<'a> {
688
692
. intern ( & Interner )
689
693
}
690
694
} ;
691
- self . lower_type_bound ( bound, self_ty) . collect :: < Vec < _ > > ( ) . into_iter ( )
695
+ self . lower_type_bound ( bound, self_ty, ignore_bindings)
696
+ . collect :: < Vec < _ > > ( )
697
+ . into_iter ( )
692
698
}
693
699
WherePredicate :: Lifetime { .. } => vec ! [ ] . into_iter ( ) ,
694
700
}
@@ -698,6 +704,7 @@ impl<'a> TyLoweringContext<'a> {
698
704
& ' a self ,
699
705
bound : & ' a TypeBound ,
700
706
self_ty : Ty ,
707
+ ignore_bindings : bool ,
701
708
) -> impl Iterator < Item = WhereClause > + ' a {
702
709
let mut bindings = None ;
703
710
let trait_ref = match bound {
@@ -711,6 +718,7 @@ impl<'a> TyLoweringContext<'a> {
711
718
trait_ref. into_iter ( ) . chain (
712
719
bindings
713
720
. into_iter ( )
721
+ . filter ( move |_| !ignore_bindings)
714
722
. flat_map ( move |tr| self . assoc_type_bindings_from_type_bound ( bound, tr) ) ,
715
723
)
716
724
}
@@ -755,6 +763,7 @@ impl<'a> TyLoweringContext<'a> {
755
763
preds. extend ( self . lower_type_bound (
756
764
bound,
757
765
TyKind :: Alias ( AliasTy :: Projection ( projection_ty. clone ( ) ) ) . intern ( & Interner ) ,
766
+ false ,
758
767
) ) ;
759
768
}
760
769
preds
@@ -766,7 +775,7 @@ impl<'a> TyLoweringContext<'a> {
766
775
let self_ty =
767
776
TyKind :: BoundVar ( BoundVar :: new ( DebruijnIndex :: INNERMOST , 0 ) ) . intern ( & Interner ) ;
768
777
let predicates = self . with_shifted_in ( DebruijnIndex :: ONE , |ctx| {
769
- bounds. iter ( ) . flat_map ( |b| ctx. lower_type_bound ( b, self_ty. clone ( ) ) ) . collect ( )
778
+ bounds. iter ( ) . flat_map ( |b| ctx. lower_type_bound ( b, self_ty. clone ( ) , false ) ) . collect ( )
770
779
} ) ;
771
780
ReturnTypeImplTrait { bounds : Binders :: new ( 1 , predicates) }
772
781
}
@@ -896,7 +905,9 @@ pub(crate) fn generic_predicates_for_param_query(
896
905
} ,
897
906
WherePredicate :: Lifetime { .. } => false ,
898
907
} )
899
- . flat_map ( |pred| ctx. lower_where_predicate ( pred) . map ( |p| Binders :: new ( generics. len ( ) , p) ) )
908
+ . flat_map ( |pred| {
909
+ ctx. lower_where_predicate ( pred, true ) . map ( |p| Binders :: new ( generics. len ( ) , p) )
910
+ } )
900
911
. collect ( )
901
912
}
902
913
@@ -918,7 +929,7 @@ pub(crate) fn trait_environment_query(
918
929
let mut traits_in_scope = Vec :: new ( ) ;
919
930
let mut clauses = Vec :: new ( ) ;
920
931
for pred in resolver. where_predicates_in_scope ( ) {
921
- for pred in ctx. lower_where_predicate ( pred) {
932
+ for pred in ctx. lower_where_predicate ( pred, false ) {
922
933
if let WhereClause :: Implemented ( tr) = & pred {
923
934
traits_in_scope. push ( ( tr. self_type_parameter ( ) . clone ( ) , tr. hir_trait_id ( ) ) ) ;
924
935
}
@@ -967,7 +978,9 @@ pub(crate) fn generic_predicates_query(
967
978
let generics = generics ( db. upcast ( ) , def) ;
968
979
resolver
969
980
. where_predicates_in_scope ( )
970
- . flat_map ( |pred| ctx. lower_where_predicate ( pred) . map ( |p| Binders :: new ( generics. len ( ) , p) ) )
981
+ . flat_map ( |pred| {
982
+ ctx. lower_where_predicate ( pred, false ) . map ( |p| Binders :: new ( generics. len ( ) , p) )
983
+ } )
971
984
. collect ( )
972
985
}
973
986
0 commit comments