]> git.lizzy.rs Git - rust.git/blob - src/test/ui/resolve/privacy-struct-ctor.rs
Auto merge of #38932 - petrochenkov:privctor, r=jseyfried
[rust.git] / src / test / ui / resolve / privacy-struct-ctor.rs
1 // Copyright 2016 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:privacy-struct-ctor.rs
12
13 #![feature(pub_restricted)]
14
15 extern crate privacy_struct_ctor as xcrate;
16
17 mod m {
18     pub struct S(u8);
19
20     pub mod n {
21         pub(m) struct Z(pub(m::n) u8);
22     }
23
24     use m::n::Z; // OK, only the type is imported
25
26     fn f() {
27         n::Z; //~ ERROR tuple struct `Z` is private
28         Z;
29         //~^ ERROR expected value, found struct `Z`
30         //~| NOTE tuple struct constructors with private fields are invisible outside of their mod
31     }
32 }
33
34 use m::S; // OK, only the type is imported
35
36 fn main() {
37     m::S; //~ ERROR tuple struct `S` is private
38     S;
39     //~^ ERROR expected value, found struct `S`
40     //~| NOTE constructor is not visible here due to private fields
41     m::n::Z; //~ ERROR tuple struct `Z` is private
42
43     xcrate::m::S; //~ ERROR tuple struct `S` is private
44     xcrate::S;
45     //~^ ERROR expected value, found struct `xcrate::S`
46     //~| NOTE constructor is not visible here due to private fields
47     xcrate::m::n::Z; //~ ERROR tuple struct `Z` is private
48 }