]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/privacy-ns.rs
e9b8e694d60605c3e445102a97571429b1eaada5
[rust.git] / src / test / run-pass / privacy-ns.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11
12 // Check we do the correct privacy checks when we import a name and there is an
13 // item with that name in both the value and type namespaces.
14
15 #![allow(dead_code)]
16 #![allow(unused_imports)]
17
18
19 // public type, private value
20 pub mod foo1 {
21     pub trait Bar {
22         fn dummy(&self) { }
23     }
24     pub struct Baz;
25
26     fn Bar() { }
27 }
28
29 fn test_unused1() {
30     use foo1::*;
31 }
32
33 fn test_single1() {
34     use foo1::Bar;
35
36     let _x: Box<Bar>;
37 }
38
39 fn test_list1() {
40     use foo1::{Bar,Baz};
41
42     let _x: Box<Bar>;
43 }
44
45 fn test_glob1() {
46     use foo1::*;
47
48     let _x: Box<Bar>;
49 }
50
51 // private type, public value
52 pub mod foo2 {
53     trait Bar {
54         fn dummy(&self) { }
55     }
56     pub struct Baz;
57
58     pub fn Bar() { }
59 }
60
61 fn test_unused2() {
62     use foo2::*;
63 }
64
65 fn test_single2() {
66     use foo2::Bar;
67
68     Bar();
69 }
70
71 fn test_list2() {
72     use foo2::{Bar,Baz};
73
74     Bar();
75 }
76
77 fn test_glob2() {
78     use foo2::*;
79
80     Bar();
81 }
82
83 // public type, public value
84 pub mod foo3 {
85     pub trait Bar {
86         fn dummy(&self) { }
87     }
88     pub struct Baz;
89
90     pub fn Bar() { }
91 }
92
93 fn test_unused3() {
94     use foo3::*;
95 }
96
97 fn test_single3() {
98     use foo3::Bar;
99
100     Bar();
101     let _x: Box<Bar>;
102 }
103
104 fn test_list3() {
105     use foo3::{Bar,Baz};
106
107     Bar();
108     let _x: Box<Bar>;
109 }
110
111 fn test_glob3() {
112     use foo3::*;
113
114     Bar();
115     let _x: Box<Bar>;
116 }
117
118 fn main() {
119 }