@@ -960,6 +960,20 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::error::ExpectedFoun
960
960
}
961
961
}
962
962
963
+ impl < ' tcx > TypeFoldable < ' tcx > for type_variable:: Default < ' tcx > {
964
+ fn super_fold_with < ' gcx : ' tcx , F : TypeFolder < ' gcx , ' tcx > > ( & self , folder : & mut F ) -> Self {
965
+ type_variable:: Default {
966
+ ty : self . ty . fold_with ( folder) ,
967
+ origin_span : self . origin_span ,
968
+ def_id : self . def_id
969
+ }
970
+ }
971
+
972
+ fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
973
+ self . ty . visit_with ( visitor)
974
+ }
975
+ }
976
+
963
977
impl < ' tcx , T : TypeFoldable < ' tcx > , I : Idx > TypeFoldable < ' tcx > for IndexVec < I , T > {
964
978
fn super_fold_with < ' gcx : ' tcx , F : TypeFolder < ' gcx , ' tcx > > ( & self , folder : & mut F ) -> Self {
965
979
self . iter ( ) . map ( |x| x. fold_with ( folder) ) . collect ( )
@@ -969,3 +983,79 @@ impl<'tcx, T: TypeFoldable<'tcx>, I: Idx> TypeFoldable<'tcx> for IndexVec<I, T>
969
983
self . iter ( ) . any ( |t| t. visit_with ( visitor) )
970
984
}
971
985
}
986
+
987
+ impl < ' tcx > TypeFoldable < ' tcx > for ty:: error:: TypeError < ' tcx > {
988
+ fn super_fold_with < ' gcx : ' tcx , F : TypeFolder < ' gcx , ' tcx > > ( & self , folder : & mut F ) -> Self {
989
+ use ty:: error:: TypeError :: * ;
990
+
991
+ match * self {
992
+ Mismatch => Mismatch ,
993
+ UnsafetyMismatch ( x) => UnsafetyMismatch ( x. fold_with ( folder) ) ,
994
+ AbiMismatch ( x) => AbiMismatch ( x. fold_with ( folder) ) ,
995
+ Mutability => Mutability ,
996
+ TupleSize ( x) => TupleSize ( x) ,
997
+ FixedArraySize ( x) => FixedArraySize ( x) ,
998
+ ArgCount => ArgCount ,
999
+ RegionsDoesNotOutlive ( a, b) => {
1000
+ RegionsDoesNotOutlive ( a. fold_with ( folder) , b. fold_with ( folder) )
1001
+ } ,
1002
+ RegionsNotSame ( a, b) => {
1003
+ RegionsNotSame ( a. fold_with ( folder) , b. fold_with ( folder) )
1004
+ } ,
1005
+ RegionsNoOverlap ( a, b) => {
1006
+ RegionsNoOverlap ( a. fold_with ( folder) , b. fold_with ( folder) )
1007
+ } ,
1008
+ RegionsInsufficientlyPolymorphic ( a, b, ref c) => {
1009
+ let c = c. clone ( ) ;
1010
+ RegionsInsufficientlyPolymorphic ( a, b. fold_with ( folder) , c)
1011
+ } ,
1012
+ RegionsOverlyPolymorphic ( a, b, ref c) => {
1013
+ let c = c. clone ( ) ;
1014
+ RegionsOverlyPolymorphic ( a, b. fold_with ( folder) , c)
1015
+ } ,
1016
+ IntMismatch ( x) => IntMismatch ( x) ,
1017
+ FloatMismatch ( x) => FloatMismatch ( x) ,
1018
+ Traits ( x) => Traits ( x) ,
1019
+ VariadicMismatch ( x) => VariadicMismatch ( x) ,
1020
+ CyclicTy => CyclicTy ,
1021
+ ProjectionNameMismatched ( x) => ProjectionNameMismatched ( x) ,
1022
+ ProjectionBoundsLength ( x) => ProjectionBoundsLength ( x) ,
1023
+ Sorts ( x) => Sorts ( x. fold_with ( folder) ) ,
1024
+ TyParamDefaultMismatch ( ref x) => TyParamDefaultMismatch ( x. fold_with ( folder) ) ,
1025
+ ExistentialMismatch ( x) => ExistentialMismatch ( x. fold_with ( folder) ) ,
1026
+ }
1027
+ }
1028
+
1029
+ fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
1030
+ use ty:: error:: TypeError :: * ;
1031
+
1032
+ match * self {
1033
+ UnsafetyMismatch ( x) => x. visit_with ( visitor) ,
1034
+ AbiMismatch ( x) => x. visit_with ( visitor) ,
1035
+ RegionsDoesNotOutlive ( a, b) |
1036
+ RegionsNotSame ( a, b) |
1037
+ RegionsNoOverlap ( a, b) => {
1038
+ a. visit_with ( visitor) || b. visit_with ( visitor)
1039
+ } ,
1040
+ RegionsInsufficientlyPolymorphic ( _, b, _) |
1041
+ RegionsOverlyPolymorphic ( _, b, _) => {
1042
+ b. visit_with ( visitor)
1043
+ } ,
1044
+ Sorts ( x) => x. visit_with ( visitor) ,
1045
+ TyParamDefaultMismatch ( ref x) => x. visit_with ( visitor) ,
1046
+ ExistentialMismatch ( x) => x. visit_with ( visitor) ,
1047
+ Mismatch |
1048
+ Mutability |
1049
+ TupleSize ( _) |
1050
+ FixedArraySize ( _) |
1051
+ ArgCount |
1052
+ IntMismatch ( _) |
1053
+ FloatMismatch ( _) |
1054
+ Traits ( _) |
1055
+ VariadicMismatch ( _) |
1056
+ CyclicTy |
1057
+ ProjectionNameMismatched ( _) |
1058
+ ProjectionBoundsLength ( _) => false ,
1059
+ }
1060
+ }
1061
+ }
0 commit comments