From 3ff81c3c4b88534a283db2dc36ec86a7a2962b3f Mon Sep 17 00:00:00 2001 From: Nicolas Sarlin Date: Thu, 19 Sep 2024 15:37:06 +0200 Subject: [PATCH] test(versionable): test bounds visibility in the generated code --- .../tests/bounds_private_in_public.rs | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 utils/tfhe-versionable/tests/bounds_private_in_public.rs diff --git a/utils/tfhe-versionable/tests/bounds_private_in_public.rs b/utils/tfhe-versionable/tests/bounds_private_in_public.rs new file mode 100644 index 0000000000..489d6ad0fc --- /dev/null +++ b/utils/tfhe-versionable/tests/bounds_private_in_public.rs @@ -0,0 +1,44 @@ +//! This test checks that the bounds added by the proc macro does not prevent the code to +//! compile by leaking a private type +use tfhe_versionable::Versionize; + +mod mymod { + use tfhe_versionable::{Versionize, VersionsDispatch}; + + #[derive(Versionize)] + #[versionize(PublicVersions)] + pub struct Public { + private: Private, + } + + impl Public { + pub fn new(val: u64) -> Self { + Self { + private: Private(val), + } + } + } + + #[derive(VersionsDispatch)] + #[allow(unused)] + pub enum PublicVersions { + V0(Public), + } + + #[derive(Versionize)] + #[versionize(PrivateVersions)] + struct Private(T); + + #[derive(VersionsDispatch)] + #[allow(dead_code)] + enum PrivateVersions { + V0(Private), + } +} + +#[test] +fn bounds_private_in_public() { + let public = mymod::Public::new(42); + + let _vers = public.versionize(); +}