kani
kani copied to clipboard
DST example fails to codegen
The following example from The Rustonomicon/Data Layout/Exotically Sized Types/47.rs shown below
// compile-flags: --edition 2018
#![allow(unused)]
struct MySuperSliceable<T: ?Sized> {
info: u32,
data: T,
}
pub fn main() {
let sized: MySuperSliceable<[u8; 8]> = MySuperSliceable {
info: 17,
data: [0; 8],
};
let dynamic: &MySuperSliceable<[u8]> = &sized;
// prints: "17 [0, 0, 0, 0, 0, 0, 0, 0]"
println!("{} {:?}", dynamic.info, &dynamic.data);
}
fails to codegen with
thread 'rustc' panicked at 'Only an array can be cast to a slice. Found types Adt(MySuperSliceable, [[u8; 8]]) and Adt(MySuperSliceable, [[u8]])', compiler/rustc_codegen_rmc/src/codegen/rvalue.rs:1076:37
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Still crashes with the same signature as of af11d38d93a.