workspace: Rust 1.85..=1.87 (#482)

* apply

* remove false positive

* manual_midpoint

* fmt

* fix macro

* reason

* lukka/get-cmake@v4.0.2

* lukka/get-cmake@v4.0.1

* revert cmake
This commit is contained in:
hinto-janai
2025-05-27 18:55:14 -04:00
committed by GitHub
parent 1c22d40bb5
commit 118f02d52e
19 changed files with 37 additions and 32 deletions

View File

@@ -286,6 +286,15 @@ used_underscore_items = "deny"
unnecessary_map_or = "deny"
map_all_any_identity = "deny"
unnecessary_literal_bound = "deny"
unnecessary_debug_formatting = "deny"
elidable_lifetime_names = "deny"
single_option_map = "deny"
non_std_lazy_statics = "deny"
unnecessary_semicolon = "deny"
precedence_bits = "deny"
as_pointer_underscore = "deny"
literal_string_with_formatting_args = "deny"
manual_midpoint = "deny"
# Warm
cast_possible_truncation = "deny"

View File

@@ -329,7 +329,7 @@ async fn handle_valid_tx(
// TODO: track double spends to quickly ignore them from their blob hash.
if let Some(tx_hash) = double_spend {
return;
};
}
// TODO: There is a race condition possible if a tx and block come in at the same time: <https://github.com/Cuprate/cuprate/issues/314>.

View File

@@ -305,7 +305,7 @@ fn next_difficulty(
if timestamps.len() > config.window {
// remove the lag.
timestamps.drain(config.window..);
};
}
let timestamps_slice = timestamps.make_contiguous();
let (window_start, window_end) = get_window_start_and_end(

View File

@@ -182,7 +182,7 @@ impl RandomXVmCache {
tracing::debug!("VM was already created.");
break 'new_vm_block cached_vm;
}
};
}
rayon_spawn_async(move || Arc::new(RandomXVm::new(&next_seed_hash).unwrap()))
.await

View File

@@ -356,7 +356,7 @@ const fn check_input_type(input: &Input) -> Result<(), TransactionError> {
/// Checks that the input has decoys.
///
/// ref: <https://monero-book.cuprate.org/consensus_rules/transactions/inputs.html#no-empty-decoys>
fn check_input_has_decoys(input: &Input) -> Result<(), TransactionError> {
const fn check_input_has_decoys(input: &Input) -> Result<(), TransactionError> {
match input {
Input::ToKey { key_offsets, .. } => {
if key_offsets.is_empty() {

View File

@@ -105,7 +105,7 @@ where
difficulty_cache.median_timestamp(u64_to_usize(BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW))
{
check_timestamp(&prepped_block.block, median_timestamp).map_err(ConsensusError::Block)?;
};
}
let next_difficulty = difficulty_cache.next_difficulty(prepped_block.hf_version);
// make sure the block's PoW is valid for this difficulty.

View File

@@ -88,7 +88,7 @@ pub(crate) fn tx_fee(tx: &Transaction) -> Result<u64, TransactionError> {
.base
.fee;
}
};
}
Ok(fee)
}

View File

@@ -357,7 +357,8 @@ pub(crate) fn random_math_init(
/// Original C code:
/// <https://github.com/monero-project/monero/blob/v0.18.3.4/src/crypto/variant4_random_math.h#L81-L168>
#[expect(clippy::needless_return)] // last iteration of unrolled loop
#[expect(clippy::needless_return, reason = "last iteration of unrolled loop")]
#[expect(clippy::unnecessary_semicolon, reason = "macro")]
pub(crate) fn v4_random_math(code: &[Instruction; NUM_INSTRUCTIONS_MAX + 1], r: &mut [u32; 9]) {
const REG_BITS: u32 = 32;

View File

@@ -264,7 +264,7 @@ mod test {
array[0].1 = ".cache/cuprate";
array[1].1 = ".config/cuprate";
array[2].1 = ".local/share/cuprate";
};
}
for (path, expected) in array {
assert!(path.is_absolute());

View File

@@ -28,7 +28,7 @@ pub fn tx_fee(tx: &Transaction) -> u64 {
Transaction::V2 { proofs, .. } => {
fee = proofs.as_ref().unwrap().base.fee;
}
};
}
fee
}

View File

@@ -27,10 +27,6 @@ impl Error {
}
}
#[expect(
clippy::missing_const_for_fn,
reason = "False-positive, `<String as Deref>::deref` is not const"
)]
fn field_data(&self) -> &str {
match self {
Self::IO(data) | Self::Format(data) => data,

View File

@@ -338,7 +338,7 @@ fn skip_epee_value<B: Buf>(r: &mut B, skipped_objects: &mut u8) -> Result<()> {
.checked_mul(len.try_into()?)
.ok_or(Error::Value("List is too big".to_string()))?;
return advance(bytes_to_skip, r);
};
}
for _ in 0..len {
match marker.inner_marker {
@@ -364,7 +364,7 @@ fn skip_epee_value<B: Buf>(r: &mut B, skipped_objects: &mut u8) -> Result<()> {
read_object::<SkipObject, _>(r, skipped_objects)?;
*skipped_objects -= 1;
}
};
}
}
Ok(())
}

View File

@@ -141,9 +141,9 @@ macro_rules! epee_object {
fn add_field<B: cuprate_epee_encoding::macros::bytes::Buf>(&mut self, name: &str, b: &mut B) -> cuprate_epee_encoding::error::Result<bool> {
match name {
$(cuprate_epee_encoding::epee_object!(@internal_field_name $field, $($alt_name)?) => {
if core::mem::replace(&mut self.$field, Some(
if self.$field.replace(
cuprate_epee_encoding::epee_object!(@internal_try_right_then_left cuprate_epee_encoding::read_epee_value(b)?, $($read_fn(b)?)?)
)).is_some() {
).is_some() {
Err(cuprate_epee_encoding::error::Error::Value(format!("Duplicate field in data: {}", cuprate_epee_encoding::epee_object!(@internal_field_name$field, $($alt_name)?))))?;
}
Ok(true)

View File

@@ -74,7 +74,7 @@ impl<C: LevinCommand + Debug> Decoder for LevinBucketCodec<C> {
LevinBucketState::WaitingForHeader => {
if src.len() < HEADER_SIZE {
return Ok(None);
};
}
let head = BucketHead::<C>::from_bytes(src);
@@ -207,13 +207,13 @@ impl<T: LevinBody> Decoder for LevinMessageCodec<T> {
tracing::trace!("Received DUMMY bucket from peer, ignoring.");
// We may have another bucket in `src`.
continue;
};
}
if flags.contains(Flags::END_FRAGMENT) {
return Err(BucketError::InvalidHeaderFlags(
"Flag end fragment received before a start fragment",
));
};
}
if flags.contains(Flags::START_FRAGMENT) {
// monerod does not require a start flag before starting a fragmented message,
@@ -254,7 +254,7 @@ impl<T: LevinBody> Decoder for LevinMessageCodec<T> {
tracing::trace!("Received DUMMY bucket from peer, ignoring.");
// We may have another bucket in `src`.
continue;
};
}
let max_size = u64_to_usize(if self.bucket_codec.handshake_message_seen {
self.bucket_codec.protocol.max_packet_size

View File

@@ -23,11 +23,10 @@ impl EpeeObjectBuilder<NetworkAddress> for TaggedNetworkAddress {
fn add_field<B: Buf>(&mut self, name: &str, b: &mut B) -> cuprate_epee_encoding::Result<bool> {
match name {
"type" => {
if std::mem::replace(
&mut self.ty,
Some(cuprate_epee_encoding::read_epee_value(b)?),
)
.is_some()
if self
.ty
.replace(cuprate_epee_encoding::read_epee_value(b)?)
.is_some()
{
return Err(cuprate_epee_encoding::Error::Format(
"Duplicate field in data.",

View File

@@ -216,7 +216,7 @@ impl<Z: BorshNetworkZone> AddressBook<Z> {
if self.white_list.contains_peer(&peer.adr) {
tracing::trace!("Peer {} is already in white list skipping.", peer.adr);
return;
};
}
if !self.gray_list.contains_peer(&peer.adr) {
tracing::trace!("Adding peer {} to gray list.", peer.adr);
peer.last_seen = 0;

View File

@@ -583,7 +583,7 @@ where
self.check_pending_peers(chain_tracker, pending_peers);
return Ok(());
};
}
// If the batch is higher than the last time we updated `amount_of_blocks_to_request`, update it
// again.

View File

@@ -73,7 +73,7 @@ fn add_transaction(
}
TxPoolWriteError::Database(e) => Err(e),
};
};
}
drop(tables_mut);
// The tx was added to the pool successfully.

View File

@@ -76,7 +76,7 @@ impl TransactionBlobs {
}
/// Returns the byte length of the blob.
pub fn len(&self) -> usize {
pub const fn len(&self) -> usize {
match self {
Self::Normal(txs) => txs.len(),
Self::Pruned(txs) => txs.len(),
@@ -85,7 +85,7 @@ impl TransactionBlobs {
}
/// Returns `true` if the byte length of the blob is `0`.
pub fn is_empty(&self) -> bool {
pub const fn is_empty(&self) -> bool {
self.len() == 0
}
@@ -125,7 +125,7 @@ impl TransactionBlobs {
/// Epee should write function.
#[cfg(feature = "epee")]
fn should_write_tx_blobs(&self) -> bool {
const fn should_write_tx_blobs(&self) -> bool {
!self.is_empty()
}
}