diff --git a/core/src/utils/racy_lock.rs b/core/src/utils/racy_lock.rs index df78874ee..b2f32b86d 100644 --- a/core/src/utils/racy_lock.rs +++ b/core/src/utils/racy_lock.rs @@ -72,17 +72,52 @@ where #[cfg(test)] mod tests { + use alloc::vec::Vec; + use super::*; #[test] - fn test_lazylock_copy() { + fn test_racy_lock_copy() { + // Lock a copy type and validate value. let lock = RacyLock::new(|| 42); assert_eq!(*lock, 42); } #[test] - fn test_lazylock_move() { - let lock = RacyLock::new(|| vec![1, 2, 3]); - assert_eq!(*lock, vec![1, 2, 3]); + fn test_racy_lock_clone() { + // Lock a no copy type. + let lock = RacyLock::new(|| Vec::from([1, 2, 3])); + + // Use the value so that the compiler forces us to clone. + let mut v = lock.clone(); + v.push(4); + + // Validate the value. + assert_eq!(v, Vec::from([1, 2, 3, 4])); + } + + #[test] + fn test_racy_lock_static() { + // Create a static lock. + static VEC: RacyLock> = RacyLock::new(|| Vec::from([1, 2, 3])); + + // Validate that the address of the value does not change. + let addr = &*VEC as *const Vec; + for _ in 0..5 { + assert_eq!(*VEC, [1, 2, 3]); + assert_eq!(addr, &(*VEC) as *const Vec) + } + } + + #[test] + fn lazy_type_inference() { + // Check that we can infer `T` from closure's type. + let _ = RacyLock::new(|| ()); + } + + #[test] + fn is_sync_send() { + fn assert_traits() {} + assert_traits::>>(); } } diff --git a/processor/Cargo.toml b/processor/Cargo.toml index a0cc0e346..ec27b6346 100644 --- a/processor/Cargo.toml +++ b/processor/Cargo.toml @@ -25,7 +25,7 @@ std = ["vm-core/std", "winter-prover/std"] [dependencies] miden-air = { package = "miden-air", path = "../air", version = "0.10", default-features = false } -tracing = { version = "0.1", default-features = false, features = [ "attributes", ] } +tracing = { version = "0.1", default-features = false, features = ["attributes"] } vm-core = { package = "miden-core", path = "../core", version = "0.10", default-features = false } winter-prover = { package = "winter-prover", version = "0.9", default-features = false }