]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/privacy-ns1.rs
Convert most code to new inner attribute syntax.
[rust.git] / src / test / compile-fail / privacy-ns1.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 #![feature(globs)]
15 #![allow(dead_code)]
16 #![allow(unused_imports)]
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_glob1() {
28     use foo1::*;
29
30     Bar();  //~ ERROR unresolved name `Bar`.
31 }
32
33 // private type, public value
34 pub mod foo2 {
35     trait Bar {
36     }
37     pub struct Baz;
38
39     pub fn Bar() { }
40 }
41
42 fn test_glob2() {
43     use foo2::*;
44
45     let _x: ~Bar;  //~ ERROR use of undeclared type name `Bar`
46 }
47
48 // neither public
49 pub mod foo3 {
50     trait Bar {
51     }
52     pub struct Baz;
53
54     fn Bar() { }
55 }
56
57 fn test_glob3() {
58     use foo3::*;
59
60     Bar();  //~ ERROR unresolved name `Bar`.
61     let _x: ~Bar;  //~ ERROR  use of undeclared type name `Bar`
62 }
63
64 fn main() {
65 }
66