]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/resolve-bad-visibility.rs
6b5cd4dce265ac8461a88ecb1ba227861dc25efc
[rustc.git] / src / test / compile-fail / resolve-bad-visibility.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 #![feature(pub_restricted)]
12
13 enum E {}
14 trait Tr {}
15
16 pub(E) struct S; //~ ERROR expected module, found enum `E`
17 pub(Tr) struct Z; //~ ERROR expected module, found trait `Tr`
18 pub(std::vec) struct F; //~ ERROR visibilities can only be restricted to ancestor modules
19 pub(nonexistent) struct G; //~ ERROR cannot find module `nonexistent` in the crate root
20 pub(too_soon) struct H; //~ ERROR cannot find module `too_soon` in the crate root
21
22 // Visibilities are resolved eagerly without waiting for modules becoming fully populated.
23 // Visibilities can only use ancestor modules legally which are always available in time,
24 // so the worst thing that can happen due to eager resolution is a suboptimal error message.
25 mod too_soon {}
26
27 fn main () {}