]> git.lizzy.rs Git - rust.git/blob - src/test/ui/privacy/privacy-ns2.rs
Rollup merge of #80327 - PankajChaudhary5:PankajChaudhary, r=GuillaumeGomez
[rust.git] / src / test / ui / privacy / privacy-ns2.rs
1 // Check we do the correct privacy checks when we import a name and there is an
2 // item with that name in both the value and type namespaces.
3
4 #![allow(dead_code)]
5 #![allow(unused_imports)]
6
7
8 // public type, private value
9 pub mod foo1 {
10     pub trait Bar {
11     }
12     pub struct Baz;
13
14     fn Bar() { }
15 }
16
17 fn test_single1() {
18     use foo1::Bar;
19
20     Bar(); //~ ERROR expected function, tuple struct or tuple variant, found trait `Bar`
21 }
22
23 fn test_list1() {
24     use foo1::{Bar,Baz};
25
26     Bar(); //~ ERROR expected function, tuple struct or tuple variant, found trait `Bar`
27 }
28
29 // private type, public value
30 pub mod foo2 {
31     trait Bar {
32     }
33     pub struct Baz;
34
35     pub fn Bar() { }
36 }
37
38 fn test_single2() {
39     use foo2::Bar;
40
41     let _x : Box<Bar>; //~ ERROR constant provided when a type was expected
42     let _x : Bar(); //~ ERROR expected type, found function `Bar`
43 }
44
45 fn test_list2() {
46     use foo2::{Bar,Baz};
47
48     let _x: Box<Bar>; //~ ERROR constant provided when a type was expected
49 }
50
51 // neither public
52 pub mod foo3 {
53     trait Bar {
54     }
55     pub struct Baz;
56
57     fn Bar() { }
58 }
59
60 fn test_unused3() {
61     use foo3::Bar;  //~ ERROR `Bar` is private
62 }
63
64 fn test_single3() {
65     use foo3::Bar;  //~ ERROR `Bar` is private
66
67     Bar();
68     let _x: Box<Bar>;
69 }
70
71 fn test_list3() {
72     use foo3::{Bar,Baz};  //~ ERROR `Bar` is private
73
74     Bar();
75     let _x: Box<Bar>;
76 }
77
78 fn main() {
79 }