]>
Commit | Line | Data |
---|---|---|
b7449926 | 1 | // run-pass |
0bf4aa26 XL |
2 | #![allow(dead_code)] |
3 | #![allow(unused_variables)] | |
54a0048b SL |
4 | // Various scenarios in which `pub` is required in blocks |
5 | ||
6 | struct S; | |
7 | ||
8 | mod m { | |
9 | fn f() { | |
10 | impl ::S { | |
11 | pub fn s(&self) {} | |
12 | } | |
13 | } | |
14 | } | |
15 | ||
16 | // ------------------------------------------------------ | |
17 | ||
18 | pub trait Tr { | |
19 | type A; | |
20 | } | |
21 | pub struct S1; | |
22 | ||
23 | fn f() { | |
24 | pub struct Z; | |
25 | ||
26 | impl ::Tr for ::S1 { | |
27 | type A = Z; // Private-in-public error unless `struct Z` is pub | |
28 | } | |
29 | } | |
30 | ||
31 | // ------------------------------------------------------ | |
32 | ||
33 | trait Tr1 { | |
34 | type A; | |
35 | fn pull(&self) -> Self::A; | |
36 | } | |
37 | struct S2; | |
38 | ||
39 | mod m1 { | |
40 | fn f() { | |
5bcae85e | 41 | pub struct Z { |
54a0048b SL |
42 | pub field: u8 |
43 | } | |
44 | ||
45 | impl ::Tr1 for ::S2 { | |
46 | type A = Z; | |
47 | fn pull(&self) -> Self::A { Z{field: 10} } | |
48 | } | |
49 | } | |
50 | } | |
51 | ||
52 | // ------------------------------------------------------ | |
53 | ||
54 | fn main() { | |
55 | S.s(); // Privacy error, unless `fn s` is pub | |
56 | let a = S2.pull().field; // Privacy error unless `field: u8` is pub | |
57 | } |