mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 01:04:03 +00:00
29 lines
777 B
Rust
29 lines
777 B
Rust
#![feature(offset_of_enum)]
|
|
|
|
use std::mem::offset_of;
|
|
|
|
struct S {
|
|
a: u8,
|
|
b: (u8, u8),
|
|
c: T,
|
|
}
|
|
|
|
struct T {
|
|
t: &'static str,
|
|
}
|
|
|
|
enum Alpha {
|
|
One(u8),
|
|
Two(u8),
|
|
}
|
|
|
|
fn main() {
|
|
offset_of!(Alpha, Two.0); //~ ERROR only a single ident or integer is stable as the field in offset_of
|
|
offset_of!(S, a);
|
|
offset_of!((u8, S), 1);
|
|
offset_of!((u32, (S, T)), 1.1); //~ ERROR only a single ident or integer is stable as the field in offset_of
|
|
offset_of!(S, b.0); //~ ERROR only a single ident or integer is stable as the field in offset_of
|
|
offset_of!((S, ()), 0.c); //~ ERROR only a single ident or integer is stable as the field in offset_of
|
|
offset_of!(S, c.t); //~ ERROR only a single ident or integer is stable as the field in offset_of
|
|
}
|