@@ -503,7 +503,7 @@ pub fn normalize_associated_type<'tcx,T>(tcx: &ty::ctxt<'tcx>, value: &T) -> T
503
503
{
504
504
debug ! ( "normalize_associated_type(t={:?})" , value) ;
505
505
506
- let value = erase_regions ( tcx , value) ;
506
+ let value = tcx . erase_regions ( value) ;
507
507
508
508
if !value. has_projection_types ( ) {
509
509
return value;
@@ -525,17 +525,15 @@ pub fn normalize_associated_type<'tcx,T>(tcx: &ty::ctxt<'tcx>, value: &T) -> T
525
525
fulfill_cx. register_predicate_obligation ( & infcx, obligation) ;
526
526
}
527
527
528
- let result = drain_fulfillment_cx_or_panic ( DUMMY_SP , & infcx, & mut fulfill_cx, & result) ;
529
-
530
- result
528
+ drain_fulfillment_cx_or_panic ( DUMMY_SP , & infcx, & mut fulfill_cx, & result)
531
529
}
532
530
533
531
pub fn drain_fulfillment_cx_or_panic < ' a , ' tcx , T > ( span : Span ,
534
532
infcx : & InferCtxt < ' a , ' tcx > ,
535
533
fulfill_cx : & mut traits:: FulfillmentContext < ' tcx > ,
536
534
result : & T )
537
535
-> T
538
- where T : TypeFoldable < ' tcx >
536
+ where T : TypeFoldable < ' tcx > + HasTypeFlags
539
537
{
540
538
match drain_fulfillment_cx ( infcx, fulfill_cx, result) {
541
539
Ok ( v) => v,
@@ -559,7 +557,7 @@ pub fn drain_fulfillment_cx<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
559
557
fulfill_cx : & mut traits:: FulfillmentContext < ' tcx > ,
560
558
result : & T )
561
559
-> Result < T , Vec < traits:: FulfillmentError < ' tcx > > >
562
- where T : TypeFoldable < ' tcx >
560
+ where T : TypeFoldable < ' tcx > + HasTypeFlags
563
561
{
564
562
debug ! ( "drain_fulfillment_cx(result={:?})" ,
565
563
result) ;
@@ -574,71 +572,8 @@ pub fn drain_fulfillment_cx<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
574
572
}
575
573
}
576
574
577
- // Use freshen to simultaneously replace all type variables with
578
- // their bindings and replace all regions with 'static. This is
579
- // sort of overkill because we do not expect there to be any
580
- // unbound type variables, hence no `TyFresh` types should ever be
581
- // inserted.
582
- Ok ( result. fold_with ( & mut infcx. freshener ( ) ) )
583
- }
584
-
585
- /// Returns an equivalent value with all free regions removed (note
586
- /// that late-bound regions remain, because they are important for
587
- /// subtyping, but they are anonymized and normalized as well). This
588
- /// is a stronger, caching version of `ty::fold::erase_regions`.
589
- pub fn erase_regions < ' tcx , T > ( cx : & ty:: ctxt < ' tcx > , value : & T ) -> T
590
- where T : TypeFoldable < ' tcx >
591
- {
592
- let value1 = value. fold_with ( & mut RegionEraser ( cx) ) ;
593
- debug ! ( "erase_regions({:?}) = {:?}" ,
594
- value, value1) ;
595
- return value1;
596
-
597
- struct RegionEraser < ' a , ' tcx : ' a > ( & ' a ty:: ctxt < ' tcx > ) ;
598
-
599
- impl < ' a , ' tcx > TypeFolder < ' tcx > for RegionEraser < ' a , ' tcx > {
600
- fn tcx ( & self ) -> & ty:: ctxt < ' tcx > { self . 0 }
601
-
602
- fn fold_ty ( & mut self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
603
- match self . tcx ( ) . normalized_cache . borrow ( ) . get ( & ty) . cloned ( ) {
604
- None => { }
605
- Some ( u) => return u
606
- }
607
-
608
- let t_norm = ty:: fold:: super_fold_ty ( self , ty) ;
609
- self . tcx ( ) . normalized_cache . borrow_mut ( ) . insert ( ty, t_norm) ;
610
- return t_norm;
611
- }
612
-
613
- fn fold_binder < T > ( & mut self , t : & ty:: Binder < T > ) -> ty:: Binder < T >
614
- where T : TypeFoldable < ' tcx >
615
- {
616
- let u = self . tcx ( ) . anonymize_late_bound_regions ( t) ;
617
- ty:: fold:: super_fold_binder ( self , & u)
618
- }
619
-
620
- fn fold_region ( & mut self , r : ty:: Region ) -> ty:: Region {
621
- // because late-bound regions affect subtyping, we can't
622
- // erase the bound/free distinction, but we can replace
623
- // all free regions with 'static.
624
- //
625
- // Note that we *CAN* replace early-bound regions -- the
626
- // type system never "sees" those, they get substituted
627
- // away. In trans, they will always be erased to 'static
628
- // whenever a substitution occurs.
629
- match r {
630
- ty:: ReLateBound ( ..) => r,
631
- _ => ty:: ReStatic
632
- }
633
- }
634
-
635
- fn fold_substs ( & mut self ,
636
- substs : & subst:: Substs < ' tcx > )
637
- -> subst:: Substs < ' tcx > {
638
- subst:: Substs { regions : subst:: ErasedRegions ,
639
- types : substs. types . fold_with ( self ) }
640
- }
641
- }
575
+ let result = infcx. resolve_type_vars_if_possible ( result) ;
576
+ Ok ( infcx. tcx . erase_regions ( & result) )
642
577
}
643
578
644
579
impl < ' a , ' tcx > InferCtxt < ' a , ' tcx > {
0 commit comments