]> git.lizzy.rs Git - rust.git/blob - tests/ui/privacy/effective_visibilities.rs
Rollup merge of #106648 - Nilstrieb:poly-cleanup, r=compiler-errors
[rust.git] / tests / ui / privacy / effective_visibilities.rs
1 #![feature(rustc_attrs)]
2
3 #[rustc_effective_visibility]
4 mod outer { //~ ERROR Direct: pub(crate), Reexported: pub(crate), Reachable: pub(crate), ReachableThroughImplTrait: pub(crate)
5     #[rustc_effective_visibility]
6     pub mod inner1 { //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
7
8         #[rustc_effective_visibility]
9         extern "C" {} //~ ERROR not in the table
10
11         #[rustc_effective_visibility]
12         pub trait PubTrait { //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
13             #[rustc_effective_visibility]
14             const A: i32; //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
15             #[rustc_effective_visibility]
16             type B; //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
17         }
18
19         #[rustc_effective_visibility]
20         struct PrivStruct; //~ ERROR Direct: pub(self), Reexported: pub(self), Reachable: pub(self), ReachableThroughImplTrait: pub(self)
21                            //~| ERROR Direct: pub(self), Reexported: pub(self), Reachable: pub(self), ReachableThroughImplTrait: pub(self)
22
23         #[rustc_effective_visibility]
24         pub union PubUnion { //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
25             #[rustc_effective_visibility]
26             a: u8, //~ ERROR Direct: pub(self), Reexported: pub(self), Reachable: pub(self), ReachableThroughImplTrait: pub(self)
27             #[rustc_effective_visibility]
28             pub b: u8, //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
29         }
30
31         #[rustc_effective_visibility]
32         pub enum Enum { //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
33             #[rustc_effective_visibility]
34             A( //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
35                //~| ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
36                 #[rustc_effective_visibility]
37                 PubUnion,  //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
38             ),
39         }
40     }
41
42     #[rustc_effective_visibility]
43     macro_rules! none_macro { //~ ERROR not in the table
44         () => {};
45     }
46
47     #[macro_export]
48     #[rustc_effective_visibility]
49     macro_rules! public_macro { //~ ERROR Direct: pub(self), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
50         () => {};
51     }
52
53     #[rustc_effective_visibility]
54     pub struct ReachableStruct { //~ ERROR Direct: pub(crate), Reexported: pub(crate), Reachable: pub, ReachableThroughImplTrait: pub
55         #[rustc_effective_visibility]
56         pub a: u8, //~ ERROR Direct: pub(crate), Reexported: pub(crate), Reachable: pub, ReachableThroughImplTrait: pub
57     }
58 }
59
60 #[rustc_effective_visibility]
61 pub use outer::inner1; //~ ERROR Direct: pub, Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
62
63 pub fn foo() -> outer::ReachableStruct { outer::ReachableStruct {a: 0} }
64
65 mod half_public_import {
66     #[rustc_effective_visibility]
67     pub type HalfPublicImport = u8; //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
68     #[rustc_effective_visibility]
69     #[allow(non_upper_case_globals)]
70     pub(crate) const HalfPublicImport: u8 = 0; //~ ERROR Direct: pub(crate), Reexported: pub(crate), Reachable: pub(crate), ReachableThroughImplTrait: pub(crate)
71 }
72
73 #[rustc_effective_visibility]
74 pub use half_public_import::HalfPublicImport; //~ ERROR Direct: pub, Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
75
76 fn main() {}