@@ -29,7 +29,7 @@ use rustc_index::bit_set::DenseBitSet;
2929use rustc_type_ir:: {
3030 AliasTy , BoundVar , CoroutineWitnessTypes , DebruijnIndex , EarlyBinder , FlagComputation , Flags ,
3131 FnSigKind , GenericArgKind , GenericTypeVisitable , ImplPolarity , InferTy , Interner , TraitRef ,
32- TypeFlags , TypeVisitableExt , Upcast , Variance ,
32+ TypeFlags , TypeVisitableExt , Upcast , Variance , VisitorResult ,
3333 elaborate:: elaborate,
3434 error:: TypeError ,
3535 fast_reject,
@@ -54,6 +54,7 @@ use crate::{
5454 TraitAssocTyId , TraitIdWrapper , TypeAliasIdWrapper , UnevaluatedConst , Unnormalized ,
5555 util:: { explicit_item_bounds, explicit_item_self_bounds} ,
5656 } ,
57+ ret,
5758} ;
5859
5960use super :: {
@@ -1601,12 +1602,12 @@ impl<'db> Interner for DbInterner<'db> {
16011602 def_id. 0 . trait_items ( self . db ( ) ) . associated_types ( ) . map ( |id| id. into ( ) )
16021603 }
16031604
1604- fn for_each_relevant_impl (
1605+ fn for_each_relevant_impl < R : VisitorResult > (
16051606 self ,
16061607 trait_def_id : Self :: TraitId ,
16071608 self_ty : Self :: Ty ,
1608- mut f : impl FnMut ( Self :: ImplId ) ,
1609- ) {
1609+ mut f : impl FnMut ( Self :: ImplId ) -> R ,
1610+ ) -> R {
16101611 let krate = self . krate . expect ( "trait solving requires setting `DbInterner::krate`" ) ;
16111612 let trait_block = trait_def_id. 0 . loc ( self . db ) . container . block ( self . db ) ;
16121613 let mut consider_impls_for_simplified_type = |simp : SimplifiedType < ' _ > | {
@@ -1641,13 +1642,14 @@ impl<'db> Interner for DbInterner<'db> {
16411642 let ( regular_impls, builtin_derive_impls) =
16421643 impls. for_trait_and_self_ty ( trait_def_id. 0 , & simp) ;
16431644 for & impl_ in regular_impls {
1644- f ( impl_. into ( ) ) ;
1645+ ret ! ( f( impl_. into( ) ) ) ;
16451646 }
16461647 for & impl_ in builtin_derive_impls {
1647- f ( impl_. into ( ) ) ;
1648+ ret ! ( f( impl_. into( ) ) ) ;
16481649 }
1650+ R :: output ( )
16491651 } ,
1650- ) ;
1652+ )
16511653 } ;
16521654
16531655 match self_ty. kind ( ) {
@@ -1676,7 +1678,7 @@ impl<'db> Interner for DbInterner<'db> {
16761678 let simp =
16771679 fast_reject:: simplify_type ( self , self_ty, fast_reject:: TreatParams :: AsRigid )
16781680 . unwrap ( ) ;
1679- consider_impls_for_simplified_type ( simp) ;
1681+ ret ! ( consider_impls_for_simplified_type( simp) ) ;
16801682 }
16811683
16821684 // HACK: For integer and float variables we have to manually look at all impls
@@ -1704,7 +1706,7 @@ impl<'db> Interner for DbInterner<'db> {
17041706 SimplifiedType :: Uint ( Usize ) ,
17051707 ] ;
17061708 for simp in possible_integers {
1707- consider_impls_for_simplified_type ( simp) ;
1709+ ret ! ( consider_impls_for_simplified_type( simp) ) ;
17081710 }
17091711 }
17101712
@@ -1719,7 +1721,7 @@ impl<'db> Interner for DbInterner<'db> {
17191721 ] ;
17201722
17211723 for simp in possible_floats {
1722- consider_impls_for_simplified_type ( simp) ;
1724+ ret ! ( consider_impls_for_simplified_type( simp) ) ;
17231725 }
17241726 }
17251727
@@ -1748,15 +1750,22 @@ impl<'db> Interner for DbInterner<'db> {
17481750 self . for_each_blanket_impl ( trait_def_id, f)
17491751 }
17501752
1751- fn for_each_blanket_impl ( self , trait_def_id : Self :: TraitId , mut f : impl FnMut ( Self :: ImplId ) ) {
1752- let Some ( krate) = self . krate else { return } ;
1753+ fn for_each_blanket_impl < R : VisitorResult > (
1754+ self ,
1755+ trait_def_id : Self :: TraitId ,
1756+ mut f : impl FnMut ( Self :: ImplId ) -> R ,
1757+ ) -> R {
1758+ let Some ( krate) = self . krate else {
1759+ return R :: output ( ) ;
1760+ } ;
17531761 let block = trait_def_id. 0 . loc ( self . db ) . container . block ( self . db ) ;
17541762
17551763 TraitImpls :: for_each_crate_and_block ( self . db , krate, block, & mut |impls| {
17561764 for & impl_ in impls. blanket_impls ( trait_def_id. 0 ) {
1757- f ( impl_. into ( ) ) ;
1765+ ret ! ( f( impl_. into( ) ) ) ;
17581766 }
1759- } ) ;
1767+ R :: output ( )
1768+ } )
17601769 }
17611770
17621771 fn has_item_definition ( self , _def_id : Self :: ImplOrTraitAssocTermId ) -> bool {
0 commit comments