aboutsummaryrefslogtreecommitdiff
path: root/tests/custom_linkme_path.rs
blob: daee74f49bc31197a97c8c4ec03731e6f1597581 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#![cfg_attr(feature = "used_linker", feature(used_with_arg))]

use linkme as link_me;

mod declaration {
    use crate::link_me::distributed_slice;

    #[distributed_slice]
    #[linkme(crate = crate::link_me)]
    pub static SLICE: [i32] = [..];

    #[test]
    fn test_slice() {
        assert!(!SLICE.is_empty());
    }

    #[distributed_slice]
    #[linkme(crate = crate::link_me)]
    pub static FUNCTIONS: [fn()] = [..];

    #[test]
    fn test_functions() {
        assert!(!FUNCTIONS.is_empty());
    }
}

mod usage {
    use crate::link_me::distributed_slice;

    #[distributed_slice(super::declaration::SLICE)]
    #[linkme(crate = crate::link_me)]
    pub static N: i32 = 9;

    #[distributed_slice(super::declaration::FUNCTIONS)]
    #[linkme(crate = crate::link_me)]
    fn test_me() {}
}