From 5b07640cd6e28a9bc3102f9727badca1c50d971c Mon Sep 17 00:00:00 2001 From: Shaobo He Date: Tue, 5 Nov 2024 15:14:27 -0800 Subject: [PATCH 1/3] Revert "Fix arbitrary to 1.3.2 (#464)" This reverts commit 500e3b234b14ed7d28cf891b949aee28f83e85f3. --- cedar-policy-generators/Cargo.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cedar-policy-generators/Cargo.toml b/cedar-policy-generators/Cargo.toml index 37ec53f38..9548fd9bc 100644 --- a/cedar-policy-generators/Cargo.toml +++ b/cedar-policy-generators/Cargo.toml @@ -5,9 +5,7 @@ version = "4.0.0" publish = false [dependencies] -# We had to fix the version of `arbitrary` as well as `derive_arbitrary` because 1.4.x introduces a breaking change -arbitrary = "=1.3.2" -derive_arbitrary = "=1.3.2" +arbitrary = "1.3" cedar-policy-core = { path = "../cedar/cedar-policy-core", version = "4.*", features = ["arbitrary"] } cedar-policy-validator = { path = "../cedar/cedar-policy-validator", version = "4.*", features = ["arbitrary"] } clap = { version = "4.3.16", features = ["derive"] } From 8ca3e37090a91ef9aa8babd0d968b6e9ab834baa Mon Sep 17 00:00:00 2001 From: Shaobo He Date: Tue, 5 Nov 2024 17:23:49 -0800 Subject: [PATCH 2/3] use `try_size_hint` to replace `size_hint` Signed-off-by: Shaobo He --- .../fuzz/fuzz_targets/abac-type-directed.rs | 12 ++++---- cedar-drt/fuzz/fuzz_targets/abac.rs | 10 ++++--- .../fuzz_targets/common-type-resolution.rs | 4 ++- .../fuzz/fuzz_targets/entity-validation.rs | 10 ++++--- .../fuzz/fuzz_targets/eval-type-directed.rs | 10 ++++--- cedar-drt/fuzz/fuzz_targets/formatter.rs | 10 ++++--- .../fuzz_targets/json-schema-roundtrip.rs | 4 ++- cedar-drt/fuzz/fuzz_targets/partial-eval.rs | 10 ++++--- .../fuzz/fuzz_targets/request-validation.rs | 10 ++++--- cedar-drt/fuzz/fuzz_targets/roundtrip.rs | 10 ++++--- .../fuzz/fuzz_targets/schema-roundtrip.rs | 4 ++- .../validation-drt-type-directed.rs | 10 ++++--- cedar-drt/fuzz/fuzz_targets/validation-drt.rs | 10 ++++--- .../validation-pbt-type-directed.rs | 10 ++++--- cedar-drt/fuzz/fuzz_targets/validation-pbt.rs | 10 ++++--- cedar-policy-generators/src/expr.rs | 28 +++++++++++-------- cedar-policy-generators/src/schema.rs | 26 +++++++++-------- 17 files changed, 113 insertions(+), 75 deletions(-) diff --git a/cedar-drt/fuzz/fuzz_targets/abac-type-directed.rs b/cedar-drt/fuzz/fuzz_targets/abac-type-directed.rs index 6e32a766d..9ff0ba95e 100644 --- a/cedar-drt/fuzz/fuzz_targets/abac-type-directed.rs +++ b/cedar-drt/fuzz/fuzz_targets/abac-type-directed.rs @@ -27,7 +27,7 @@ use cedar_policy_generators::{ schema::Schema, settings::ABACSettings, }; -use libfuzzer_sys::arbitrary::{self, Arbitrary, Unstructured}; +use libfuzzer_sys::arbitrary::{self, Arbitrary, MaxRecursionReached, Unstructured}; use log::{debug, info}; use serde::Serialize; use std::convert::TryFrom; @@ -91,9 +91,11 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> std::result::Result<(usize, Option), MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, HierarchyGenerator::size_hint(depth), Schema::arbitrary_policy_size_hint(&SETTINGS, depth), Schema::arbitrary_request_size_hint(depth), @@ -104,7 +106,7 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), - ]) + ])) } } diff --git a/cedar-drt/fuzz/fuzz_targets/abac.rs b/cedar-drt/fuzz/fuzz_targets/abac.rs index 3fb51f096..22bbb7db4 100644 --- a/cedar-drt/fuzz/fuzz_targets/abac.rs +++ b/cedar-drt/fuzz/fuzz_targets/abac.rs @@ -90,9 +90,11 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> arbitrary::Result<(usize, Option), arbitrary::MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, HierarchyGenerator::size_hint(depth), Schema::arbitrary_policy_size_hint(&SETTINGS, depth), Schema::arbitrary_request_size_hint(depth), @@ -103,7 +105,7 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), - ]) + ])) } } diff --git a/cedar-drt/fuzz/fuzz_targets/common-type-resolution.rs b/cedar-drt/fuzz/fuzz_targets/common-type-resolution.rs index 4becd8c0d..4ff791b12 100644 --- a/cedar-drt/fuzz/fuzz_targets/common-type-resolution.rs +++ b/cedar-drt/fuzz/fuzz_targets/common-type-resolution.rs @@ -71,7 +71,9 @@ impl<'a> Arbitrary<'a> for Input { }) } - fn size_hint(depth: usize) -> (usize, Option) { + fn try_size_hint( + depth: usize, + ) -> arbitrary::Result<(usize, Option), arbitrary::MaxRecursionReached> { Schema::arbitrary_size_hint(depth) } } diff --git a/cedar-drt/fuzz/fuzz_targets/entity-validation.rs b/cedar-drt/fuzz/fuzz_targets/entity-validation.rs index 95e9ec792..166f3c489 100644 --- a/cedar-drt/fuzz/fuzz_targets/entity-validation.rs +++ b/cedar-drt/fuzz/fuzz_targets/entity-validation.rs @@ -58,11 +58,13 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Ok(Self { schema, hierarchy }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> arbitrary::Result<(usize, Option), arbitrary::MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, HierarchyGenerator::size_hint(depth), - ]) + ])) } } diff --git a/cedar-drt/fuzz/fuzz_targets/eval-type-directed.rs b/cedar-drt/fuzz/fuzz_targets/eval-type-directed.rs index 4d6e3593e..1855aebb5 100644 --- a/cedar-drt/fuzz/fuzz_targets/eval-type-directed.rs +++ b/cedar-drt/fuzz/fuzz_targets/eval-type-directed.rs @@ -88,9 +88,11 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> arbitrary::Result<(usize, Option), arbitrary::MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, HierarchyGenerator::size_hint(depth), Schema::arbitrary_policy_size_hint(&SETTINGS, depth), Schema::arbitrary_request_size_hint(depth), @@ -101,7 +103,7 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), - ]) + ])) } } diff --git a/cedar-drt/fuzz/fuzz_targets/formatter.rs b/cedar-drt/fuzz/fuzz_targets/formatter.rs index 7f496d2c1..2782e21c0 100644 --- a/cedar-drt/fuzz/fuzz_targets/formatter.rs +++ b/cedar-drt/fuzz/fuzz_targets/formatter.rs @@ -70,13 +70,15 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Ok(Self { policy, seed }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> arbitrary::Result<(usize, Option), arbitrary::MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, HierarchyGenerator::size_hint(depth), Schema::arbitrary_policy_size_hint(&SETTINGS, depth), ::size_hint(depth), - ]) + ])) } } diff --git a/cedar-drt/fuzz/fuzz_targets/json-schema-roundtrip.rs b/cedar-drt/fuzz/fuzz_targets/json-schema-roundtrip.rs index 424d72142..a22dd984e 100644 --- a/cedar-drt/fuzz/fuzz_targets/json-schema-roundtrip.rs +++ b/cedar-drt/fuzz/fuzz_targets/json-schema-roundtrip.rs @@ -60,7 +60,9 @@ impl<'a> Arbitrary<'a> for Input { Ok(Self { schema }) } - fn size_hint(depth: usize) -> (usize, Option) { + fn try_size_hint( + depth: usize, + ) -> arbitrary::Result<(usize, Option), arbitrary::MaxRecursionReached> { Schema::arbitrary_size_hint(depth) } } diff --git a/cedar-drt/fuzz/fuzz_targets/partial-eval.rs b/cedar-drt/fuzz/fuzz_targets/partial-eval.rs index 78b440383..e905d0025 100644 --- a/cedar-drt/fuzz/fuzz_targets/partial-eval.rs +++ b/cedar-drt/fuzz/fuzz_targets/partial-eval.rs @@ -98,9 +98,11 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> arbitrary::Result<(usize, Option), arbitrary::MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, HierarchyGenerator::size_hint(depth), Schema::arbitrary_policy_size_hint(&SETTINGS, depth), Schema::arbitrary_request_size_hint(depth), @@ -111,7 +113,7 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), - ]) + ])) } } // The main fuzz target. This is for type-directed fuzzing of ABAC diff --git a/cedar-drt/fuzz/fuzz_targets/request-validation.rs b/cedar-drt/fuzz/fuzz_targets/request-validation.rs index c5023d077..4f02840da 100644 --- a/cedar-drt/fuzz/fuzz_targets/request-validation.rs +++ b/cedar-drt/fuzz/fuzz_targets/request-validation.rs @@ -78,9 +78,11 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> arbitrary::Result<(usize, Option), arbitrary::MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, HierarchyGenerator::size_hint(depth), Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), @@ -90,7 +92,7 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), - ]) + ])) } } diff --git a/cedar-drt/fuzz/fuzz_targets/roundtrip.rs b/cedar-drt/fuzz/fuzz_targets/roundtrip.rs index e1a700e6a..17dbcacaf 100644 --- a/cedar-drt/fuzz/fuzz_targets/roundtrip.rs +++ b/cedar-drt/fuzz/fuzz_targets/roundtrip.rs @@ -60,12 +60,14 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Ok(Self { policy }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> arbitrary::Result<(usize, Option), arbitrary::MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, HierarchyGenerator::size_hint(depth), Schema::arbitrary_policy_size_hint(&SETTINGS, depth), - ]) + ])) } } diff --git a/cedar-drt/fuzz/fuzz_targets/schema-roundtrip.rs b/cedar-drt/fuzz/fuzz_targets/schema-roundtrip.rs index aba271fcd..dfb33eb2a 100644 --- a/cedar-drt/fuzz/fuzz_targets/schema-roundtrip.rs +++ b/cedar-drt/fuzz/fuzz_targets/schema-roundtrip.rs @@ -62,7 +62,9 @@ impl<'a> Arbitrary<'a> for Input { Ok(Self { schema }) } - fn size_hint(depth: usize) -> (usize, Option) { + fn try_size_hint( + depth: usize, + ) -> arbitrary::Result<(usize, Option), arbitrary::MaxRecursionReached> { Schema::arbitrary_size_hint(depth) } } diff --git a/cedar-drt/fuzz/fuzz_targets/validation-drt-type-directed.rs b/cedar-drt/fuzz/fuzz_targets/validation-drt-type-directed.rs index 1602ca082..507cdd674 100644 --- a/cedar-drt/fuzz/fuzz_targets/validation-drt-type-directed.rs +++ b/cedar-drt/fuzz/fuzz_targets/validation-drt-type-directed.rs @@ -56,11 +56,13 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Ok(Self { schema, policy }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> arbitrary::Result<(usize, Option), arbitrary::MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, Schema::arbitrary_policy_size_hint(&SETTINGS, depth), - ]) + ])) } } diff --git a/cedar-drt/fuzz/fuzz_targets/validation-drt.rs b/cedar-drt/fuzz/fuzz_targets/validation-drt.rs index c24c90880..024cdbb30 100644 --- a/cedar-drt/fuzz/fuzz_targets/validation-drt.rs +++ b/cedar-drt/fuzz/fuzz_targets/validation-drt.rs @@ -58,12 +58,14 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Ok(Self { schema, policy }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> arbitrary::Result<(usize, Option), arbitrary::MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, HierarchyGenerator::size_hint(depth), Schema::arbitrary_policy_size_hint(&SETTINGS, depth), - ]) + ])) } } diff --git a/cedar-drt/fuzz/fuzz_targets/validation-pbt-type-directed.rs b/cedar-drt/fuzz/fuzz_targets/validation-pbt-type-directed.rs index 7bd683156..a41140b4d 100644 --- a/cedar-drt/fuzz/fuzz_targets/validation-pbt-type-directed.rs +++ b/cedar-drt/fuzz/fuzz_targets/validation-pbt-type-directed.rs @@ -89,9 +89,11 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> arbitrary::Result<(usize, Option), arbitrary::MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, HierarchyGenerator::size_hint(depth), Schema::arbitrary_policy_size_hint(&SETTINGS, depth), Schema::arbitrary_request_size_hint(depth), @@ -102,7 +104,7 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), - ]) + ])) } } diff --git a/cedar-drt/fuzz/fuzz_targets/validation-pbt.rs b/cedar-drt/fuzz/fuzz_targets/validation-pbt.rs index 7ed352f64..d65d90eb5 100644 --- a/cedar-drt/fuzz/fuzz_targets/validation-pbt.rs +++ b/cedar-drt/fuzz/fuzz_targets/validation-pbt.rs @@ -288,9 +288,11 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> arbitrary::Result<(usize, Option), arbitrary::MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, HierarchyGenerator::size_hint(depth), Schema::arbitrary_policy_size_hint(&SETTINGS, depth), Schema::arbitrary_request_size_hint(depth), @@ -301,7 +303,7 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), - ]) + ])) } } diff --git a/cedar-policy-generators/src/expr.rs b/cedar-policy-generators/src/expr.rs index 7f7a872d5..e694bc9a6 100644 --- a/cedar-policy-generators/src/expr.rs +++ b/cedar-policy-generators/src/expr.rs @@ -27,7 +27,7 @@ use crate::schema::{ use crate::settings::ABACSettings; use crate::size_hint_utils::{size_hint_for_choose, size_hint_for_range, size_hint_for_ratio}; use crate::{accum, gen, gen_inner, uniform}; -use arbitrary::{Arbitrary, Unstructured}; +use arbitrary::{Arbitrary, MaxRecursionReached, Unstructured}; use cedar_policy_core::ast::{self, UnreservedId}; use cedar_policy_validator::json_schema; use smol_str::SmolStr; @@ -1916,9 +1916,11 @@ impl<'a> ExprGenerator<'a> { /// size hint for arbitrary_attr_value_for_type() #[allow(dead_code)] - pub fn generate_attr_value_for_type_size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::recursion_guard(depth, |depth| { - arbitrary::size_hint::and( + pub fn generate_attr_value_for_type_size_hint( + depth: usize, + ) -> std::result::Result<(usize, Option), MaxRecursionReached> { + arbitrary::size_hint::try_recursion_guard(depth, |depth| { + Ok(arbitrary::size_hint::and( size_hint_for_range(0, 7), arbitrary::size_hint::or_all(&[ ::size_hint(depth), @@ -1931,13 +1933,13 @@ impl<'a> ExprGenerator<'a> { ), size_hint_for_ratio(9, 10), size_hint_for_range(0, 4), - Self::generate_attr_value_for_type_size_hint(depth), + Self::generate_attr_value_for_type_size_hint(depth)?, ]), (1, None), // not sure how to hint for arbitrary_loop() (1, None), // not sure how to hint for arbitrary_loop() (1, None), // not sure how to hint for arbitrary_loop() ]), - ) + )) }) } @@ -2088,14 +2090,16 @@ impl<'a> ExprGenerator<'a> { /// size hint for generate_attr_value_for_schematype() #[allow(dead_code)] - pub fn generate_attr_value_for_schematype_size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::recursion_guard(depth, |depth| { - arbitrary::size_hint::or_all(&[ - Self::generate_attr_value_for_type_size_hint(depth), + pub fn generate_attr_value_for_schematype_size_hint( + depth: usize, + ) -> std::result::Result<(usize, Option), MaxRecursionReached> { + arbitrary::size_hint::try_recursion_guard(depth, |depth| { + Ok(arbitrary::size_hint::or_all(&[ + Self::generate_attr_value_for_type_size_hint(depth)?, (1, None), // not sure how to hint for arbitrary_loop() Self::arbitrary_uid_with_type_size_hint(depth), - Self::generate_attr_value_for_type_size_hint(depth), - ]) + Self::generate_attr_value_for_type_size_hint(depth)?, + ])) }) } diff --git a/cedar-policy-generators/src/schema.rs b/cedar-policy-generators/src/schema.rs index 8e48c9cd4..ee55bcde6 100644 --- a/cedar-policy-generators/src/schema.rs +++ b/cedar-policy-generators/src/schema.rs @@ -28,7 +28,7 @@ use crate::request::Request; use crate::settings::ABACSettings; use crate::size_hint_utils::{size_hint_for_choose, size_hint_for_range, size_hint_for_ratio}; use crate::{accum, gen, gen_inner, uniform}; -use arbitrary::{self, Arbitrary, Unstructured}; +use arbitrary::{self, Arbitrary, MaxRecursionReached, Unstructured}; use cedar_policy_core::ast::{self, Effect, PolicyID, UnreservedId}; use cedar_policy_core::extensions::Extensions; use cedar_policy_validator::json_schema::CommonTypeId; @@ -119,13 +119,15 @@ fn arbitrary_attrspec>( ))) } /// size hint for arbitrary_attrspec -fn arbitrary_attrspec_size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::recursion_guard(depth, |depth| { - arbitrary::size_hint::and_all(&[ +fn arbitrary_attrspec_size_hint( + depth: usize, +) -> std::result::Result<(usize, Option), MaxRecursionReached> { + arbitrary::size_hint::try_recursion_guard(depth, |depth| { + Ok(arbitrary::size_hint::and_all(&[ as Arbitrary>::size_hint(depth), arbitrary_typeofattribute_size_hint(depth), ::size_hint(depth), - ]) + ])) }) } @@ -1077,19 +1079,21 @@ impl Schema { }) } /// size hint for arbitrary() - pub fn arbitrary_size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ + pub fn arbitrary_size_hint( + depth: usize, + ) -> std::result::Result<(usize, Option), MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ as Arbitrary>::size_hint(depth), - arbitrary_attrspec_size_hint(depth), // actually we do one of these per Name that was generated - size_hint_for_ratio(1, 2), // actually many of these calls + arbitrary_attrspec_size_hint(depth)?, // actually we do one of these per Name that was generated + size_hint_for_ratio(1, 2), // actually many of these calls as Arbitrary>::size_hint(depth), size_hint_for_ratio(1, 8), // actually many of these calls size_hint_for_ratio(1, 4), // zero to many of these calls size_hint_for_ratio(1, 2), // zero to many of these calls - arbitrary_attrspec_size_hint(depth), + arbitrary_attrspec_size_hint(depth)?, size_hint_for_ratio(1, 2), // actually many of these calls ::size_hint(depth), - ]) + ])) } /// Get an arbitrary Hierarchy conforming to the schema. From 96fbce987c51b3d11f5d2a64990c336dfd41b8bb Mon Sep 17 00:00:00 2001 From: shaobo-he-aws <130499339+shaobo-he-aws@users.noreply.github.com> Date: Wed, 6 Nov 2024 09:38:08 -0800 Subject: [PATCH 3/3] Update Cargo.toml --- cedar-policy-generators/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cedar-policy-generators/Cargo.toml b/cedar-policy-generators/Cargo.toml index 9548fd9bc..8042ba342 100644 --- a/cedar-policy-generators/Cargo.toml +++ b/cedar-policy-generators/Cargo.toml @@ -5,7 +5,7 @@ version = "4.0.0" publish = false [dependencies] -arbitrary = "1.3" +arbitrary = "1.4" cedar-policy-core = { path = "../cedar/cedar-policy-core", version = "4.*", features = ["arbitrary"] } cedar-policy-validator = { path = "../cedar/cedar-policy-validator", version = "4.*", features = ["arbitrary"] } clap = { version = "4.3.16", features = ["derive"] }