Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clippy: needless_lifetimes #4377

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion account-decoder/src/parse_address_lookup_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub struct UiLookupTable {
pub addresses: Vec<String>,
}

impl<'a> From<AddressLookupTable<'a>> for UiLookupTable {
impl From<AddressLookupTable<'_>> for UiLookupTable {
fn from(address_lookup_table: AddressLookupTable) -> Self {
Self {
deactivation_slot: address_lookup_table.meta.deactivation_slot.to_string(),
Expand Down
6 changes: 3 additions & 3 deletions accounts-db/src/account_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl<'a> AccountStorageIter<'a> {
}
}

impl<'a> Iterator for AccountStorageIter<'a> {
impl Iterator for AccountStorageIter<'_> {
type Item = (Slot, Arc<AccountStorageEntry>);

fn next(&mut self) -> Option<Self::Item> {
Expand All @@ -264,7 +264,7 @@ pub struct ShrinkInProgress<'a> {
}

/// called when the shrink is no longer in progress. This means we can release the old append vec and update the map of slot -> append vec
impl<'a> Drop for ShrinkInProgress<'a> {
impl Drop for ShrinkInProgress<'_> {
fn drop(&mut self) {
assert_eq!(
self.storage
Expand All @@ -289,7 +289,7 @@ impl<'a> Drop for ShrinkInProgress<'a> {
}
}

impl<'a> ShrinkInProgress<'a> {
impl ShrinkInProgress<'_> {
pub fn new_storage(&self) -> &Arc<AccountStorageEntry> {
&self.new_store
}
Expand Down
2 changes: 1 addition & 1 deletion accounts-db/src/account_storage/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl<'storage> StoredAccountMeta<'storage> {
}
}

impl<'storage> ReadableAccount for StoredAccountMeta<'storage> {
impl ReadableAccount for StoredAccountMeta<'_> {
fn lamports(&self) -> u64 {
match self {
Self::AppendVec(av) => av.lamports(),
Expand Down
8 changes: 4 additions & 4 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ enum StoreTo<'a> {
Storage(&'a Arc<AccountStorageEntry>),
}

impl<'a> StoreTo<'a> {
impl StoreTo<'_> {
fn is_cached(&self) -> bool {
matches!(self, StoreTo::Cache)
}
Expand Down Expand Up @@ -1091,7 +1091,7 @@ pub enum LoadedAccount<'a> {
Cached(Cow<'a, CachedAccount>),
}

impl<'a> LoadedAccount<'a> {
impl LoadedAccount<'_> {
pub fn loaded_hash(&self) -> AccountHash {
match self {
LoadedAccount::Stored(stored_account_meta) => *stored_account_meta.hash(),
Expand Down Expand Up @@ -1131,7 +1131,7 @@ impl<'a> LoadedAccount<'a> {
}
}

impl<'a> ReadableAccount for LoadedAccount<'a> {
impl ReadableAccount for LoadedAccount<'_> {
fn lamports(&self) -> u64 {
match self {
LoadedAccount::Stored(stored_account_meta) => stored_account_meta.lamports(),
Expand Down Expand Up @@ -1875,7 +1875,7 @@ impl solana_frozen_abi::abi_example::AbiExample for AccountsDb {
}
}

impl<'a> ZeroLamport for StoredAccountMeta<'a> {
impl ZeroLamport for StoredAccountMeta<'_> {
fn is_zero_lamport(&self) -> bool {
self.lamports() == 0
}
Expand Down
2 changes: 1 addition & 1 deletion accounts-db/src/accounts_db/scan_account_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct ScanState<'a> {
stats_num_zero_lamport_accounts_ancient: Arc<AtomicU64>,
}

impl<'a> AppendVecScan for ScanState<'a> {
impl AppendVecScan for ScanState<'_> {
fn set_slot(&mut self, slot: Slot, is_ancient: bool) {
self.current_slot = slot;
self.is_ancient = is_ancient;
Expand Down
2 changes: 1 addition & 1 deletion accounts-db/src/accounts_db/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2361,7 +2361,7 @@ lazy_static! {
pub static ref RENT_COLLECTOR: RentCollector = RentCollector::default();
}

impl<'a> CalcAccountsHashConfig<'a> {
impl CalcAccountsHashConfig<'_> {
pub(crate) fn default() -> Self {
Self {
use_bg_thread_pool: false,
Expand Down
4 changes: 2 additions & 2 deletions accounts-db/src/accounts_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ struct ItemLocation<'a> {
pointer: SlotGroupPointer,
}

impl<'a> AccountsHasher<'a> {
impl AccountsHasher<'_> {
pub fn calculate_hash(hashes: Vec<Vec<Hash>>) -> (Hash, usize) {
let cumulative_offsets = CumulativeOffsets::from_raw(&hashes);

Expand Down Expand Up @@ -1384,7 +1384,7 @@ mod tests {
static ref ACTIVE_STATS: ActiveStats = ActiveStats::default();
}

impl<'a> AccountsHasher<'a> {
impl AccountsHasher<'_> {
fn new(dir_for_temp_cache_files: PathBuf) -> Self {
Self {
zero_lamport_accounts: ZeroLamportAccounts::Excluded,
Expand Down
4 changes: 2 additions & 2 deletions accounts-db/src/accounts_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,8 @@ impl<'a, T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> AccountsIndexIter
}
}

impl<'a, T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> Iterator
for AccountsIndexIterator<'a, T, U>
impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> Iterator
for AccountsIndexIterator<'_, T, U>
{
type Item = Vec<(Pubkey, AccountMapEntry<T>)>;
fn next(&mut self) -> Option<Self::Item> {
Expand Down
2 changes: 1 addition & 1 deletion accounts-db/src/active_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub struct ActiveStatGuard<'a> {
item: ActiveStatItem,
}

impl<'a> Drop for ActiveStatGuard<'a> {
impl Drop for ActiveStatGuard<'_> {
fn drop(&mut self) {
self.stats.update_and_log(self.item, |stat| {
stat.fetch_sub(1, Ordering::Relaxed).wrapping_sub(1)
Expand Down
4 changes: 2 additions & 2 deletions accounts-db/src/storable_accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl<'a> From<&'a StoredAccountMeta<'a>> for AccountForStorage<'a> {
}
}

impl<'a> ZeroLamport for AccountForStorage<'a> {
impl ZeroLamport for AccountForStorage<'_> {
fn is_zero_lamport(&self) -> bool {
self.lamports() == 0
}
Expand All @@ -47,7 +47,7 @@ impl<'a> AccountForStorage<'a> {
}
}

impl<'a> ReadableAccount for AccountForStorage<'a> {
impl ReadableAccount for AccountForStorage<'_> {
fn lamports(&self) -> u64 {
match self {
AccountForStorage::AddressAndAccount((_pubkey, account)) => account.lamports(),
Expand Down
2 changes: 1 addition & 1 deletion bench-tps/src/send_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ trait Sliceable {
fn get_pubkey(&self) -> Pubkey;
}

impl<'a, T: Sliceable + Send + Sync> SendBatchTransactions<'a, T> for Vec<(T, Transaction)>
impl<T: Sliceable + Send + Sync> SendBatchTransactions<'_, T> for Vec<(T, Transaction)>
where
<T as Sliceable>::Slice: Signers,
{
Expand Down
2 changes: 1 addition & 1 deletion core/src/banking_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl RollingCondition for RollingConditionGrouped {
}
}

impl<'a> Write for GroupedWriter<'a> {
impl Write for GroupedWriter<'_> {
fn write(&mut self, buf: &[u8]) -> std::result::Result<usize, io::Error> {
self.underlying.write_with_datetime(buf, &self.now)
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/consensus/heaviest_subtree_fork_choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@ impl<'a> AncestorIterator<'a> {
}
}

impl<'a> Iterator for AncestorIterator<'a> {
impl Iterator for AncestorIterator<'_> {
type Item = SlotHashKey;
fn next(&mut self) -> Option<Self::Item> {
let parent_slot_hash_key = self
Expand Down
2 changes: 1 addition & 1 deletion core/src/repair/repair_generic_traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl<'a> GenericTraversal<'a> {
}
}

impl<'a> Iterator for GenericTraversal<'a> {
impl Iterator for GenericTraversal<'_> {
type Item = Slot;
fn next(&mut self) -> Option<Self::Item> {
let next = self.pending.pop();
Expand Down
2 changes: 1 addition & 1 deletion core/src/repair/repair_weighted_traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl<'a> RepairWeightTraversal<'a> {
}
}

impl<'a> Iterator for RepairWeightTraversal<'a> {
impl Iterator for RepairWeightTraversal<'_> {
type Item = Visit;
fn next(&mut self) -> Option<Self::Item> {
let next = self.pending.pop();
Expand Down
4 changes: 2 additions & 2 deletions cost-model/src/transaction_cost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub enum TransactionCost<'a, Tx> {
Transaction(UsageCostDetails<'a, Tx>),
}

impl<'a, Tx> TransactionCost<'a, Tx> {
impl<Tx> TransactionCost<'_, Tx> {
pub fn sum(&self) -> u64 {
#![allow(clippy::assertions_on_constants)]
match self {
Expand Down Expand Up @@ -160,7 +160,7 @@ pub struct UsageCostDetails<'a, Tx> {
pub allocated_accounts_data_size: u64,
}

impl<'a, Tx> UsageCostDetails<'a, Tx> {
impl<Tx> UsageCostDetails<'_, Tx> {
pub fn sum(&self) -> u64 {
self.signature_cost
.saturating_add(self.write_lock_cost)
Expand Down
6 changes: 3 additions & 3 deletions gossip/src/cluster_info_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,20 @@ impl<'a, T> TimedGuard<'a, T> {
}
}

impl<'a, T> Deref for TimedGuard<'a, T> {
impl<T> Deref for TimedGuard<'_, T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.guard
}
}

impl<'a, T> DerefMut for TimedGuard<'a, T> {
impl<T> DerefMut for TimedGuard<'_, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.guard
}
}

impl<'a, T> Drop for TimedGuard<'a, T> {
impl<T> Drop for TimedGuard<'_, T> {
fn drop(&mut self) {
self.counter.add_measure(&mut self.timer);
}
Expand Down
2 changes: 1 addition & 1 deletion gossip/src/crds_gossip_pull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ impl<'a> CrdsTimeouts<'a> {
}
}

impl<'a> Index<&Pubkey> for CrdsTimeouts<'a> {
impl Index<&Pubkey> for CrdsTimeouts<'_> {
type Output = u64;

fn index(&self, pubkey: &Pubkey) -> &Self::Output {
Expand Down
4 changes: 2 additions & 2 deletions ledger/src/ancestor_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl<'a> AncestorIterator<'a> {
}
}
}
impl<'a> Iterator for AncestorIterator<'a> {
impl Iterator for AncestorIterator<'_> {
type Item = Slot;

fn next(&mut self) -> Option<Self::Item> {
Expand All @@ -57,7 +57,7 @@ impl<'a> From<AncestorIterator<'a>> for AncestorIteratorWithHash<'a> {
Self { ancestor_iterator }
}
}
impl<'a> Iterator for AncestorIteratorWithHash<'a> {
impl Iterator for AncestorIteratorWithHash<'_> {
type Item = (Slot, Hash);
fn next(&mut self) -> Option<Self::Item> {
self.ancestor_iterator
Expand Down
2 changes: 1 addition & 1 deletion ledger/src/next_slots_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl<'a> NextSlotsIterator<'a> {
}
}

impl<'a> Iterator for NextSlotsIterator<'a> {
impl Iterator for NextSlotsIterator<'_> {
type Item = (Slot, SlotMeta);
fn next(&mut self) -> Option<Self::Item> {
if self.pending_slots.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion ledger/src/rooted_slot_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl<'a> RootedSlotIterator<'a> {
}
}
}
impl<'a> Iterator for RootedSlotIterator<'a> {
impl Iterator for RootedSlotIterator<'_> {
type Item = (Slot, Option<SlotMeta>);

fn next(&mut self) -> Option<Self::Item> {
Expand Down
2 changes: 1 addition & 1 deletion ledger/src/shred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ pub(crate) enum SignedData<'a> {
MerkleRoot(Hash),
}

impl<'a> AsRef<[u8]> for SignedData<'a> {
impl AsRef<[u8]> for SignedData<'_> {
fn as_ref(&self) -> &[u8] {
match self {
Self::Chunk(chunk) => chunk,
Expand Down
2 changes: 1 addition & 1 deletion program-runtime/src/invoke_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ macro_rules! declare_process_instruction {
};
}

impl<'a> ContextObject for InvokeContext<'a> {
impl ContextObject for InvokeContext<'_> {
fn trace(&mut self, state: [u64; 12]) {
self.syscall_context
.last_mut()
Expand Down
4 changes: 2 additions & 2 deletions programs/bpf_loader/src/syscalls/cpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ enum VmValue<'a, 'b, T> {
Translated(&'a mut T),
}

impl<'a, 'b, T> VmValue<'a, 'b, T> {
impl<T> VmValue<'_, '_, T> {
fn get(&self) -> Result<&T, Error> {
match self {
VmValue::VmAddress {
Expand Down Expand Up @@ -2867,7 +2867,7 @@ mod tests {
rent_epoch: Epoch,
}

impl<'a> MockAccountInfo<'a> {
impl MockAccountInfo<'_> {
fn new(key: Pubkey, account: &AccountSharedData) -> MockAccountInfo {
MockAccountInfo {
key,
Expand Down
2 changes: 1 addition & 1 deletion programs/bpf_loader/src/syscalls/mem_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ impl<'a> Iterator for MemoryChunkIterator<'a> {
}
}

impl<'a> DoubleEndedIterator for MemoryChunkIterator<'a> {
impl DoubleEndedIterator for MemoryChunkIterator<'_> {
fn next_back(&mut self) -> Option<Self::Item> {
if self.vm_addr_start == self.vm_addr_end {
return None;
Expand Down
2 changes: 1 addition & 1 deletion rpc-client/src/http_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl<'a> StatsUpdater<'a> {
}
}

impl<'a> Drop for StatsUpdater<'a> {
impl Drop for StatsUpdater<'_> {
fn drop(&mut self) {
let mut stats = self.stats.write().unwrap();
stats.request_count += 1;
Expand Down
6 changes: 3 additions & 3 deletions runtime/src/serde_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ struct SerializableBankAndStorage<'a> {
}

#[cfg(test)]
impl<'a> Serialize for SerializableBankAndStorage<'a> {
impl Serialize for SerializableBankAndStorage<'_> {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::ser::Serializer,
Expand Down Expand Up @@ -738,7 +738,7 @@ struct SerializableBankAndStorageNoExtra<'a> {
}

#[cfg(test)]
impl<'a> Serialize for SerializableBankAndStorageNoExtra<'a> {
impl Serialize for SerializableBankAndStorageNoExtra<'_> {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::ser::Serializer,
Expand Down Expand Up @@ -788,7 +788,7 @@ struct SerializableAccountsDb<'a> {
write_version: StoredMetaWriteVersion,
}

impl<'a> Serialize for SerializableAccountsDb<'a> {
impl Serialize for SerializableAccountsDb<'_> {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::ser::Serializer,
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/transaction_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl<'a, 'b, Tx: SVMMessage> TransactionBatch<'a, 'b, Tx> {
}

// Unlock all locked accounts in destructor.
impl<'a, 'b, Tx: SVMMessage> Drop for TransactionBatch<'a, 'b, Tx> {
impl<Tx: SVMMessage> Drop for TransactionBatch<'_, '_, Tx> {
fn drop(&mut self) {
if self.needs_unlock() {
self.set_needs_unlock(false);
Expand Down
2 changes: 1 addition & 1 deletion sdk/account-info/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct AccountInfo<'a> {
pub executable: bool,
}

impl<'a> fmt::Debug for AccountInfo<'a> {
impl fmt::Debug for AccountInfo<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut f = f.debug_struct("AccountInfo");

Expand Down
2 changes: 1 addition & 1 deletion sdk/file-download/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub fn download_file<'a, 'b>(
notification_count: u64,
}

impl<'e, 'f, R: Read> Read for DownloadProgress<'e, 'f, R> {
impl<R: Read> Read for DownloadProgress<'_, '_, R> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
let n = self.response.read(buf)?;

Expand Down
Loading
Loading