@@ -2232,41 +2232,40 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2232
2232
let param_env = tcx. param_env ( block. owner . to_def_id ( ) ) ;
2233
2233
let cause = ObligationCause :: misc ( span, block. owner . def_id ) ;
2234
2234
let mut fulfillment_errors = Vec :: new ( ) ;
2235
- let mut applicable_candidates = Vec :: new ( ) ;
2236
-
2237
- for & ( impl_, ( assoc_item, def_scope) ) in & candidates {
2238
- let ocx = ObligationCtxt :: new ( & infcx) ;
2235
+ let mut applicable_candidates: Vec < _ > = candidates
2236
+ . iter ( )
2237
+ . filter_map ( | & ( impl_, ( assoc_item, def_scope) ) | {
2238
+ let ocx = ObligationCtxt :: new ( & infcx) ;
2239
2239
2240
- let impl_ty = tcx. type_of ( impl_) ;
2241
- let impl_substs = self . fresh_item_substs ( impl_, & infcx) ;
2242
- let impl_ty = impl_ty. subst ( tcx, impl_substs) ;
2243
- let impl_ty = ocx. normalize ( & cause, param_env, impl_ty) ;
2240
+ let impl_ty = tcx. type_of ( impl_) ;
2241
+ let impl_substs = self . fresh_item_substs ( impl_, & infcx) ;
2242
+ let impl_ty = impl_ty. subst ( tcx, impl_substs) ;
2243
+ let impl_ty = ocx. normalize ( & cause, param_env, impl_ty) ;
2244
2244
2245
- // Check that the Self-types can be related.
2246
- // FIXME(fmease): Should we use `eq` here?
2247
- if ocx. sup ( & ObligationCause :: dummy ( ) , param_env, impl_ty, self_ty) . is_err ( ) {
2248
- continue ;
2249
- }
2245
+ // Check that the Self-types can be related.
2246
+ // FIXME(fmease): Should we use `eq` here?
2247
+ ocx. sup ( & ObligationCause :: dummy ( ) , param_env, impl_ty, self_ty) . ok ( ) ?;
2250
2248
2251
- // Check whether the impl imposes obligations we have to worry about.
2252
- let impl_bounds = tcx. predicates_of ( impl_) ;
2253
- let impl_bounds = impl_bounds. instantiate ( tcx, impl_substs) ;
2249
+ // Check whether the impl imposes obligations we have to worry about.
2250
+ let impl_bounds = tcx. predicates_of ( impl_) ;
2251
+ let impl_bounds = impl_bounds. instantiate ( tcx, impl_substs) ;
2254
2252
2255
- let impl_bounds = ocx. normalize ( & cause, param_env, impl_bounds) ;
2253
+ let impl_bounds = ocx. normalize ( & cause, param_env, impl_bounds) ;
2256
2254
2257
- let impl_obligations =
2258
- traits:: predicates_for_generics ( |_, _| cause. clone ( ) , param_env, impl_bounds) ;
2255
+ let impl_obligations =
2256
+ traits:: predicates_for_generics ( |_, _| cause. clone ( ) , param_env, impl_bounds) ;
2259
2257
2260
- ocx. register_obligations ( impl_obligations) ;
2258
+ ocx. register_obligations ( impl_obligations) ;
2261
2259
2262
- let errors = ocx. select_where_possible ( ) ;
2263
- if !errors. is_empty ( ) {
2264
- fulfillment_errors = errors;
2265
- continue ;
2266
- }
2260
+ let errors = ocx. select_where_possible ( ) ;
2261
+ if !errors. is_empty ( ) {
2262
+ fulfillment_errors = errors;
2263
+ return None ;
2264
+ }
2267
2265
2268
- applicable_candidates. push ( ( assoc_item, def_scope) ) ;
2269
- }
2266
+ Some ( ( assoc_item, def_scope) )
2267
+ } )
2268
+ . collect ( ) ;
2270
2269
2271
2270
if applicable_candidates. len ( ) > 1 {
2272
2271
return Err ( self . complain_about_ambiguous_inherent_assoc_type (
0 commit comments