From 6b3feb49c603096dd904a4689f2b57ba3ed6b27d Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 6 Aug 2024 14:16:53 -0400 Subject: [PATCH] Mark `{f32,f64}::{next_up,next_down,midpoint}` inline Most float functions are marked `#[inline]` so any float symbols used by these functions only need to be provided if the function itself is used. RFL recently noticed that `next_up`, `next_down`, and `midpoint` for `f32` and `f64` are not inline, which causes linker errors when building with certain configurations [1]. Add the missing attributes so the symbols should no longer be required. Cc: Gary Guo Reported-by: Alice Ryhl Link: https://lore.kernel.org/all/20240806150619.192882-1-ojeda@kernel.org/ [1] --- library/core/src/num/f32.rs | 3 +++ library/core/src/num/f64.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs index 08d863f17caf7..eca75e1b6c394 100644 --- a/library/core/src/num/f32.rs +++ b/library/core/src/num/f32.rs @@ -797,6 +797,7 @@ impl f32 { /// [`INFINITY`]: Self::INFINITY /// [`MIN`]: Self::MIN /// [`MAX`]: Self::MAX + #[inline] #[unstable(feature = "float_next_up_down", issue = "91399")] #[rustc_const_unstable(feature = "float_next_up_down", issue = "91399")] pub const fn next_up(self) -> Self { @@ -845,6 +846,7 @@ impl f32 { /// [`INFINITY`]: Self::INFINITY /// [`MIN`]: Self::MIN /// [`MAX`]: Self::MAX + #[inline] #[unstable(feature = "float_next_up_down", issue = "91399")] #[rustc_const_unstable(feature = "float_next_up_down", issue = "91399")] pub const fn next_down(self) -> Self { @@ -1042,6 +1044,7 @@ impl f32 { /// assert_eq!(1f32.midpoint(4.0), 2.5); /// assert_eq!((-5.5f32).midpoint(8.0), 1.25); /// ``` + #[inline] #[unstable(feature = "num_midpoint", issue = "110840")] pub fn midpoint(self, other: f32) -> f32 { cfg_if! { diff --git a/library/core/src/num/f64.rs b/library/core/src/num/f64.rs index 5d33eea6d011f..533861381f922 100644 --- a/library/core/src/num/f64.rs +++ b/library/core/src/num/f64.rs @@ -805,6 +805,7 @@ impl f64 { /// [`INFINITY`]: Self::INFINITY /// [`MIN`]: Self::MIN /// [`MAX`]: Self::MAX + #[inline] #[unstable(feature = "float_next_up_down", issue = "91399")] #[rustc_const_unstable(feature = "float_next_up_down", issue = "91399")] pub const fn next_up(self) -> Self { @@ -853,6 +854,7 @@ impl f64 { /// [`INFINITY`]: Self::INFINITY /// [`MIN`]: Self::MIN /// [`MAX`]: Self::MAX + #[inline] #[unstable(feature = "float_next_up_down", issue = "91399")] #[rustc_const_unstable(feature = "float_next_up_down", issue = "91399")] pub const fn next_down(self) -> Self { @@ -1051,6 +1053,7 @@ impl f64 { /// assert_eq!(1f64.midpoint(4.0), 2.5); /// assert_eq!((-5.5f64).midpoint(8.0), 1.25); /// ``` + #[inline] #[unstable(feature = "num_midpoint", issue = "110840")] pub fn midpoint(self, other: f64) -> f64 { const LO: f64 = f64::MIN_POSITIVE * 2.;