@@ -232,7 +232,7 @@ impl TyKind<'tcx> {
232
232
233
233
// `TyKind` is used a lot. Make sure it doesn't unintentionally get bigger.
234
234
#[ cfg( all( target_arch = "x86_64" , target_pointer_width = "64" ) ) ]
235
- static_assert_size ! ( TyKind <' _>, 24 ) ;
235
+ static_assert_size ! ( TyKind <' _>, 32 ) ;
236
236
237
237
/// A closure can be modeled as a struct that looks like:
238
238
///
@@ -957,7 +957,7 @@ impl<'tcx> PolyExistentialTraitRef<'tcx> {
957
957
///
958
958
/// `Decodable` and `Encodable` are implemented for `Binder<T>` using the `impl_binder_encode_decode!` macro.
959
959
#[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash , Debug ) ]
960
- pub struct Binder < T > ( T ) ;
960
+ pub struct Binder < T > ( T , u32 ) ;
961
961
962
962
impl < T > Binder < T > {
963
963
/// Wraps `value` in a binder, asserting that `value` does not
@@ -969,12 +969,12 @@ impl<T> Binder<T> {
969
969
T : TypeFoldable < ' tcx > ,
970
970
{
971
971
debug_assert ! ( !value. has_escaping_bound_vars( ) ) ;
972
- Binder ( value)
972
+ Binder ( value, 0 )
973
973
}
974
974
975
975
/// Wraps `value` in a binder, binding higher-ranked vars (if any).
976
976
pub fn bind ( value : T ) -> Binder < T > {
977
- Binder ( value)
977
+ Binder ( value, 0 )
978
978
}
979
979
980
980
/// Skips the binder and returns the "bound" value. This is a
@@ -998,7 +998,7 @@ impl<T> Binder<T> {
998
998
}
999
999
1000
1000
pub fn as_ref ( & self ) -> Binder < & T > {
1001
- Binder ( & self . 0 )
1001
+ Binder ( & self . 0 , self . 1 )
1002
1002
}
1003
1003
1004
1004
pub fn map_bound_ref < F , U > ( & self , f : F ) -> Binder < U >
@@ -1012,7 +1012,7 @@ impl<T> Binder<T> {
1012
1012
where
1013
1013
F : FnOnce ( T ) -> U ,
1014
1014
{
1015
- Binder ( f ( self . 0 ) )
1015
+ Binder ( f ( self . 0 ) , self . 1 )
1016
1016
}
1017
1017
1018
1018
/// Wraps a `value` in a binder, using the same bound variables as the
@@ -1025,7 +1025,7 @@ impl<T> Binder<T> {
1025
1025
/// because bound vars aren't allowed to change here, whereas they are
1026
1026
/// in `bind`. This may be (debug) asserted in the future.
1027
1027
pub fn rebind < U > ( & self , value : U ) -> Binder < U > {
1028
- Binder ( value)
1028
+ Binder ( value, self . 1 )
1029
1029
}
1030
1030
1031
1031
/// Unwraps and returns the value within, but only if it contains
@@ -1056,7 +1056,7 @@ impl<T> Binder<T> {
1056
1056
where
1057
1057
F : FnOnce ( T , U ) -> R ,
1058
1058
{
1059
- Binder ( f ( self . 0 , u. 0 ) )
1059
+ Binder ( f ( self . 0 , u. 0 ) , self . 1 )
1060
1060
}
1061
1061
1062
1062
/// Splits the contents into two things that share the same binder
@@ -1070,13 +1070,14 @@ impl<T> Binder<T> {
1070
1070
F : FnOnce ( T ) -> ( U , V ) ,
1071
1071
{
1072
1072
let ( u, v) = f ( self . 0 ) ;
1073
- ( Binder ( u) , Binder ( v) )
1073
+ ( Binder ( u, self . 1 ) , Binder ( v, self . 1 ) )
1074
1074
}
1075
1075
}
1076
1076
1077
1077
impl < T > Binder < Option < T > > {
1078
1078
pub fn transpose ( self ) -> Option < Binder < T > > {
1079
- self . 0 . map ( Binder )
1079
+ let bound_vars = self . 1 ;
1080
+ self . 0 . map ( |v| Binder ( v, bound_vars) )
1080
1081
}
1081
1082
}
1082
1083
0 commit comments