summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/redundant_pub_crate.rs
blob: f96cfd3184384c6e09128891da36b02f88057064 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// run-rustfix
#![allow(dead_code)]
#![warn(clippy::redundant_pub_crate)]

mod m1 {
    fn f() {}
    pub(crate) fn g() {} // private due to m1
    pub fn h() {}

    mod m1_1 {
        fn f() {}
        pub(crate) fn g() {} // private due to m1_1 and m1
        pub fn h() {}
    }

    pub(crate) mod m1_2 {
        // ^ private due to m1
        fn f() {}
        pub(crate) fn g() {} // private due to m1_2 and m1
        pub fn h() {}
    }

    pub mod m1_3 {
        fn f() {}
        pub(crate) fn g() {} // private due to m1
        pub fn h() {}
    }
}

pub(crate) mod m2 {
    fn f() {}
    pub(crate) fn g() {} // already crate visible due to m2
    pub fn h() {}

    mod m2_1 {
        fn f() {}
        pub(crate) fn g() {} // private due to m2_1
        pub fn h() {}
    }

    pub(crate) mod m2_2 {
        // ^ already crate visible due to m2
        fn f() {}
        pub(crate) fn g() {} // already crate visible due to m2_2 and m2
        pub fn h() {}
    }

    pub mod m2_3 {
        fn f() {}
        pub(crate) fn g() {} // already crate visible due to m2
        pub fn h() {}
    }
}

pub mod m3 {
    fn f() {}
    pub(crate) fn g() {} // ok: m3 is exported
    pub fn h() {}

    mod m3_1 {
        fn f() {}
        pub(crate) fn g() {} // private due to m3_1
        pub fn h() {}
    }

    pub(crate) mod m3_2 {
        // ^ ok
        fn f() {}
        pub(crate) fn g() {} // already crate visible due to m3_2
        pub fn h() {}
    }

    pub mod m3_3 {
        fn f() {}
        pub(crate) fn g() {} // ok: m3 and m3_3 are exported
        pub fn h() {}
    }
}

mod m4 {
    fn f() {}
    pub(crate) fn g() {} // private: not re-exported by `pub use m4::*`
    pub fn h() {}

    mod m4_1 {
        fn f() {}
        pub(crate) fn g() {} // private due to m4_1
        pub fn h() {}
    }

    pub(crate) mod m4_2 {
        // ^ private: not re-exported by `pub use m4::*`
        fn f() {}
        pub(crate) fn g() {} // private due to m4_2
        pub fn h() {}
    }

    pub mod m4_3 {
        fn f() {}
        pub(crate) fn g() {} // ok: m4_3 is re-exported by `pub use m4::*`
        pub fn h() {}
    }
}

pub use m4::*;

mod issue_8732 {
    #[allow(unused_macros)]
    macro_rules! some_macro {
        () => {};
    }

    #[allow(unused_imports)]
    pub(crate) use some_macro; // ok: macro exports are exempt
}

fn main() {}