@@ -218,7 +218,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
218
218
diag : & mut Diag < ' _ > ,
219
219
lower_bound : RegionVid ,
220
220
) {
221
- let mut suggestions = vec ! [ ] ;
222
221
let tcx = self . infcx . tcx ;
223
222
224
223
// find generic associated types in the given region 'lower_bound'
@@ -242,7 +241,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
242
241
243
242
// find higher-ranked trait bounds bounded to the generic associated types
244
243
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) | {
246
245
for pred in generics. predicates {
247
246
let BoundPredicate ( WhereBoundPredicate { bound_generic_params, bounds, .. } ) =
248
247
pred. kind
@@ -251,17 +250,32 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
251
250
} ;
252
251
if bound_generic_params
253
252
. 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)
255
254
. is_some ( )
256
255
{
257
256
for bound in * bounds {
258
257
hrtb_bounds. push ( bound) ;
259
258
}
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
+ }
260
273
}
261
274
}
262
275
} ) ;
263
276
debug ! ( ?hrtb_bounds) ;
264
277
278
+ let mut suggestions = vec ! [ ] ;
265
279
hrtb_bounds. iter ( ) . for_each ( |bound| {
266
280
let Trait ( PolyTraitRef { trait_ref, span : trait_span, .. } ) = bound else {
267
281
return ;
0 commit comments