@@ -282,6 +282,7 @@ fn compare_method_predicate_entailment<'tcx>(
282282 let emitted = report_trait_method_mismatch (
283283 infcx,
284284 cause,
285+ param_env,
285286 terr,
286287 ( trait_m, trait_sig) ,
287288 ( impl_m, impl_sig) ,
@@ -575,10 +576,10 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
575576 hir. get_if_local ( impl_m. def_id )
576577 . and_then ( |node| node. fn_decl ( ) )
577578 . map ( |decl| ( decl. output . span ( ) , Cow :: from ( "return type in trait" ) , false ) ) ,
578- Some ( infer:: ValuePairs :: Terms ( ExpectedFound {
579+ Some ( param_env . and ( infer:: ValuePairs :: Terms ( ExpectedFound {
579580 expected : trait_return_ty. into ( ) ,
580581 found : impl_return_ty. into ( ) ,
581- } ) ) ,
582+ } ) ) ) ,
582583 terr,
583584 false ,
584585 ) ;
@@ -602,6 +603,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
602603 let emitted = report_trait_method_mismatch (
603604 infcx,
604605 cause,
606+ param_env,
605607 terr,
606608 ( trait_m, trait_sig) ,
607609 ( impl_m, impl_sig) ,
@@ -915,6 +917,7 @@ impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
915917fn report_trait_method_mismatch < ' tcx > (
916918 infcx : & InferCtxt < ' tcx > ,
917919 mut cause : ObligationCause < ' tcx > ,
920+ param_env : ty:: ParamEnv < ' tcx > ,
918921 terr : TypeError < ' tcx > ,
919922 ( trait_m, trait_sig) : ( ty:: AssocItem , ty:: FnSig < ' tcx > ) ,
920923 ( impl_m, impl_sig) : ( ty:: AssocItem , ty:: FnSig < ' tcx > ) ,
@@ -1000,10 +1003,10 @@ fn report_trait_method_mismatch<'tcx>(
10001003 & mut diag,
10011004 & cause,
10021005 trait_err_span. map ( |sp| ( sp, Cow :: from ( "type in trait" ) , false ) ) ,
1003- Some ( infer:: ValuePairs :: PolySigs ( ExpectedFound {
1006+ Some ( param_env . and ( infer:: ValuePairs :: PolySigs ( ExpectedFound {
10041007 expected : ty:: Binder :: dummy ( trait_sig) ,
10051008 found : ty:: Binder :: dummy ( impl_sig) ,
1006- } ) ) ,
1009+ } ) ) ) ,
10071010 terr,
10081011 false ,
10091012 ) ;
@@ -1797,10 +1800,10 @@ fn compare_const_predicate_entailment<'tcx>(
17971800 & mut diag,
17981801 & cause,
17991802 trait_c_span. map ( |span| ( span, Cow :: from ( "type in trait" ) , false ) ) ,
1800- Some ( infer:: ValuePairs :: Terms ( ExpectedFound {
1803+ Some ( param_env . and ( infer:: ValuePairs :: Terms ( ExpectedFound {
18011804 expected : trait_ty. into ( ) ,
18021805 found : impl_ty. into ( ) ,
1803- } ) ) ,
1806+ } ) ) ) ,
18041807 terr,
18051808 false ,
18061809 ) ;
0 commit comments