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
Bar()14 fn Bar() { }
15 }
16
test_single1()17 fn test_single1() {
18 use foo1::Bar;
19
20 Bar(); //~ ERROR expected function, tuple struct or tuple variant, found trait `Bar`
21 }
22
test_list1()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
Bar()35 pub fn Bar() { }
36 }
37
test_single2()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
test_list2()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
Bar()57 fn Bar() { }
58 }
59
test_unused3()60 fn test_unused3() {
61 use foo3::Bar; //~ ERROR `Bar` is private
62 }
63
test_single3()64 fn test_single3() {
65 use foo3::Bar; //~ ERROR `Bar` is private
66
67 Bar();
68 let _x: Box<Bar>;
69 }
70
test_list3()71 fn test_list3() {
72 use foo3::{Bar,Baz}; //~ ERROR `Bar` is private
73
74 Bar();
75 let _x: Box<Bar>;
76 }
77
main()78 fn main() {
79 }
80