It happens due to coercions you request by annotating a type:
fn main() {
let x: Box<i32> = Box::new(5);
let p: &Box<i32> = &x;
let pp: &i32 = &x;
[...]
}
You see, the third let binding ought to be a type error, but due to the way the & operator works in Rust, it may dereference the inner type an unspecified number of times until the type fits.
Ok, I see. Then I guess that the desired behavior would be to get a compilation error at 'let pp', right? I came across this situation while I was playing with this example: