@@ -4,9 +4,7 @@ use crate::infer::canonical::{
4
4
use crate :: infer:: { InferCtxt , InferOk } ;
5
5
use crate :: traits:: query:: Fallible ;
6
6
use crate :: traits:: ObligationCause ;
7
- use rustc_infer:: infer:: canonical:: { Canonical , Certainty } ;
8
- use rustc_infer:: traits:: query:: NoSolution ;
9
- use rustc_infer:: traits:: PredicateObligations ;
7
+ use rustc_infer:: infer:: canonical:: Canonical ;
10
8
use rustc_middle:: ty:: fold:: TypeFoldable ;
11
9
use rustc_middle:: ty:: { ParamEnvAnd , TyCtxt } ;
12
10
use std:: fmt;
@@ -19,6 +17,7 @@ pub mod implied_outlives_bounds;
19
17
pub mod normalize;
20
18
pub mod outlives;
21
19
pub mod prove_predicate;
20
+ use self :: prove_predicate:: ProvePredicate ;
22
21
pub mod subtype;
23
22
24
23
pub use rustc_middle:: traits:: query:: type_op:: * ;
@@ -81,14 +80,9 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Copy + TypeFoldable<'tcx> + 'tcx {
81
80
query_key : ParamEnvAnd < ' tcx , Self > ,
82
81
infcx : & InferCtxt < ' _ , ' tcx > ,
83
82
output_query_region_constraints : & mut QueryRegionConstraints < ' tcx > ,
84
- ) -> Fallible < (
85
- Self :: QueryResponse ,
86
- Option < Canonical < ' tcx , ParamEnvAnd < ' tcx , Self > > > ,
87
- PredicateObligations < ' tcx > ,
88
- Certainty ,
89
- ) > {
83
+ ) -> Fallible < ( Self :: QueryResponse , Option < Canonical < ' tcx , ParamEnvAnd < ' tcx , Self > > > ) > {
90
84
if let Some ( result) = QueryTypeOp :: try_fast_path ( infcx. tcx , & query_key) {
91
- return Ok ( ( result, None , vec ! [ ] , Certainty :: Proven ) ) ;
85
+ return Ok ( ( result, None ) ) ;
92
86
}
93
87
94
88
// FIXME(#33684) -- We need to use
@@ -110,7 +104,20 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Copy + TypeFoldable<'tcx> + 'tcx {
110
104
output_query_region_constraints,
111
105
) ?;
112
106
113
- Ok ( ( value, Some ( canonical_self) , obligations, canonical_result. value . certainty ) )
107
+ // Typically, instantiating NLL query results does not
108
+ // create obligations. However, in some cases there
109
+ // are unresolved type variables, and unify them *can*
110
+ // create obligations. In that case, we have to go
111
+ // fulfill them. We do this via a (recursive) query.
112
+ for obligation in obligations {
113
+ let ( ( ) , _) = ProvePredicate :: fully_perform_into (
114
+ obligation. param_env . and ( ProvePredicate :: new ( obligation. predicate ) ) ,
115
+ infcx,
116
+ output_query_region_constraints,
117
+ ) ?;
118
+ }
119
+
120
+ Ok ( ( value, Some ( canonical_self) ) )
114
121
}
115
122
}
116
123
@@ -122,39 +129,9 @@ where
122
129
123
130
fn fully_perform ( self , infcx : & InferCtxt < ' _ , ' tcx > ) -> Fallible < TypeOpOutput < ' tcx , Self > > {
124
131
let mut region_constraints = QueryRegionConstraints :: default ( ) ;
125
- let ( output, canonicalized_query, mut obligations , _ ) =
132
+ let ( output, canonicalized_query) =
126
133
Q :: fully_perform_into ( self , infcx, & mut region_constraints) ?;
127
134
128
- // Typically, instantiating NLL query results does not
129
- // create obligations. However, in some cases there
130
- // are unresolved type variables, and unify them *can*
131
- // create obligations. In that case, we have to go
132
- // fulfill them. We do this via a (recursive) query.
133
- while !obligations. is_empty ( ) {
134
- trace ! ( "{:#?}" , obligations) ;
135
- let mut progress = false ;
136
- for obligation in std:: mem:: take ( & mut obligations) {
137
- let obligation = infcx. resolve_vars_if_possible ( obligation) ;
138
- match ProvePredicate :: fully_perform_into (
139
- obligation. param_env . and ( ProvePredicate :: new ( obligation. predicate ) ) ,
140
- infcx,
141
- & mut region_constraints,
142
- ) {
143
- Ok ( ( ( ) , _, new, certainty) ) => {
144
- obligations. extend ( new) ;
145
- progress = true ;
146
- if let Certainty :: Ambiguous = certainty {
147
- obligations. push ( obligation) ;
148
- }
149
- }
150
- Err ( _) => obligations. push ( obligation) ,
151
- }
152
- }
153
- if !progress {
154
- return Err ( NoSolution ) ;
155
- }
156
- }
157
-
158
135
// Promote the final query-region-constraints into a
159
136
// (optional) ref-counted vector:
160
137
let region_constraints =
0 commit comments