diff --git a/program-test/src/lib.rs b/program-test/src/lib.rs index c6103a7bfa5992..2c0f92256c407c 100644 --- a/program-test/src/lib.rs +++ b/program-test/src/lib.rs @@ -90,8 +90,9 @@ thread_local! { static INVOKE_CONTEXT: RefCell> = const { RefCell::new(None) }; } fn set_invoke_context(new: &mut InvokeContext) { - INVOKE_CONTEXT - .with(|invoke_context| unsafe { invoke_context.replace(Some(transmute::<_, usize>(new))) }); + INVOKE_CONTEXT.with(|invoke_context| unsafe { + invoke_context.replace(Some(transmute::<&mut InvokeContext, usize>(new))) + }); } fn get_invoke_context<'a, 'b>() -> &'a mut InvokeContext<'b> { let ptr = INVOKE_CONTEXT.with(|invoke_context| match *invoke_context.borrow() { diff --git a/programs/bpf_loader/src/lib.rs b/programs/bpf_loader/src/lib.rs index c4d705efa5f1ff..84e703979bb4bd 100644 --- a/programs/bpf_loader/src/lib.rs +++ b/programs/bpf_loader/src/lib.rs @@ -1335,7 +1335,11 @@ fn execute<'a, 'b: 'a>( ) -> Result<(), Box> { // We dropped the lifetime tracking in the Executor by setting it to 'static, // thus we need to reintroduce the correct lifetime of InvokeContext here again. - let executable = unsafe { mem::transmute::<_, &'a Executable>>(executable) }; + let executable = unsafe { + mem::transmute::<&'a Executable>, &'a Executable>>( + executable, + ) + }; let log_collector = invoke_context.get_log_collector(); let transaction_context = &invoke_context.transaction_context; let instruction_context = transaction_context.get_current_instruction_context()?; diff --git a/programs/loader-v4/src/lib.rs b/programs/loader-v4/src/lib.rs index 6a3aa69b00d013..fd03b42155e1fc 100644 --- a/programs/loader-v4/src/lib.rs +++ b/programs/loader-v4/src/lib.rs @@ -146,8 +146,12 @@ fn execute<'a, 'b: 'a>( ) -> Result<(), Box> { // We dropped the lifetime tracking in the Executor by setting it to 'static, // thus we need to reintroduce the correct lifetime of InvokeContext here again. - let executable = - unsafe { std::mem::transmute::<_, &'a Executable>>(executable) }; + let executable = unsafe { + std::mem::transmute::< + &'a Executable>, + &'a Executable>, + >(executable) + }; let log_collector = invoke_context.get_log_collector(); let stack_height = invoke_context.get_stack_height(); let transaction_context = &invoke_context.transaction_context; diff --git a/programs/sbf/rust/invoke/src/processor.rs b/programs/sbf/rust/invoke/src/processor.rs index 1943f8f4b578db..e441ba872b3b81 100644 --- a/programs/sbf/rust/invoke/src/processor.rs +++ b/programs/sbf/rust/invoke/src/processor.rs @@ -67,9 +67,9 @@ fn do_nested_invokes(num_nested_invokes: u64, accounts: &[AccountInfo]) -> Progr } solana_program::entrypoint!(process_instruction); -fn process_instruction( +fn process_instruction<'a>( program_id: &Pubkey, - accounts: &[AccountInfo], + accounts: &[AccountInfo<'a>], instruction_data: &[u8], ) -> ProgramResult { msg!("invoke Rust program"); @@ -1158,7 +1158,7 @@ fn process_instruction( let mut lamports = account.lamports(); account .lamports - .replace(unsafe { mem::transmute(&mut lamports) }); + .replace(unsafe { mem::transmute::<&'_ mut u64, &'a mut u64>(&mut lamports) }); let callee_program_id = accounts[CALLEE_PROGRAM_INDEX].key; invoke( diff --git a/unified-scheduler-logic/src/lib.rs b/unified-scheduler-logic/src/lib.rs index 2bae4f603582f5..50647904ca61c2 100644 --- a/unified-scheduler-logic/src/lib.rs +++ b/unified-scheduler-logic/src/lib.rs @@ -316,8 +316,8 @@ mod utils { #[cfg_attr(miri, ignore)] fn test_ub_illegally_created_multiple_tokens() { // Unauthorized token minting! - let mut token1 = unsafe { mem::transmute(()) }; - let mut token2 = unsafe { mem::transmute(()) }; + let mut token1 = unsafe { mem::transmute::<(), Token>(()) }; + let mut token2 = unsafe { mem::transmute::<(), Token>(()) }; let queue = TokenCell::new(FakeQueue { v: Vec::with_capacity(20),