]> git.proxmox.com Git - rustc.git/blob - tests/ui/resolve/privacy-enum-ctor.rs
New upstream version 1.74.1+dfsg1
[rustc.git] / tests / ui / resolve / privacy-enum-ctor.rs
1 mod m {
2 pub enum E {
3 Fn(u8),
4 Struct {
5 s: u8,
6 },
7 Unit,
8 }
9
10 pub mod n {
11 pub(in m) enum Z {
12 Fn(u8),
13 Struct {
14 s: u8,
15 },
16 Unit,
17 }
18 }
19
20 use m::n::Z; // OK, only the type is imported
21
22 fn f() {
23 n::Z;
24 //~^ ERROR expected value, found enum `n::Z`
25 Z;
26 //~^ ERROR expected value, found enum `Z`
27 let _: Z = Z::Fn;
28 //~^ ERROR mismatched types
29 let _: Z = Z::Struct;
30 //~^ ERROR expected value, found struct variant `Z::Struct`
31 let _ = Z::Unit();
32 //~^ ERROR expected function, found enum variant `Z::Unit`
33 let _ = Z::Unit {};
34 // This is ok, it is equivalent to not having braces
35 }
36 }
37
38 use m::E; // OK, only the type is imported
39
40 fn main() {
41 let _: E = m::E;
42 //~^ ERROR expected value, found enum `m::E`
43 let _: E = m::E::Fn;
44 //~^ ERROR mismatched types
45 let _: E = m::E::Struct;
46 //~^ ERROR expected value, found struct variant `m::E::Struct`
47 let _: E = m::E::Unit();
48 //~^ ERROR expected function, found enum variant `m::E::Unit`
49 let _: E = E;
50 //~^ ERROR expected value, found enum `E`
51 let _: E = E::Fn;
52 //~^ ERROR mismatched types
53 let _: E = E::Struct;
54 //~^ ERROR expected value, found struct variant `E::Struct`
55 let _: E = E::Unit();
56 //~^ ERROR expected function, found enum variant `E::Unit`
57 let _: Z = m::n::Z;
58 //~^ ERROR cannot find type `Z` in this scope
59 //~| ERROR expected value, found enum `m::n::Z`
60 //~| ERROR enum `Z` is private
61 let _: Z = m::n::Z::Fn;
62 //~^ ERROR cannot find type `Z` in this scope
63 //~| ERROR enum `Z` is private
64 let _: Z = m::n::Z::Struct;
65 //~^ ERROR cannot find type `Z` in this scope
66 //~| ERROR expected value, found struct variant `m::n::Z::Struct`
67 //~| ERROR enum `Z` is private
68 let _: Z = m::n::Z::Unit {};
69 //~^ ERROR cannot find type `Z` in this scope
70 //~| ERROR enum `Z` is private
71 }