@@ -12,22 +12,19 @@ use crate::infer::canonical::{
1212 Canonical , CanonicalQueryResponse , CanonicalVarValues , Certainty , OriginalQueryValues ,
1313 QueryOutlivesConstraint , QueryRegionConstraints , QueryResponse ,
1414} ;
15- use crate :: infer:: nll_relate:: { TypeRelating , TypeRelatingDelegate } ;
1615use crate :: infer:: region_constraints:: { Constraint , RegionConstraintData } ;
17- use crate :: infer:: { DefineOpaqueTypes , InferCtxt , InferOk , InferResult , NllRegionVariableOrigin } ;
16+ use crate :: infer:: { DefineOpaqueTypes , InferCtxt , InferOk , InferResult } ;
1817use crate :: traits:: query:: NoSolution ;
1918use crate :: traits:: { Obligation , ObligationCause , PredicateObligation } ;
20- use crate :: traits:: { PredicateObligations , TraitEngine , TraitEngineExt } ;
19+ use crate :: traits:: { TraitEngine , TraitEngineExt } ;
2120use rustc_data_structures:: captures:: Captures ;
2221use rustc_index:: Idx ;
2322use rustc_index:: IndexVec ;
2423use rustc_middle:: arena:: ArenaAllocatable ;
2524use rustc_middle:: mir:: ConstraintCategory ;
2625use 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 } ;
2927use rustc_middle:: ty:: { GenericArg , GenericArgKind } ;
30- use rustc_span:: { Span , Symbol } ;
3128use std:: fmt:: Debug ;
3229use std:: iter;
3330
@@ -290,31 +287,19 @@ impl<'tcx> InferCtxt<'tcx> {
290287 }
291288
292289 ( 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+ ) ;
304295 }
305296
306297 ( 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+ ) ;
318303 }
319304
320305 _ => {
@@ -697,60 +682,3 @@ pub fn make_query_region_constraints<'tcx>(
697682
698683 QueryRegionConstraints { outlives, member_constraints : member_constraints. clone ( ) }
699684}
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