raydium-io / raydium-contract-instructions

121 stars 122 forks source link

Not compiles with Rust 1.78.0 #23

Open palinko91 opened 6 months ago

palinko91 commented 6 months ago

The library compiled with 1.17.1 but with the new Rust version it not compiles anymore:


   --> raydium-contract-instructions/src/farm_instruction.rs:113:38
    |
113 |                 let value = unsafe { &mut *(&mut output[1] as *mut u8 as *mut InitArgs) };
    |                                      ^^^^^^^^^^^^---------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |                                                  |
    |                                                  backing allocation comes from here
    |
    = note: casting from `u8` (1 bytes) to `farm_instruction::InitArgs` (24 bytes)
    = note: `#[deny(invalid_reference_casting)]` on by default

error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused
   --> raydium-contract-instructions/src/farm_instruction.rs:119:38
    |
119 |                 let value = unsafe { &mut *(&mut output[1] as *mut u8 as *mut u64) };
    |                                      ^^^^^^^^^^^^---------^^^^^^^^^^^^^^^^^^^^^^^^
    |                                                  |
    |                                                  backing allocation comes from here
    |
    = note: casting from `u8` (1 bytes) to `u64` (8 bytes)

error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused
   --> raydium-contract-instructions/src/farm_instruction.rs:125:38
    |
125 |                 let value = unsafe { &mut *(&mut output[1] as *mut u8 as *mut u64) };
    |                                      ^^^^^^^^^^^^---------^^^^^^^^^^^^^^^^^^^^^^^^
    |                                                  |
    |                                                  backing allocation comes from here
    |
    = note: casting from `u8` (1 bytes) to `u64` (8 bytes)

error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused
   --> raydium-contract-instructions/src/farm_instruction.rs:141:38
    |
141 |                 let value = unsafe { &mut *(&mut output[1] as *mut u8 as *mut u64) };
    |                                      ^^^^^^^^^^^^---------^^^^^^^^^^^^^^^^^^^^^^^^
    |                                                  |
    |                                                  backing allocation comes from here
    |
    = note: casting from `u8` (1 bytes) to `u64` (8 bytes)

error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused
   --> raydium-contract-instructions/src/farm_instruction.rs:146:38
    |
146 |                 let value = unsafe { &mut *(&mut output[1] as *mut u8 as *mut u64) };
    |                                      ^^^^^^^^^^^^---------^^^^^^^^^^^^^^^^^^^^^^^^
    |                                                  |
    |                                                  backing allocation comes from here
    |
    = note: casting from `u8` (1 bytes) to `u64` (8 bytes)

error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused
   --> raydium-contract-instructions/src/staking_instruction.rs:108:38
    |
108 |                 let value = unsafe { &mut *(&mut output[1] as *mut u8 as *mut InitArgs) };
    |                                      ^^^^^^^^^^^^---------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |                                                  |
    |                                                  backing allocation comes from here
    |
    = note: casting from `u8` (1 bytes) to `staking_instruction::InitArgs` (32 bytes)

error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused
   --> raydium-contract-instructions/src/staking_instruction.rs:114:38
    |
114 |                 let value = unsafe { &mut *(&mut output[1] as *mut u8 as *mut u64) };
    |                                      ^^^^^^^^^^^^---------^^^^^^^^^^^^^^^^^^^^^^^^
    |                                                  |
    |                                                  backing allocation comes from here
    |
    = note: casting from `u8` (1 bytes) to `u64` (8 bytes)

error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused
   --> raydium-contract-instructions/src/staking_instruction.rs:120:38
    |
120 |                 let value = unsafe { &mut *(&mut output[1] as *mut u8 as *mut u64) };
    |                                      ^^^^^^^^^^^^---------^^^^^^^^^^^^^^^^^^^^^^^^
    |                                                  |
    |                                                  backing allocation comes from here
    |
    = note: casting from `u8` (1 bytes) to `u64` (8 bytes)

error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused
   --> raydium-contract-instructions/src/staking_instruction.rs:136:38
    |
136 |                 let value = unsafe { &mut *(&mut output[1] as *mut u8 as *mut u64) };
    |                                      ^^^^^^^^^^^^---------^^^^^^^^^^^^^^^^^^^^^^^^
    |                                                  |
    |                                                  backing allocation comes from here
    |
    = note: casting from `u8` (1 bytes) to `u64` (8 bytes)

error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused
   --> raydium-contract-instructions/src/staking_instruction.rs:141:38
    |
141 |                 let value = unsafe { &mut *(&mut output[1] as *mut u8 as *mut u64) };
    |                                      ^^^^^^^^^^^^---------^^^^^^^^^^^^^^^^^^^^^^^^
    |                                                  |
    |                                                  backing allocation comes from here
    |
    = note: casting from `u8` (1 bytes) to `u64` (8 bytes)

error: could not compile `raydium-contract-instructions` (lib) due to 10 previous errors```
ChefJodlak commented 6 months ago

Bump