]> git.lizzy.rs Git - rust.git/blob - src/test/ui/privacy/privacy-ns2.rs
update ui tests
[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, found trait `Bar`
21 }
22
23 fn test_list1() {
24     use foo1::{Bar,Baz};
25
26     Bar(); //~ ERROR expected function, 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 expected type, found function `Bar`
42 }
43
44 fn test_list2() {
45     use foo2::{Bar,Baz};
46
47     let _x: Box<Bar>; //~ ERROR expected type, found function `Bar`
48 }
49
50 // neither public
51 pub mod foo3 {
52     trait Bar {
53     }
54     pub struct Baz;
55
56     fn Bar() { }
57 }
58
59 fn test_unused3() {
60     use foo3::Bar;  //~ ERROR `Bar` is private
61 }
62
63 fn test_single3() {
64     use foo3::Bar;  //~ ERROR `Bar` is private
65
66     Bar();
67     let _x: Box<Bar>;
68 }
69
70 fn test_list3() {
71     use foo3::{Bar,Baz};  //~ ERROR `Bar` is private
72
73     Bar();
74     let _x: Box<Bar>;
75 }
76
77 fn main() {
78 }