Skip to content

Commit 5dfa9f9

Browse files
authored
Use rust edition 2024 (#474)
* Use rust edition 2024 * Make no_mangle unsafe * Fix clippy
1 parent b64eda4 commit 5dfa9f9

Some content is hidden

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

47 files changed

+159
-160
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ description = "CKB's Virtual machine"
44
version = "0.24.0"
55
license = "MIT"
66
authors = ["Nervos Core Dev <dev@nervos.org>"]
7-
edition = "2021"
8-
rust-version = "1.81.0"
7+
edition = "2024"
8+
rust-version = "1.85.0"
99
build = "build.rs"
1010
exclude = ["/benches", "/tests"]
1111
homepage = "https://github.com/nervosnetwork/ckb-vm"

benches/vm_benchmark.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ extern crate criterion;
44
use bytes::Bytes;
55
#[cfg(has_asm)]
66
use ckb_vm::{
7+
ISA_B, ISA_IMC, ISA_MOP,
78
decoder::{DefaultDecoder, InstDecoder},
89
machine::{
10+
AbstractDefaultMachineBuilder, DefaultMachineRunner, SupportMachine, VERSION0, VERSION2,
911
asm::{
10-
traces::{MemoizedDynamicTraceDecoder, MemoizedFixedTraceDecoder},
1112
AbstractAsmMachine, AsmCoreMachine, AsmDefaultMachineBuilder, AsmMachine,
13+
traces::{MemoizedDynamicTraceDecoder, MemoizedFixedTraceDecoder},
1214
},
13-
AbstractDefaultMachineBuilder, DefaultMachineRunner, SupportMachine, VERSION0, VERSION2,
1415
},
15-
ISA_B, ISA_IMC, ISA_MOP,
1616
};
17-
use ckb_vm::{run, SparseMemory};
17+
use ckb_vm::{SparseMemory, run};
1818
use criterion::Criterion;
1919
use std::fs;
2020

definitions/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ description = "Common definition files for CKB VM"
44
version = "0.24.0"
55
license = "MIT"
66
authors = ["Nervos Core Dev <dev@nervos.org>"]
7-
edition = "2021"
8-
rust-version = "1.81.0"
7+
edition = "2024"
8+
rust-version = "1.85.0"
99
autobins = false
1010
homepage = "https://github.com/nervosnetwork/ckb-vm"
1111
repository = "https://github.com/nervosnetwork/ckb-vm"

definitions/src/asm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::{instructions::Instruction, RISCV_GENERAL_REGISTER_NUMBER};
2-
use std::alloc::{dealloc, Layout};
1+
use crate::{RISCV_GENERAL_REGISTER_NUMBER, instructions::Instruction};
2+
use std::alloc::{Layout, dealloc};
33

44
// The number of trace items to keep
55
pub const TRACE_SIZE: usize = 8192;

definitions/src/generate_asm_constants.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
use ckb_vm_definitions::{
2+
MEMORY_FRAME_PAGE_SHIFTS, MEMORY_FRAME_SHIFTS, MEMORY_FRAMESIZE, RISCV_PAGE_SHIFTS,
3+
RISCV_PAGESIZE,
24
asm::{
35
AsmCoreMachine, FixedTrace, InvokeData, RET_CYCLES_OVERFLOW, RET_DECODE_TRACE,
46
RET_DYNAMIC_JUMP, RET_EBREAK, RET_ECALL, RET_INVALID_PERMISSION, RET_MAX_CYCLES_EXCEEDED,
57
RET_OUT_OF_BOUND, RET_PAUSE, RET_SLOWPATH, TRACE_ITEM_LENGTH,
68
},
79
for_each_inst,
8-
instructions::{instruction_opcode_name, MAXIMUM_OPCODE, MINIMAL_OPCODE},
10+
instructions::{MAXIMUM_OPCODE, MINIMAL_OPCODE, instruction_opcode_name},
911
memory::{FLAG_DIRTY, FLAG_EXECUTABLE, FLAG_FREEZED, FLAG_WRITABLE, FLAG_WXORX_BIT},
1012
registers::{RA, SP},
11-
MEMORY_FRAMESIZE, MEMORY_FRAME_PAGE_SHIFTS, MEMORY_FRAME_SHIFTS, RISCV_PAGESIZE,
12-
RISCV_PAGE_SHIFTS,
1313
};
14-
use std::alloc::{alloc, Layout};
14+
use std::alloc::{Layout, alloc};
1515
use std::mem::{size_of, zeroed};
1616

1717
macro_rules! print_inst_label {

examples/check_real_memory.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// This example is mainly to test whether there is memory overflow.
22
// Under linux, we choose to use smem, which can monitor memory changes more accurately
33

4-
use ckb_vm::{run_with_memory, Bytes, FlatMemory, SparseMemory};
5-
use std::process::{id, Command};
4+
use ckb_vm::{Bytes, FlatMemory, SparseMemory, run_with_memory};
5+
use std::process::{Command, id};
66

77
#[cfg(has_asm)]
88
use ckb_vm::{
9+
ISA_IMC,
910
machine::{
10-
asm::{AsmCoreMachine, AsmDefaultMachineBuilder, AsmMachine},
1111
DefaultMachineRunner, SupportMachine, VERSION0,
12+
asm::{AsmCoreMachine, AsmDefaultMachineBuilder, AsmMachine},
1213
},
13-
ISA_IMC,
1414
};
1515

1616
#[cfg(has_asm)]

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.81.0
1+
1.85.0

src/cost_model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{
2-
instructions::{extract_opcode, insts},
32
Instruction,
3+
instructions::{extract_opcode, insts},
44
};
55

66
// Returns the spent cycles to execute the specific instruction.

src/debugger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{machine::SupportMachine, Error};
1+
use crate::{Error, machine::SupportMachine};
22

33
pub trait Debugger<Mac: SupportMachine>: Send + Sync {
44
fn initialize(&mut self, machine: &mut Mac) -> Result<(), Error>;

src/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use ckb_vm_definitions::registers::{RA, ZERO};
33

44
use crate::error::OutOfBoundKind;
55
use crate::instructions::{
6-
a, b, extract_opcode, i, instruction_length, m, rvc, set_instruction_length_n, Instruction,
7-
InstructionFactory, Itype, R4type, R5type, Register, Rtype, Utype,
6+
Instruction, InstructionFactory, Itype, R4type, R5type, Register, Rtype, Utype, a, b,
7+
extract_opcode, i, instruction_length, m, rvc, set_instruction_length_n,
88
};
99
use crate::machine::VERSION2;
1010
use crate::memory::Memory;

0 commit comments

Comments
 (0)