-
Notifications
You must be signed in to change notification settings - Fork 12.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check representation of unnamed fields
- Loading branch information
1 parent
6ee6111
commit bf6482b
Showing
9 changed files
with
153 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#![allow(incomplete_features)] | ||
#![feature(unnamed_fields)] | ||
|
||
struct A { //~ ERROR struct with unnamed fields must have `#[repr(C)]` representation | ||
_: struct { | ||
a: i32, | ||
} | ||
} | ||
|
||
union B { //~ ERROR union with unnamed fields must have `#[repr(C)]` representation | ||
_: struct { | ||
b: i32, | ||
} | ||
} | ||
|
||
#[derive(Clone, Copy)] | ||
struct Foo {} | ||
|
||
struct C { //~ ERROR struct with unnamed fields must have `#[repr(C)]` representation | ||
_: Foo, | ||
} | ||
|
||
union D { //~ ERROR union with unnamed fields must have `#[repr(C)]` representation | ||
_: Foo, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
error: struct with unnamed fields must have `#[repr(C)]` representation | ||
--> $DIR/repr_check.rs:4:1 | ||
| | ||
LL | struct A { | ||
| ^^^^^^^^ struct defined here | ||
LL | / _: struct { | ||
LL | | a: i32, | ||
LL | | } | ||
| |_____- unnamed field defined here | ||
|
||
error: union with unnamed fields must have `#[repr(C)]` representation | ||
--> $DIR/repr_check.rs:10:1 | ||
| | ||
LL | union B { | ||
| ^^^^^^^ union defined here | ||
LL | / _: struct { | ||
LL | | b: i32, | ||
LL | | } | ||
| |_____- unnamed field defined here | ||
|
||
error: struct with unnamed fields must have `#[repr(C)]` representation | ||
--> $DIR/repr_check.rs:19:1 | ||
| | ||
LL | struct C { | ||
| ^^^^^^^^ struct defined here | ||
LL | _: Foo, | ||
| ------ unnamed field defined here | ||
|
||
error: union with unnamed fields must have `#[repr(C)]` representation | ||
--> $DIR/repr_check.rs:23:1 | ||
| | ||
LL | union D { | ||
| ^^^^^^^ union defined here | ||
LL | _: Foo, | ||
| ------ unnamed field defined here | ||
|
||
error: aborting due to 4 previous errors | ||
|