@@ -12,23 +12,20 @@ use std::iter;
1212
1313use rustc_index:: { Idx , IndexVec } ;
1414use rustc_middle:: arena:: ArenaAllocatable ;
15+ use rustc_middle:: bug;
1516use rustc_middle:: mir:: ConstraintCategory ;
1617use rustc_middle:: ty:: { self , BoundVar , GenericArg , GenericArgKind , Ty , TyCtxt , TypeFoldable } ;
17- use rustc_middle:: { bug, span_bug} ;
1818use tracing:: { debug, instrument} ;
1919
2020use crate :: infer:: canonical:: instantiate:: { CanonicalExt , instantiate_value} ;
2121use crate :: infer:: canonical:: {
2222 Canonical , CanonicalQueryResponse , CanonicalVarValues , Certainty , OriginalQueryValues ,
23- QueryOutlivesConstraint , QueryRegionConstraints , QueryResponse ,
23+ QueryRegionConstraints , QueryResponse ,
2424} ;
2525use crate :: infer:: region_constraints:: { Constraint , RegionConstraintData } ;
2626use crate :: infer:: { DefineOpaqueTypes , InferCtxt , InferOk , InferResult , SubregionOrigin } ;
2727use crate :: traits:: query:: NoSolution ;
28- use crate :: traits:: {
29- Obligation , ObligationCause , PredicateObligation , PredicateObligations , ScrubbedTraitError ,
30- TraitEngine ,
31- } ;
28+ use crate :: traits:: { ObligationCause , PredicateObligations , ScrubbedTraitError , TraitEngine } ;
3229
3330impl < ' tcx > InferCtxt < ' tcx > {
3431 /// This method is meant to be invoked as the final step of a canonical query
@@ -169,15 +166,13 @@ impl<'tcx> InferCtxt<'tcx> {
169166 where
170167 R : Debug + TypeFoldable < TyCtxt < ' tcx > > ,
171168 {
172- let InferOk { value : result_args, mut obligations } =
169+ let InferOk { value : result_args, obligations } =
173170 self . query_response_instantiation ( cause, param_env, original_values, query_response) ?;
174171
175- obligations. extend ( self . query_outlives_constraints_into_obligations (
176- cause,
177- param_env,
178- & query_response. value . region_constraints . outlives ,
179- & result_args,
180- ) ) ;
172+ for ( predicate, _category) in & query_response. value . region_constraints . outlives {
173+ let predicate = instantiate_value ( self . tcx , & result_args, * predicate) ;
174+ self . register_outlives_constraint ( predicate, cause) ;
175+ }
181176
182177 let user_result: R =
183178 query_response. instantiate_projected ( self . tcx , & result_args, |q_r| q_r. value . clone ( ) ) ;
@@ -525,47 +520,6 @@ impl<'tcx> InferCtxt<'tcx> {
525520 self . unify_canonical_vars ( cause, param_env, original_values, instantiated_query_response)
526521 }
527522
528- /// Converts the region constraints resulting from a query into an
529- /// iterator of obligations.
530- fn query_outlives_constraints_into_obligations (
531- & self ,
532- cause : & ObligationCause < ' tcx > ,
533- param_env : ty:: ParamEnv < ' tcx > ,
534- uninstantiated_region_constraints : & [ QueryOutlivesConstraint < ' tcx > ] ,
535- result_args : & CanonicalVarValues < ' tcx > ,
536- ) -> impl Iterator < Item = PredicateObligation < ' tcx > > {
537- uninstantiated_region_constraints. iter ( ) . map ( move |& constraint| {
538- let predicate = instantiate_value ( self . tcx , result_args, constraint) ;
539- self . query_outlives_constraint_to_obligation ( predicate, cause. clone ( ) , param_env)
540- } )
541- }
542-
543- pub fn query_outlives_constraint_to_obligation (
544- & self ,
545- ( predicate, _) : QueryOutlivesConstraint < ' tcx > ,
546- cause : ObligationCause < ' tcx > ,
547- param_env : ty:: ParamEnv < ' tcx > ,
548- ) -> Obligation < ' tcx , ty:: Predicate < ' tcx > > {
549- let ty:: OutlivesPredicate ( k1, r2) = predicate;
550-
551- let atom = match k1. unpack ( ) {
552- GenericArgKind :: Lifetime ( r1) => ty:: PredicateKind :: Clause (
553- ty:: ClauseKind :: RegionOutlives ( ty:: OutlivesPredicate ( r1, r2) ) ,
554- ) ,
555- GenericArgKind :: Type ( t1) => ty:: PredicateKind :: Clause ( ty:: ClauseKind :: TypeOutlives (
556- ty:: OutlivesPredicate ( t1, r2) ,
557- ) ) ,
558- GenericArgKind :: Const ( ..) => {
559- // Consts cannot outlive one another, so we don't expect to
560- // encounter this branch.
561- span_bug ! ( cause. span, "unexpected const outlives {:?}" , predicate) ;
562- }
563- } ;
564- let predicate = ty:: Binder :: dummy ( atom) ;
565-
566- Obligation :: new ( self . tcx , cause, param_env, predicate)
567- }
568-
569523 /// Given two sets of values for the same set of canonical variables, unify them.
570524 /// The second set is produced lazily by supplying indices from the first set.
571525 fn unify_canonical_vars (
0 commit comments