Skip to content

Commit b6f441d

Browse files
committed
Add some tests
1 parent fa42726 commit b6f441d

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

src/test/run-pass/issue-31776.rs

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
// Various scenarios in which `pub` is required in blocks
12+
13+
struct S;
14+
15+
mod m {
16+
fn f() {
17+
impl ::S {
18+
pub fn s(&self) {}
19+
}
20+
}
21+
}
22+
23+
// ------------------------------------------------------
24+
25+
pub trait Tr {
26+
type A;
27+
}
28+
pub struct S1;
29+
30+
fn f() {
31+
pub struct Z;
32+
33+
impl ::Tr for ::S1 {
34+
type A = Z; // Private-in-public error unless `struct Z` is pub
35+
}
36+
}
37+
38+
// ------------------------------------------------------
39+
40+
trait Tr1 {
41+
type A;
42+
fn pull(&self) -> Self::A;
43+
}
44+
struct S2;
45+
46+
mod m1 {
47+
fn f() {
48+
struct Z {
49+
pub field: u8
50+
}
51+
52+
impl ::Tr1 for ::S2 {
53+
type A = Z;
54+
fn pull(&self) -> Self::A { Z{field: 10} }
55+
}
56+
}
57+
}
58+
59+
// ------------------------------------------------------
60+
61+
fn main() {
62+
S.s(); // Privacy error, unless `fn s` is pub
63+
let a = S2.pull().field; // Privacy error unless `field: u8` is pub
64+
}

0 commit comments

Comments
 (0)