@@ -256,10 +256,21 @@ fn compare_predicate_entailment<'tcx>(
256256 infer:: HigherRankedType ,
257257 tcx. fn_sig ( impl_m. def_id ) ,
258258 ) ;
259+ let unnormalized_impl_fty = tcx. mk_fn_ptr ( ty:: Binder :: dummy ( unnormalized_impl_sig) ) ;
260+
261+ // We need to check that the impl's args are well-formed given
262+ // the hybrid param-env (impl + trait method where-clauses).
263+ ocx. register_obligation ( traits:: Obligation :: new (
264+ tcx,
265+ cause. clone ( ) ,
266+ param_env,
267+ ty:: Binder :: dummy ( ty:: PredicateKind :: WellFormed (
268+ tcx. mk_fn_ptr ( ty:: Binder :: dummy ( unnormalized_impl_sig) ) . into ( ) ,
269+ ) ) ,
270+ ) ) ;
259271
260272 let norm_cause = ObligationCause :: misc ( impl_m_span, impl_m_hir_id) ;
261- let impl_sig = ocx. normalize ( & norm_cause, param_env, unnormalized_impl_sig) ;
262- let impl_fty = tcx. mk_fn_ptr ( ty:: Binder :: dummy ( impl_sig) ) ;
273+ let impl_fty = ocx. normalize ( & norm_cause, param_env, unnormalized_impl_fty) ;
263274 debug ! ( "compare_impl_method: impl_fty={:?}" , impl_fty) ;
264275
265276 let trait_sig = tcx. bound_fn_sig ( trait_m. def_id ) . subst ( tcx, trait_to_placeholder_substs) ;
@@ -300,25 +311,6 @@ fn compare_predicate_entailment<'tcx>(
300311 return Err ( emitted) ;
301312 }
302313
303- // Finally, we need to check that the impl's args are well-formed given
304- // the hybrid param-env (impl + trait method where-clauses).
305- for ( unnormalized_arg, arg) in
306- std:: iter:: zip ( unnormalized_impl_sig. inputs_and_output , impl_sig. inputs_and_output )
307- {
308- ocx. register_obligation ( traits:: Obligation :: new (
309- tcx,
310- cause. clone ( ) ,
311- param_env,
312- ty:: Binder :: dummy ( ty:: PredicateKind :: WellFormed ( unnormalized_arg. into ( ) ) ) ,
313- ) ) ;
314- ocx. register_obligation ( traits:: Obligation :: new (
315- tcx,
316- cause. clone ( ) ,
317- param_env,
318- ty:: Binder :: dummy ( ty:: PredicateKind :: WellFormed ( arg. into ( ) ) ) ,
319- ) ) ;
320- }
321-
322314 // Check that all obligations are satisfied by the implementation's
323315 // version.
324316 let errors = ocx. select_all_or_error ( ) ;
0 commit comments