-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(versionable): test bounds visibility in the generated code
- Loading branch information
1 parent
bce5cd3
commit 3ff81c3
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<T> { | ||
private: Private<T>, | ||
} | ||
|
||
impl Public<u64> { | ||
pub fn new(val: u64) -> Self { | ||
Self { | ||
private: Private(val), | ||
} | ||
} | ||
} | ||
|
||
#[derive(VersionsDispatch)] | ||
#[allow(unused)] | ||
pub enum PublicVersions<T> { | ||
V0(Public<T>), | ||
} | ||
|
||
#[derive(Versionize)] | ||
#[versionize(PrivateVersions)] | ||
struct Private<T>(T); | ||
|
||
#[derive(VersionsDispatch)] | ||
#[allow(dead_code)] | ||
enum PrivateVersions<T> { | ||
V0(Private<T>), | ||
} | ||
} | ||
|
||
#[test] | ||
fn bounds_private_in_public() { | ||
let public = mymod::Public::new(42); | ||
|
||
let _vers = public.versionize(); | ||
} |