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