@@ -18,17 +18,15 @@ use rustc_index::IndexVec;
18
18
use rustc_infer:: infer:: canonical:: query_response:: make_query_region_constraints;
19
19
use rustc_infer:: infer:: canonical:: CanonicalVarValues ;
20
20
use rustc_infer:: infer:: canonical:: { CanonicalExt , QueryRegionConstraints } ;
21
+ use rustc_infer:: infer:: resolve:: EagerResolver ;
21
22
use rustc_infer:: infer:: { DefineOpaqueTypes , InferCtxt , InferOk } ;
22
23
use rustc_middle:: infer:: canonical:: Canonical ;
23
24
use rustc_middle:: traits:: query:: NoSolution ;
24
25
use rustc_middle:: traits:: solve:: {
25
26
ExternalConstraintsData , MaybeCause , PredefinedOpaquesData , QueryInput ,
26
27
} ;
27
28
use rustc_middle:: traits:: ObligationCause ;
28
- use rustc_middle:: ty:: {
29
- self , BoundVar , GenericArgKind , Ty , TyCtxt , TypeFoldable , TypeFolder , TypeSuperFoldable ,
30
- TypeVisitableExt ,
31
- } ;
29
+ use rustc_middle:: ty:: { self , BoundVar , GenericArgKind , Ty , TyCtxt , TypeFoldable } ;
32
30
use rustc_span:: DUMMY_SP ;
33
31
use std:: iter;
34
32
use std:: ops:: Deref ;
@@ -58,7 +56,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
58
56
) -> ( Vec < ty:: GenericArg < ' tcx > > , CanonicalInput < ' tcx , T > ) {
59
57
let opaque_types = self . infcx . clone_opaque_types_for_query_response ( ) ;
60
58
let ( goal, opaque_types) =
61
- ( goal, opaque_types) . fold_with ( & mut EagerResolver { infcx : self . infcx } ) ;
59
+ ( goal, opaque_types) . fold_with ( & mut EagerResolver :: new ( self . infcx ) ) ;
62
60
63
61
let mut orig_values = Default :: default ( ) ;
64
62
let canonical_goal = Canonicalizer :: canonicalize (
@@ -115,7 +113,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
115
113
let external_constraints = self . compute_external_query_constraints ( ) ?;
116
114
117
115
let ( var_values, mut external_constraints) =
118
- ( var_values, external_constraints) . fold_with ( & mut EagerResolver { infcx : self . infcx } ) ;
116
+ ( var_values, external_constraints) . fold_with ( & mut EagerResolver :: new ( self . infcx ) ) ;
119
117
// Remove any trivial region constraints once we've resolved regions
120
118
external_constraints
121
119
. region_constraints
@@ -364,86 +362,13 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
364
362
}
365
363
}
366
364
367
- /// Resolves ty, region, and const vars to their inferred values or their root vars.
368
- struct EagerResolver < ' a , ' tcx > {
369
- infcx : & ' a InferCtxt < ' tcx > ,
370
- }
371
-
372
- impl < ' tcx > TypeFolder < TyCtxt < ' tcx > > for EagerResolver < ' _ , ' tcx > {
373
- fn interner ( & self ) -> TyCtxt < ' tcx > {
374
- self . infcx . tcx
375
- }
376
-
377
- fn fold_ty ( & mut self , t : Ty < ' tcx > ) -> Ty < ' tcx > {
378
- match * t. kind ( ) {
379
- ty:: Infer ( ty:: TyVar ( vid) ) => match self . infcx . probe_ty_var ( vid) {
380
- Ok ( t) => t. fold_with ( self ) ,
381
- Err ( _) => Ty :: new_var ( self . infcx . tcx , self . infcx . root_var ( vid) ) ,
382
- } ,
383
- ty:: Infer ( ty:: IntVar ( vid) ) => self . infcx . opportunistic_resolve_int_var ( vid) ,
384
- ty:: Infer ( ty:: FloatVar ( vid) ) => self . infcx . opportunistic_resolve_float_var ( vid) ,
385
- _ => {
386
- if t. has_infer ( ) {
387
- t. super_fold_with ( self )
388
- } else {
389
- t
390
- }
391
- }
392
- }
393
- }
394
-
395
- fn fold_region ( & mut self , r : ty:: Region < ' tcx > ) -> ty:: Region < ' tcx > {
396
- match * r {
397
- ty:: ReVar ( vid) => self
398
- . infcx
399
- . inner
400
- . borrow_mut ( )
401
- . unwrap_region_constraints ( )
402
- . opportunistic_resolve_var ( self . infcx . tcx , vid) ,
403
- _ => r,
404
- }
405
- }
406
-
407
- fn fold_const ( & mut self , c : ty:: Const < ' tcx > ) -> ty:: Const < ' tcx > {
408
- match c. kind ( ) {
409
- ty:: ConstKind :: Infer ( ty:: InferConst :: Var ( vid) ) => {
410
- // FIXME: we need to fold the ty too, I think.
411
- match self . infcx . probe_const_var ( vid) {
412
- Ok ( c) => c. fold_with ( self ) ,
413
- Err ( _) => {
414
- ty:: Const :: new_var ( self . infcx . tcx , self . infcx . root_const_var ( vid) , c. ty ( ) )
415
- }
416
- }
417
- }
418
- ty:: ConstKind :: Infer ( ty:: InferConst :: EffectVar ( vid) ) => {
419
- debug_assert_eq ! ( c. ty( ) , self . infcx. tcx. types. bool ) ;
420
- match self . infcx . probe_effect_var ( vid) {
421
- Some ( c) => c. as_const ( self . infcx . tcx ) ,
422
- None => ty:: Const :: new_infer (
423
- self . infcx . tcx ,
424
- ty:: InferConst :: EffectVar ( self . infcx . root_effect_var ( vid) ) ,
425
- self . infcx . tcx . types . bool ,
426
- ) ,
427
- }
428
- }
429
- _ => {
430
- if c. has_infer ( ) {
431
- c. super_fold_with ( self )
432
- } else {
433
- c
434
- }
435
- }
436
- }
437
- }
438
- }
439
-
440
365
impl < ' tcx > inspect:: ProofTreeBuilder < ' tcx > {
441
366
pub fn make_canonical_state < T : TypeFoldable < TyCtxt < ' tcx > > > (
442
367
ecx : & EvalCtxt < ' _ , ' tcx > ,
443
368
data : T ,
444
369
) -> inspect:: CanonicalState < ' tcx , T > {
445
370
let state = inspect:: State { var_values : ecx. var_values , data } ;
446
- let state = state. fold_with ( & mut EagerResolver { infcx : ecx. infcx } ) ;
371
+ let state = state. fold_with ( & mut EagerResolver :: new ( ecx. infcx ) ) ;
447
372
Canonicalizer :: canonicalize (
448
373
ecx. infcx ,
449
374
CanonicalizeMode :: Response { max_input_universe : ecx. max_input_universe } ,
0 commit comments