@@ -161,9 +161,6 @@ pub trait SysvarSerialize:
161161/// Implements the [`Sysvar::get`] method for both SBF and host targets.
162162#[ macro_export]
163163macro_rules! impl_sysvar_get {
164- // DEPRECATED: This variant is only for the deprecated Fees sysvar and should be
165- // removed once Fees is no longer in use. It uses the old-style direct syscall
166- // approach instead of the new sol_get_sysvar syscall.
167164 ( $syscall_name: ident) => {
168165 fn get( ) -> Result <Self , $crate:: __private:: ProgramError > {
169166 let mut var = Self :: default ( ) ;
@@ -182,24 +179,6 @@ macro_rules! impl_sysvar_get {
182179 }
183180 }
184181 } ;
185- ( $sysvar_id: expr) => {
186- fn get( ) -> Result <Self , $crate:: __private:: ProgramError > {
187- // Allocate uninitialized memory for the sysvar struct
188- let mut uninit = core:: mem:: MaybeUninit :: <Self >:: uninit( ) ;
189- let size = core:: mem:: size_of:: <Self >( ) as u64 ;
190- // Safety: we build a mutable slice pointing to the uninitialized
191- // buffer. The `get_sysvar` syscall will fill exactly `size`
192- // bytes, after which the buffer is fully initialised.
193- let dst = unsafe {
194- core:: slice:: from_raw_parts_mut( uninit. as_mut_ptr( ) as * mut u8 , size as usize )
195- } ;
196- // Attempt to load the sysvar data using the provided sysvar id.
197- $crate:: get_sysvar( dst, & $sysvar_id, 0 , size) ?;
198- // Safety: `get_sysvar` succeeded and initialised the buffer.
199- let var = unsafe { uninit. assume_init( ) } ;
200- Ok ( var)
201- }
202- } ;
203182}
204183
205184/// Handler for retrieving a slice of sysvar data from the `sol_get_sysvar`
@@ -290,19 +269,6 @@ mod tests {
290269 } ) ) ;
291270 }
292271
293- /// Convert a value to its in-memory byte representation.
294- ///
295- /// Safety: This relies on the type's plain old data layout. Intended for tests.
296- pub fn to_bytes < T > ( value : & T ) -> Vec < u8 > {
297- unsafe {
298- let size = core:: mem:: size_of :: < T > ( ) ;
299- let ptr = ( value as * const T ) as * const u8 ;
300- let mut data = vec ! [ 0u8 ; size] ;
301- std:: ptr:: copy_nonoverlapping ( ptr, data. as_mut_ptr ( ) , size) ;
302- data
303- }
304- }
305-
306272 #[ test]
307273 fn test_sysvar_account_info_to_from ( ) {
308274 let test_sysvar = TestSysvar :: default ( ) ;
0 commit comments