@@ -997,33 +997,38 @@ pub fn resolve_indexing_op(
997
997
struct Valid ;
998
998
impl Valid {
999
999
fn valid_impl (
1000
- impls : impl Iterator < Item = ImplId > ,
1000
+ mut impls : impl Iterator < Item = ImplId > ,
1001
1001
table : & mut InferenceTable ,
1002
1002
self_ty : & Ty ,
1003
1003
) -> Option < Arc < ImplData > > {
1004
1004
let db = table. db ;
1005
- for impl_ in impls {
1006
- let impl_data = db. impl_data ( impl_) ;
1007
- let substs =
1008
- TyBuilder :: subst_for_def ( db, impl_) . fill_with_inference_vars ( table) . build ( ) ;
1009
- let impl_ty =
1010
- substs. apply ( db. impl_self_ty ( impl_) . into_value_and_skipped_binders ( ) . 0 , Interner ) ;
1011
-
1012
- if !table. unify ( self_ty, & impl_ty) {
1013
- continue ;
1014
- }
1015
-
1016
- let wh_goals = crate :: chalk_db:: convert_where_clauses ( db, impl_. into ( ) , & substs)
1017
- . into_iter ( )
1018
- . map ( |b| b. into_well_formed_goal ( Interner ) . cast ( Interner ) ) ;
1019
-
1020
- let goal = crate :: Goal :: all ( Interner , wh_goals) ;
1021
-
1022
- if table. try_obligation ( goal) . is_some ( ) {
1023
- return Some ( impl_data) ;
1005
+ loop {
1006
+ let impl_ = impls. next ( ) ?;
1007
+ let r = table. run_in_snapshot ( |table| {
1008
+ let impl_data = db. impl_data ( impl_) ;
1009
+ let substs =
1010
+ TyBuilder :: subst_for_def ( db, impl_) . fill_with_inference_vars ( table) . build ( ) ;
1011
+ let impl_ty = substs
1012
+ . apply ( db. impl_self_ty ( impl_) . into_value_and_skipped_binders ( ) . 0 , Interner ) ;
1013
+
1014
+ table
1015
+ . unify ( self_ty, & impl_ty)
1016
+ . then ( || {
1017
+ let wh_goals =
1018
+ crate :: chalk_db:: convert_where_clauses ( db, impl_. into ( ) , & substs)
1019
+ . into_iter ( )
1020
+ . map ( |b| b. into_well_formed_goal ( Interner ) . cast ( Interner ) ) ;
1021
+
1022
+ let goal = crate :: Goal :: all ( Interner , wh_goals) ;
1023
+
1024
+ table. try_obligation ( goal) . map ( |_| impl_data)
1025
+ } )
1026
+ . flatten ( )
1027
+ } ) ;
1028
+ if r. is_some ( ) {
1029
+ break r;
1024
1030
}
1025
1031
}
1026
- None
1027
1032
}
1028
1033
1029
1034
fn is_valid_item (
0 commit comments