下面这段代码会爆栈:

fn main() {
    let _b = Box::new([0; 1024 * 4096]);
}

stack-overflow

再仔细看看文档里面说的:

alloc::boxed::Box
pub fn new(x: T) -> Self

Allocates memory on the heap and then places x into it. This doesn’t actually allocate if T is zero-sized.

也就是说,在将这个巨型数组放到堆上之前,需要在栈上先创建这个数组,之后才会将这个数组移动到堆上

但是在 release 构建下,则能通过编译……