Open
Description
The following program compiles:
#![feature(offset_of_slice)]
mod foo {
pub struct Inner {
foo: u8,
tail: [u8],
// tail: dyn core::fmt::Debug,
}
pub struct Outer {
pub dst: Inner,
}
}
fn main() {
assert_eq!(core::mem::offset_of!(foo::Outer, dst), 0);
}
It does not compile if the type of tail
is changed to a dyn
type. I believe neither version should compile, because tail
is a private field, and therefore information about its type should not leak to places where it is not visible.
rustc version: 1.87.0-nightly (2025-03-09 3ea711f)
@rustbot label F-offset_of_slice C-bug