]> git.lizzy.rs Git - rust.git/blob - src/test/ui/privacy/privacy-ns2.rs
Rollup merge of #76765 - guswynn:async_return, r=tmandry
[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 wrong number of const arguments: expected 0, found 1
42     //~^ ERROR wrong number of type arguments: expected at least 1, found 0
43     let _x : Bar(); //~ ERROR expected type, found function `Bar`
44 }
45
46 fn test_list2() {
47     use foo2::{Bar,Baz};
48
49     let _x: Box<Bar>; //~ ERROR wrong number of const arguments: expected 0, found 1
50     //~^ ERROR wrong number of type arguments: expected at least 1, found 0
51 }
52
53 // neither public
54 pub mod foo3 {
55     trait Bar {
56     }
57     pub struct Baz;
58
59     fn Bar() { }
60 }
61
62 fn test_unused3() {
63     use foo3::Bar;  //~ ERROR `Bar` is private
64 }
65
66 fn test_single3() {
67     use foo3::Bar;  //~ ERROR `Bar` is private
68
69     Bar();
70     let _x: Box<Bar>;
71 }
72
73 fn test_list3() {
74     use foo3::{Bar,Baz};  //~ ERROR `Bar` is private
75
76     Bar();
77     let _x: Box<Bar>;
78 }
79
80 fn main() {
81 }