Skip to content

Commit c71e99a

Browse files
committed
Use Options::DEFAULT to fill out Options constructor
Now-upstreamed changes require the `Options` structure to define more fields. We use a `const` variable here (versus `impl Default`) so it can be used in other `const` contexts.
1 parent 7ac28e4 commit c71e99a

File tree

3 files changed

+19
-26
lines changed

3 files changed

+19
-26
lines changed

src/fuzzing/fastalloc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const OPTIONS: func::Options = func::Options {
1111
clobbers: true,
1212
reftypes: false,
1313
callsite_ish_constraints: true,
14+
..func::Options::DEFAULT
1415
};
1516

1617
/// A convenience wrapper to generate a [`func::Func`] with `fastalloc`-specific

src/fuzzing/func.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -376,27 +376,26 @@ pub struct Options {
376376
pub num_clobbers_per_inst: RangeInclusive<usize>,
377377
}
378378

379-
impl core::default::Default for Options {
380-
fn default() -> Self {
381-
Options {
382-
reused_inputs: false,
383-
fixed_regs: false,
384-
fixed_nonallocatable: false,
385-
clobbers: false,
386-
reftypes: false,
387-
callsite_ish_constraints: false,
388-
num_blocks: 1..=100,
389-
num_vregs_per_block: 5..=15,
390-
num_uses_per_inst: 0..=10,
391-
num_callsite_ish_vregs_per_inst: 0..=20,
392-
num_clobbers_per_inst: 0..=10,
393-
}
394-
}
379+
impl Options {
380+
/// Default options for generating functions.
381+
pub const DEFAULT: Self = Self {
382+
reused_inputs: false,
383+
fixed_regs: false,
384+
fixed_nonallocatable: false,
385+
clobbers: false,
386+
reftypes: false,
387+
callsite_ish_constraints: false,
388+
num_blocks: 1..=100,
389+
num_vregs_per_block: 5..=15,
390+
num_uses_per_inst: 0..=10,
391+
num_callsite_ish_vregs_per_inst: 0..=20,
392+
num_clobbers_per_inst: 0..=10,
393+
};
395394
}
396395

397396
impl Arbitrary<'_> for Func {
398397
fn arbitrary(u: &mut Unstructured) -> ArbitraryResult<Func> {
399-
Func::arbitrary_with_options(u, &Options::default())
398+
Func::arbitrary_with_options(u, &Options::DEFAULT)
400399
}
401400
}
402401

src/fuzzing/ion.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const OPTIONS: func::Options = func::Options {
1313
clobbers: true,
1414
reftypes: true,
1515
callsite_ish_constraints: true,
16+
..func::Options::DEFAULT
1617
};
1718

1819
/// A convenience wrapper to generate a [`func::Func`] with `ion`-specific
@@ -26,15 +27,7 @@ pub struct TestCase {
2627

2728
impl Arbitrary<'_> for TestCase {
2829
fn arbitrary(u: &mut Unstructured) -> Result<TestCase> {
29-
let options = func::Options {
30-
reused_inputs: true,
31-
fixed_regs: true,
32-
fixed_nonallocatable: true,
33-
clobbers: true,
34-
reftypes: true,
35-
callsite_ish_constraints: true,
36-
};
37-
let func = func::Func::arbitrary_with_options(u, &options)?;
30+
let func = func::Func::arbitrary_with_options(u, &OPTIONS)?;
3831
let annotate = bool::arbitrary(u)?;
3932
let check_ssa = bool::arbitrary(u)?;
4033
Ok(TestCase {

0 commit comments

Comments
 (0)