From a35b4234df9815e7741aff8fe7cc4dfde12dcc2c Mon Sep 17 00:00:00 2001 From: Oliver Middleton Date: Sat, 4 Jan 2020 23:44:19 +0000 Subject: [PATCH] Remove negative number check from float sqrt It hasn't been UB to pass negative numbers to sqrt since https://reviews.llvm.org/D28797 which was included in LLVM 5. --- src/libstd/f32.rs | 2 +- src/libstd/f64.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index 54e0caeddaa0b..267d7013b1e42 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -376,7 +376,7 @@ impl f32 { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn sqrt(self) -> f32 { - if self < 0.0 { NAN } else { unsafe { intrinsics::sqrtf32(self) } } + unsafe { intrinsics::sqrtf32(self) } } /// Returns `e^(self)`, (the exponential function). diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index aa32e5fb998bc..61ce7b29e26fc 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -342,7 +342,7 @@ impl f64 { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn sqrt(self) -> f64 { - if self < 0.0 { NAN } else { unsafe { intrinsics::sqrtf64(self) } } + unsafe { intrinsics::sqrtf64(self) } } /// Returns `e^(self)`, (the exponential function).