diff --git a/.travis.yml b/.travis.yml index e925be0..735c022 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,9 +10,11 @@ matrix: include: - rust: stable before_script: - - rustup component add rustfmt-preview + - rustup component add rustfmt + - rustup component add clippy script: - cargo fmt -- --check + - cargo clippy - cargo test - rust: stable script: @@ -24,10 +26,7 @@ matrix: script: - cargo test --release - rust: nightly - before_script: - - rustup component add clippy-preview script: - - cargo clippy - cargo test - rust: nightly script: diff --git a/Cargo.toml b/Cargo.toml index 47b7d13..574d88c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,9 @@ authors = ["Brian L. Troutwine "] [dependencies] afl = "0.4" arbitrary = "0.2" -bh_alloc = "0.1" +bh_alloc = "0.2.4" +strum = "0.13.0" +strum_macros = "0.13.0" [[bin]] path = "src/bin/stdlib/str/repeat.rs" @@ -19,3 +21,6 @@ name = "hash_map" [[bin]] path = "src/bin/stdlib/collections/vec_deque.rs" name = "vec_deque" + +[patch.crates-io] +strum_macros = { git = "https://github.com/Peternator7/strum" } diff --git a/src/lib.rs b/src/lib.rs index 7d3ba64..88d067b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,7 @@ extern crate arbitrary; +extern crate strum; +#[macro_use] +extern crate strum_macros; #[deny(warnings)] #[deny(bad_style)] #[deny(missing_docs)] diff --git a/src/stdlib/collections/hash_map.rs b/src/stdlib/collections/hash_map.rs index aebe34d..1a1e04e 100644 --- a/src/stdlib/collections/hash_map.rs +++ b/src/stdlib/collections/hash_map.rs @@ -157,7 +157,7 @@ where /// `HashMap` and `PropHashMap`. Some map directly to functions /// available on the types, others require a more elaborate interpretation /// step. -#[derive(Clone, Debug)] +#[derive(Clone, EnumCount, Debug)] pub enum Op { /// This operation triggers `std::collections::HashMap::shrink_to_fit` ShrinkToFit, @@ -196,13 +196,7 @@ where where U: Unstructured + ?Sized, { - // ================ WARNING ================ - // - // `total_enum_fields` is a goofy annoyance but it should match - // _exactly_ the number of fields available in `Op`. If it - // does not then we'll fail to generate `Op` variants for use in our - // QC tests. - let total_enum_fields = 6; + let total_enum_fields = OP_COUNT as u8; let variant: u8 = Arbitrary::arbitrary(u)?; let op = match variant % total_enum_fields { 0 => { diff --git a/src/stdlib/collections/vec_deque.rs b/src/stdlib/collections/vec_deque.rs index fb3aa0d..272a175 100644 --- a/src/stdlib/collections/vec_deque.rs +++ b/src/stdlib/collections/vec_deque.rs @@ -143,7 +143,7 @@ impl PropVecDeque { /// The `Op` defines the set of operations that are available against /// `VecDeque` and `PropVecDeque`. Some map directly to functions /// available on the types, others require a more elaborate interpretation step. -#[derive(Clone, Debug)] +#[derive(Clone, EnumCount, Debug)] pub enum Op { /// This operation triggers `std::collections::VecDeque::shrink_to_fit` ShrinkToFit, @@ -173,13 +173,7 @@ where where U: Unstructured + ?Sized, { - // ================ WARNING ================ - // - // `total_enum_fields` is a goofy annoyance but it should match - // _exactly_ the number of fields available in `Op`. If it - // does not then we'll fail to generate `Op` variants for use in our - // QC tests. - let total_enum_fields = 9; + let total_enum_fields = OP_COUNT as u8; let variant: u8 = Arbitrary::arbitrary(u)?; let op = match variant % total_enum_fields { 0 => {