Skip to content

Commit 3ad8234

Browse files
committed
unsilence unused_variables warning and fix occurrences
1 parent 28b2ad4 commit 3ad8234

File tree

7 files changed

+114
-124
lines changed

7 files changed

+114
-124
lines changed

crates/wasmi/src/engine/translator/func2/layout/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl StackLayout {
3434
/// # Errors
3535
///
3636
/// If too many local variables are being registered.
37-
pub fn register_locals(&mut self, amount: u32, ty: ValType) -> Result<(), Error> {
37+
pub fn register_locals(&mut self, amount: u32, _ty: ValType) -> Result<(), Error> {
3838
self.len_locals += amount as usize;
3939
Ok(())
4040
}

crates/wasmi/src/engine/translator/func2/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![expect(dead_code, unused_imports, unused_variables)]
1+
#![expect(dead_code, unused_imports)]
22

33
#[macro_use]
44
mod utils;
@@ -250,7 +250,7 @@ impl FuncTranslator {
250250

251251
/// Translates the end of the Wasm function enclosing Wasm `block`.
252252
fn translate_end_func(&mut self, frame: BlockControlFrame) -> Result<(), Error> {
253-
let fuel_info = match (&self.fuel_costs, frame.consume_fuel_instr()) {
253+
let _fuel_info = match (&self.fuel_costs, frame.consume_fuel_instr()) {
254254
(Some(fuel_costs), Some(consume_fuel)) => {
255255
FuelInfo::some(fuel_costs.clone(), consume_fuel)
256256
}
@@ -351,7 +351,7 @@ impl FuncTranslator {
351351
};
352352
self.instrs.push_instr(instr);
353353
}
354-
n => {
354+
_ => {
355355
let height = frame.height();
356356
let result = self.layout.temp_to_reg(OperandIdx::from(height - 1))?;
357357
let values = BoundedRegSpan::new(RegSpan::new(result), len_results);
@@ -362,22 +362,22 @@ impl FuncTranslator {
362362
}
363363

364364
/// Translates the end of a Wasm `loop` control frame.
365-
fn translate_end_loop(&mut self, frame: LoopControlFrame) -> Result<(), Error> {
365+
fn translate_end_loop(&mut self, _frame: LoopControlFrame) -> Result<(), Error> {
366366
todo!()
367367
}
368368

369369
/// Translates the end of a Wasm `if` control frame.
370-
fn translate_end_if(&mut self, frame: IfControlFrame) -> Result<(), Error> {
370+
fn translate_end_if(&mut self, _frame: IfControlFrame) -> Result<(), Error> {
371371
todo!()
372372
}
373373

374374
/// Translates the end of a Wasm `else` control frame.
375-
fn translate_end_else(&mut self, frame: ElseControlFrame) -> Result<(), Error> {
375+
fn translate_end_else(&mut self, _frame: ElseControlFrame) -> Result<(), Error> {
376376
todo!()
377377
}
378378

379379
/// Translates the end of an unreachable Wasm control frame.
380-
fn translate_end_unreachable(&mut self, frame: UnreachableControlFrame) -> Result<(), Error> {
380+
fn translate_end_unreachable(&mut self, _frame: UnreachableControlFrame) -> Result<(), Error> {
381381
todo!()
382382
}
383383

crates/wasmi/src/engine/translator/func2/simd/visit.rs

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,155 +2,155 @@ use super::FuncTranslator;
22
use wasmparser::VisitSimdOperator;
33

44
impl VisitSimdOperator<'_> for FuncTranslator {
5-
fn visit_v128_load(&mut self, memarg: wasmparser::MemArg) -> Self::Output {
5+
fn visit_v128_load(&mut self, _memarg: wasmparser::MemArg) -> Self::Output {
66
todo!()
77
}
88

9-
fn visit_v128_load8x8_s(&mut self, memarg: wasmparser::MemArg) -> Self::Output {
9+
fn visit_v128_load8x8_s(&mut self, _memarg: wasmparser::MemArg) -> Self::Output {
1010
todo!()
1111
}
1212

13-
fn visit_v128_load8x8_u(&mut self, memarg: wasmparser::MemArg) -> Self::Output {
13+
fn visit_v128_load8x8_u(&mut self, _memarg: wasmparser::MemArg) -> Self::Output {
1414
todo!()
1515
}
1616

17-
fn visit_v128_load16x4_s(&mut self, memarg: wasmparser::MemArg) -> Self::Output {
17+
fn visit_v128_load16x4_s(&mut self, _memarg: wasmparser::MemArg) -> Self::Output {
1818
todo!()
1919
}
2020

21-
fn visit_v128_load16x4_u(&mut self, memarg: wasmparser::MemArg) -> Self::Output {
21+
fn visit_v128_load16x4_u(&mut self, _memarg: wasmparser::MemArg) -> Self::Output {
2222
todo!()
2323
}
2424

25-
fn visit_v128_load32x2_s(&mut self, memarg: wasmparser::MemArg) -> Self::Output {
25+
fn visit_v128_load32x2_s(&mut self, _memarg: wasmparser::MemArg) -> Self::Output {
2626
todo!()
2727
}
2828

29-
fn visit_v128_load32x2_u(&mut self, memarg: wasmparser::MemArg) -> Self::Output {
29+
fn visit_v128_load32x2_u(&mut self, _memarg: wasmparser::MemArg) -> Self::Output {
3030
todo!()
3131
}
3232

33-
fn visit_v128_load8_splat(&mut self, memarg: wasmparser::MemArg) -> Self::Output {
33+
fn visit_v128_load8_splat(&mut self, _memarg: wasmparser::MemArg) -> Self::Output {
3434
todo!()
3535
}
3636

37-
fn visit_v128_load16_splat(&mut self, memarg: wasmparser::MemArg) -> Self::Output {
37+
fn visit_v128_load16_splat(&mut self, _memarg: wasmparser::MemArg) -> Self::Output {
3838
todo!()
3939
}
4040

41-
fn visit_v128_load32_splat(&mut self, memarg: wasmparser::MemArg) -> Self::Output {
41+
fn visit_v128_load32_splat(&mut self, _memarg: wasmparser::MemArg) -> Self::Output {
4242
todo!()
4343
}
4444

45-
fn visit_v128_load64_splat(&mut self, memarg: wasmparser::MemArg) -> Self::Output {
45+
fn visit_v128_load64_splat(&mut self, _memarg: wasmparser::MemArg) -> Self::Output {
4646
todo!()
4747
}
4848

49-
fn visit_v128_load32_zero(&mut self, memarg: wasmparser::MemArg) -> Self::Output {
49+
fn visit_v128_load32_zero(&mut self, _memarg: wasmparser::MemArg) -> Self::Output {
5050
todo!()
5151
}
5252

53-
fn visit_v128_load64_zero(&mut self, memarg: wasmparser::MemArg) -> Self::Output {
53+
fn visit_v128_load64_zero(&mut self, _memarg: wasmparser::MemArg) -> Self::Output {
5454
todo!()
5555
}
5656

57-
fn visit_v128_store(&mut self, memarg: wasmparser::MemArg) -> Self::Output {
57+
fn visit_v128_store(&mut self, _memarg: wasmparser::MemArg) -> Self::Output {
5858
todo!()
5959
}
6060

61-
fn visit_v128_load8_lane(&mut self, memarg: wasmparser::MemArg, lane: u8) -> Self::Output {
61+
fn visit_v128_load8_lane(&mut self, _memarg: wasmparser::MemArg, _lane: u8) -> Self::Output {
6262
todo!()
6363
}
6464

65-
fn visit_v128_load16_lane(&mut self, memarg: wasmparser::MemArg, lane: u8) -> Self::Output {
65+
fn visit_v128_load16_lane(&mut self, _memarg: wasmparser::MemArg, _lane: u8) -> Self::Output {
6666
todo!()
6767
}
6868

69-
fn visit_v128_load32_lane(&mut self, memarg: wasmparser::MemArg, lane: u8) -> Self::Output {
69+
fn visit_v128_load32_lane(&mut self, _memarg: wasmparser::MemArg, _lane: u8) -> Self::Output {
7070
todo!()
7171
}
7272

73-
fn visit_v128_load64_lane(&mut self, memarg: wasmparser::MemArg, lane: u8) -> Self::Output {
73+
fn visit_v128_load64_lane(&mut self, _memarg: wasmparser::MemArg, _lane: u8) -> Self::Output {
7474
todo!()
7575
}
7676

77-
fn visit_v128_store8_lane(&mut self, memarg: wasmparser::MemArg, lane: u8) -> Self::Output {
77+
fn visit_v128_store8_lane(&mut self, _memarg: wasmparser::MemArg, _lane: u8) -> Self::Output {
7878
todo!()
7979
}
8080

81-
fn visit_v128_store16_lane(&mut self, memarg: wasmparser::MemArg, lane: u8) -> Self::Output {
81+
fn visit_v128_store16_lane(&mut self, _memarg: wasmparser::MemArg, _lane: u8) -> Self::Output {
8282
todo!()
8383
}
8484

85-
fn visit_v128_store32_lane(&mut self, memarg: wasmparser::MemArg, lane: u8) -> Self::Output {
85+
fn visit_v128_store32_lane(&mut self, _memarg: wasmparser::MemArg, _lane: u8) -> Self::Output {
8686
todo!()
8787
}
8888

89-
fn visit_v128_store64_lane(&mut self, memarg: wasmparser::MemArg, lane: u8) -> Self::Output {
89+
fn visit_v128_store64_lane(&mut self, _memarg: wasmparser::MemArg, _lane: u8) -> Self::Output {
9090
todo!()
9191
}
9292

93-
fn visit_v128_const(&mut self, value: wasmparser::V128) -> Self::Output {
93+
fn visit_v128_const(&mut self, _value: wasmparser::V128) -> Self::Output {
9494
todo!()
9595
}
9696

97-
fn visit_i8x16_shuffle(&mut self, lanes: [u8; 16]) -> Self::Output {
97+
fn visit_i8x16_shuffle(&mut self, _lanes: [u8; 16]) -> Self::Output {
9898
todo!()
9999
}
100100

101-
fn visit_i8x16_extract_lane_s(&mut self, lane: u8) -> Self::Output {
101+
fn visit_i8x16_extract_lane_s(&mut self, _lane: u8) -> Self::Output {
102102
todo!()
103103
}
104104

105-
fn visit_i8x16_extract_lane_u(&mut self, lane: u8) -> Self::Output {
105+
fn visit_i8x16_extract_lane_u(&mut self, _lane: u8) -> Self::Output {
106106
todo!()
107107
}
108108

109-
fn visit_i8x16_replace_lane(&mut self, lane: u8) -> Self::Output {
109+
fn visit_i8x16_replace_lane(&mut self, _lane: u8) -> Self::Output {
110110
todo!()
111111
}
112112

113-
fn visit_i16x8_extract_lane_s(&mut self, lane: u8) -> Self::Output {
113+
fn visit_i16x8_extract_lane_s(&mut self, _lane: u8) -> Self::Output {
114114
todo!()
115115
}
116116

117-
fn visit_i16x8_extract_lane_u(&mut self, lane: u8) -> Self::Output {
117+
fn visit_i16x8_extract_lane_u(&mut self, _lane: u8) -> Self::Output {
118118
todo!()
119119
}
120120

121-
fn visit_i16x8_replace_lane(&mut self, lane: u8) -> Self::Output {
121+
fn visit_i16x8_replace_lane(&mut self, _lane: u8) -> Self::Output {
122122
todo!()
123123
}
124124

125-
fn visit_i32x4_extract_lane(&mut self, lane: u8) -> Self::Output {
125+
fn visit_i32x4_extract_lane(&mut self, _lane: u8) -> Self::Output {
126126
todo!()
127127
}
128128

129-
fn visit_i32x4_replace_lane(&mut self, lane: u8) -> Self::Output {
129+
fn visit_i32x4_replace_lane(&mut self, _lane: u8) -> Self::Output {
130130
todo!()
131131
}
132132

133-
fn visit_i64x2_extract_lane(&mut self, lane: u8) -> Self::Output {
133+
fn visit_i64x2_extract_lane(&mut self, _lane: u8) -> Self::Output {
134134
todo!()
135135
}
136136

137-
fn visit_i64x2_replace_lane(&mut self, lane: u8) -> Self::Output {
137+
fn visit_i64x2_replace_lane(&mut self, _lane: u8) -> Self::Output {
138138
todo!()
139139
}
140140

141-
fn visit_f32x4_extract_lane(&mut self, lane: u8) -> Self::Output {
141+
fn visit_f32x4_extract_lane(&mut self, _lane: u8) -> Self::Output {
142142
todo!()
143143
}
144144

145-
fn visit_f32x4_replace_lane(&mut self, lane: u8) -> Self::Output {
145+
fn visit_f32x4_replace_lane(&mut self, _lane: u8) -> Self::Output {
146146
todo!()
147147
}
148148

149-
fn visit_f64x2_extract_lane(&mut self, lane: u8) -> Self::Output {
149+
fn visit_f64x2_extract_lane(&mut self, _lane: u8) -> Self::Output {
150150
todo!()
151151
}
152152

153-
fn visit_f64x2_replace_lane(&mut self, lane: u8) -> Self::Output {
153+
fn visit_f64x2_replace_lane(&mut self, _lane: u8) -> Self::Output {
154154
todo!()
155155
}
156156

crates/wasmi/src/engine/translator/func2/stack/control.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,29 @@ pub struct ElseOperands {
2323
/// The end indices of each `else` operands.
2424
ends: Vec<usize>,
2525
/// All operands of all allocated `else` control frames.
26-
providers: Vec<Operand>,
26+
operands: Vec<Operand>,
2727
}
2828

2929
impl Reset for ElseOperands {
3030
fn reset(&mut self) {
3131
self.ends.clear();
32-
self.providers.clear();
32+
self.operands.clear();
3333
}
3434
}
3535

3636
impl ElseOperands {
3737
/// Pushes operands for a new Wasm `else` control frame.
3838
pub fn push(&mut self, operands: impl IntoIterator<Item = Operand>) {
39-
self.providers.extend(operands);
40-
let end = self.providers.len();
41-
let index = self.ends.len();
39+
self.operands.extend(operands);
40+
let end = self.operands.len();
4241
self.ends.push(end);
4342
}
4443

4544
/// Pops the top-most Wasm `else` operands from `self` and returns it.
4645
pub fn pop(&mut self) -> Option<Drain<Operand>> {
4746
let end = self.ends.pop()?;
4847
let start = self.ends.last().copied().unwrap_or(0);
49-
Some(self.providers.drain(start..end))
48+
Some(self.operands.drain(start..end))
5049
}
5150
}
5251

@@ -203,7 +202,6 @@ impl ControlStack {
203202
/// Acquires the target [`ControlFrame`] at the given relative `depth`.
204203
pub fn acquire_target(&mut self, depth: usize) -> AcquiredTarget {
205204
let is_root = self.is_root(depth);
206-
let height = self.height();
207205
let frame = self.get_mut(depth);
208206
if is_root {
209207
AcquiredTarget::Return(frame)
@@ -274,7 +272,7 @@ impl ControlFrame {
274272
ControlFrame::Loop(frame) => frame.branch_to(),
275273
ControlFrame::If(frame) => frame.branch_to(),
276274
ControlFrame::Else(frame) => frame.branch_to(),
277-
ControlFrame::Unreachable(frame) => {
275+
ControlFrame::Unreachable(_) => {
278276
panic!("invalid query for unreachable control frame: `ControlFrame::branch_to`")
279277
}
280278
}
@@ -289,7 +287,7 @@ impl ControlFrame {
289287
ControlFrame::Loop(frame) => frame.consume_fuel_instr(),
290288
ControlFrame::If(frame) => frame.consume_fuel_instr(),
291289
ControlFrame::Else(frame) => frame.consume_fuel_instr(),
292-
ControlFrame::Unreachable(frame) => {
290+
ControlFrame::Unreachable(_) => {
293291
panic!("invalid query for unreachable control frame: `ControlFrame::consume_fuel_instr`")
294292
}
295293
}

crates/wasmi/src/engine/translator/func2/stack/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,7 @@ impl Stack {
307307
/// # Errors
308308
///
309309
/// If the stack height exceeds the maximum height.
310-
pub fn push_unreachable(
311-
&mut self,
312-
ty: BlockType,
313-
kind: UnreachableControlFrame,
314-
) -> Result<(), Error> {
310+
pub fn push_unreachable(&mut self, kind: UnreachableControlFrame) -> Result<(), Error> {
315311
self.controls.push_unreachable(kind);
316312
Ok(())
317313
}

crates/wasmi/src/engine/translator/func2/stack/operands.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,10 @@ impl OperandStack {
257257
#[must_use]
258258
fn operand_to_temp_at(&mut self, index: OperandIdx) -> Option<StackOperand> {
259259
let operand = self.get_at(index);
260-
let ty = match operand {
261-
StackOperand::Temp { ty, instr } => return None,
260+
match operand {
261+
StackOperand::Temp { .. } => return None,
262262
StackOperand::Immediate { val } => val.ty(),
263-
StackOperand::Local {
264-
local_index,
265-
next_local,
266-
prev_local,
267-
} => self.locals.ty(local_index),
263+
StackOperand::Local { local_index, .. } => self.locals.ty(local_index),
268264
};
269265
self.unlink_local(operand);
270266
self.operands[usize::from(index)] = operand;

0 commit comments

Comments
 (0)