@@ -11,7 +11,7 @@ pub use BoundRegionConversionTime::*;
1111pub use RegionVariableOrigin :: * ;
1212pub use SubregionOrigin :: * ;
1313
14- use crate :: infer:: relate:: { Relate , RelateResult } ;
14+ use crate :: infer:: relate:: RelateResult ;
1515use crate :: traits:: { self , ObligationCause , ObligationInspector , PredicateObligation , TraitEngine } ;
1616use error_reporting:: TypeErrCtxt ;
1717use free_regions:: RegionRelations ;
@@ -45,7 +45,7 @@ use rustc_middle::ty::{ConstVid, EffectVid, FloatVid, IntVid, TyVid};
4545use rustc_middle:: ty:: { GenericArg , GenericArgKind , GenericArgs , GenericArgsRef } ;
4646use rustc_middle:: { bug, span_bug} ;
4747use rustc_span:: symbol:: Symbol ;
48- use rustc_span:: { Span , DUMMY_SP } ;
48+ use rustc_span:: Span ;
4949use snapshot:: undo_log:: InferCtxtUndoLogs ;
5050use std:: cell:: { Cell , RefCell } ;
5151use std:: fmt;
@@ -335,149 +335,6 @@ pub struct InferCtxt<'tcx> {
335335 pub obligation_inspector : Cell < Option < ObligationInspector < ' tcx > > > ,
336336}
337337
338- impl < ' tcx > ty:: InferCtxtLike for InferCtxt < ' tcx > {
339- type Interner = TyCtxt < ' tcx > ;
340-
341- fn interner ( & self ) -> TyCtxt < ' tcx > {
342- self . tcx
343- }
344-
345- fn universe_of_ty ( & self , vid : TyVid ) -> Option < ty:: UniverseIndex > {
346- // FIXME(BoxyUwU): this is kind of jank and means that printing unresolved
347- // ty infers will give you the universe of the var it resolved to not the universe
348- // it actually had. It also means that if you have a `?0.1` and infer it to `u8` then
349- // try to print out `?0.1` it will just print `?0`.
350- match self . probe_ty_var ( vid) {
351- Err ( universe) => Some ( universe) ,
352- Ok ( _) => None ,
353- }
354- }
355-
356- fn universe_of_lt ( & self , lt : ty:: RegionVid ) -> Option < ty:: UniverseIndex > {
357- match self . inner . borrow_mut ( ) . unwrap_region_constraints ( ) . probe_value ( lt) {
358- Err ( universe) => Some ( universe) ,
359- Ok ( _) => None ,
360- }
361- }
362-
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) {
366- Err ( universe) => Some ( universe) ,
367- Ok ( _) => None ,
368- }
369- }
370-
371- fn root_ty_var ( & self , var : TyVid ) -> TyVid {
372- self . root_var ( var)
373- }
374-
375- fn root_const_var ( & self , var : ConstVid ) -> ConstVid {
376- self . root_const_var ( var)
377- }
378-
379- fn opportunistic_resolve_ty_var ( & self , vid : TyVid ) -> Ty < ' tcx > {
380- match self . probe_ty_var ( vid) {
381- Ok ( ty) => ty,
382- Err ( _) => Ty :: new_var ( self . tcx , self . root_var ( vid) ) ,
383- }
384- }
385-
386- fn opportunistic_resolve_int_var ( & self , vid : IntVid ) -> Ty < ' tcx > {
387- self . opportunistic_resolve_int_var ( vid)
388- }
389-
390- fn opportunistic_resolve_float_var ( & self , vid : FloatVid ) -> Ty < ' tcx > {
391- self . opportunistic_resolve_float_var ( vid)
392- }
393-
394- fn opportunistic_resolve_ct_var ( & self , vid : ConstVid ) -> ty:: Const < ' tcx > {
395- match self . probe_const_var ( vid) {
396- Ok ( ct) => ct,
397- Err ( _) => ty:: Const :: new_var ( self . tcx , self . root_const_var ( vid) ) ,
398- }
399- }
400-
401- fn opportunistic_resolve_effect_var ( & self , vid : EffectVid ) -> ty:: Const < ' tcx > {
402- match self . probe_effect_var ( vid) {
403- Some ( ct) => ct,
404- None => {
405- ty:: Const :: new_infer ( self . tcx , InferConst :: EffectVar ( self . root_effect_var ( vid) ) )
406- }
407- }
408- }
409-
410- fn opportunistic_resolve_lt_var ( & self , vid : ty:: RegionVid ) -> ty:: Region < ' tcx > {
411- self . inner . borrow_mut ( ) . unwrap_region_constraints ( ) . opportunistic_resolve_var ( self . tcx , vid)
412- }
413-
414- fn defining_opaque_types ( & self ) -> & ' tcx ty:: List < LocalDefId > {
415- self . defining_opaque_types
416- }
417-
418- fn next_ty_infer ( & self ) -> Ty < ' tcx > {
419- self . next_ty_var ( DUMMY_SP )
420- }
421-
422- fn next_const_infer ( & self ) -> ty:: Const < ' tcx > {
423- self . next_const_var ( DUMMY_SP )
424- }
425-
426- fn fresh_args_for_item ( & self , def_id : DefId ) -> ty:: GenericArgsRef < ' tcx > {
427- self . fresh_args_for_item ( DUMMY_SP , def_id)
428- }
429-
430- fn instantiate_binder_with_infer < T : TypeFoldable < Self :: Interner > + Copy > (
431- & self ,
432- value : ty:: Binder < ' tcx , T > ,
433- ) -> T {
434- self . instantiate_binder_with_fresh_vars (
435- DUMMY_SP ,
436- BoundRegionConversionTime :: HigherRankedType ,
437- value,
438- )
439- }
440-
441- fn enter_forall < T : TypeFoldable < TyCtxt < ' tcx > > + Copy , U > (
442- & self ,
443- value : ty:: Binder < ' tcx , T > ,
444- f : impl FnOnce ( T ) -> U ,
445- ) -> U {
446- self . enter_forall ( value, f)
447- }
448-
449- fn relate < T : Relate < TyCtxt < ' tcx > > > (
450- & self ,
451- param_env : ty:: ParamEnv < ' tcx > ,
452- lhs : T ,
453- variance : ty:: Variance ,
454- rhs : T ,
455- ) -> Result < Vec < Goal < ' tcx , ty:: Predicate < ' tcx > > > , NoSolution > {
456- self . at ( & ObligationCause :: dummy ( ) , param_env) . relate_no_trace ( lhs, variance, rhs)
457- }
458-
459- fn eq_structurally_relating_aliases < T : Relate < TyCtxt < ' tcx > > > (
460- & self ,
461- param_env : ty:: ParamEnv < ' tcx > ,
462- lhs : T ,
463- rhs : T ,
464- ) -> Result < Vec < Goal < ' tcx , ty:: Predicate < ' tcx > > > , NoSolution > {
465- self . at ( & ObligationCause :: dummy ( ) , param_env)
466- . eq_structurally_relating_aliases_no_trace ( lhs, rhs)
467- }
468-
469- fn resolve_vars_if_possible < T > ( & self , value : T ) -> T
470- where
471- T : TypeFoldable < TyCtxt < ' tcx > > ,
472- {
473- self . resolve_vars_if_possible ( value)
474- }
475-
476- fn probe < T > ( & self , probe : impl FnOnce ( ) -> T ) -> T {
477- self . probe ( |_| probe ( ) )
478- }
479- }
480-
481338/// See the `error_reporting` module for more details.
482339#[ derive( Clone , Copy , Debug , PartialEq , Eq , TypeFoldable , TypeVisitable ) ]
483340pub enum ValuePairs < ' tcx > {
@@ -831,6 +688,10 @@ impl<'tcx> InferCtxt<'tcx> {
831688 self . tcx . dcx ( )
832689 }
833690
691+ pub fn defining_opaque_types ( & self ) -> & ' tcx ty:: List < LocalDefId > {
692+ self . defining_opaque_types
693+ }
694+
834695 pub fn next_trait_solver ( & self ) -> bool {
835696 self . next_trait_solver
836697 }
0 commit comments