From f7ceb1a8862495b343acc26260eb314ed088b49f Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Tue, 21 Apr 2020 13:37:18 -0400 Subject: [PATCH] Error on casting floats to integers This is intended for a crater run to know the total (worst case) extent of slowdowns introduced by changing the behavior here. --- src/librustc_typeck/check/cast.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 981e6d2c47eef..fed9755bc3b24 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -613,6 +613,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { (Int(CEnum), Int(_)) => Ok(CastKind::EnumCast), (Int(Char) | Int(Bool), Int(_)) => Ok(CastKind::PrimIntCast), + (Float, Int(_)) if std::env::var_os("RUSTC_BOOTSTRAP").is_none() => Err(CastError::IllegalCast), (Int(_) | Float, Int(_) | Float) => Ok(CastKind::NumericCast), } }