]> git.proxmox.com Git - rustc.git/blame - src/test/ui/privacy/privacy-ns2.rs
Update upstream source from tag 'upstream/1.30.0_beta.7+dfsg1'
[rustc.git] / src / test / ui / privacy / privacy-ns2.rs
CommitLineData
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
19pub mod foo1 {
9346a6ac 20 pub trait Bar {
1a4d82fc
JJ
21 }
22 pub struct Baz;
23
24 fn Bar() { }
25}
26
27fn test_single1() {
5bcae85e 28 use foo1::Bar;
1a4d82fc 29
32a655c1 30 Bar(); //~ ERROR expected function, found trait `Bar`
1a4d82fc
JJ
31}
32
33fn test_list1() {
5bcae85e 34 use foo1::{Bar,Baz};
1a4d82fc 35
32a655c1 36 Bar(); //~ ERROR expected function, found trait `Bar`
1a4d82fc
JJ
37}
38
39// private type, public value
40pub mod foo2 {
9346a6ac 41 trait Bar {
1a4d82fc
JJ
42 }
43 pub struct Baz;
44
45 pub fn Bar() { }
46}
47
48fn test_single2() {
5bcae85e 49 use foo2::Bar;
1a4d82fc 50
32a655c1 51 let _x : Box<Bar>; //~ ERROR expected type, found function `Bar`
1a4d82fc
JJ
52}
53
54fn test_list2() {
5bcae85e 55 use foo2::{Bar,Baz};
1a4d82fc 56
32a655c1 57 let _x: Box<Bar>; //~ ERROR expected type, found function `Bar`
1a4d82fc
JJ
58}
59
60// neither public
61pub mod foo3 {
9346a6ac 62 trait Bar {
1a4d82fc
JJ
63 }
64 pub struct Baz;
65
66 fn Bar() { }
67}
68
69fn test_unused3() {
70 use foo3::Bar; //~ ERROR `Bar` is private
71}
72
73fn test_single3() {
74 use foo3::Bar; //~ ERROR `Bar` is private
75
76 Bar();
77 let _x: Box<Bar>;
78}
79
80fn test_list3() {
81 use foo3::{Bar,Baz}; //~ ERROR `Bar` is private
82
83 Bar();
84 let _x: Box<Bar>;
85}
86
87fn main() {
88}