Skip to content

Commit 625e3db

Browse files
authored
Update rust toolchain to v1.86 (#89)
1 parent f6332f6 commit 625e3db

10 files changed

Lines changed: 23 additions & 24 deletions

File tree

evm-tests/ethcore-builtin/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ struct ModexpPricer {
112112

113113
impl Pricer for Linear {
114114
fn cost(&self, input: &[u8]) -> U256 {
115-
U256::from(self.base) + U256::from(self.word) * U256::from((input.len() + 31) / 32)
115+
U256::from(self.base) + U256::from(self.word) * U256::from(input.len().div_ceil(32))
116116
}
117117
}
118118

evm/src/backend/memory.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl<'vicinity> MemoryBackend<'vicinity> {
9292
}
9393

9494
/// Get a mutable reference to the underlying `BTreeMap` storing the state.
95-
pub fn state_mut(&mut self) -> &mut BTreeMap<H160, MemoryAccount> {
95+
pub const fn state_mut(&mut self) -> &mut BTreeMap<H160, MemoryAccount> {
9696
&mut self.state
9797
}
9898
}
@@ -173,7 +173,7 @@ impl Backend for MemoryBackend<'_> {
173173
fn is_empty_storage(&self, address: H160) -> bool {
174174
self.state
175175
.get(&address)
176-
.map_or(true, |v| v.storage.is_empty())
176+
.is_none_or(|v| v.storage.is_empty())
177177
}
178178

179179
fn original_storage(&self, address: H160, index: H256) -> Option<H256> {

evm/src/core/eval/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn eval_table<H: InterpreterHandler>(
5151
table_elem!($operation, $state, _pc, $definition)
5252
};
5353
($operation:ident, $state:ident, $pc:ident, $definition:expr) => {
54-
#[allow(non_snake_case)]
54+
#[allow(non_snake_case, clippy::missing_const_for_fn)]
5555
fn $operation($state: &mut Machine, _opcode: Opcode, $pc: usize) -> Control {
5656
$definition
5757
}
@@ -301,7 +301,7 @@ fn eval_table<H: InterpreterHandler>(
301301
state.exit(e.clone().into());
302302
return Control::Exit(ExitReason::Error(e));
303303
}
304-
};
304+
}
305305
let control = TABLE[op.as_usize()](state, op, pc);
306306

307307
#[cfg(feature = "tracing")]

evm/src/core/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl Machine {
7474
&self.stack
7575
}
7676
/// Mutable reference of machine stack.
77-
pub fn stack_mut(&mut self) -> &mut Stack {
77+
pub const fn stack_mut(&mut self) -> &mut Stack {
7878
&mut self.stack
7979
}
8080
/// Reference of machine memory.
@@ -83,7 +83,7 @@ impl Machine {
8383
&self.memory
8484
}
8585
/// Mutable reference of machine memory.
86-
pub fn memory_mut(&mut self) -> &mut Memory {
86+
pub const fn memory_mut(&mut self) -> &mut Memory {
8787
&mut self.memory
8888
}
8989
/// Return a reference of the program counter.

evm/src/executor/stack/executor.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ impl<'config> StackSubstateMetadata<'config> {
247247
&self.gasometer
248248
}
249249

250-
pub fn gasometer_mut(&mut self) -> &mut Gasometer<'config> {
250+
pub const fn gasometer_mut(&mut self) -> &mut Gasometer<'config> {
251251
&mut self.gasometer
252252
}
253253

@@ -445,7 +445,7 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
445445
&self.state
446446
}
447447

448-
pub fn state_mut(&mut self) -> &mut S {
448+
pub const fn state_mut(&mut self) -> &mut S {
449449
&mut self.state
450450
}
451451

@@ -942,7 +942,7 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
942942
self.state
943943
.metadata_mut()
944944
.access_addresses([caller, address].iter().copied());
945-
};
945+
}
946946

947947
self.warm_access_list(access_list);
948948
}
@@ -1287,7 +1287,7 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
12871287
Ok(())
12881288
}
12891289

1290-
log::debug!(target: "evm", "Create execution using address {}: {:?}", created_address, reason);
1290+
log::debug!(target: "evm", "Create execution using address {created_address}: {reason:?}");
12911291

12921292
match reason {
12931293
ExitReason::Succeed(s) => {
@@ -1355,7 +1355,7 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
13551355
reason: &ExitReason,
13561356
return_data: Vec<u8>,
13571357
) -> Vec<u8> {
1358-
log::debug!(target: "evm", "Call execution using address {}: {:?}", code_address, reason);
1358+
log::debug!(target: "evm", "Call execution using address {code_address}: {reason:?}");
13591359
match reason {
13601360
ExitReason::Succeed(_) => {
13611361
let _ = self.exit_substate(&StackExitKind::Succeeded);

evm/src/executor/stack/memory.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ impl<'config> MemoryStackSubstate<'config> {
4343
}
4444

4545
#[must_use]
46+
#[allow(clippy::missing_const_for_fn)]
4647
pub fn logs(&self) -> &[Log] {
4748
&self.logs
4849
}
4950

50-
pub fn logs_mut(&mut self) -> &mut Vec<Log> {
51+
pub const fn logs_mut(&mut self) -> &mut Vec<Log> {
5152
&mut self.logs
5253
}
5354

@@ -56,7 +57,7 @@ impl<'config> MemoryStackSubstate<'config> {
5657
&self.metadata
5758
}
5859

59-
pub fn metadata_mut(&mut self) -> &mut StackSubstateMetadata<'config> {
60+
pub const fn metadata_mut(&mut self) -> &mut StackSubstateMetadata<'config> {
6061
&mut self.metadata
6162
}
6263

@@ -315,9 +316,7 @@ impl<'config> MemoryStackSubstate<'config> {
315316
if local_is_accessed {
316317
false
317318
} else {
318-
self.parent
319-
.as_ref()
320-
.map_or(true, |p| p.recursive_is_cold(f))
319+
self.parent.as_ref().is_none_or(|p| p.recursive_is_cold(f))
321320
}
322321
}
323322

evm/src/gasometer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ pub const fn init_code_cost(data: &[u8]) -> u64 {
481481
// As per EIP-3860:
482482
// > We define initcode_cost(initcode) to equal INITCODE_WORD_COST * ceil(len(initcode) / 32).
483483
// where INITCODE_WORD_COST is 2.
484-
2 * ((data.len() as u64 + 31) / 32)
484+
2 * (data.len() as u64).div_ceil(32)
485485
}
486486

487487
/// Counts the number of addresses and storage keys in the access list

evm/src/runtime/eval/system.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub fn extcodecopy<H: Handler>(runtime: &mut Runtime, handler: &H) -> Control<H>
167167
) {
168168
Ok(()) => (),
169169
Err(e) => return Control::Exit(e.into()),
170-
};
170+
}
171171

172172
Control::Continue
173173
}
@@ -204,7 +204,7 @@ pub fn returndatacopy<H: Handler>(runtime: &mut Runtime) -> Control<H> {
204204
.resize_offset(memory_offset, len));
205205
if data_offset
206206
.checked_add(len.into())
207-
.map_or(true, |l| l > U256::from(runtime.return_data_buffer.len()))
207+
.is_none_or(|l| l > U256::from(runtime.return_data_buffer.len()))
208208
{
209209
return Control::Exit(ExitError::OutOfOffset.into());
210210
}
@@ -343,7 +343,7 @@ pub fn mcopy<H: Handler>(runtime: &mut Runtime, _handler: &mut H) -> Control<H>
343343
match runtime.machine.memory_mut().copy(src, dst, len) {
344344
Ok(()) => (),
345345
Err(e) => return Control::Exit(e.into()),
346-
};
346+
}
347347

348348
Control::Continue
349349
}

evm/src/runtime/interrupt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub struct ResolveCreate<'a> {
1414
}
1515

1616
impl<'a> ResolveCreate<'a> {
17-
pub(crate) fn new(runtime: &'a mut Runtime) -> Self {
17+
pub(crate) const fn new(runtime: &'a mut Runtime) -> Self {
1818
Self { _runtime: runtime }
1919
}
2020
}
@@ -25,7 +25,7 @@ pub struct ResolveCall<'a> {
2525
}
2626

2727
impl<'a> ResolveCall<'a> {
28-
pub(crate) fn new(runtime: &'a mut Runtime) -> Self {
28+
pub(crate) const fn new(runtime: &'a mut Runtime) -> Self {
2929
Self { _runtime: runtime }
3030
}
3131
}

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "1.81.0"
2+
channel = "1.86.0"
33
components = ["rustfmt", "clippy"]

0 commit comments

Comments
 (0)