11use crate :: infer:: canonical:: {
22 Canonicalized , CanonicalizedQueryResponse , OriginalQueryValues , QueryRegionConstraints ,
33} ;
4- use crate :: infer:: { InferCtxt , InferOk } ;
4+ use crate :: infer:: { InferCtxt } ;
55use crate :: traits:: query:: Fallible ;
66use crate :: traits:: ObligationCause ;
77use rustc_infer:: infer:: canonical:: { Canonical , Certainty } ;
@@ -81,14 +81,14 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Copy + TypeFoldable<'tcx> + 'tcx {
8181 query_key : ParamEnvAnd < ' tcx , Self > ,
8282 infcx : & InferCtxt < ' _ , ' tcx > ,
8383 output_query_region_constraints : & mut QueryRegionConstraints < ' tcx > ,
84+ obligations : & mut PredicateObligations < ' tcx > ,
8485 ) -> Fallible < (
8586 Self :: QueryResponse ,
8687 Option < Canonical < ' tcx , ParamEnvAnd < ' tcx , Self > > > ,
87- PredicateObligations < ' tcx > ,
8888 Certainty ,
8989 ) > {
9090 if let Some ( result) = QueryTypeOp :: try_fast_path ( infcx. tcx , & query_key) {
91- return Ok ( ( result, None , vec ! [ ] , Certainty :: Proven ) ) ;
91+ return Ok ( ( result, None , Certainty :: Proven ) ) ;
9292 }
9393
9494 // FIXME(#33684) -- We need to use
@@ -101,16 +101,17 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Copy + TypeFoldable<'tcx> + 'tcx {
101101 infcx. canonicalize_query_keep_static ( query_key, & mut canonical_var_values) ;
102102 let canonical_result = Self :: perform_query ( infcx. tcx , canonical_self) ?;
103103
104- let InferOk { value, obligations } = infcx
104+ let value = infcx
105105 . instantiate_nll_query_response_and_region_obligations (
106106 & ObligationCause :: dummy ( ) ,
107107 old_param_env,
108108 & canonical_var_values,
109109 canonical_result,
110110 output_query_region_constraints,
111+ obligations,
111112 ) ?;
112113
113- Ok ( ( value, Some ( canonical_self) , obligations , canonical_result. value . certainty ) )
114+ Ok ( ( value, Some ( canonical_self) , canonical_result. value . certainty ) )
114115 }
115116}
116117
@@ -122,8 +123,9 @@ where
122123
123124 fn fully_perform ( self , infcx : & InferCtxt < ' _ , ' tcx > ) -> Fallible < TypeOpOutput < ' tcx , Self > > {
124125 let mut region_constraints = QueryRegionConstraints :: default ( ) ;
125- let ( output, canonicalized_query, mut obligations, _) =
126- Q :: fully_perform_into ( self , infcx, & mut region_constraints) ?;
126+ let mut obligations = Vec :: new ( ) ;
127+ let ( output, canonicalized_query, _) =
128+ Q :: fully_perform_into ( self , infcx, & mut region_constraints, & mut obligations) ?;
127129
128130 // Typically, instantiating NLL query results does not
129131 // create obligations. However, in some cases there
@@ -133,15 +135,15 @@ where
133135 while !obligations. is_empty ( ) {
134136 trace ! ( "{:#?}" , obligations) ;
135137 let mut progress = false ;
136- for obligation in std :: mem :: take ( & mut obligations) {
137- let obligation = infcx. resolve_vars_if_possible ( obligation ) ;
138+ for _ in 0 .. obligations. len ( ) {
139+ let obligation = infcx. resolve_vars_if_possible ( obligations . swap_remove ( 0 ) ) ;
138140 match ProvePredicate :: fully_perform_into (
139141 obligation. param_env . and ( ProvePredicate :: new ( obligation. predicate ) ) ,
140142 infcx,
141143 & mut region_constraints,
144+ & mut obligations,
142145 ) {
143- Ok ( ( ( ) , _, new, certainty) ) => {
144- obligations. extend ( new) ;
146+ Ok ( ( ( ) , _, certainty) ) => {
145147 progress = true ;
146148 if let Certainty :: Ambiguous = certainty {
147149 obligations. push ( obligation) ;
0 commit comments