]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #59148 - lcnr:unchecked_maths, r=eddyb
authorbors <bors@rust-lang.org>
Mon, 3 Jun 2019 22:05:55 +0000 (22:05 +0000)
committerbors <bors@rust-lang.org>
Mon, 3 Jun 2019 22:05:55 +0000 (22:05 +0000)
add support for unchecked math

add compiler support for
```rust
/// Returns the result of an unchecked addition, resulting in
/// undefined behavior when `x + y > T::max_value()` or `x + y < T::min_value()`.
pub fn unchecked_add<T>(x: T, y: T) -> T;

/// Returns the result of an unchecked substraction, resulting in
/// undefined behavior when `x - y > T::max_value()` or `x - y < T::min_value()`.
pub fn unchecked_sub<T>(x: T, y: T) -> T;

/// Returns the result of an unchecked multiplication, resulting in
/// undefined behavior when `x * y > T::max_value()` or `x * y < T::min_value()`.
pub fn unchecked_mul<T>(x: T, y: T) -> T;
```

cc https://github.com/rust-lang/rfcs/issues/2508

1  2 
src/librustc_codegen_llvm/intrinsic.rs