@@ -218,7 +218,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
218218 diag : & mut Diag < ' _ > ,
219219 lower_bound : RegionVid ,
220220 ) {
221- let mut suggestions = vec ! [ ] ;
222221 let tcx = self . infcx . tcx ;
223222
224223 // find generic associated types in the given region 'lower_bound'
@@ -242,7 +241,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
242241
243242 // find higher-ranked trait bounds bounded to the generic associated types
244243 let mut hrtb_bounds = vec ! [ ] ;
245- gat_id_and_generics. iter ( ) . flatten ( ) . for_each ( |( gat_hir_id, generics) | {
244+ gat_id_and_generics. iter ( ) . flatten ( ) . for_each ( |& ( gat_hir_id, generics) | {
246245 for pred in generics. predicates {
247246 let BoundPredicate ( WhereBoundPredicate { bound_generic_params, bounds, .. } ) =
248247 pred. kind
@@ -251,17 +250,32 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
251250 } ;
252251 if bound_generic_params
253252 . iter ( )
254- . rfind ( |bgp| tcx. local_def_id_to_hir_id ( bgp. def_id ) == * gat_hir_id)
253+ . rfind ( |bgp| tcx. local_def_id_to_hir_id ( bgp. def_id ) == gat_hir_id)
255254 . is_some ( )
256255 {
257256 for bound in * bounds {
258257 hrtb_bounds. push ( bound) ;
259258 }
259+ } else {
260+ for bound in * bounds {
261+ if let Trait ( trait_bound) = bound {
262+ if trait_bound
263+ . bound_generic_params
264+ . iter ( )
265+ . rfind ( |bgp| tcx. local_def_id_to_hir_id ( bgp. def_id ) == gat_hir_id)
266+ . is_some ( )
267+ {
268+ hrtb_bounds. push ( bound) ;
269+ return ;
270+ }
271+ }
272+ }
260273 }
261274 }
262275 } ) ;
263276 debug ! ( ?hrtb_bounds) ;
264277
278+ let mut suggestions = vec ! [ ] ;
265279 hrtb_bounds. iter ( ) . for_each ( |bound| {
266280 let Trait ( PolyTraitRef { trait_ref, span : trait_span, .. } ) = bound else {
267281 return ;
0 commit comments