From 4ab656f7a1354d901293202003678343c50026c7 Mon Sep 17 00:00:00 2001 From: Travis Hance Date: Tue, 5 Nov 2024 09:17:02 -0600 Subject: [PATCH] tests: add a test that get_impl_paths and recursive-checking handles weird Send/Sync impls correctly --- source/rust_verify_test/tests/traits.rs | 96 +++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/source/rust_verify_test/tests/traits.rs b/source/rust_verify_test/tests/traits.rs index 2c44a0595..fc8625401 100644 --- a/source/rust_verify_test/tests/traits.rs +++ b/source/rust_verify_test/tests/traits.rs @@ -4225,3 +4225,99 @@ test_verify_one_file! { } } => Err(err) => assert_vir_error_msg(err, "found a cyclic self-reference in a definition") } + +test_verify_one_file! { + #[test] test_recursion_through_sync_impl_is_checked verus_code! { + trait Tr { + proof fn tr_g() { + } + } + + struct X { + rc: std::rc::Rc, + t: T, + s: S, + } + + #[verifier::external] + unsafe impl Sync for X { + } + + + trait Sr { + proof fn f() { } + } + + struct Y { + r: R, + } + + impl Sr for Y { + proof fn f() { } + } + + + struct A1 { } + + struct B1 { } + + impl Tr for A1 { + proof fn tr_g() { + test(); + } + } + + + proof fn test() { + let r = Y::>::f(); + } + } => Err(err) => assert_vir_error_msg(err, "found a cyclic self-reference in a definition") +} + +test_verify_one_file! { + #[test] test_recursion_through_send_impl_is_checked verus_code! { + trait Tr { + proof fn tr_g() { + } + } + + struct X { + rc: std::rc::Rc, + t: T, + s: S, + } + + #[verifier::external] + unsafe impl Send for X { + } + + + trait Sr { + proof fn f() { } + } + + struct Y { + r: R, + } + + impl Sr for Y { + proof fn f() { } + } + + + struct A1 { } + + struct B1 { } + + impl Tr for A1 { + proof fn tr_g() { + test(); + } + } + + + proof fn test() { + let r = Y::>::f(); + } + } => Err(err) => assert_vir_error_msg(err, "found a cyclic self-reference in a definition") +}