Skip to content

Commit 1942157

Browse files
authored
make FuncToValidate fields pub (#1495)
This also removes the `FuncToValidate::new` constructor and its uses.
1 parent 7e0c6e5 commit 1942157

File tree

2 files changed

+20
-28
lines changed

2 files changed

+20
-28
lines changed

crates/wasmparser/src/validator.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -986,12 +986,12 @@ impl Validator {
986986
let state = self.module.as_mut().unwrap();
987987

988988
let (index, ty) = state.next_code_index_and_type(offset)?;
989-
Ok(FuncToValidate::new(
989+
Ok(FuncToValidate {
990990
index,
991991
ty,
992-
ValidatorResources(state.module.arc().clone()),
993-
&self.features,
994-
))
992+
resources: ValidatorResources(state.module.arc().clone()),
993+
features: self.features,
994+
})
995995
}
996996

997997
/// Validates [`Payload::DataSection`](crate::Payload).

crates/wasmparser/src/validator/func.rs

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,18 @@ use crate::{FunctionBody, Operator, WasmFeatures, WasmModuleResources};
1010
/// for sending to other threads while the original
1111
/// [`Validator`](crate::Validator) continues processing other functions.
1212
pub struct FuncToValidate<T> {
13-
resources: T,
14-
index: u32,
15-
ty: u32,
16-
features: WasmFeatures,
13+
/// Reusable, heap allocated resources to drive the Wasm validation.
14+
pub resources: T,
15+
/// The core Wasm function index being validated.
16+
pub index: u32,
17+
/// The core Wasm type index of the function being validated,
18+
/// defining the results and parameters to the function.
19+
pub ty: u32,
20+
/// The Wasm features enabled to validate the function.
21+
pub features: WasmFeatures,
1722
}
1823

1924
impl<T: WasmModuleResources> FuncToValidate<T> {
20-
/// Creates a new function to validate which will have the specified
21-
/// configuration parameters:
22-
///
23-
/// * `index` - the core wasm function index being validated
24-
/// * `ty` - the core wasm type index of the function being validated,
25-
/// defining the results and parameters to the function.
26-
/// * `resources` - metadata and type information about the module that
27-
/// this function is validated within.
28-
/// * `features` - enabled WebAssembly features.
29-
pub fn new(index: u32, ty: u32, resources: T, features: &WasmFeatures) -> FuncToValidate<T> {
30-
FuncToValidate {
31-
resources,
32-
index,
33-
ty,
34-
features: *features,
35-
}
36-
}
37-
3825
/// Converts this [`FuncToValidate`] into a [`FuncValidator`] using the
3926
/// `allocs` provided.
4027
///
@@ -310,8 +297,13 @@ mod tests {
310297

311298
#[test]
312299
fn operand_stack_height() {
313-
let mut v = FuncToValidate::new(0, 0, EmptyResources::default(), &Default::default())
314-
.into_validator(Default::default());
300+
let mut v = FuncToValidate {
301+
index: 0,
302+
ty: 0,
303+
resources: EmptyResources::default(),
304+
features: Default::default(),
305+
}
306+
.into_validator(Default::default());
315307

316308
// Initially zero values on the stack.
317309
assert_eq!(v.operand_stack_height(), 0);

0 commit comments

Comments
 (0)