1
1
use crate :: infer:: canonical:: {
2
2
Canonicalized , CanonicalizedQueryResponse , OriginalQueryValues , QueryRegionConstraints ,
3
3
} ;
4
- use crate :: infer:: { InferCtxt , InferOk } ;
4
+ use crate :: infer:: { InferCtxt } ;
5
5
use crate :: traits:: query:: Fallible ;
6
6
use crate :: traits:: ObligationCause ;
7
7
use rustc_infer:: infer:: canonical:: { Canonical , Certainty } ;
@@ -81,14 +81,14 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Copy + TypeFoldable<'tcx> + 'tcx {
81
81
query_key : ParamEnvAnd < ' tcx , Self > ,
82
82
infcx : & InferCtxt < ' _ , ' tcx > ,
83
83
output_query_region_constraints : & mut QueryRegionConstraints < ' tcx > ,
84
+ obligations : & mut PredicateObligations < ' tcx > ,
84
85
) -> Fallible < (
85
86
Self :: QueryResponse ,
86
87
Option < Canonical < ' tcx , ParamEnvAnd < ' tcx , Self > > > ,
87
- PredicateObligations < ' tcx > ,
88
88
Certainty ,
89
89
) > {
90
90
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 ) ) ;
92
92
}
93
93
94
94
// FIXME(#33684) -- We need to use
@@ -101,16 +101,17 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Copy + TypeFoldable<'tcx> + 'tcx {
101
101
infcx. canonicalize_query_keep_static ( query_key, & mut canonical_var_values) ;
102
102
let canonical_result = Self :: perform_query ( infcx. tcx , canonical_self) ?;
103
103
104
- let InferOk { value, obligations } = infcx
104
+ let value = infcx
105
105
. instantiate_nll_query_response_and_region_obligations (
106
106
& ObligationCause :: dummy ( ) ,
107
107
old_param_env,
108
108
& canonical_var_values,
109
109
canonical_result,
110
110
output_query_region_constraints,
111
+ obligations,
111
112
) ?;
112
113
113
- Ok ( ( value, Some ( canonical_self) , obligations , canonical_result. value . certainty ) )
114
+ Ok ( ( value, Some ( canonical_self) , canonical_result. value . certainty ) )
114
115
}
115
116
}
116
117
@@ -122,8 +123,9 @@ where
122
123
123
124
fn fully_perform ( self , infcx : & InferCtxt < ' _ , ' tcx > ) -> Fallible < TypeOpOutput < ' tcx , Self > > {
124
125
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) ?;
127
129
128
130
// Typically, instantiating NLL query results does not
129
131
// create obligations. However, in some cases there
@@ -133,15 +135,15 @@ where
133
135
while !obligations. is_empty ( ) {
134
136
trace ! ( "{:#?}" , obligations) ;
135
137
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 ) ) ;
138
140
match ProvePredicate :: fully_perform_into (
139
141
obligation. param_env . and ( ProvePredicate :: new ( obligation. predicate ) ) ,
140
142
infcx,
141
143
& mut region_constraints,
144
+ & mut obligations,
142
145
) {
143
- Ok ( ( ( ) , _, new, certainty) ) => {
144
- obligations. extend ( new) ;
146
+ Ok ( ( ( ) , _, certainty) ) => {
145
147
progress = true ;
146
148
if let Certainty :: Ambiguous = certainty {
147
149
obligations. push ( obligation) ;
0 commit comments