Skip to content

Commit 89300cd

Browse files
committed
Add tests.
1 parent 57fda67 commit 89300cd

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed

src/test/ui/issues/auxiliary/issue-75907.rs

+12
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,15 @@ pub struct Bar(pub u8, u8, u8);
33
pub fn make_bar() -> Bar {
44
Bar(1, 12, 10)
55
}
6+
7+
mod inner {
8+
pub struct Foo(u8, pub u8, u8);
9+
10+
impl Foo {
11+
pub fn new() -> Foo {
12+
Foo(1, 12, 10)
13+
}
14+
}
15+
}
16+
17+
pub use inner::Foo;

src/test/ui/issues/issue-75907_b.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33

44
extern crate issue_75907 as a;
55

6-
use a::{make_bar, Bar};
6+
use a::{make_bar, Bar, Foo};
77

88
fn main() {
99
let Bar(x, y, z) = make_bar();
1010
//~^ ERROR cannot match against a tuple struct which contains private fields
11+
12+
let Foo(x, y, z) = Foo::new();
13+
//~^ ERROR cannot match against a tuple struct which contains private fields
1114
}

src/test/ui/issues/issue-75907_b.stderr

+24-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,30 @@ error[E0532]: cannot match against a tuple struct which contains private fields
22
--> $DIR/issue-75907_b.rs:9:9
33
|
44
LL | let Bar(x, y, z) = make_bar();
5-
| ^^^ constructor is not visible here due to private fields
5+
| ^^^
6+
|
7+
note: constructor is not visible here due to private fields
8+
--> $DIR/issue-75907_b.rs:9:16
9+
|
10+
LL | let Bar(x, y, z) = make_bar();
11+
| ^ ^ private field
12+
| |
13+
| private field
14+
15+
error[E0532]: cannot match against a tuple struct which contains private fields
16+
--> $DIR/issue-75907_b.rs:12:9
17+
|
18+
LL | let Foo(x, y, z) = Foo::new();
19+
| ^^^
20+
|
21+
note: constructor is not visible here due to private fields
22+
--> $DIR/issue-75907_b.rs:12:13
23+
|
24+
LL | let Foo(x, y, z) = Foo::new();
25+
| ^ ^ private field
26+
| |
27+
| private field
628

7-
error: aborting due to previous error
29+
error: aborting due to 2 previous errors
830

931
For more information about this error, try `rustc --explain E0532`.

src/test/ui/rfc-2008-non-exhaustive/struct.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0423]: cannot initialize a tuple struct which contains private fields
22
--> $DIR/struct.rs:20:14
33
|
44
LL | let ts = TupleStruct(640, 480);
5-
| ^^^^^^^^^^^ constructor is not visible here due to private fields
5+
| ^^^^^^^^^^^
66

77
error[E0423]: expected value, found struct `UnitStruct`
88
--> $DIR/struct.rs:29:14

0 commit comments

Comments
 (0)