explain what happens in a test

This commit is contained in:
Ralf Jung 2020-05-03 12:24:40 +02:00
parent 9ec526478f
commit ff1f0b06cc
2 changed files with 2 additions and 1 deletions

View File

@ -8,5 +8,6 @@ fn main() {
let bad = unsafe {
std::mem::transmute::<u64, &[u8]>(42)
};
// This created a slice with length 0, so the following will fail the bounds check.
bad[0];
}

View File

@ -1 +1 @@
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', $DIR/transmute_fat2.rs:11:5
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', $DIR/transmute_fat2.rs:12:5