Skip to content

Commit 5900abc

Browse files
committed
test(versionable): test bounds visibility in the generated code
1 parent 2e8c436 commit 5900abc

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//! This test checks that the bounds added by the proc macro does not prevent the code to
2+
//! compile by leaking a private type
3+
use tfhe_versionable::Versionize;
4+
5+
mod mymod {
6+
use tfhe_versionable::{Versionize, VersionsDispatch};
7+
8+
#[derive(Versionize)]
9+
#[versionize(PublicVersions)]
10+
pub struct Public<T> {
11+
private: Private<T>,
12+
}
13+
14+
impl Public<u64> {
15+
pub fn new(val: u64) -> Self {
16+
Self {
17+
private: Private(val),
18+
}
19+
}
20+
}
21+
22+
#[derive(VersionsDispatch)]
23+
#[allow(unused)]
24+
pub enum PublicVersions<T> {
25+
V0(Public<T>),
26+
}
27+
28+
#[derive(Versionize)]
29+
#[versionize(PrivateVersions)]
30+
struct Private<T>(T);
31+
32+
#[derive(VersionsDispatch)]
33+
#[allow(dead_code)]
34+
enum PrivateVersions<T> {
35+
V0(Private<T>),
36+
}
37+
}
38+
39+
#[test]
40+
fn bounds_private_in_public() {
41+
let public = mymod::Public::new(42);
42+
43+
let _vers = public.versionize();
44+
}

0 commit comments

Comments
 (0)