@@ -630,12 +630,15 @@ impl methods for resolve_state {
630
630
fn resolve1( typ: ty:: t) -> ty:: t {
631
631
#debug( "Resolve1(%s)" , typ. to_str( self . infcx) ) ;
632
632
indent( fn & ( ) -> ty:: t {
633
- if !ty:: get ( typ) . has_vars { ret typ; }
633
+ if !ty:: type_needs_infer ( typ) { ret typ; }
634
634
635
- let tb = ty:: get( typ) ;
636
- alt tb. struct {
637
- ty : : ty_var( vid) { self . resolve_ty_var( vid) }
638
- _ if !tb. has_regions && !self. deep { typ }
635
+ alt ty:: get( typ) . struct {
636
+ ty : : ty_var( vid) {
637
+ self . resolve_ty_var( vid)
638
+ }
639
+ _ if !ty:: type_has_regions( typ) && !self . deep {
640
+ typ
641
+ }
639
642
_ {
640
643
ty:: fold_regions_and_ty(
641
644
self . infcx. tcx, typ,
@@ -935,6 +938,7 @@ iface combine {
935
938
fn contratys( a: ty:: t, b: ty:: t) -> cres < ty:: t > ;
936
939
fn tys( a: ty:: t, b: ty:: t) -> cres < ty:: t > ;
937
940
fn tps( as: [ ty:: t] , bs: [ ty:: t] ) -> cres < [ ty:: t ] > ;
941
+ fn self_tys( a: option < ty:: t > , b: option < ty:: t > ) -> cres < option < ty:: t > > ;
938
942
fn substs( as: ty:: substs, bs: ty:: substs) -> cres < ty:: substs > ;
939
943
fn fns( a: ty:: fn_ty, b: ty:: fn_ty) -> cres < ty:: fn_ty > ;
940
944
fn flds( a: ty:: field, b: ty:: field) -> cres < ty:: field > ;
@@ -982,8 +986,10 @@ fn super_substs<C:combine>(
982
986
}
983
987
984
988
self . tps( a. tps, b. tps) . chain { |tps|
985
- eq_opt_regions( self . infcx( ) , a. self_r, b. self_r) . chain { |self_r|
986
- ok ( { self_r : self_r, tps : tps} )
989
+ self . self_tys( a. self_ty, b. self_ty) . chain { |self_ty|
990
+ eq_opt_regions( self . infcx( ) , a. self_r, b. self_r) . chain { |self_r|
991
+ ok ( { self_r : self_r, self_ty : self_ty, tps : tps} )
992
+ }
987
993
}
988
994
}
989
995
}
@@ -995,6 +1001,7 @@ fn super_tps<C:combine>(
995
1001
// (otherwise the type system would be unsound). In the
996
1002
// future we could allow type parameters to declare a
997
1003
// variance.
1004
+
998
1005
if check vec:: same_length( as , bs) {
999
1006
iter2( as , bs) { |a, b| self . infcx( ) . eq_tys( a, b) } . then { ||
1000
1007
ok( as)
@@ -1004,6 +1011,31 @@ fn super_tps<C:combine>(
1004
1011
}
1005
1012
}
1006
1013
1014
+ fn super_self_tys < C : combine > (
1015
+ self : C , a: option < ty:: t > , b: option < ty:: t > ) -> cres < option < ty:: t > > {
1016
+
1017
+ // Note: the self type parameter is (currently) always treated as
1018
+ // *invariant* (otherwise the type system would be unsound).
1019
+
1020
+ alt ( a, b) {
1021
+ ( none, none) {
1022
+ ok( none)
1023
+ }
1024
+ ( some( a) , some( b) ) {
1025
+ self . infcx( ) . eq_tys( a, b) . then { ||
1026
+ ok( some( a) )
1027
+ }
1028
+ }
1029
+ ( none, some( _) ) |
1030
+ ( some( _) , none) {
1031
+ // I think it should never happen that we unify two substs and
1032
+ // one of them has a self_ty and one doesn't...? I could be
1033
+ // wrong about this.
1034
+ err( ty:: terr_self_substs)
1035
+ }
1036
+ }
1037
+ }
1038
+
1007
1039
fn super_flds < C : combine > (
1008
1040
self : C , a: ty:: field, b: ty:: field) -> cres < ty:: field > {
1009
1041
@@ -1374,6 +1406,10 @@ impl of combine for sub {
1374
1406
fn tps( as: [ ty:: t] , bs: [ ty:: t] ) -> cres < [ ty:: t ] > {
1375
1407
super_tps( self , as, bs)
1376
1408
}
1409
+
1410
+ fn self_tys( a: option < ty:: t > , b: option < ty:: t > ) -> cres < option < ty:: t > > {
1411
+ super_self_tys( self , a, b)
1412
+ }
1377
1413
}
1378
1414
1379
1415
impl of combine for lub {
@@ -1549,6 +1585,10 @@ impl of combine for lub {
1549
1585
fn tps( as : [ ty:: t] , bs: [ ty:: t] ) -> cres<[ ty:: t] > {
1550
1586
super_tps( self , as , bs)
1551
1587
}
1588
+
1589
+ fn self_tys( a: option<ty:: t>, b: option<ty:: t>) -> cres<option<ty:: t>> {
1590
+ super_self_tys( self , a, b)
1591
+ }
1552
1592
}
1553
1593
1554
1594
impl of combine for glb {
@@ -1739,6 +1779,10 @@ impl of combine for glb {
1739
1779
fn tps( as : [ ty:: t] , bs: [ ty:: t] ) -> cres<[ ty:: t] > {
1740
1780
super_tps( self , as , bs)
1741
1781
}
1782
+
1783
+ fn self_tys( a: option<ty:: t>, b: option<ty:: t>) -> cres<option<ty:: t>> {
1784
+ super_self_tys( self , a, b)
1785
+ }
1742
1786
}
1743
1787
1744
1788
// ______________________________________________________________________
0 commit comments