Skip to content

Commit

Permalink
Error on casting floats to integers
Browse files Browse the repository at this point in the history
This is intended for a crater run to know the total (worst case) extent of
slowdowns introduced by changing the behavior here.
  • Loading branch information
Mark-Simulacrum committed Apr 21, 2020
1 parent 45d050c commit f7ceb1a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/librustc_typeck/check/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
Expand Down

0 comments on commit f7ceb1a

Please sign in to comment.