Skip to content

Commit

Permalink
Add doc aliases for libm and IEEE names
Browse files Browse the repository at this point in the history
Searching "fma" in the Rust documentation returns results for
`intrinsics::fma*`, but does not point to the user-facing `mul_add`. Add
aliases for `fma*` and the IEEE operation name `fusedMultiplyAdd`. Add
the IEEE name to `sqrt` as well, `squareRoot`.
  • Loading branch information
tgross35 committed Jan 5, 2025
1 parent ead4a8f commit 37f2875
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions library/std/src/f128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ impl f128 {
/// ```
#[inline]
#[rustc_allow_incoherent_impl]
#[doc(alias = "fmaf128", alias = "fusedMultiplyAdd")]
#[unstable(feature = "f128", issue = "116909")]
#[must_use = "method returns a new number and does not mutate the original value"]
pub fn mul_add(self, a: f128, b: f128) -> f128 {
Expand Down Expand Up @@ -384,6 +385,7 @@ impl f128 {
/// # }
/// ```
#[inline]
#[doc(alias = "squareRoot")]
#[rustc_allow_incoherent_impl]
#[unstable(feature = "f128", issue = "116909")]
#[must_use = "method returns a new number and does not mutate the original value"]
Expand Down
2 changes: 2 additions & 0 deletions library/std/src/f16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ impl f16 {
#[inline]
#[rustc_allow_incoherent_impl]
#[unstable(feature = "f16", issue = "116909")]
#[doc(alias = "fmaf16", alias = "fusedMultiplyAdd")]
#[must_use = "method returns a new number and does not mutate the original value"]
pub fn mul_add(self, a: f16, b: f16) -> f16 {
unsafe { intrinsics::fmaf16(self, a, b) }
Expand Down Expand Up @@ -384,6 +385,7 @@ impl f16 {
/// # }
/// ```
#[inline]
#[doc(alias = "squareRoot")]
#[rustc_allow_incoherent_impl]
#[unstable(feature = "f16", issue = "116909")]
#[must_use = "method returns a new number and does not mutate the original value"]
Expand Down
2 changes: 2 additions & 0 deletions library/std/src/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ impl f32 {
/// assert_eq!(one_plus_eps * one_minus_eps + minus_one, 0.0);
/// ```
#[rustc_allow_incoherent_impl]
#[doc(alias = "fmaf", alias = "fusedMultiplyAdd")]
#[must_use = "method returns a new number and does not mutate the original value"]
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
Expand Down Expand Up @@ -360,6 +361,7 @@ impl f32 {
/// assert!(negative.sqrt().is_nan());
/// assert!(negative_zero.sqrt() == negative_zero);
/// ```
#[doc(alias = "squareRoot")]
#[rustc_allow_incoherent_impl]
#[must_use = "method returns a new number and does not mutate the original value"]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
2 changes: 2 additions & 0 deletions library/std/src/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ impl f64 {
/// assert_eq!(one_plus_eps * one_minus_eps + minus_one, 0.0);
/// ```
#[rustc_allow_incoherent_impl]
#[doc(alias = "fma", alias = "fusedMultiplyAdd")]
#[must_use = "method returns a new number and does not mutate the original value"]
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
Expand Down Expand Up @@ -360,6 +361,7 @@ impl f64 {
/// assert!(negative.sqrt().is_nan());
/// assert!(negative_zero.sqrt() == negative_zero);
/// ```
#[doc(alias = "squareRoot")]
#[rustc_allow_incoherent_impl]
#[must_use = "method returns a new number and does not mutate the original value"]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down

0 comments on commit 37f2875

Please sign in to comment.