@@ -232,7 +232,7 @@ impl TyKind<'tcx> {
232232
233233// `TyKind` is used a lot. Make sure it doesn't unintentionally get bigger.
234234#[ cfg( all( target_arch = "x86_64" , target_pointer_width = "64" ) ) ]
235- static_assert_size ! ( TyKind <' _>, 24 ) ;
235+ static_assert_size ! ( TyKind <' _>, 32 ) ;
236236
237237/// A closure can be modeled as a struct that looks like:
238238///
@@ -957,7 +957,7 @@ impl<'tcx> PolyExistentialTraitRef<'tcx> {
957957///
958958/// `Decodable` and `Encodable` are implemented for `Binder<T>` using the `impl_binder_encode_decode!` macro.
959959#[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash , Debug ) ]
960- pub struct Binder < T > ( T ) ;
960+ pub struct Binder < T > ( T , u32 ) ;
961961
962962impl < T > Binder < T > {
963963 /// Wraps `value` in a binder, asserting that `value` does not
@@ -969,12 +969,12 @@ impl<T> Binder<T> {
969969 T : TypeFoldable < ' tcx > ,
970970 {
971971 debug_assert ! ( !value. has_escaping_bound_vars( ) ) ;
972- Binder ( value)
972+ Binder ( value, 0 )
973973 }
974974
975975 /// Wraps `value` in a binder, binding higher-ranked vars (if any).
976976 pub fn bind ( value : T ) -> Binder < T > {
977- Binder ( value)
977+ Binder ( value, 0 )
978978 }
979979
980980 /// Skips the binder and returns the "bound" value. This is a
@@ -998,7 +998,7 @@ impl<T> Binder<T> {
998998 }
999999
10001000 pub fn as_ref ( & self ) -> Binder < & T > {
1001- Binder ( & self . 0 )
1001+ Binder ( & self . 0 , self . 1 )
10021002 }
10031003
10041004 pub fn map_bound_ref < F , U > ( & self , f : F ) -> Binder < U >
@@ -1012,7 +1012,7 @@ impl<T> Binder<T> {
10121012 where
10131013 F : FnOnce ( T ) -> U ,
10141014 {
1015- Binder ( f ( self . 0 ) )
1015+ Binder ( f ( self . 0 ) , self . 1 )
10161016 }
10171017
10181018 /// Wraps a `value` in a binder, using the same bound variables as the
@@ -1025,7 +1025,7 @@ impl<T> Binder<T> {
10251025 /// because bound vars aren't allowed to change here, whereas they are
10261026 /// in `bind`. This may be (debug) asserted in the future.
10271027 pub fn rebind < U > ( & self , value : U ) -> Binder < U > {
1028- Binder ( value)
1028+ Binder ( value, self . 1 )
10291029 }
10301030
10311031 /// Unwraps and returns the value within, but only if it contains
@@ -1056,7 +1056,7 @@ impl<T> Binder<T> {
10561056 where
10571057 F : FnOnce ( T , U ) -> R ,
10581058 {
1059- Binder ( f ( self . 0 , u. 0 ) )
1059+ Binder ( f ( self . 0 , u. 0 ) , self . 1 )
10601060 }
10611061
10621062 /// Splits the contents into two things that share the same binder
@@ -1070,13 +1070,14 @@ impl<T> Binder<T> {
10701070 F : FnOnce ( T ) -> ( U , V ) ,
10711071 {
10721072 let ( u, v) = f ( self . 0 ) ;
1073- ( Binder ( u) , Binder ( v) )
1073+ ( Binder ( u, self . 1 ) , Binder ( v, self . 1 ) )
10741074 }
10751075}
10761076
10771077impl < T > Binder < Option < T > > {
10781078 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) )
10801081 }
10811082}
10821083
0 commit comments