Skip to content

Commit

Permalink
Add widening tests for cast_sign_loss lint
Browse files Browse the repository at this point in the history
  • Loading branch information
krishna-veerareddy committed Dec 6, 2019
1 parent 7002a9e commit c0fb74b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/ui/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,34 +42,54 @@ fn main() {
i32::max_value() as u32;
i64::max_value() as u64;
i128::max_value() as u128;

(-1i8).abs() as u8;
(-1i16).abs() as u16;
(-1i32).abs() as u32;
(-1i64).abs() as u64;
(-1isize).abs() as usize;

(-1i8).checked_abs().unwrap() as u8;
(-1i16).checked_abs().unwrap() as u16;
(-1i32).checked_abs().unwrap() as u32;
(-1i64).checked_abs().unwrap() as u64;
(-1isize).checked_abs().unwrap() as usize;

(-1i8).rem_euclid(1i8) as u8;
(-1i8).rem_euclid(1i8) as u16;
(-1i16).rem_euclid(1i16) as u16;
(-1i16).rem_euclid(1i16) as u32;
(-1i32).rem_euclid(1i32) as u32;
(-1i32).rem_euclid(1i32) as u64;
(-1i64).rem_euclid(1i64) as u64;
(-1i64).rem_euclid(1i64) as u128;
(-1isize).rem_euclid(1isize) as usize;
(1i8).rem_euclid(-1i8) as u8;
(1i8).rem_euclid(-1i8) as u16;
(1i16).rem_euclid(-1i16) as u16;
(1i16).rem_euclid(-1i16) as u32;
(1i32).rem_euclid(-1i32) as u32;
(1i32).rem_euclid(-1i32) as u64;
(1i64).rem_euclid(-1i64) as u64;
(1i64).rem_euclid(-1i64) as u128;
(1isize).rem_euclid(-1isize) as usize;

(-1i8).checked_rem_euclid(1i8).unwrap() as u8;
(-1i8).checked_rem_euclid(1i8).unwrap() as u16;
(-1i16).checked_rem_euclid(1i16).unwrap() as u16;
(-1i16).checked_rem_euclid(1i16).unwrap() as u32;
(-1i32).checked_rem_euclid(1i32).unwrap() as u32;
(-1i32).checked_rem_euclid(1i32).unwrap() as u64;
(-1i64).checked_rem_euclid(1i64).unwrap() as u64;
(-1i64).checked_rem_euclid(1i64).unwrap() as u128;
(-1isize).checked_rem_euclid(1isize).unwrap() as usize;
(1i8).checked_rem_euclid(-1i8).unwrap() as u8;
(1i8).checked_rem_euclid(-1i8).unwrap() as u16;
(1i16).checked_rem_euclid(-1i16).unwrap() as u16;
(1i16).checked_rem_euclid(-1i16).unwrap() as u32;
(1i32).checked_rem_euclid(-1i32).unwrap() as u32;
(1i32).checked_rem_euclid(-1i32).unwrap() as u64;
(1i64).checked_rem_euclid(-1i64).unwrap() as u64;
(1i64).checked_rem_euclid(-1i64).unwrap() as u128;
(1isize).checked_rem_euclid(-1isize).unwrap() as usize;
}

0 comments on commit c0fb74b

Please sign in to comment.