]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/privacy-ns2.rs
Auto merge of #22517 - brson:relnotes, r=Gankro
[rust.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     // In an ideal world, these would be private instead of inaccessible.
29     use foo1::Bar;  //~ ERROR `Bar` is inaccessible
30
31     Bar();
32 }
33
34 fn test_list1() {
35     use foo1::{Bar,Baz};  //~ ERROR `Bar` is inaccessible
36
37     Bar();
38 }
39
40 // private type, public value
41 pub mod foo2 {
42     trait Bar {
43     }
44     pub struct Baz;
45
46     pub fn Bar() { }
47 }
48
49 fn test_single2() {
50     use foo2::Bar;  //~ ERROR `Bar` is private
51
52     let _x : Box<Bar>;
53 }
54
55 fn test_list2() {
56     use foo2::{Bar,Baz};  //~ ERROR `Bar` is private
57
58     let _x: Box<Bar>;
59 }
60
61 // neither public
62 pub mod foo3 {
63     trait Bar {
64     }
65     pub struct Baz;
66
67     fn Bar() { }
68 }
69
70 fn test_unused3() {
71     use foo3::Bar;  //~ ERROR `Bar` is private
72 }
73
74 fn test_single3() {
75     use foo3::Bar;  //~ ERROR `Bar` is private
76
77     Bar();
78     let _x: Box<Bar>;
79 }
80
81 fn test_list3() {
82     use foo3::{Bar,Baz};  //~ ERROR `Bar` is private
83
84     Bar();
85     let _x: Box<Bar>;
86 }
87
88 fn main() {
89 }