Rust compiler fails to catch index out of bound error.

44 points nagabhushan1995

The following code produces a compilation error:

let a = [1, 2, 3];
let b = a[10];

However, the following code compiles successfully (although panics at runtime):

let a = [1, 2, 3];
let b = a[10];
println!("{}", mem::size_of_val(&a));

I am not sure if I am missing something here. Why does the second code snippet not throw a compilation error?