@@ -11,7 +11,7 @@ pub use RegionVariableOrigin::*;
11
11
pub use SubregionOrigin :: * ;
12
12
pub use ValuePairs :: * ;
13
13
14
- use crate :: infer:: relate:: RelateResult ;
14
+ use crate :: infer:: relate:: { Relate , RelateResult } ;
15
15
use crate :: traits:: { self , ObligationCause , ObligationInspector , PredicateObligation , TraitEngine } ;
16
16
use error_reporting:: TypeErrCtxt ;
17
17
use free_regions:: RegionRelations ;
@@ -35,6 +35,7 @@ use rustc_middle::infer::unify_key::{ConstVidKey, EffectVidKey};
35
35
use rustc_middle:: mir:: interpret:: { ErrorHandled , EvalToValTreeResult } ;
36
36
use rustc_middle:: mir:: ConstraintCategory ;
37
37
use rustc_middle:: traits:: select;
38
+ use rustc_middle:: traits:: solve:: { Goal , NoSolution } ;
38
39
use rustc_middle:: ty:: error:: { ExpectedFound , TypeError } ;
39
40
use rustc_middle:: ty:: fold:: BoundVarReplacerDelegate ;
40
41
use rustc_middle:: ty:: fold:: { TypeFoldable , TypeFolder , TypeSuperFoldable } ;
@@ -352,29 +353,21 @@ impl<'tcx> ty::InferCtxtLike for InferCtxt<'tcx> {
352
353
}
353
354
}
354
355
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) {
358
358
Err ( universe) => Some ( universe) ,
359
359
Ok ( _) => None ,
360
360
}
361
361
}
362
362
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) {
365
366
Err ( universe) => Some ( universe) ,
366
367
Ok ( _) => None ,
367
368
}
368
369
}
369
370
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
-
378
371
fn opportunistic_resolve_ty_var ( & self , vid : TyVid ) -> Ty < ' tcx > {
379
372
match self . probe_ty_var ( vid) {
380
373
Ok ( ty) => ty,
@@ -406,6 +399,26 @@ impl<'tcx> ty::InferCtxtLike for InferCtxt<'tcx> {
406
399
}
407
400
}
408
401
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
+
409
422
fn instantiate_binder_with_infer < T : TypeFoldable < Self :: Interner > + Copy > (
410
423
& self ,
411
424
value : ty:: Binder < ' tcx , T > ,
@@ -417,13 +430,40 @@ impl<'tcx> ty::InferCtxtLike for InferCtxt<'tcx> {
417
430
)
418
431
}
419
432
420
- fn enter_forall < T : TypeFoldable < Self :: Interner > + Copy , U > (
433
+ fn enter_forall < T : TypeFoldable < TyCtxt < ' tcx > > + Copy , U > (
421
434
& self ,
422
435
value : ty:: Binder < ' tcx , T > ,
423
436
f : impl FnOnce ( T ) -> U ,
424
437
) -> U {
425
438
self . enter_forall ( value, f)
426
439
}
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
+ }
427
467
}
428
468
429
469
/// See the `error_reporting` module for more details.
@@ -436,6 +476,7 @@ pub enum ValuePairs<'tcx> {
436
476
PolySigs ( ExpectedFound < ty:: PolyFnSig < ' tcx > > ) ,
437
477
ExistentialTraitRef ( ExpectedFound < ty:: PolyExistentialTraitRef < ' tcx > > ) ,
438
478
ExistentialProjection ( ExpectedFound < ty:: PolyExistentialProjection < ' tcx > > ) ,
479
+ DummyPair ,
439
480
}
440
481
441
482
impl < ' tcx > ValuePairs < ' tcx > {
@@ -1858,6 +1899,10 @@ impl<'tcx> TypeTrace<'tcx> {
1858
1899
values : Terms ( ExpectedFound :: new ( a_is_expected, a. into ( ) , b. into ( ) ) ) ,
1859
1900
}
1860
1901
}
1902
+
1903
+ fn dummy ( cause : & ObligationCause < ' tcx > ) -> TypeTrace < ' tcx > {
1904
+ TypeTrace { cause : cause. clone ( ) , values : ValuePairs :: DummyPair }
1905
+ }
1861
1906
}
1862
1907
1863
1908
impl < ' tcx > SubregionOrigin < ' tcx > {
0 commit comments