@@ -194,23 +194,36 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
194194 & self ,
195195 diag : & mut Diag < ' _ > ,
196196 lower_bound : RegionVid ,
197- ) -> Option < ( ) > {
197+ ) {
198198 let tcx = self . infcx . tcx ;
199199
200200 // find generic associated types in the given region 'lower_bound'
201201 let scc = self . regioncx . constraint_sccs ( ) . scc ( lower_bound) ;
202- let placeholder: ty:: PlaceholderRegion = self . regioncx . placeholder_representative ( scc) ?;
203- let placeholder_id = placeholder. bound . kind . get_id ( ) ?. as_local ( ) ?;
204- let gat_hir_id = self . infcx . tcx . local_def_id_to_hir_id ( placeholder_id) ;
205- let generics_impl =
206- self . infcx . tcx . parent_hir_node ( self . infcx . tcx . parent_hir_id ( gat_hir_id) ) . generics ( ) ?;
202+ let Some ( gat_hir_id) = self
203+ . regioncx
204+ . placeholder_representative ( scc)
205+ . and_then ( |placeholder| placeholder. bound . kind . get_id ( ) )
206+ . and_then ( |id| id. as_local ( ) )
207+ . map ( |local| self . infcx . tcx . local_def_id_to_hir_id ( local) )
208+ else {
209+ return ;
210+ } ;
207211
208212 // Look for the where-bound which introduces the placeholder.
209213 // As we're using the HIR, we need to handle both `for<'a> T: Trait<'a>`
210214 // and `T: for<'a> Trait`<'a>.
211215 let mut hrtb_bounds = vec ! [ ] ;
212216
213- for pred in generics_impl. predicates {
217+ // FIXME(amandasystems) we can probably flatten this.
218+ for pred in self
219+ . infcx
220+ . tcx
221+ . parent_hir_node ( self . infcx . tcx . parent_hir_id ( gat_hir_id) )
222+ . generics ( )
223+ . map ( |gen_impl| gen_impl. predicates )
224+ . into_iter ( )
225+ . flatten ( )
226+ {
214227 let BoundPredicate ( WhereBoundPredicate { bound_generic_params, bounds, .. } ) =
215228 pred. kind
216229 else {
@@ -271,7 +284,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
271284 Applicability :: MaybeIncorrect ,
272285 ) ;
273286 }
274- Some ( ( ) )
275287 }
276288
277289 /// Produces nice borrowck error diagnostics for all the errors collected in `nll_errors`.
0 commit comments