Open
Description
I don't know if this is a bug or working as intended. So I'm filing an issue just in case.
trait Trait {}
impl Trait for usize {}
static X: usize = std::mem::size_of_val(&X as &dyn Trait);
fn main() {
println!("{X}");
}
This code compiles and prints 8
. I'm not sure if this code is supposed to compile.
See also #142532 and #142404 for shenanigans with uninitialized statics.
Meta
rustc --version --verbose
:
rustc 1.89.0-nightly (be19eda0d 2025-06-22)
binary: rustc
commit-hash: be19eda0dc4c22c5cf5f1b48fd163acf9bd4b0a6
commit-date: 2025-06-22
host: aarch64-apple-darwin
release: 1.89.0-nightly
LLVM version: 20.1.7
@rustbot labels +A-const-eval