-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-offset_of_slice`#![feature(offset_of_slice)]``#![feature(offset_of_slice)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-offset_of_slice`#![feature(offset_of_slice)]``#![feature(offset_of_slice)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.