@@ -662,8 +662,6 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
662
662
let trait_m = tcx. opt_associated_item ( impl_m. trait_item_def_id . unwrap ( ) ) . unwrap ( ) ;
663
663
let impl_trait_ref =
664
664
tcx. impl_trait_ref ( impl_m. impl_container ( tcx) . unwrap ( ) ) . unwrap ( ) . instantiate_identity ( ) ;
665
- let param_env = tcx. param_env ( impl_m_def_id) ;
666
-
667
665
// First, check a few of the same things as `compare_impl_method`,
668
666
// just so we don't ICE during substitution later.
669
667
check_method_is_structurally_compatible ( tcx, impl_m, trait_m, impl_trait_ref, true ) ?;
@@ -689,6 +687,19 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
689
687
let trait_to_placeholder_args =
690
688
impl_to_placeholder_args. rebase_onto ( tcx, impl_m. container_id ( tcx) , trait_to_impl_args) ;
691
689
690
+ let hybrid_preds = tcx
691
+ . predicates_of ( impl_m. container_id ( tcx) )
692
+ . instantiate_identity ( tcx)
693
+ . into_iter ( )
694
+ . chain ( tcx. predicates_of ( trait_m. def_id ) . instantiate_own ( tcx, trait_to_placeholder_args) )
695
+ . map ( |( clause, _) | clause) ;
696
+ let param_env = ty:: ParamEnv :: new ( tcx. mk_clauses_from_iter ( hybrid_preds) , Reveal :: UserFacing ) ;
697
+ let param_env = traits:: normalize_param_env_or_error (
698
+ tcx,
699
+ param_env,
700
+ ObligationCause :: misc ( tcx. def_span ( impl_m_def_id) , impl_m_def_id) ,
701
+ ) ;
702
+
692
703
let infcx = & tcx. infer_ctxt ( ) . build ( ) ;
693
704
let ocx = ObligationCtxt :: new ( infcx) ;
694
705
0 commit comments