@@ -18,17 +18,15 @@ use rustc_index::IndexVec;
1818use rustc_infer:: infer:: canonical:: query_response:: make_query_region_constraints;
1919use rustc_infer:: infer:: canonical:: CanonicalVarValues ;
2020use rustc_infer:: infer:: canonical:: { CanonicalExt , QueryRegionConstraints } ;
21+ use rustc_infer:: infer:: resolve:: EagerResolver ;
2122use rustc_infer:: infer:: { DefineOpaqueTypes , InferCtxt , InferOk } ;
2223use rustc_middle:: infer:: canonical:: Canonical ;
2324use rustc_middle:: traits:: query:: NoSolution ;
2425use rustc_middle:: traits:: solve:: {
2526 ExternalConstraintsData , MaybeCause , PredefinedOpaquesData , QueryInput ,
2627} ;
2728use 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 } ;
3230use rustc_span:: DUMMY_SP ;
3331use std:: iter;
3432use std:: ops:: Deref ;
@@ -58,7 +56,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
5856 ) -> ( Vec < ty:: GenericArg < ' tcx > > , CanonicalInput < ' tcx , T > ) {
5957 let opaque_types = self . infcx . clone_opaque_types_for_query_response ( ) ;
6058 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 ) ) ;
6260
6361 let mut orig_values = Default :: default ( ) ;
6462 let canonical_goal = Canonicalizer :: canonicalize (
@@ -115,7 +113,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
115113 let external_constraints = self . compute_external_query_constraints ( ) ?;
116114
117115 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 ) ) ;
119117 // Remove any trivial region constraints once we've resolved regions
120118 external_constraints
121119 . region_constraints
@@ -364,86 +362,13 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
364362 }
365363}
366364
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-
440365impl < ' tcx > inspect:: ProofTreeBuilder < ' tcx > {
441366 pub fn make_canonical_state < T : TypeFoldable < TyCtxt < ' tcx > > > (
442367 ecx : & EvalCtxt < ' _ , ' tcx > ,
443368 data : T ,
444369 ) -> inspect:: CanonicalState < ' tcx , T > {
445370 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 ) ) ;
447372 Canonicalizer :: canonicalize (
448373 ecx. infcx ,
449374 CanonicalizeMode :: Response { max_input_universe : ecx. max_input_universe } ,
0 commit comments