@@ -10,7 +10,7 @@ use rustc_hir::intravisit;
1010use rustc_hir:: { GenericParamKind , ImplItemKind } ;
1111use rustc_infer:: infer:: outlives:: env:: OutlivesEnvironment ;
1212use rustc_infer:: infer:: { self , InferCtxt , TyCtxtInferExt } ;
13- use rustc_infer:: traits:: util;
13+ use rustc_infer:: traits:: { util, FulfillmentErrorLike } ;
1414use rustc_middle:: ty:: error:: { ExpectedFound , TypeError } ;
1515use rustc_middle:: ty:: fold:: BottomUpFolder ;
1616use rustc_middle:: ty:: util:: ExplicitSelf ;
@@ -225,7 +225,7 @@ fn compare_method_predicate_entailment<'tcx>(
225225 let param_env = traits:: normalize_param_env_or_error ( tcx, param_env, normalize_cause) ;
226226
227227 let infcx = & tcx. infer_ctxt ( ) . build ( ) ;
228- let ocx = ObligationCtxt :: new ( infcx) ;
228+ let ocx = ObligationCtxt :: new_with_diagnostics ( infcx) ;
229229
230230 debug ! ( "compare_impl_method: caller_bounds={:?}" , param_env. caller_bounds( ) ) ;
231231
@@ -493,7 +493,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
493493 ) ;
494494
495495 let infcx = & tcx. infer_ctxt ( ) . build ( ) ;
496- let ocx = ObligationCtxt :: new ( infcx) ;
496+ let ocx = ObligationCtxt :: new_with_diagnostics ( infcx) ;
497497
498498 // Normalize the impl signature with fresh variables for lifetime inference.
499499 let misc_cause = ObligationCause :: misc ( return_span, impl_m_def_id) ;
@@ -764,17 +764,23 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
764764 Ok ( & * tcx. arena . alloc ( remapped_types) )
765765}
766766
767- struct ImplTraitInTraitCollector < ' a , ' tcx > {
768- ocx : & ' a ObligationCtxt < ' a , ' tcx > ,
767+ struct ImplTraitInTraitCollector < ' a , ' tcx , E >
768+ where
769+ E : FulfillmentErrorLike < ' tcx > ,
770+ {
771+ ocx : & ' a ObligationCtxt < ' a , ' tcx , E > ,
769772 types : FxIndexMap < DefId , ( Ty < ' tcx > , ty:: GenericArgsRef < ' tcx > ) > ,
770773 span : Span ,
771774 param_env : ty:: ParamEnv < ' tcx > ,
772775 body_id : LocalDefId ,
773776}
774777
775- impl < ' a , ' tcx > ImplTraitInTraitCollector < ' a , ' tcx > {
778+ impl < ' a , ' tcx , E > ImplTraitInTraitCollector < ' a , ' tcx , E >
779+ where
780+ E : FulfillmentErrorLike < ' tcx > ,
781+ {
776782 fn new (
777- ocx : & ' a ObligationCtxt < ' a , ' tcx > ,
783+ ocx : & ' a ObligationCtxt < ' a , ' tcx , E > ,
778784 span : Span ,
779785 param_env : ty:: ParamEnv < ' tcx > ,
780786 body_id : LocalDefId ,
@@ -783,7 +789,10 @@ impl<'a, 'tcx> ImplTraitInTraitCollector<'a, 'tcx> {
783789 }
784790}
785791
786- impl < ' tcx > TypeFolder < TyCtxt < ' tcx > > for ImplTraitInTraitCollector < ' _ , ' tcx > {
792+ impl < ' tcx , E > TypeFolder < TyCtxt < ' tcx > > for ImplTraitInTraitCollector < ' _ , ' tcx , E >
793+ where
794+ E : FulfillmentErrorLike < ' tcx > ,
795+ {
787796 fn interner ( & self ) -> TyCtxt < ' tcx > {
788797 self . ocx . infcx . tcx
789798 }
@@ -1777,7 +1786,7 @@ fn compare_const_predicate_entailment<'tcx>(
17771786 ) ;
17781787
17791788 let infcx = tcx. infer_ctxt ( ) . build ( ) ;
1780- let ocx = ObligationCtxt :: new ( & infcx) ;
1789+ let ocx = ObligationCtxt :: new_with_diagnostics ( & infcx) ;
17811790
17821791 let impl_ct_own_bounds = impl_ct_predicates. instantiate_own ( tcx, impl_args) ;
17831792 for ( predicate, span) in impl_ct_own_bounds {
@@ -1910,7 +1919,7 @@ fn compare_type_predicate_entailment<'tcx>(
19101919 let param_env = ty:: ParamEnv :: new ( tcx. mk_clauses ( & hybrid_preds. predicates ) , Reveal :: UserFacing ) ;
19111920 let param_env = traits:: normalize_param_env_or_error ( tcx, param_env, normalize_cause) ;
19121921 let infcx = tcx. infer_ctxt ( ) . build ( ) ;
1913- let ocx = ObligationCtxt :: new ( & infcx) ;
1922+ let ocx = ObligationCtxt :: new_with_diagnostics ( & infcx) ;
19141923
19151924 debug ! ( "compare_type_predicate_entailment: caller_bounds={:?}" , param_env. caller_bounds( ) ) ;
19161925
@@ -1977,7 +1986,7 @@ pub(super) fn check_type_bounds<'tcx>(
19771986 let rebased_args = impl_ty_args. rebase_onto ( tcx, container_id, impl_trait_ref. args ) ;
19781987
19791988 let infcx = tcx. infer_ctxt ( ) . build ( ) ;
1980- let ocx = ObligationCtxt :: new ( & infcx) ;
1989+ let ocx = ObligationCtxt :: new_with_diagnostics ( & infcx) ;
19811990
19821991 // A synthetic impl Trait for RPITIT desugaring has no HIR, which we currently use to get the
19831992 // span for an impl's associated type. Instead, for these, use the def_span for the synthesized
0 commit comments