@@ -11,7 +11,7 @@ pub use RegionVariableOrigin::*;
1111pub use SubregionOrigin :: * ;
1212pub use ValuePairs :: * ;
1313
14- use crate :: infer:: relate:: RelateResult ;
14+ use crate :: infer:: relate:: { Relate , RelateResult } ;
1515use crate :: traits:: { self , ObligationCause , ObligationInspector , PredicateObligation , TraitEngine } ;
1616use error_reporting:: TypeErrCtxt ;
1717use free_regions:: RegionRelations ;
@@ -35,6 +35,7 @@ use rustc_middle::infer::unify_key::{ConstVidKey, EffectVidKey};
3535use rustc_middle:: mir:: interpret:: { ErrorHandled , EvalToValTreeResult } ;
3636use rustc_middle:: mir:: ConstraintCategory ;
3737use rustc_middle:: traits:: select;
38+ use rustc_middle:: traits:: solve:: { Goal , NoSolution } ;
3839use rustc_middle:: ty:: error:: { ExpectedFound , TypeError } ;
3940use rustc_middle:: ty:: fold:: BoundVarReplacerDelegate ;
4041use rustc_middle:: ty:: fold:: { TypeFoldable , TypeFolder , TypeSuperFoldable } ;
@@ -352,29 +353,21 @@ impl<'tcx> ty::InferCtxtLike for InferCtxt<'tcx> {
352353 }
353354 }
354355
355- fn universe_of_ct ( & self , ct : ConstVid ) -> Option < ty:: UniverseIndex > {
356- // Same issue as with `universe_of_ty`
357- match self . probe_const_var ( ct) {
356+ fn universe_of_lt ( & self , lt : ty:: RegionVid ) -> Option < ty:: UniverseIndex > {
357+ match self . inner . borrow_mut ( ) . unwrap_region_constraints ( ) . probe_value ( lt) {
358358 Err ( universe) => Some ( universe) ,
359359 Ok ( _) => None ,
360360 }
361361 }
362362
363- fn universe_of_lt ( & self , lt : ty:: RegionVid ) -> Option < ty:: UniverseIndex > {
364- match self . inner . borrow_mut ( ) . unwrap_region_constraints ( ) . probe_value ( lt) {
363+ fn universe_of_ct ( & self , ct : ConstVid ) -> Option < ty:: UniverseIndex > {
364+ // Same issue as with `universe_of_ty`
365+ match self . probe_const_var ( ct) {
365366 Err ( universe) => Some ( universe) ,
366367 Ok ( _) => None ,
367368 }
368369 }
369370
370- fn opportunistic_resolve_lt_var ( & self , vid : ty:: RegionVid ) -> ty:: Region < ' tcx > {
371- self . inner . borrow_mut ( ) . unwrap_region_constraints ( ) . opportunistic_resolve_var ( self . tcx , vid)
372- }
373-
374- fn defining_opaque_types ( & self ) -> & ' tcx ty:: List < LocalDefId > {
375- self . defining_opaque_types
376- }
377-
378371 fn opportunistic_resolve_ty_var ( & self , vid : TyVid ) -> Ty < ' tcx > {
379372 match self . probe_ty_var ( vid) {
380373 Ok ( ty) => ty,
@@ -406,6 +399,26 @@ impl<'tcx> ty::InferCtxtLike for InferCtxt<'tcx> {
406399 }
407400 }
408401
402+ fn opportunistic_resolve_lt_var ( & self , vid : ty:: RegionVid ) -> ty:: Region < ' tcx > {
403+ self . inner . borrow_mut ( ) . unwrap_region_constraints ( ) . opportunistic_resolve_var ( self . tcx , vid)
404+ }
405+
406+ fn defining_opaque_types ( & self ) -> & ' tcx ty:: List < LocalDefId > {
407+ self . defining_opaque_types
408+ }
409+
410+ fn next_ty_infer ( & self ) -> Ty < ' tcx > {
411+ self . next_ty_var ( DUMMY_SP )
412+ }
413+
414+ fn next_const_infer ( & self ) -> ty:: Const < ' tcx > {
415+ self . next_const_var ( DUMMY_SP )
416+ }
417+
418+ fn fresh_args_for_item ( & self , def_id : DefId ) -> ty:: GenericArgsRef < ' tcx > {
419+ self . fresh_args_for_item ( DUMMY_SP , def_id)
420+ }
421+
409422 fn instantiate_binder_with_infer < T : TypeFoldable < Self :: Interner > + Copy > (
410423 & self ,
411424 value : ty:: Binder < ' tcx , T > ,
@@ -417,13 +430,40 @@ impl<'tcx> ty::InferCtxtLike for InferCtxt<'tcx> {
417430 )
418431 }
419432
420- fn enter_forall < T : TypeFoldable < Self :: Interner > + Copy , U > (
433+ fn enter_forall < T : TypeFoldable < TyCtxt < ' tcx > > + Copy , U > (
421434 & self ,
422435 value : ty:: Binder < ' tcx , T > ,
423436 f : impl FnOnce ( T ) -> U ,
424437 ) -> U {
425438 self . enter_forall ( value, f)
426439 }
440+
441+ fn relate < T : Relate < TyCtxt < ' tcx > > > (
442+ & self ,
443+ param_env : ty:: ParamEnv < ' tcx > ,
444+ lhs : T ,
445+ variance : ty:: Variance ,
446+ rhs : T ,
447+ ) -> Result < Vec < Goal < ' tcx , ty:: Predicate < ' tcx > > > , NoSolution > {
448+ self . at ( & ObligationCause :: dummy ( ) , param_env) . relate_no_trace ( lhs, variance, rhs)
449+ }
450+
451+ fn eq_structurally_relating_aliases < T : Relate < TyCtxt < ' tcx > > > (
452+ & self ,
453+ param_env : ty:: ParamEnv < ' tcx > ,
454+ lhs : T ,
455+ rhs : T ,
456+ ) -> Result < Vec < Goal < ' tcx , ty:: Predicate < ' tcx > > > , NoSolution > {
457+ self . at ( & ObligationCause :: dummy ( ) , param_env)
458+ . eq_structurally_relating_aliases_no_trace ( lhs, rhs)
459+ }
460+
461+ fn resolve_vars_if_possible < T > ( & self , value : T ) -> T
462+ where
463+ T : TypeFoldable < TyCtxt < ' tcx > > ,
464+ {
465+ self . resolve_vars_if_possible ( value)
466+ }
427467}
428468
429469/// See the `error_reporting` module for more details.
@@ -436,6 +476,7 @@ pub enum ValuePairs<'tcx> {
436476 PolySigs ( ExpectedFound < ty:: PolyFnSig < ' tcx > > ) ,
437477 ExistentialTraitRef ( ExpectedFound < ty:: PolyExistentialTraitRef < ' tcx > > ) ,
438478 ExistentialProjection ( ExpectedFound < ty:: PolyExistentialProjection < ' tcx > > ) ,
479+ DummyPair ,
439480}
440481
441482impl < ' tcx > ValuePairs < ' tcx > {
@@ -1858,6 +1899,10 @@ impl<'tcx> TypeTrace<'tcx> {
18581899 values : Terms ( ExpectedFound :: new ( a_is_expected, a. into ( ) , b. into ( ) ) ) ,
18591900 }
18601901 }
1902+
1903+ fn dummy ( cause : & ObligationCause < ' tcx > ) -> TypeTrace < ' tcx > {
1904+ TypeTrace { cause : cause. clone ( ) , values : ValuePairs :: DummyPair }
1905+ }
18611906}
18621907
18631908impl < ' tcx > SubregionOrigin < ' tcx > {
0 commit comments