Skip to content

Commit 0ba072c

Browse files
authored
Merge pull request #5638 from stacks-network/fix/clippy-ci-stacks-lib-needless-lifetimes
Fix clippy::needless_lifetimes warnings throughout stackslib
2 parents 088f6ba + 31ffc3f commit 0ba072c

File tree

38 files changed

+232
-252
lines changed

38 files changed

+232
-252
lines changed

stackslib/src/burnchains/bitcoin/bits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use crate::chainstate::stacks::{
3939
};
4040

4141
/// Parse a script into its structured constituant opcodes and data and collect them
42-
pub fn parse_script<'a>(script: &'a Script) -> Vec<Instruction<'a>> {
42+
pub fn parse_script(script: &Script) -> Vec<Instruction<'_>> {
4343
// we will have to accept non-minimial pushdata since there's at least one OP_RETURN
4444
// in the transaction stream that has this property already.
4545
script.iter(false).collect()

stackslib/src/burnchains/bitcoin/spv.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl FromColumn<Sha256dHash> for Sha256dHash {
132132
}
133133

134134
impl FromRow<BlockHeader> for BlockHeader {
135-
fn from_row<'a>(row: &'a Row) -> Result<BlockHeader, db_error> {
135+
fn from_row(row: &Row) -> Result<BlockHeader, db_error> {
136136
let version: u32 = row.get_unwrap("version");
137137
let prev_blockhash: Sha256dHash = Sha256dHash::from_column(row, "prev_blockhash")?;
138138
let merkle_root: Sha256dHash = Sha256dHash::from_column(row, "merkle_root")?;
@@ -225,7 +225,7 @@ impl SpvClient {
225225
&mut self.headers_db
226226
}
227227

228-
pub fn tx_begin<'a>(&'a mut self) -> Result<DBTx<'a>, btc_error> {
228+
pub fn tx_begin(&mut self) -> Result<DBTx<'_>, btc_error> {
229229
if !self.readwrite {
230230
return Err(db_error::ReadOnly.into());
231231
}
@@ -741,8 +741,8 @@ impl SpvClient {
741741
}
742742

743743
/// Insert a block header
744-
fn insert_block_header<'a>(
745-
tx: &mut DBTx<'a>,
744+
fn insert_block_header(
745+
tx: &mut DBTx<'_>,
746746
header: BlockHeader,
747747
height: u64,
748748
) -> Result<(), btc_error> {

stackslib/src/burnchains/db.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,21 @@ pub struct BlockCommitMetadata {
8484
}
8585

8686
impl FromColumn<AffirmationMap> for AffirmationMap {
87-
fn from_column<'a>(row: &'a Row, col_name: &str) -> Result<AffirmationMap, DBError> {
87+
fn from_column(row: &Row, col_name: &str) -> Result<AffirmationMap, DBError> {
8888
let txt: String = row.get_unwrap(col_name);
8989
let am = AffirmationMap::decode(&txt).ok_or(DBError::ParseError)?;
9090
Ok(am)
9191
}
9292
}
9393

9494
impl FromRow<AffirmationMap> for AffirmationMap {
95-
fn from_row<'a>(row: &'a Row) -> Result<AffirmationMap, DBError> {
95+
fn from_row(row: &Row) -> Result<AffirmationMap, DBError> {
9696
AffirmationMap::from_column(row, "affirmation_map")
9797
}
9898
}
9999

100100
impl FromRow<BlockCommitMetadata> for BlockCommitMetadata {
101-
fn from_row<'a>(row: &'a Row) -> Result<BlockCommitMetadata, DBError> {
101+
fn from_row(row: &Row) -> Result<BlockCommitMetadata, DBError> {
102102
let burn_block_hash = BurnchainHeaderHash::from_column(row, "burn_block_hash")?;
103103
let txid = Txid::from_column(row, "txid")?;
104104
let block_height = u64::from_column(row, "block_height")?;
@@ -311,7 +311,7 @@ const BURNCHAIN_DB_INDEXES: &[&str] = &[
311311
"CREATE INDEX IF NOT EXISTS index_block_commit_metadata_burn_block_hash_anchor_block ON block_commit_metadata(burn_block_hash,anchor_block);",
312312
];
313313

314-
impl<'a> BurnchainDBTransaction<'a> {
314+
impl BurnchainDBTransaction<'_> {
315315
/// Store a burnchain block header into the burnchain database.
316316
/// Returns the row ID on success.
317317
pub(crate) fn store_burnchain_db_entry(
@@ -1103,7 +1103,7 @@ impl BurnchainDB {
11031103
&self.conn
11041104
}
11051105

1106-
pub fn tx_begin<'a>(&'a mut self) -> Result<BurnchainDBTransaction<'a>, BurnchainError> {
1106+
pub fn tx_begin(&mut self) -> Result<BurnchainDBTransaction<'_>, BurnchainError> {
11071107
let sql_tx = tx_begin_immediate(&mut self.conn)?;
11081108
Ok(BurnchainDBTransaction { sql_tx })
11091109
}

stackslib/src/burnchains/tests/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,6 @@ impl TestBurnchainBlock {
644644
}
645645

646646
pub fn mine_pox<
647-
'a,
648647
T: BlockEventDispatcher,
649648
N: CoordinatorNotices,
650649
R: RewardSetProvider,
@@ -655,7 +654,7 @@ impl TestBurnchainBlock {
655654
&self,
656655
db: &mut SortitionDB,
657656
burnchain: &Burnchain,
658-
coord: &mut ChainsCoordinator<'a, T, N, R, CE, FE, B>,
657+
coord: &mut ChainsCoordinator<'_, T, N, R, CE, FE, B>,
659658
) -> BlockSnapshot {
660659
let mut indexer = BitcoinIndexer::new_unit_test(&burnchain.working_dir);
661660
let parent_hdr = indexer
@@ -783,7 +782,6 @@ impl TestBurnchainFork {
783782
}
784783

785784
pub fn mine_pending_blocks_pox<
786-
'a,
787785
T: BlockEventDispatcher,
788786
N: CoordinatorNotices,
789787
R: RewardSetProvider,
@@ -794,7 +792,7 @@ impl TestBurnchainFork {
794792
&mut self,
795793
db: &mut SortitionDB,
796794
burnchain: &Burnchain,
797-
coord: &mut ChainsCoordinator<'a, T, N, R, CE, FE, B>,
795+
coord: &mut ChainsCoordinator<'_, T, N, R, CE, FE, B>,
798796
) -> BlockSnapshot {
799797
let mut snapshot = {
800798
let ic = db.index_conn();

stackslib/src/chainstate/burn/db/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl_byte_array_from_column_only!(TrieHash);
5353
impl_byte_array_from_column_only!(MessageSignature);
5454

5555
impl FromColumn<VRFPublicKey> for VRFPublicKey {
56-
fn from_column<'a>(row: &'a Row, column_name: &str) -> Result<VRFPublicKey, db_error> {
56+
fn from_column(row: &Row, column_name: &str) -> Result<VRFPublicKey, db_error> {
5757
let pubkey_hex: String = row.get_unwrap(column_name);
5858
match VRFPublicKey::from_hex(&pubkey_hex) {
5959
Some(pubk) => Ok(pubk),
@@ -63,7 +63,7 @@ impl FromColumn<VRFPublicKey> for VRFPublicKey {
6363
}
6464

6565
impl FromColumn<StacksAddress> for StacksAddress {
66-
fn from_column<'a>(row: &'a Row, column_name: &str) -> Result<Self, db_error> {
66+
fn from_column(row: &Row, column_name: &str) -> Result<Self, db_error> {
6767
let address_str: String = row.get_unwrap(column_name);
6868
match Self::from_string(&address_str) {
6969
Some(a) => Ok(a),
@@ -73,14 +73,14 @@ impl FromColumn<StacksAddress> for StacksAddress {
7373
}
7474

7575
impl FromColumn<PrincipalData> for PrincipalData {
76-
fn from_column<'a>(row: &'a Row, column_name: &str) -> Result<Self, db_error> {
76+
fn from_column(row: &Row, column_name: &str) -> Result<Self, db_error> {
7777
let address_str: String = row.get_unwrap(column_name);
7878
Self::parse(&address_str).map_err(|_| db_error::ParseError)
7979
}
8080
}
8181

8282
impl FromColumn<PoxAddress> for PoxAddress {
83-
fn from_column<'a>(row: &'a Row, column_name: &str) -> Result<Self, db_error> {
83+
fn from_column(row: &Row, column_name: &str) -> Result<Self, db_error> {
8484
let address_str: String = row.get_unwrap(column_name);
8585
match Self::from_db_string(&address_str) {
8686
Some(a) => Ok(a),
@@ -90,7 +90,7 @@ impl FromColumn<PoxAddress> for PoxAddress {
9090
}
9191

9292
impl FromColumn<BitcoinAddress> for BitcoinAddress {
93-
fn from_column<'a>(row: &'a Row, column_name: &str) -> Result<Self, db_error> {
93+
fn from_column(row: &Row, column_name: &str) -> Result<Self, db_error> {
9494
let address_str: String = row.get_unwrap(column_name);
9595
match Self::from_string(&address_str) {
9696
Some(a) => Ok(a),

stackslib/src/chainstate/burn/db/processing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use crate::chainstate::stacks::index::{Error as MARFError, MARFValue, MarfTrieId
3535
use crate::core::INITIAL_MINING_BONUS_WINDOW;
3636
use crate::util_lib::db::Error as DBError;
3737

38-
impl<'a> SortitionHandleTx<'a> {
38+
impl SortitionHandleTx<'_> {
3939
/// Run a blockstack operation's "check()" method and return the result.
4040
fn check_transaction(
4141
&mut self,

stackslib/src/chainstate/burn/db/sortdb.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -96,25 +96,25 @@ pub const REWARD_WINDOW_END: u64 = 144 * 90 + REWARD_WINDOW_START;
9696
pub type BlockHeaderCache = HashMap<ConsensusHash, (Option<BlockHeaderHash>, ConsensusHash)>;
9797

9898
impl FromRow<SortitionId> for SortitionId {
99-
fn from_row<'a>(row: &'a Row) -> Result<SortitionId, db_error> {
99+
fn from_row(row: &Row) -> Result<SortitionId, db_error> {
100100
SortitionId::from_column(row, "sortition_id")
101101
}
102102
}
103103

104104
impl FromRow<ConsensusHash> for ConsensusHash {
105-
fn from_row<'a>(row: &'a Row) -> Result<ConsensusHash, db_error> {
105+
fn from_row(row: &Row) -> Result<ConsensusHash, db_error> {
106106
ConsensusHash::from_column(row, "consensus_hash")
107107
}
108108
}
109109

110110
impl FromRow<BurnchainHeaderHash> for BurnchainHeaderHash {
111-
fn from_row<'a>(row: &'a Row) -> Result<BurnchainHeaderHash, db_error> {
111+
fn from_row(row: &Row) -> Result<BurnchainHeaderHash, db_error> {
112112
BurnchainHeaderHash::from_column(row, "burn_header_hash")
113113
}
114114
}
115115

116116
impl FromRow<MissedBlockCommit> for MissedBlockCommit {
117-
fn from_row<'a>(row: &'a Row) -> Result<MissedBlockCommit, db_error> {
117+
fn from_row(row: &Row) -> Result<MissedBlockCommit, db_error> {
118118
let intended_sortition = SortitionId::from_column(row, "intended_sortition_id")?;
119119
let input_json: String = row.get_unwrap("input");
120120
let input =
@@ -130,7 +130,7 @@ impl FromRow<MissedBlockCommit> for MissedBlockCommit {
130130
}
131131

132132
impl FromRow<BlockSnapshot> for BlockSnapshot {
133-
fn from_row<'a>(row: &'a Row) -> Result<BlockSnapshot, db_error> {
133+
fn from_row(row: &Row) -> Result<BlockSnapshot, db_error> {
134134
let block_height = u64::from_column(row, "block_height")?;
135135
let burn_header_hash = BurnchainHeaderHash::from_column(row, "burn_header_hash")?;
136136
let burn_header_timestamp = u64::from_column(row, "burn_header_timestamp")?;
@@ -211,7 +211,7 @@ impl FromRow<BlockSnapshot> for BlockSnapshot {
211211
}
212212

213213
impl FromRow<LeaderKeyRegisterOp> for LeaderKeyRegisterOp {
214-
fn from_row<'a>(row: &'a Row) -> Result<LeaderKeyRegisterOp, db_error> {
214+
fn from_row(row: &Row) -> Result<LeaderKeyRegisterOp, db_error> {
215215
let txid = Txid::from_column(row, "txid")?;
216216
let vtxindex: u32 = row.get_unwrap("vtxindex");
217217
let block_height = u64::from_column(row, "block_height")?;
@@ -240,7 +240,7 @@ impl FromRow<LeaderKeyRegisterOp> for LeaderKeyRegisterOp {
240240
}
241241

242242
impl FromRow<LeaderBlockCommitOp> for LeaderBlockCommitOp {
243-
fn from_row<'a>(row: &'a Row) -> Result<LeaderBlockCommitOp, db_error> {
243+
fn from_row(row: &Row) -> Result<LeaderBlockCommitOp, db_error> {
244244
let txid = Txid::from_column(row, "txid")?;
245245
let vtxindex: u32 = row.get_unwrap("vtxindex");
246246
let block_height = u64::from_column(row, "block_height")?;
@@ -314,7 +314,7 @@ impl FromRow<LeaderBlockCommitOp> for LeaderBlockCommitOp {
314314
}
315315

316316
impl FromRow<StackStxOp> for StackStxOp {
317-
fn from_row<'a>(row: &'a Row) -> Result<StackStxOp, db_error> {
317+
fn from_row(row: &Row) -> Result<StackStxOp, db_error> {
318318
let txid = Txid::from_column(row, "txid")?;
319319
let vtxindex: u32 = row.get_unwrap("vtxindex");
320320
let block_height = u64::from_column(row, "block_height")?;
@@ -357,7 +357,7 @@ impl FromRow<StackStxOp> for StackStxOp {
357357
}
358358

359359
impl FromRow<DelegateStxOp> for DelegateStxOp {
360-
fn from_row<'a>(row: &'a Row) -> Result<DelegateStxOp, db_error> {
360+
fn from_row(row: &Row) -> Result<DelegateStxOp, db_error> {
361361
let txid = Txid::from_column(row, "txid")?;
362362
let vtxindex: u32 = row.get_unwrap("vtxindex");
363363
let block_height = u64::from_column(row, "block_height")?;
@@ -389,7 +389,7 @@ impl FromRow<DelegateStxOp> for DelegateStxOp {
389389
}
390390

391391
impl FromRow<TransferStxOp> for TransferStxOp {
392-
fn from_row<'a>(row: &'a Row) -> Result<TransferStxOp, db_error> {
392+
fn from_row(row: &Row) -> Result<TransferStxOp, db_error> {
393393
let txid = Txid::from_column(row, "txid")?;
394394
let vtxindex: u32 = row.get_unwrap("vtxindex");
395395
let block_height = u64::from_column(row, "block_height")?;
@@ -417,7 +417,7 @@ impl FromRow<TransferStxOp> for TransferStxOp {
417417
}
418418

419419
impl FromRow<VoteForAggregateKeyOp> for VoteForAggregateKeyOp {
420-
fn from_row<'a>(row: &'a Row) -> Result<VoteForAggregateKeyOp, db_error> {
420+
fn from_row(row: &Row) -> Result<VoteForAggregateKeyOp, db_error> {
421421
let txid = Txid::from_column(row, "txid")?;
422422
let vtxindex: u32 = row.get_unwrap("vtxindex");
423423
let block_height = u64::from_column(row, "block_height")?;
@@ -450,15 +450,15 @@ impl FromRow<VoteForAggregateKeyOp> for VoteForAggregateKeyOp {
450450
}
451451

452452
impl FromColumn<ASTRules> for ASTRules {
453-
fn from_column<'a>(row: &'a Row, column_name: &str) -> Result<ASTRules, db_error> {
453+
fn from_column(row: &Row, column_name: &str) -> Result<ASTRules, db_error> {
454454
let x: u8 = row.get_unwrap(column_name);
455455
let ast_rules = ASTRules::from_u8(x).ok_or(db_error::ParseError)?;
456456
Ok(ast_rules)
457457
}
458458
}
459459

460460
impl FromRow<(ASTRules, u64)> for (ASTRules, u64) {
461-
fn from_row<'a>(row: &'a Row) -> Result<(ASTRules, u64), db_error> {
461+
fn from_row(row: &Row) -> Result<(ASTRules, u64), db_error> {
462462
let ast_rules = ASTRules::from_column(row, "ast_rule_id")?;
463463
let height = u64::from_column(row, "block_height")?;
464464
Ok((ast_rules, height))
@@ -479,7 +479,7 @@ pub struct InitialMiningBonus {
479479
}
480480

481481
impl FromRow<AcceptedStacksBlockHeader> for AcceptedStacksBlockHeader {
482-
fn from_row<'a>(row: &'a Row) -> Result<AcceptedStacksBlockHeader, db_error> {
482+
fn from_row(row: &Row) -> Result<AcceptedStacksBlockHeader, db_error> {
483483
let tip_consensus_hash = ConsensusHash::from_column(row, "tip_consensus_hash")?;
484484
let consensus_hash = ConsensusHash::from_column(row, "consensus_hash")?;
485485
let block_hash = BlockHeaderHash::from_column(row, "stacks_block_hash")?;
@@ -495,7 +495,7 @@ impl FromRow<AcceptedStacksBlockHeader> for AcceptedStacksBlockHeader {
495495
}
496496

497497
impl FromRow<StacksEpoch> for StacksEpoch {
498-
fn from_row<'a>(row: &'a Row) -> Result<StacksEpoch, db_error> {
498+
fn from_row(row: &Row) -> Result<StacksEpoch, db_error> {
499499
let epoch_id_u32: u32 = row.get_unwrap("epoch_id");
500500
let epoch_id = StacksEpochId::try_from(epoch_id_u32).map_err(|_| db_error::ParseError)?;
501501

@@ -1533,7 +1533,7 @@ impl SortitionHandle for SortitionHandleConn<'_> {
15331533
}
15341534
}
15351535

1536-
impl<'a> SortitionHandleTx<'a> {
1536+
impl SortitionHandleTx<'_> {
15371537
pub fn set_stacks_block_accepted(
15381538
&mut self,
15391539
consensus_hash: &ConsensusHash,
@@ -2646,7 +2646,7 @@ impl<'a> SortitionHandleConn<'a> {
26462646
// Connection methods
26472647
impl SortitionDB {
26482648
/// Begin a transaction.
2649-
pub fn tx_begin<'a>(&'a mut self) -> Result<SortitionDBTx<'a>, db_error> {
2649+
pub fn tx_begin(&mut self) -> Result<SortitionDBTx<'_>, db_error> {
26502650
if !self.readwrite {
26512651
return Err(db_error::ReadOnly);
26522652
}
@@ -2663,7 +2663,7 @@ impl SortitionDB {
26632663
}
26642664

26652665
/// Make an indexed connection
2666-
pub fn index_conn<'a>(&'a self) -> SortitionDBConn<'a> {
2666+
pub fn index_conn(&self) -> SortitionDBConn<'_> {
26672667
SortitionDBConn::new(
26682668
&self.marf,
26692669
SortitionDBTxContext {
@@ -2739,7 +2739,7 @@ impl SortitionDB {
27392739
))
27402740
}
27412741

2742-
pub fn conn<'a>(&'a self) -> &'a Connection {
2742+
pub fn conn(&self) -> &Connection {
27432743
self.marf.sqlite_conn()
27442744
}
27452745

@@ -3556,8 +3556,8 @@ impl SortitionDB {
35563556
}
35573557

35583558
#[cfg(any(test, feature = "testing"))]
3559-
pub fn override_ast_rule_height<'a>(
3560-
tx: &mut DBTx<'a>,
3559+
pub fn override_ast_rule_height(
3560+
tx: &mut DBTx<'_>,
35613561
ast_rules: ASTRules,
35623562
height: u64,
35633563
) -> Result<(), db_error> {
@@ -3699,7 +3699,7 @@ impl SortitionDB {
36993699
}
37003700
}
37013701

3702-
impl<'a> SortitionDBTx<'a> {
3702+
impl SortitionDBTx<'_> {
37033703
pub fn find_sortition_tip_affirmation_map(
37043704
&mut self,
37053705
chain_tip: &SortitionId,
@@ -3720,7 +3720,7 @@ impl<'a> SortitionDBTx<'a> {
37203720
}
37213721
}
37223722

3723-
impl<'a> SortitionDBConn<'a> {
3723+
impl SortitionDBConn<'_> {
37243724
pub fn as_handle<'b>(&'b self, chain_tip: &SortitionId) -> SortitionHandleConn<'b> {
37253725
SortitionHandleConn {
37263726
index: self.index,
@@ -4719,7 +4719,7 @@ impl SortitionDB {
47194719
}
47204720

47214721
/// DO NOT CALL during Stacks block processing (including during Clarity VM evaluation). This function returns the latest data known to the node, which may not have been at the time of original block assembly.
4722-
pub fn index_handle_at_tip<'a>(&'a self) -> SortitionHandleConn<'a> {
4722+
pub fn index_handle_at_tip(&self) -> SortitionHandleConn<'_> {
47234723
let sortition_id = SortitionDB::get_canonical_sortition_tip(self.conn()).unwrap();
47244724
self.index_handle(&sortition_id)
47254725
}
@@ -4737,7 +4737,7 @@ impl SortitionDB {
47374737

47384738
/// Open a tx handle at the burn chain tip
47394739
/// DO NOT CALL during Stacks block processing (including during Clarity VM evaluation). This function returns the latest data known to the node, which may not have been at the time of original block assembly.
4740-
pub fn tx_begin_at_tip<'a>(&'a mut self) -> SortitionHandleTx<'a> {
4740+
pub fn tx_begin_at_tip(&mut self) -> SortitionHandleTx<'_> {
47414741
let sortition_id = SortitionDB::get_canonical_sortition_tip(self.conn()).unwrap();
47424742
self.tx_handle_begin(&sortition_id).unwrap()
47434743
}
@@ -5394,7 +5394,7 @@ impl SortitionDB {
53945394
}
53955395
}
53965396

5397-
impl<'a> SortitionHandleTx<'a> {
5397+
impl SortitionHandleTx<'_> {
53985398
/// Append a snapshot to a chain tip, and update various chain tip statistics.
53995399
/// Returns the new state root of this fork.
54005400
/// `initialize_bonus` - if Some(..), then this snapshot is the first mined snapshot,
@@ -6608,7 +6608,7 @@ pub mod tests {
66086608
use crate::core::{StacksEpochExtension, *};
66096609
use crate::util_lib::db::Error as db_error;
66106610

6611-
impl<'a> SortitionHandleTx<'a> {
6611+
impl SortitionHandleTx<'_> {
66126612
/// Update the canonical Stacks tip (testing only)
66136613
pub fn test_update_canonical_stacks_tip(
66146614
&mut self,

0 commit comments

Comments
 (0)