(我正在使用 Rust 1.44.1)
以下示例由于算术溢出而无法构建(调试模式)(我明白为什么):
fn main() {
    let i: u8 = 255 + 1;
}
error: this arithmetic operation will overflow
 --> src/main.rs:2:17
  |
2 |     let i: u8 = 255 + 1;
  |                 ^^^^^^^ attempt to add with overflow
  |
  = note: `#[deny(arithmetic_overflow)]` on by default
虽然此示例正确构建:
fn main() {
    let i: u8 = 255;
    let _j: u8 = i + 1;
}
由于i它是不可变的,因此我预计会出现与第一个示例相同的错误。
我错过了什么或者这是编译器没有处理的东西吗?