@@ -12,22 +12,19 @@ use crate::infer::canonical::{
12
12
Canonical , CanonicalQueryResponse , CanonicalVarValues , Certainty , OriginalQueryValues ,
13
13
QueryOutlivesConstraint , QueryRegionConstraints , QueryResponse ,
14
14
} ;
15
- use crate :: infer:: nll_relate:: { TypeRelating , TypeRelatingDelegate } ;
16
15
use crate :: infer:: region_constraints:: { Constraint , RegionConstraintData } ;
17
- use crate :: infer:: { DefineOpaqueTypes , InferCtxt , InferOk , InferResult , NllRegionVariableOrigin } ;
16
+ use crate :: infer:: { DefineOpaqueTypes , InferCtxt , InferOk , InferResult } ;
18
17
use crate :: traits:: query:: NoSolution ;
19
18
use crate :: traits:: { Obligation , ObligationCause , PredicateObligation } ;
20
- use crate :: traits:: { PredicateObligations , TraitEngine , TraitEngineExt } ;
19
+ use crate :: traits:: { TraitEngine , TraitEngineExt } ;
21
20
use rustc_data_structures:: captures:: Captures ;
22
21
use rustc_index:: Idx ;
23
22
use rustc_index:: IndexVec ;
24
23
use rustc_middle:: arena:: ArenaAllocatable ;
25
24
use rustc_middle:: mir:: ConstraintCategory ;
26
25
use rustc_middle:: ty:: fold:: TypeFoldable ;
27
- use rustc_middle:: ty:: relate:: TypeRelation ;
28
- use rustc_middle:: ty:: { self , BoundVar , ToPredicate , Ty , TyCtxt } ;
26
+ use rustc_middle:: ty:: { self , BoundVar , Ty , TyCtxt } ;
29
27
use rustc_middle:: ty:: { GenericArg , GenericArgKind } ;
30
- use rustc_span:: { Span , Symbol } ;
31
28
use std:: fmt:: Debug ;
32
29
use std:: iter;
33
30
@@ -290,31 +287,19 @@ impl<'tcx> InferCtxt<'tcx> {
290
287
}
291
288
292
289
( GenericArgKind :: Type ( v1) , GenericArgKind :: Type ( v2) ) => {
293
- TypeRelating :: new (
294
- self ,
295
- QueryTypeRelatingDelegate {
296
- infcx : self ,
297
- param_env,
298
- cause,
299
- obligations : & mut obligations,
300
- } ,
301
- ty:: Variance :: Invariant ,
302
- )
303
- . relate ( v1, v2) ?;
290
+ obligations. extend (
291
+ self . at ( & cause, param_env)
292
+ . eq ( DefineOpaqueTypes :: Yes , v1, v2) ?
293
+ . into_obligations ( ) ,
294
+ ) ;
304
295
}
305
296
306
297
( GenericArgKind :: Const ( v1) , GenericArgKind :: Const ( v2) ) => {
307
- TypeRelating :: new (
308
- self ,
309
- QueryTypeRelatingDelegate {
310
- infcx : self ,
311
- param_env,
312
- cause,
313
- obligations : & mut obligations,
314
- } ,
315
- ty:: Variance :: Invariant ,
316
- )
317
- . relate ( v1, v2) ?;
298
+ obligations. extend (
299
+ self . at ( & cause, param_env)
300
+ . eq ( DefineOpaqueTypes :: Yes , v1, v2) ?
301
+ . into_obligations ( ) ,
302
+ ) ;
318
303
}
319
304
320
305
_ => {
@@ -697,60 +682,3 @@ pub fn make_query_region_constraints<'tcx>(
697
682
698
683
QueryRegionConstraints { outlives, member_constraints : member_constraints. clone ( ) }
699
684
}
700
-
701
- struct QueryTypeRelatingDelegate < ' a , ' tcx > {
702
- infcx : & ' a InferCtxt < ' tcx > ,
703
- obligations : & ' a mut Vec < PredicateObligation < ' tcx > > ,
704
- param_env : ty:: ParamEnv < ' tcx > ,
705
- cause : & ' a ObligationCause < ' tcx > ,
706
- }
707
-
708
- impl < ' tcx > TypeRelatingDelegate < ' tcx > for QueryTypeRelatingDelegate < ' _ , ' tcx > {
709
- fn span ( & self ) -> Span {
710
- self . cause . span
711
- }
712
-
713
- fn param_env ( & self ) -> ty:: ParamEnv < ' tcx > {
714
- self . param_env
715
- }
716
-
717
- fn create_next_universe ( & mut self ) -> ty:: UniverseIndex {
718
- self . infcx . create_next_universe ( )
719
- }
720
-
721
- fn next_existential_region_var (
722
- & mut self ,
723
- from_forall : bool ,
724
- _name : Option < Symbol > ,
725
- ) -> ty:: Region < ' tcx > {
726
- let origin = NllRegionVariableOrigin :: Existential { from_forall } ;
727
- self . infcx . next_nll_region_var ( origin)
728
- }
729
-
730
- fn next_placeholder_region ( & mut self , placeholder : ty:: PlaceholderRegion ) -> ty:: Region < ' tcx > {
731
- ty:: Region :: new_placeholder ( self . infcx . tcx , placeholder)
732
- }
733
-
734
- fn push_outlives (
735
- & mut self ,
736
- sup : ty:: Region < ' tcx > ,
737
- sub : ty:: Region < ' tcx > ,
738
- _info : ty:: VarianceDiagInfo < ' tcx > ,
739
- ) {
740
- self . obligations . push ( Obligation {
741
- cause : self . cause . clone ( ) ,
742
- param_env : self . param_env ,
743
- predicate : ty:: ClauseKind :: RegionOutlives ( ty:: OutlivesPredicate ( sup, sub) )
744
- . to_predicate ( self . infcx . tcx ) ,
745
- recursion_depth : 0 ,
746
- } ) ;
747
- }
748
-
749
- fn forbid_inference_vars ( ) -> bool {
750
- true
751
- }
752
-
753
- fn register_obligations ( & mut self , obligations : PredicateObligations < ' tcx > ) {
754
- self . obligations . extend ( obligations) ;
755
- }
756
- }
0 commit comments