@@ -10,7 +10,7 @@ use rustc_hir::intravisit;
10
10
use rustc_hir:: { GenericParamKind , ImplItemKind } ;
11
11
use rustc_infer:: infer:: outlives:: env:: OutlivesEnvironment ;
12
12
use rustc_infer:: infer:: { self , InferCtxt , TyCtxtInferExt } ;
13
- use rustc_infer:: traits:: util;
13
+ use rustc_infer:: traits:: { util, FulfillmentErrorLike } ;
14
14
use rustc_middle:: ty:: error:: { ExpectedFound , TypeError } ;
15
15
use rustc_middle:: ty:: fold:: BottomUpFolder ;
16
16
use rustc_middle:: ty:: util:: ExplicitSelf ;
@@ -225,7 +225,7 @@ fn compare_method_predicate_entailment<'tcx>(
225
225
let param_env = traits:: normalize_param_env_or_error ( tcx, param_env, normalize_cause) ;
226
226
227
227
let infcx = & tcx. infer_ctxt ( ) . build ( ) ;
228
- let ocx = ObligationCtxt :: new ( infcx) ;
228
+ let ocx = ObligationCtxt :: new_with_diagnostics ( infcx) ;
229
229
230
230
debug ! ( "compare_impl_method: caller_bounds={:?}" , param_env. caller_bounds( ) ) ;
231
231
@@ -493,7 +493,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
493
493
) ;
494
494
495
495
let infcx = & tcx. infer_ctxt ( ) . build ( ) ;
496
- let ocx = ObligationCtxt :: new ( infcx) ;
496
+ let ocx = ObligationCtxt :: new_with_diagnostics ( infcx) ;
497
497
498
498
// Normalize the impl signature with fresh variables for lifetime inference.
499
499
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>(
764
764
Ok ( & * tcx. arena . alloc ( remapped_types) )
765
765
}
766
766
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 > ,
769
772
types : FxIndexMap < DefId , ( Ty < ' tcx > , ty:: GenericArgsRef < ' tcx > ) > ,
770
773
span : Span ,
771
774
param_env : ty:: ParamEnv < ' tcx > ,
772
775
body_id : LocalDefId ,
773
776
}
774
777
775
- impl < ' a , ' tcx > ImplTraitInTraitCollector < ' a , ' tcx > {
778
+ impl < ' a , ' tcx , E > ImplTraitInTraitCollector < ' a , ' tcx , E >
779
+ where
780
+ E : FulfillmentErrorLike < ' tcx > ,
781
+ {
776
782
fn new (
777
- ocx : & ' a ObligationCtxt < ' a , ' tcx > ,
783
+ ocx : & ' a ObligationCtxt < ' a , ' tcx , E > ,
778
784
span : Span ,
779
785
param_env : ty:: ParamEnv < ' tcx > ,
780
786
body_id : LocalDefId ,
@@ -783,7 +789,10 @@ impl<'a, 'tcx> ImplTraitInTraitCollector<'a, 'tcx> {
783
789
}
784
790
}
785
791
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
+ {
787
796
fn interner ( & self ) -> TyCtxt < ' tcx > {
788
797
self . ocx . infcx . tcx
789
798
}
@@ -1777,7 +1786,7 @@ fn compare_const_predicate_entailment<'tcx>(
1777
1786
) ;
1778
1787
1779
1788
let infcx = tcx. infer_ctxt ( ) . build ( ) ;
1780
- let ocx = ObligationCtxt :: new ( & infcx) ;
1789
+ let ocx = ObligationCtxt :: new_with_diagnostics ( & infcx) ;
1781
1790
1782
1791
let impl_ct_own_bounds = impl_ct_predicates. instantiate_own ( tcx, impl_args) ;
1783
1792
for ( predicate, span) in impl_ct_own_bounds {
@@ -1910,7 +1919,7 @@ fn compare_type_predicate_entailment<'tcx>(
1910
1919
let param_env = ty:: ParamEnv :: new ( tcx. mk_clauses ( & hybrid_preds. predicates ) , Reveal :: UserFacing ) ;
1911
1920
let param_env = traits:: normalize_param_env_or_error ( tcx, param_env, normalize_cause) ;
1912
1921
let infcx = tcx. infer_ctxt ( ) . build ( ) ;
1913
- let ocx = ObligationCtxt :: new ( & infcx) ;
1922
+ let ocx = ObligationCtxt :: new_with_diagnostics ( & infcx) ;
1914
1923
1915
1924
debug ! ( "compare_type_predicate_entailment: caller_bounds={:?}" , param_env. caller_bounds( ) ) ;
1916
1925
@@ -1977,7 +1986,7 @@ pub(super) fn check_type_bounds<'tcx>(
1977
1986
let rebased_args = impl_ty_args. rebase_onto ( tcx, container_id, impl_trait_ref. args ) ;
1978
1987
1979
1988
let infcx = tcx. infer_ctxt ( ) . build ( ) ;
1980
- let ocx = ObligationCtxt :: new ( & infcx) ;
1989
+ let ocx = ObligationCtxt :: new_with_diagnostics ( & infcx) ;
1981
1990
1982
1991
// A synthetic impl Trait for RPITIT desugaring has no HIR, which we currently use to get the
1983
1992
// span for an impl's associated type. Instead, for these, use the def_span for the synthesized
0 commit comments