]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/xcrate-private-by-default.rs
rollup merge of #17355 : gamazeps/issue17210
[rust.git] / src / test / compile-fail / xcrate-private-by-default.rs
1 // Copyright 2013 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 // aux-build:static_priv_by_default.rs
12
13 extern crate static_priv_by_default;
14
15 fn foo<T>() {}
16
17 fn main() {
18     // Actual public items should be public
19     static_priv_by_default::a;
20     static_priv_by_default::b;
21     static_priv_by_default::c;
22     foo::<static_priv_by_default::d>();
23     foo::<static_priv_by_default::e>();
24
25     // publicly re-exported items should be available
26     static_priv_by_default::bar::e;
27     static_priv_by_default::bar::f;
28     static_priv_by_default::bar::g;
29     foo::<static_priv_by_default::bar::h>();
30     foo::<static_priv_by_default::bar::i>();
31
32     // private items at the top should be inaccessible
33     static_priv_by_default::j;
34     //~^ ERROR: static `j` is private
35     static_priv_by_default::k;
36     //~^ ERROR: function `k` is private
37     static_priv_by_default::l;
38     //~^ ERROR: struct `l` is private
39     foo::<static_priv_by_default::m>();
40     //~^ ERROR: enum `m` is private
41     foo::<static_priv_by_default::n>();
42     //~^ ERROR: type `n` is private
43
44     // public items in a private mod should be inaccessible
45     static_priv_by_default::foo::a;
46     //~^ ERROR: static `a` is private
47     static_priv_by_default::foo::b;
48     //~^ ERROR: function `b` is private
49     static_priv_by_default::foo::c;
50     //~^ ERROR: struct `c` is private
51     foo::<static_priv_by_default::foo::d>();
52     //~^ ERROR: enum `d` is private
53     foo::<static_priv_by_default::foo::e>();
54     //~^ ERROR: type `e` is private
55 }