@@ -215,7 +215,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
215215 diag : & mut Diag < ' _ > ,
216216 lower_bound : RegionVid ,
217217 ) {
218- let mut suggestions = vec ! [ ] ;
219218 let tcx = self . infcx . tcx ;
220219
221220 // find generic associated types in the given region 'lower_bound'
@@ -239,7 +238,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
239238
240239 // find higher-ranked trait bounds bounded to the generic associated types
241240 let mut hrtb_bounds = vec ! [ ] ;
242- gat_id_and_generics. iter ( ) . flatten ( ) . for_each ( |( gat_hir_id, generics) | {
241+ gat_id_and_generics. iter ( ) . flatten ( ) . for_each ( |& ( gat_hir_id, generics) | {
243242 for pred in generics. predicates {
244243 let BoundPredicate ( WhereBoundPredicate { bound_generic_params, bounds, .. } ) =
245244 pred. kind
@@ -248,17 +247,32 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
248247 } ;
249248 if bound_generic_params
250249 . iter ( )
251- . rfind ( |bgp| tcx. local_def_id_to_hir_id ( bgp. def_id ) == * gat_hir_id)
250+ . rfind ( |bgp| tcx. local_def_id_to_hir_id ( bgp. def_id ) == gat_hir_id)
252251 . is_some ( )
253252 {
254253 for bound in * bounds {
255254 hrtb_bounds. push ( bound) ;
256255 }
256+ } else {
257+ for bound in * bounds {
258+ if let Trait ( trait_bound) = bound {
259+ if trait_bound
260+ . bound_generic_params
261+ . iter ( )
262+ . rfind ( |bgp| tcx. local_def_id_to_hir_id ( bgp. def_id ) == gat_hir_id)
263+ . is_some ( )
264+ {
265+ hrtb_bounds. push ( bound) ;
266+ return ;
267+ }
268+ }
269+ }
257270 }
258271 }
259272 } ) ;
260273 debug ! ( ?hrtb_bounds) ;
261274
275+ let mut suggestions = vec ! [ ] ;
262276 hrtb_bounds. iter ( ) . for_each ( |bound| {
263277 let Trait ( PolyTraitRef { trait_ref, span : trait_span, .. } ) = bound else {
264278 return ;
0 commit comments