]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/privacy-ns2.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / compile-fail / privacy-ns2.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 // 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 {
20 pub trait Bar {
21 }
22 pub struct Baz;
23
24 fn Bar() { }
25 }
26
27 fn test_single1() {
28 use foo1::Bar; //~ ERROR function `Bar` is private
29
30 Bar();
31 }
32
33 fn test_list1() {
34 use foo1::{Bar,Baz}; //~ ERROR `Bar` is private
35
36 Bar();
37 }
38
39 // private type, public value
40 pub mod foo2 {
41 trait Bar {
42 }
43 pub struct Baz;
44
45 pub fn Bar() { }
46 }
47
48 fn test_single2() {
49 use foo2::Bar; //~ ERROR trait `Bar` is private
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 {
62 trait Bar {
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 }