Change:
} #[test] <ins> fn seek_past_i64() { let buf = [0xff]; let mut r = Cursor::new(&buf[..]); assert_eq!(r.seek(SeekFrom::Start(6)).unwrap(), 6); assert_eq!(r.seek(SeekFrom::Current(0x7ffffffffffffff0)).unwrap(), 0x7ffffffffffffff6); assert_eq!(r.seek(SeekFrom::Current(0x10)).unwrap(), 0x8000000000000006); assert_eq!(r.seek(SeekFrom::Current(0)).unwrap(), 0x8000000000000006); assert!(r.seek(SeekFrom::Current(0x7ffffffffffffffd)).is_err()); assert_eq!(r.seek(SeekFrom::Current(-0x8000000000000000)).unwrap(), 6); let mut r = Cursor::new(vec![10]); assert_eq!(r.seek(SeekFrom::Start(6)).unwrap(), 6); assert_eq!(r.seek(SeekFrom::Current(0x7ffffffffffffff0)).unwrap(), 0x7ffffffffffffff6); assert_eq!(r.seek(SeekFrom::Current(0x10)).unwrap(), 0x8000000000000006); assert_eq!(r.seek(SeekFrom::Current(0)).unwrap(), 0x8000000000000006); assert!(r.seek(SeekFrom::Current(0x7ffffffffffffffd)).is_err()); assert_eq!(r.seek(SeekFrom::Current(-0x8000000000000000)).unwrap(), 6); let mut buf = [0]; let mut r = Cursor::new(&mut buf[..]); assert_eq!(r.seek(SeekFrom::Start(6)).unwrap(), 6); assert_eq!(r.seek(SeekFrom::Current(0x7ffffffffffffff0)).unwrap(), 0x7ffffffffffffff6); assert_eq!(r.seek(SeekFrom::Current(0x10)).unwrap(), 0x8000000000000006); assert_eq!(r.seek(SeekFrom::Current(0)).unwrap(), 0x8000000000000006); assert!(r.seek(SeekFrom::Current(0x7ffffffffffffffd)).is_err()); assert_eq!(r.seek(SeekFrom::Current(-0x8000000000000000)).unwrap(), 6); let mut r = Cursor::new(vec![10].into_boxed_slice()); assert_eq!(r.seek(SeekFrom::Start(6)).unwrap(), 6); assert_eq!(r.seek(SeekFrom::Current(0x7ffffffffffffff0)).unwrap(), 0x7ffffffffffffff6); assert_eq!(r.seek(SeekFrom::Current(0x10)).unwrap(), 0x8000000000000006); assert_eq!(r.seek(SeekFrom::Current(0)).unwrap(), 0x8000000000000006); assert!(r.seek(SeekFrom::Current(0x7ffffffffffffffd)).is_err()); assert_eq!(r.seek(SeekFrom::Current(-0x8000000000000000)).unwrap(), 6); } #[test] </ins> fn seek_before_0() { let buf = [0xff]; let mut r = Cursor::new(&buf[..]);

Discussion:
Seems to be a reroll . I have some idea how to fix it, will try to draft a pull request later, but it basically requires checking the sign of the , ging if required and casting to , and using or . I will divide into cases to demonstrate that this is required, to save repeating phrases, I will use the following notation: S means , L means ; P means , N means ; O+ means we will notice bads by checking OF on add (), O- means we will notice them by checking OF on sub ( after ), Z+ means we will notice by adding as and making sure result is non-negative, Z- is making sure it is negative, D+ mean we will notice bads by asserting OF is set on add (), D- is likewise for sub (). Note the we don't need to consider , because after and we still get the right, large, positive number. So, we have the following cases and appropriate checks that spot trouble: SP -O+Z+D- (there's never a problem, but the others false-positive) LP -O+Z-D- (but D- requires also that the result is non-zero). SN -O-Z+D+ LN -O-D+ (there's never a problem, but the others false-positive) Overall, we see that there is no one test which works for all cases, and a minimum of two cases (and tests) yields the solution described above.
Thanks for the report! I'd definitely believe that the exact implementation here is slightly wrong and could use some tweaking.
I wrote a test that should fail and an implementation that should fix, just waiting for build & tests to finish on my machine before PR. Edit: PR