]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
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 | // Check we do the correct privacy checks when we import a name and there is an | |
12 | // item with that name in both the value and type namespaces. | |
13 | ||
14 | #![allow(dead_code)] | |
15 | #![allow(unused_imports)] | |
16 | ||
17 | ||
18 | // public type, private value | |
19 | pub mod foo1 { | |
9346a6ac | 20 | pub trait Bar { |
1a4d82fc JJ |
21 | } |
22 | pub struct Baz; | |
23 | ||
24 | fn Bar() { } | |
25 | } | |
26 | ||
27 | fn test_single1() { | |
54a0048b | 28 | use foo1::Bar; //~ ERROR function `Bar` is private |
1a4d82fc JJ |
29 | |
30 | Bar(); | |
31 | } | |
32 | ||
33 | fn test_list1() { | |
54a0048b | 34 | use foo1::{Bar,Baz}; //~ ERROR `Bar` is private |
1a4d82fc JJ |
35 | |
36 | Bar(); | |
37 | } | |
38 | ||
39 | // private type, public value | |
40 | pub mod foo2 { | |
9346a6ac | 41 | trait Bar { |
1a4d82fc JJ |
42 | } |
43 | pub struct Baz; | |
44 | ||
45 | pub fn Bar() { } | |
46 | } | |
47 | ||
48 | fn test_single2() { | |
54a0048b | 49 | use foo2::Bar; //~ ERROR trait `Bar` is private |
1a4d82fc JJ |
50 | |
51 | let _x : Box<Bar>; | |
52 | } | |
53 | ||
54 | fn test_list2() { | |
55 | use foo2::{Bar,Baz}; //~ ERROR `Bar` is private | |
56 | ||
57 | let _x: Box<Bar>; | |
58 | } | |
59 | ||
60 | // neither public | |
61 | pub mod foo3 { | |
9346a6ac | 62 | trait Bar { |
1a4d82fc JJ |
63 | } |
64 | pub struct Baz; | |
65 | ||
66 | fn Bar() { } | |
67 | } | |
68 | ||
69 | fn test_unused3() { | |
70 | use foo3::Bar; //~ ERROR `Bar` is private | |
71 | } | |
72 | ||
73 | fn test_single3() { | |
74 | use foo3::Bar; //~ ERROR `Bar` is private | |
75 | ||
76 | Bar(); | |
77 | let _x: Box<Bar>; | |
78 | } | |
79 | ||
80 | fn test_list3() { | |
81 | use foo3::{Bar,Baz}; //~ ERROR `Bar` is private | |
82 | ||
83 | Bar(); | |
84 | let _x: Box<Bar>; | |
85 | } | |
86 | ||
87 | fn main() { | |
88 | } |