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