]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/privacy-ns.rs
Auto merge of #22517 - brson:relnotes, r=Gankro
[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     }
23     pub struct Baz;
24
25     fn Bar() { }
26 }
27
28 fn test_unused1() {
29     use foo1::*;
30 }
31
32 fn test_single1() {
33     use foo1::Bar;
34
35     let _x: Box<Bar>;
36 }
37
38 fn test_list1() {
39     use foo1::{Bar,Baz};
40
41     let _x: Box<Bar>;
42 }
43
44 fn test_glob1() {
45     use foo1::*;
46
47     let _x: Box<Bar>;
48 }
49
50 // private type, public value
51 pub mod foo2 {
52     trait Bar {
53     }
54     pub struct Baz;
55
56     pub fn Bar() { }
57 }
58
59 fn test_unused2() {
60     use foo2::*;
61 }
62
63 fn test_single2() {
64     use foo2::Bar;
65
66     Bar();
67 }
68
69 fn test_list2() {
70     use foo2::{Bar,Baz};
71
72     Bar();
73 }
74
75 fn test_glob2() {
76     use foo2::*;
77
78     Bar();
79 }
80
81 // public type, public value
82 pub mod foo3 {
83     pub trait Bar {
84     }
85     pub struct Baz;
86
87     pub fn Bar() { }
88 }
89
90 fn test_unused3() {
91     use foo3::*;
92 }
93
94 fn test_single3() {
95     use foo3::Bar;
96
97     Bar();
98     let _x: Box<Bar>;
99 }
100
101 fn test_list3() {
102     use foo3::{Bar,Baz};
103
104     Bar();
105     let _x: Box<Bar>;
106 }
107
108 fn test_glob3() {
109     use foo3::*;
110
111     Bar();
112     let _x: Box<Bar>;
113 }
114
115 fn main() {
116 }