overflowing_literals vs exceeding_bitshifts


Only the first line, which is exceeding_bitshifts, is a hard error and the rest, overflowing_literals, are just warnings.

fn main() {
  println!("{}", 1 << 32);

  println!("{}", 5_000_000_000i32);
  println!("{}", 5_000_000_000);  // i32
  println!("{}", 1e1000f32);
  println!("{}", 1e1000);  // f64

Does it not make more sense to turn both of them hard errors? I mean, what are possible use cases of overflowing literals? (Maybe for some macro sorcery?) If some people really mean to have an overflowed value, they can use something like 5_000_000_000u64 as i32, even within const contexts.



exceeding_bitshifts is not a hard error, it’s just a lint that’s deny by default. But I agree that overflowing_literals should also be deny by default.

1 Like

closed #3

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.