arithmetic_overflow diagnostic triggers when shifting u8 but not &u8
fn main() {
let x = 1u8;
println!("{}", (x << 8) as i32);
}
This triggers an arithmetic_overflow diagnostic. However, changing 1u8 to &1u8 will make it not trigger the diagnostic, even though it is still known statically to be a guaranteed overflow.
This diagnostic will be triggered if you use the compiler option -Zinline-mir. This is also the case for a number of other scenarios, like if you use the explicit method shl instead of the operator, and it applies to other operations like Add.
I suspect the right way to handle this is to just do nothing until MIR inlining is enabled by default, and then possibly change the attribute in operation trait implementations defined in library/core/src/ops/ to use #[inline(always)] so they'll be inlined even on mir-opt-level=1.