Skip to content

Commit e0e379b

Browse files
committed
Add test for public struct with private fields
1 parent a4f47de commit e0e379b

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

tests/ui/xcrate/auxiliary/xcrate_unit_struct.rs

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ pub struct TupleStruct(pub usize, pub &'static str);
1818

1919
#[derive(Copy, Clone)]
2020
pub struct StructWithFields {
21+
pub foo: isize,
22+
}
23+
24+
#[derive(Copy, Clone)]
25+
pub struct StructWithPrivFields {
2126
foo: isize,
2227
}
2328

tests/ui/xcrate/xcrate-unit-struct.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ extern crate xcrate_unit_struct;
88
fn main() {
99
let _ = xcrate_unit_struct::StructWithFields;
1010
//~^ ERROR expected value, found struct `xcrate_unit_struct::StructWithFields`
11+
let _ = xcrate_unit_struct::StructWithPrivFields;
12+
//~^ ERROR expected value, found struct `xcrate_unit_struct::StructWithPrivFields`
1113
let _ = xcrate_unit_struct::Struct;
1214
}

tests/ui/xcrate/xcrate-unit-struct.stderr

+12-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ LL | let _ = xcrate_unit_struct::StructWithFields;
99
LL | pub struct StructWithFields {
1010
| --------------------------- `xcrate_unit_struct::StructWithFields` defined here
1111

12-
error: aborting due to previous error
12+
error[E0423]: expected value, found struct `xcrate_unit_struct::StructWithPrivFields`
13+
--> $DIR/xcrate-unit-struct.rs:11:13
14+
|
15+
LL | let _ = xcrate_unit_struct::StructWithPrivFields;
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `xcrate_unit_struct::StructWithPrivFields { foo: val }`
17+
|
18+
::: $DIR/auxiliary/xcrate_unit_struct.rs:25:1
19+
|
20+
LL | pub struct StructWithPrivFields {
21+
| ------------------------------- `xcrate_unit_struct::StructWithPrivFields` defined here
22+
23+
error: aborting due to 2 previous errors
1324

1425
For more information about this error, try `rustc --explain E0423`.

0 commit comments

Comments
 (0)