Change:
} impl<T: Foo> Foo for Vec<T> { <del> const N: i32 = T::N << 42; // FIXME this should warn </del> <ins> const N: i32 = T::N << 42; //~ WARN: arithmetic operation will overflow </ins> } pub fn foo(x: i32) { <del> let _ = x << 42; //~ ERROR: arithmetic operation will overflow </del> <ins> let _ = x << 42; //~ WARN: arithmetic operation will overflow </ins> } pub fn main() { let n = 1u8 << 7; <del> let n = 1u8 << 8;   //~ ERROR: arithmetic operation will overflow </del> <ins> let n = 1u8 << 8;   //~ WARN: arithmetic operation will overflow </ins> let n = 1u16 << 15; <del> let n = 1u16 << 16; //~ ERROR: arithmetic operation will overflow </del> <ins> let n = 1u16 << 16; //~ WARN: arithmetic operation will overflow </ins> let n = 1u32 << 31; <del> let n = 1u32 << 32; //~ ERROR: arithmetic operation will overflow </del> <ins> let n = 1u32 << 32; //~ WARN: arithmetic operation will overflow </ins> let n = 1u64 << 63; <del> let n = 1u64 << 64; //~ ERROR: arithmetic operation will overflow </del> <ins> let n = 1u64 << 64; //~ WARN: arithmetic operation will overflow </ins> let n = 1i8 << 7; <del> let n = 1i8 << 8;   //~ ERROR: arithmetic operation will overflow </del> <ins> let n = 1i8 << 8;   //~ WARN: arithmetic operation will overflow </ins> let n = 1i16 << 15; <del> let n = 1i16 << 16; //~ ERROR: arithmetic operation will overflow </del> <ins> let n = 1i16 << 16; //~ WARN: arithmetic operation will overflow </ins> let n = 1i32 << 31; <del> let n = 1i32 << 32; //~ ERROR: arithmetic operation will overflow </del> <ins> let n = 1i32 << 32; //~ WARN: arithmetic operation will overflow </ins> let n = 1i64 << 63; <del> let n = 1i64 << 64; //~ ERROR: arithmetic operation will overflow </del> <ins> let n = 1i64 << 64; //~ WARN: arithmetic operation will overflow </ins> let n = 1u8 >> 7; <del> let n = 1u8 >> 8;   //~ ERROR: arithmetic operation will overflow </del> <ins> let n = 1u8 >> 8;   //~ WARN: arithmetic operation will overflow </ins> let n = 1u16 >> 15; <del> let n = 1u16 >> 16; //~ ERROR: arithmetic operation will overflow </del> <ins> let n = 1u16 >> 16; //~ WARN: arithmetic operation will overflow </ins> let n = 1u32 >> 31; <del> let n = 1u32 >> 32; //~ ERROR: arithmetic operation will overflow </del> <ins> let n = 1u32 >> 32; //~ WARN: arithmetic operation will overflow </ins> let n = 1u64 >> 63; <del> let n = 1u64 >> 64; //~ ERROR: arithmetic operation will overflow </del> <ins> let n = 1u64 >> 64; //~ WARN: arithmetic operation will overflow </ins> let n = 1i8 >> 7; <del> let n = 1i8 >> 8;   //~ ERROR: arithmetic operation will overflow </del> <ins> let n = 1i8 >> 8;   //~ WARN: arithmetic operation will overflow </ins> let n = 1i16 >> 15; <del> let n = 1i16 >> 16; //~ ERROR: arithmetic operation will overflow </del> <ins> let n = 1i16 >> 16; //~ WARN: arithmetic operation will overflow </ins> let n = 1i32 >> 31; <del> let n = 1i32 >> 32; //~ ERROR: arithmetic operation will overflow </del> <ins> let n = 1i32 >> 32; //~ WARN: arithmetic operation will overflow </ins> let n = 1i64 >> 63; <del> let n = 1i64 >> 64; //~ ERROR: arithmetic operation will overflow </del> <ins> let n = 1i64 >> 64; //~ WARN: arithmetic operation will overflow </ins> let n = 1u8; let n = n << 7; <del> let n = n << 8; //~ ERROR: arithmetic operation will overflow </del> <ins> let n = n << 8; //~ WARN: arithmetic operation will overflow </ins> <del> let n = 1u8 << -8; //~ ERROR: arithmetic operation will overflow </del> <ins> let n = 1u8 << -8; //~ WARN: arithmetic operation will overflow </ins> let n = 1i8<<(1isize+-1); let n = 1u8 << (4+3); <del> let n = 1u8 << (4+4); //~ ERROR: arithmetic operation will overflow </del> <ins> let n = 1u8 << (4+4); //~ WARN: arithmetic operation will overflow </ins> let n = 1i64 >> [63][0]; <del> let n = 1i64 >> [64][0]; //~ ERROR: arithmetic operation will overflow </del> <ins> let n = 1i64 >> [64][0]; //~ WARN: arithmetic operation will overflow </ins> #[cfg(target_pointer_width = "32")] const BITS: usize = 32; #[cfg(target_pointer_width = "64")] const BITS: usize = 64; <del> let n = 1_isize << BITS; //~ ERROR: arithmetic operation will overflow let n = 1_usize << BITS; //~ ERROR: arithmetic operation will overflow </del> <ins> let n = 1_isize << BITS; //~ WARN: arithmetic operation will overflow let n = 1_usize << BITS; //~ WARN: arithmetic operation will overflow </ins> }

Discussion:
The lint should fire on the following code, but it does not: (This testcase now exists in-tree as a FIXME in .) Cc <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --This issue has been assigned to via . <!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOT_END --
I'd like to take this. claim
I have some plans to follow-up on with some cleanup. That might at least partially resolve this issue here. So it's probably best to wait until after that is done.
All right, landed, so what I planned here is done. The remaining issue is about associated consts. The issue there is that fails, or maybe we are hitting an , but I have not tried further. The issue is all yours, :)
Great! I'll start investigating.
Never mind, that one is already fixed on beta.
got reverted in , so we have to reopen this.