@@ -12,23 +12,20 @@ use std::iter;
12
12
13
13
use rustc_index:: { Idx , IndexVec } ;
14
14
use rustc_middle:: arena:: ArenaAllocatable ;
15
+ use rustc_middle:: bug;
15
16
use rustc_middle:: mir:: ConstraintCategory ;
16
17
use rustc_middle:: ty:: { self , BoundVar , GenericArg , GenericArgKind , Ty , TyCtxt , TypeFoldable } ;
17
- use rustc_middle:: { bug, span_bug} ;
18
18
use tracing:: { debug, instrument} ;
19
19
20
20
use crate :: infer:: canonical:: instantiate:: { CanonicalExt , instantiate_value} ;
21
21
use crate :: infer:: canonical:: {
22
22
Canonical , CanonicalQueryResponse , CanonicalVarValues , Certainty , OriginalQueryValues ,
23
- QueryOutlivesConstraint , QueryRegionConstraints , QueryResponse ,
23
+ QueryRegionConstraints , QueryResponse ,
24
24
} ;
25
25
use crate :: infer:: region_constraints:: { Constraint , RegionConstraintData } ;
26
26
use crate :: infer:: { DefineOpaqueTypes , InferCtxt , InferOk , InferResult } ;
27
27
use 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 } ;
32
29
33
30
impl < ' tcx > InferCtxt < ' tcx > {
34
31
/// This method is meant to be invoked as the final step of a canonical query
@@ -169,15 +166,13 @@ impl<'tcx> InferCtxt<'tcx> {
169
166
where
170
167
R : Debug + TypeFoldable < TyCtxt < ' tcx > > ,
171
168
{
172
- let InferOk { value : result_args, mut obligations } =
169
+ let InferOk { value : result_args, obligations } =
173
170
self . query_response_instantiation ( cause, param_env, original_values, query_response) ?;
174
171
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 . outlives_predicate_with_cause ( predicate, cause) ;
175
+ }
181
176
182
177
let user_result: R =
183
178
query_response. instantiate_projected ( self . tcx , & result_args, |q_r| q_r. value . clone ( ) ) ;
@@ -525,47 +520,6 @@ impl<'tcx> InferCtxt<'tcx> {
525
520
self . unify_canonical_vars ( cause, param_env, original_values, instantiated_query_response)
526
521
}
527
522
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
-
569
523
/// Given two sets of values for the same set of canonical variables, unify them.
570
524
/// The second set is produced lazily by supplying indices from the first set.
571
525
fn unify_canonical_vars (
0 commit comments