]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/privacy/restricted/lookup-ignores-private.rs
Imported Upstream version 1.10.0+dfsg1
[rustc.git] / src / test / compile-fail / privacy / restricted / lookup-ignores-private.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(rustc_attrs, pub_restricted)]
12 #![allow(warnings)]
13
14 mod foo {
15 pub use foo::bar::S;
16 mod bar {
17 #[derive(Default)]
18 pub struct S {
19 pub(foo) x: i32,
20 }
21 impl S {
22 pub(foo) fn f(&self) -> i32 { 0 }
23 }
24
25 pub struct S2 {
26 pub(crate) x: bool,
27 }
28 impl S2 {
29 pub(crate) fn f(&self) -> bool { false }
30 }
31
32 impl ::std::ops::Deref for S {
33 type Target = S2;
34 fn deref(&self) -> &S2 { unimplemented!() }
35 }
36 }
37 }
38
39 #[rustc_error]
40 fn main() { //~ ERROR compilation successful
41 let s = foo::S::default();
42 let _: bool = s.x;
43 let _: bool = s.f();
44 }