Skip to content

Commit 73159f7

Browse files
Fix new lints required by Rust 1.83 (#606)
* cargo fix all new 1.83 lints except for static_mut_refs * use LazyLock for CONTEXT * allow static_mut_refs for wallet storage paths * bump MSRV to 1.82 and use the recent is_none_or
1 parent ea6b83e commit 73159f7

File tree

55 files changed

+94
-128
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+94
-128
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ members = [
6262
]
6363

6464
[workspace.package]
65-
rust-version = "1.81.0"
65+
rust-version = "1.82.0"
6666
version = "0.15.3"
6767
authors = ["Kaspa developers"]
6868
license = "ISC"

cli/src/modules/history.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,7 @@ impl History {
8686
}
8787
};
8888
let length = ids.size_hint().0;
89-
let skip = if let Some(last) = last {
90-
if last > length {
91-
0
92-
} else {
93-
length - last
94-
}
95-
} else {
96-
0
97-
};
89+
let skip = if let Some(last) = last { length.saturating_sub(last) } else { 0 };
9890
let mut index = 0;
9991
let page = 25;
10092

consensus/client/src/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ impl Header {
266266

267267
impl TryCastFromJs for Header {
268268
type Error = Error;
269-
fn try_cast_from<'a, R>(value: &'a R) -> Result<Cast<Self>, Self::Error>
269+
fn try_cast_from<'a, R>(value: &'a R) -> Result<Cast<'a, Self>, Self::Error>
270270
where
271271
R: AsRef<JsValue> + 'a,
272272
{

consensus/client/src/input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ impl AsRef<TransactionInput> for TransactionInput {
200200

201201
impl TryCastFromJs for TransactionInput {
202202
type Error = Error;
203-
fn try_cast_from<'a, R>(value: &'a R) -> std::result::Result<Cast<Self>, Self::Error>
203+
fn try_cast_from<'a, R>(value: &'a R) -> std::result::Result<Cast<'a, Self>, Self::Error>
204204
where
205205
R: AsRef<JsValue> + 'a,
206206
{

consensus/client/src/output.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl From<&TransactionOutput> for cctx::TransactionOutput {
139139

140140
impl TryCastFromJs for TransactionOutput {
141141
type Error = Error;
142-
fn try_cast_from<'a, R>(value: &'a R) -> std::result::Result<Cast<Self>, Self::Error>
142+
fn try_cast_from<'a, R>(value: &'a R) -> std::result::Result<Cast<'a, Self>, Self::Error>
143143
where
144144
R: AsRef<JsValue> + 'a,
145145
{

consensus/client/src/transaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ impl Transaction {
280280

281281
impl TryCastFromJs for Transaction {
282282
type Error = Error;
283-
fn try_cast_from<'a, R>(value: &'a R) -> std::result::Result<Cast<Self>, Self::Error>
283+
fn try_cast_from<'a, R>(value: &'a R) -> std::result::Result<Cast<'a, Self>, Self::Error>
284284
where
285285
R: AsRef<JsValue> + 'a,
286286
{

consensus/client/src/utxo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ impl TryIntoUtxoEntryReferences for JsValue {
282282

283283
impl TryCastFromJs for UtxoEntry {
284284
type Error = Error;
285-
fn try_cast_from<'a, R>(value: &'a R) -> Result<Cast<Self>, Self::Error>
285+
fn try_cast_from<'a, R>(value: &'a R) -> Result<Cast<'a, Self>, Self::Error>
286286
where
287287
R: AsRef<JsValue> + 'a,
288288
{
@@ -405,7 +405,7 @@ impl TryFrom<JsValue> for UtxoEntries {
405405

406406
impl TryCastFromJs for UtxoEntryReference {
407407
type Error = Error;
408-
fn try_cast_from<'a, R>(value: &'a R) -> Result<Cast<Self>, Self::Error>
408+
fn try_cast_from<'a, R>(value: &'a R) -> Result<Cast<'a, Self>, Self::Error>
409409
where
410410
R: AsRef<JsValue> + 'a,
411411
{

consensus/core/src/config/constants.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub mod consensus {
3636

3737
/// Size of the **sampled** median time window (independent of BPS)
3838
pub const MEDIAN_TIME_SAMPLED_WINDOW_SIZE: u64 =
39-
((2 * NEW_TIMESTAMP_DEVIATION_TOLERANCE - 1) + PAST_MEDIAN_TIME_SAMPLE_INTERVAL - 1) / PAST_MEDIAN_TIME_SAMPLE_INTERVAL;
39+
(2 * NEW_TIMESTAMP_DEVIATION_TOLERANCE - 1).div_ceil(PAST_MEDIAN_TIME_SAMPLE_INTERVAL);
4040

4141
//
4242
// ~~~~~~~~~~~~~~~~~~~~~~~~~ Max difficulty target ~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -71,8 +71,7 @@ pub mod consensus {
7171
pub const DIFFICULTY_WINDOW_SAMPLE_INTERVAL: u64 = 4;
7272

7373
/// Size of the **sampled** difficulty window (independent of BPS)
74-
pub const DIFFICULTY_SAMPLED_WINDOW_SIZE: u64 =
75-
(NEW_DIFFICULTY_WINDOW_DURATION + DIFFICULTY_WINDOW_SAMPLE_INTERVAL - 1) / DIFFICULTY_WINDOW_SAMPLE_INTERVAL;
74+
pub const DIFFICULTY_SAMPLED_WINDOW_SIZE: u64 = NEW_DIFFICULTY_WINDOW_DURATION.div_ceil(DIFFICULTY_WINDOW_SAMPLE_INTERVAL);
7675

7776
//
7877
// ~~~~~~~~~~~~~~~~~~~ Finality & Pruning ~~~~~~~~~~~~~~~~~~~

consensus/core/src/network.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ impl Serialize for NetworkId {
344344

345345
struct NetworkIdVisitor;
346346

347-
impl<'de> de::Visitor<'de> for NetworkIdVisitor {
347+
impl de::Visitor<'_> for NetworkIdVisitor {
348348
type Value = NetworkId;
349349

350350
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
@@ -413,7 +413,7 @@ impl TryFrom<JsValue> for NetworkId {
413413

414414
impl TryCastFromJs for NetworkId {
415415
type Error = NetworkIdError;
416-
fn try_cast_from<'a, R>(value: &'a R) -> Result<Cast<Self>, Self::Error>
416+
fn try_cast_from<'a, R>(value: &'a R) -> Result<Cast<'a, Self>, Self::Error>
417417
where
418418
R: AsRef<JsValue> + 'a,
419419
{

consensus/core/src/tx.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ impl<'a, T: VerifiableTransaction> Iterator for PopulatedInputIterator<'a, T> {
321321
}
322322
}
323323

324-
impl<'a, T: VerifiableTransaction> ExactSizeIterator for PopulatedInputIterator<'a, T> {}
324+
impl<T: VerifiableTransaction> ExactSizeIterator for PopulatedInputIterator<'_, T> {}
325325

326326
/// Represents a read-only referenced transaction along with fully populated UTXO entry data
327327
pub struct PopulatedTransaction<'a> {
@@ -336,7 +336,7 @@ impl<'a> PopulatedTransaction<'a> {
336336
}
337337
}
338338

339-
impl<'a> VerifiableTransaction for PopulatedTransaction<'a> {
339+
impl VerifiableTransaction for PopulatedTransaction<'_> {
340340
fn tx(&self) -> &Transaction {
341341
self.tx
342342
}
@@ -368,7 +368,7 @@ impl<'a> ValidatedTransaction<'a> {
368368
}
369369
}
370370

371-
impl<'a> VerifiableTransaction for ValidatedTransaction<'a> {
371+
impl VerifiableTransaction for ValidatedTransaction<'_> {
372372
fn tx(&self) -> &Transaction {
373373
self.tx
374374
}

0 commit comments

Comments
 (0)