Skip to content

Commit

Permalink
Merge pull request #1884 from multiversx/mvec-ref-mut-rename
Browse files Browse the repository at this point in the history
ManagedVecRefMut rename
  • Loading branch information
andrei-marinica authored Nov 28, 2024
2 parents 5aa2f18 + d173698 commit cbd9a3c
Show file tree
Hide file tree
Showing 40 changed files with 59 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use crate::tx_mock::{BlockchainUpdate, TxCache, TxInput, TxResult};

/// Every unimplemented fn will be implemented and moved to its corresponding file.
///
/// This file will be deleted.
pub fn register_meta_esdt(tx_input: TxInput, tx_cache: TxCache) -> (TxResult, BlockchainUpdate) {
unimplemented!()
}
Expand Down
1 change: 1 addition & 0 deletions contracts/examples/crypto-kitties/common/random/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub trait Randomizeable {

impl Random {
/// block random seed + salt creates a stronger randomness source
#[allow(static_mut_refs)]
pub fn new<M: ManagedTypeApi>(
seed: ManagedByteArray<M, SEED_SIZE>,
salt: ManagedByteArray<M, SALT_SIZE>,
Expand Down
1 change: 0 additions & 1 deletion data/codec/src/impl_for_types/impl_phantom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::{
/// Empty structure with an empty bytes representation. Equivalent to `false`, `0` or `[u8; 0]`, but more explicit.
///
/// Note: the unit type `()` would have naturally fit this role, but we decided to make the unit type multi-value only.
impl<T> TopEncode for PhantomData<T> {
#[inline]
fn top_encode_or_handle_err<O, H>(&self, output: O, _h: H) -> Result<(), H::HandledErr>
Expand Down
2 changes: 1 addition & 1 deletion data/codec/src/single/nested_de_input_slice.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{DecodeError, DecodeErrorHandler, NestedDecode, NestedDecodeInput};

/// A nested decode buffer implementation on referenced data.
impl<'a> NestedDecodeInput for &'a [u8] {
impl NestedDecodeInput for &[u8] {
fn remaining_len(&self) -> usize {
self.len()
}
Expand Down
1 change: 0 additions & 1 deletion data/codec/src/single/top_en_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::{
use alloc::vec::Vec;

/// Specifies objects that can receive the result of a TopEncode computation.
/// in principle from NestedEncode performed on nested items.
///
/// All methods consume the object, so they can only be called once.
Expand Down
1 change: 1 addition & 0 deletions framework/base/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![no_std]
#![allow(deprecated)]
#![allow(clippy::needless_lifetimes)] // TODO: fix them all!

pub use multiversx_sc_derive::{self as derive, contract, module, proxy};

Expand Down
2 changes: 1 addition & 1 deletion framework/base/src/storage/mappers/map_mapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ where
}
}

impl<'a, SA, A, K, V> VacantEntry<'a, SA, A, K, V>
impl<SA, A, K, V> VacantEntry<'_, SA, A, K, V>
where
SA: StorageMapperApi,
A: StorageAddress<SA>,
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion framework/base/src/types/managed/basic/managed_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ impl<M: ManagedTypeApi> ManagedBuffer<M> {
/// ## Safety
///
/// The reference points to a shared value. Make sure the handle is not leaked.
pub unsafe fn temp_const_ref(
raw_handle: RawHandle,
) -> ManagedRef<'static, M, ManagedBuffer<M>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ mod managed_vec_item;
mod managed_vec_item_nested_tuple;
mod managed_vec_item_payload;
mod managed_vec_owned_iter;
mod managed_vec_ref;
mod managed_vec_ref_iter;
mod managed_vec_ref_mut;
pub(crate) mod preloaded_managed_buffer;
mod randomness_source;
mod token_identifier;
Expand Down Expand Up @@ -53,8 +53,8 @@ pub use managed_vec_item::{
pub use managed_vec_item_nested_tuple::ManagedVecItemNestedTuple;
pub use managed_vec_item_payload::*;
pub use managed_vec_owned_iter::ManagedVecOwnedIterator;
pub use managed_vec_ref::ManagedVecRef;
pub use managed_vec_ref_iter::ManagedVecRefIterator;
pub use managed_vec_ref_mut::ManagedVecRefMut;
pub use randomness_source::RandomnessSource;
pub use token_identifier::TokenIdentifier;

Expand Down
4 changes: 2 additions & 2 deletions framework/base/src/types/managed/wrapped/managed_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ where
}
}

impl<'a, M, T> NestedEncode for ManagedRef<'a, M, T>
impl<M, T> NestedEncode for ManagedRef<'_, M, T>
where
M: ManagedTypeApi,
T: ManagedType<M> + NestedEncode,
Expand All @@ -158,7 +158,7 @@ where
}
}

impl<'a, M, T> core::fmt::Debug for ManagedRef<'a, M, T>
impl<M, T> core::fmt::Debug for ManagedRef<'_, M, T>
where
M: ManagedTypeApi,
T: ManagedType<M> + core::fmt::Debug,
Expand Down
14 changes: 7 additions & 7 deletions framework/base/src/types/managed/wrapped/managed_ref_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ where
pub(super) handle: T::OwnHandle,
}

impl<'a, M, T> ManagedRefMut<'a, M, T>
impl<M, T> ManagedRefMut<'_, M, T>
where
M: ManagedTypeApi,
T: ManagedType<M>,
{
pub fn new(value: &'a mut T) -> Self {
pub fn new(value: &mut T) -> Self {
Self {
_phantom_m: PhantomData,
_phantom_t: PhantomData,
Expand All @@ -44,7 +44,7 @@ where
}
}

impl<'a, M, T> ManagedRefMut<'a, M, T>
impl<M, T> ManagedRefMut<'_, M, T>
where
M: ManagedTypeApi,
T: ManagedType<M> + Clone,
Expand All @@ -55,7 +55,7 @@ where
}
}

impl<'a, M, T> Clone for ManagedRefMut<'a, M, T>
impl<M, T> Clone for ManagedRefMut<'_, M, T>
where
M: ManagedTypeApi,
T: ManagedType<M>,
Expand All @@ -70,7 +70,7 @@ where
}
}

impl<'a, M, T> Deref for ManagedRefMut<'a, M, T>
impl<M, T> Deref for ManagedRefMut<'_, M, T>
where
M: ManagedTypeApi,
T: ManagedType<M>,
Expand All @@ -83,7 +83,7 @@ where
}
}

impl<'a, M, T> DerefMut for ManagedRefMut<'a, M, T>
impl<M, T> DerefMut for ManagedRefMut<'_, M, T>
where
M: ManagedTypeApi,
T: ManagedType<M>,
Expand All @@ -93,7 +93,7 @@ where
}
}

impl<'a, M, T> Borrow<T> for ManagedRefMut<'a, M, T>
impl<M, T> Borrow<T> for ManagedRefMut<'_, M, T>
where
M: ManagedTypeApi,
T: ManagedType<M>,
Expand Down
8 changes: 4 additions & 4 deletions framework/base/src/types/managed/wrapped/managed_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::{
TopEncodeMultiOutput, TopEncodeOutput,
},
types::{
ManagedBuffer, ManagedBufferNestedDecodeInput, ManagedType, ManagedVecItem, ManagedVecRef,
ManagedVecRefIterator, MultiValueEncoded, MultiValueManagedVec,
ManagedBuffer, ManagedBufferNestedDecodeInput, ManagedType, ManagedVecItem,
ManagedVecRefIterator, ManagedVecRefMut, MultiValueEncoded, MultiValueManagedVec,
},
};
use alloc::{format, vec::Vec};
Expand Down Expand Up @@ -182,8 +182,8 @@ where
}
}

pub fn get_mut(&mut self, index: usize) -> ManagedVecRef<M, T> {
ManagedVecRef::new(self.get_handle(), index)
pub fn get_mut(&mut self, index: usize) -> ManagedVecRefMut<M, T> {
ManagedVecRefMut::new(self.get_handle(), index)
}

pub(super) unsafe fn get_unsafe(&self, index: usize) -> T {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use core::{

use super::{ManagedRef, ManagedRefMut};

pub struct ManagedVecRef<'a, M, T>
pub struct ManagedVecRefMut<'a, M, T>
where
M: ManagedTypeApi,
T: ManagedVecItem,
Expand All @@ -22,7 +22,7 @@ where
item: ManuallyDrop<T>,
}

impl<'a, M, T> ManagedVecRef<'a, M, T>
impl<M, T> ManagedVecRefMut<'_, M, T>
where
M: ManagedTypeApi,
T: ManagedVecItem,
Expand All @@ -47,7 +47,7 @@ where
}
}

impl<'a, M, T> Drop for ManagedVecRef<'a, M, T>
impl<M, T> Drop for ManagedVecRefMut<'_, M, T>
where
M: ManagedTypeApi,
T: ManagedVecItem,
Expand All @@ -63,7 +63,7 @@ where
}
}

impl<'a, M, T> Deref for ManagedVecRef<'a, M, T>
impl<M, T> Deref for ManagedVecRefMut<'_, M, T>
where
M: ManagedTypeApi,
T: ManagedVecItem,
Expand All @@ -75,7 +75,7 @@ where
}
}

impl<'a, M, T> DerefMut for ManagedVecRef<'a, M, T>
impl<M, T> DerefMut for ManagedVecRefMut<'_, M, T>
where
M: ManagedTypeApi,
T: ManagedVecItem,
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions framework/meta/src/cmd/code_report/render_code_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ impl<'a> CodeReportRender<'a> {

fn write_report_for_contract(
&mut self,
path: &String,
size: &String,
has_allocator: &String,
has_panic: &String,
path: &str,
size: &str,
has_allocator: &str,
has_panic: &str,
) {
self.writeln(format!(
"| {} | {} | {} | {} |",
path.split('/').last().unwrap_or_else(|| path),
path.split('/').last().unwrap_or(path),
size,
has_allocator,
has_panic
Expand Down
2 changes: 1 addition & 1 deletion framework/meta/src/cmd/template/template_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct TemplateSource<'a> {
pub metadata: TemplateMetadata,
}

impl<'a> TemplateSource<'a> {
impl TemplateSource<'_> {
pub fn copy_template(&self, target_path: impl AsRef<Path>, args_tag: FrameworkVersion) {
whitelisted_deep_copy(
&self.source_path,
Expand Down
6 changes: 3 additions & 3 deletions framework/scenario/src/facade/expr/file_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const FILE_PREFIX: &str = "file:";
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct FilePath<'a>(pub &'a str);

impl<'a> FilePath<'a> {
impl FilePath<'_> {
pub fn eval_to_expr(&self) -> String {
format!("{FILE_PREFIX}{}", self.0)
}
Expand All @@ -36,9 +36,9 @@ where
}
}

impl<'a, Env> TxCodeValue<Env> for FilePath<'a> where Env: ScenarioTxEnv {}
impl<Env> TxCodeValue<Env> for FilePath<'_> where Env: ScenarioTxEnv {}

impl<'a> RegisterCodeSource for FilePath<'a> {
impl RegisterCodeSource for FilePath<'_> {
fn into_code(self, env_data: ScenarioTxEnvData) -> Vec<u8> {
self.resolve_contents(&env_data.interpreter_context())
}
Expand Down
1 change: 1 addition & 0 deletions framework/scenario/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(clippy::type_complexity)]
#![allow(clippy::needless_lifetimes)] // TODO: fix them all!

pub mod api;
pub mod bech32;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ where
pub data: ScenarioTxEnvData,
}

impl<'w, GatewayProxy> TxEnv for InteractorEnvExec<'w, GatewayProxy>
impl<GatewayProxy> TxEnv for InteractorEnvExec<'_, GatewayProxy>
where
GatewayProxy: GatewayAsyncService,
{
Expand All @@ -51,7 +51,7 @@ where
}
}

impl<'w, GatewayProxy> ScenarioTxEnv for InteractorEnvExec<'w, GatewayProxy>
impl<GatewayProxy> ScenarioTxEnv for InteractorEnvExec<'_, GatewayProxy>
where
GatewayProxy: GatewayAsyncService,
{
Expand All @@ -60,7 +60,7 @@ where
}
}

impl<'w, GatewayProxy> TxEnvWithTxHash for InteractorEnvExec<'w, GatewayProxy>
impl<GatewayProxy> TxEnvWithTxHash for InteractorEnvExec<'_, GatewayProxy>
where
GatewayProxy: GatewayAsyncService,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ where
}
}

impl<'w, GatewayProxy> InteractorExecStep<'w, GatewayProxy, TransferStep, ()>
impl<GatewayProxy> InteractorExecStep<'_, GatewayProxy, TransferStep, ()>
where
GatewayProxy: GatewayAsyncService,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ where
pub data: ScenarioTxEnvData,
}

impl<'w, GatewayProxy> TxEnv for InteractorEnvQuery<'w, GatewayProxy>
impl<GatewayProxy> TxEnv for InteractorEnvQuery<'_, GatewayProxy>
where
GatewayProxy: GatewayAsyncService,
{
Expand All @@ -48,7 +48,7 @@ where
}
}

impl<'w, GatewayProxy> ScenarioTxEnv for InteractorEnvQuery<'w, GatewayProxy>
impl<GatewayProxy> ScenarioTxEnv for InteractorEnvQuery<'_, GatewayProxy>
where
GatewayProxy: GatewayAsyncService,
{
Expand Down
2 changes: 1 addition & 1 deletion framework/snippets/src/multi/interactor_step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub enum InteractorStepRef<'a> {
ScDeploy(&'a mut ScDeployStep),
}

impl<'a> InteractorStepRef<'a> {
impl InteractorStepRef<'_> {
pub fn to_transaction<GatewayProxy: GatewayAsyncService>(
&self,
interactor: &InteractorBase<GatewayProxy>,
Expand Down
2 changes: 2 additions & 0 deletions framework/wasm-adapter/src/api/unsafe_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ static mut BUFFER_1: [u8; BUFFER_1_SIZE] = [0u8; BUFFER_1_SIZE];
/// The second buffer is for when the first one is busy with something else.
static mut BUFFER_2: [u8; BUFFER_2_SIZE] = [0u8; BUFFER_2_SIZE];

#[allow(static_mut_refs)]
pub(crate) unsafe fn buffer_1_ptr() -> *mut u8 {
BUFFER_1.as_mut_ptr()
}

#[allow(static_mut_refs)]
pub(crate) unsafe fn buffer_2_ptr() -> *mut u8 {
BUFFER_2.as_mut_ptr()
}
2 changes: 1 addition & 1 deletion framework/wasm-adapter/src/wasm_alloc/leaking_allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ unsafe impl GlobalAlloc for LeakingAllocator {
if new_total > *size {
// Request enough new space for this allocation, even if we have some space left over from the last one incase they end up non-contiguous.
// Round up to a number of pages
let requested_pages = (requested_size + PAGE_SIZE - 1) / PAGE_SIZE;
let requested_pages = requested_size.div_ceil(PAGE_SIZE);
let previous_page_count = memory_grow(PageCount(requested_pages));

let previous_size = previous_page_count.size_in_bytes();
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/src/crypto/public_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl PublicKey {
}
}

impl<'a> From<&'a PrivateKey> for PublicKey {
impl From<&PrivateKey> for PublicKey {
fn from(private_key: &PrivateKey) -> PublicKey {
let bytes = private_key.to_bytes();

Expand Down
2 changes: 1 addition & 1 deletion sdk/core/src/gateway/gateway_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl<'a> GetAccountRequest<'a> {
}
}

impl<'a> GatewayRequest for GetAccountRequest<'a> {
impl GatewayRequest for GetAccountRequest<'_> {
type Payload = ();
type DecodedJson = AccountResponse;
type Result = Account;
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/src/gateway/gateway_account_esdt_roles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl<'a> GetAccountEsdtRolesRequest<'a> {
}
}

impl<'a> GatewayRequest for GetAccountEsdtRolesRequest<'a> {
impl GatewayRequest for GetAccountEsdtRolesRequest<'_> {
type Payload = ();
type DecodedJson = EsdtRolesResponse;
type Result = HashMap<String, Vec<String>>;
Expand Down
Loading

0 comments on commit cbd9a3c

Please sign in to comment.