2023-12-05 22:15:26 +00:00
|
|
|
#![feature(extern_types)]
|
2022-09-11 07:37:49 +00:00
|
|
|
|
|
|
|
use std::mem::offset_of;
|
|
|
|
|
2023-04-21 08:53:34 +00:00
|
|
|
struct Alpha {
|
2022-09-11 07:37:49 +00:00
|
|
|
x: u8,
|
|
|
|
y: u16,
|
2023-04-21 08:53:34 +00:00
|
|
|
z: [u8],
|
|
|
|
}
|
|
|
|
|
|
|
|
trait Trait {}
|
|
|
|
|
|
|
|
struct Beta {
|
|
|
|
x: u8,
|
|
|
|
y: u16,
|
|
|
|
z: dyn Trait,
|
|
|
|
}
|
|
|
|
|
|
|
|
extern {
|
|
|
|
type Extern;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Gamma {
|
|
|
|
x: u8,
|
|
|
|
y: u16,
|
|
|
|
z: Extern,
|
2022-09-11 07:37:49 +00:00
|
|
|
}
|
|
|
|
|
2023-05-17 02:56:59 +00:00
|
|
|
struct Delta<T: ?Sized> {
|
|
|
|
x: u8,
|
|
|
|
y: u16,
|
|
|
|
z: T,
|
|
|
|
}
|
|
|
|
|
2022-09-11 07:37:49 +00:00
|
|
|
fn main() {
|
2023-04-21 08:53:34 +00:00
|
|
|
offset_of!(Alpha, z); //~ ERROR the size for values of type
|
|
|
|
offset_of!(Beta, z); //~ ERROR the size for values of type
|
|
|
|
offset_of!(Gamma, z); //~ ERROR the size for values of type
|
2023-06-02 00:41:02 +00:00
|
|
|
offset_of!((u8, dyn Trait), 0); // ok
|
|
|
|
offset_of!((u8, dyn Trait), 1); //~ ERROR the size for values of type
|
2022-09-11 07:37:49 +00:00
|
|
|
}
|
2023-05-17 02:56:59 +00:00
|
|
|
|
|
|
|
fn delta() {
|
|
|
|
offset_of!(Delta<Alpha>, z); //~ ERROR the size for values of type
|
|
|
|
offset_of!(Delta<Extern>, z); //~ ERROR the size for values of type
|
2023-05-17 20:10:36 +00:00
|
|
|
offset_of!(Delta<dyn Trait>, z); //~ ERROR the size for values of type
|
2023-05-17 02:56:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn generic_with_maybe_sized<T: ?Sized>() -> usize {
|
|
|
|
offset_of!(Delta<T>, z) //~ ERROR the size for values of type
|
|
|
|
}
|