Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 65fa0ab

Browse files
committedApr 13, 2025·
Auto merge of #139734 - ChrisDenton:rollup-28qn740, r=ChrisDenton
Rollup of 6 pull requests Successful merges: - #139107 (std: make `cmath` functions safe) - #139607 (Add regression test for #127424) - #139691 (Document that `opt-dist` requires metrics to be enabled) - #139707 (Fix comment in bootstrap) - #139708 (Fix name of field in doc comment) - #139709 (bootstrap: fix typo in doc string) r? `@ghost` `@rustbot` modify labels: rollup
2 parents fda35a6 + 6b26d3c commit 65fa0ab

File tree

11 files changed

+174
-133
lines changed

11 files changed

+174
-133
lines changed
 

‎compiler/rustc_hir/src/hir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,7 @@ pub enum PatKind<'hir> {
17561756
Never,
17571757

17581758
/// A tuple pattern (e.g., `(a, b)`).
1759-
/// If the `..` pattern fragment is present, then `Option<usize>` denotes its position.
1759+
/// If the `..` pattern fragment is present, then `DotDotPos` denotes its position.
17601760
/// `0 <= position <= subpats.len()`
17611761
Tuple(&'hir [Pat<'hir>], DotDotPos),
17621762

‎library/std/src/f128.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ impl f128 {
666666
#[unstable(feature = "f128", issue = "116909")]
667667
#[must_use = "method returns a new number and does not mutate the original value"]
668668
pub fn cbrt(self) -> f128 {
669-
unsafe { cmath::cbrtf128(self) }
669+
cmath::cbrtf128(self)
670670
}
671671

672672
/// Compute the distance between the origin and a point (`x`, `y`) on the
@@ -703,7 +703,7 @@ impl f128 {
703703
#[unstable(feature = "f128", issue = "116909")]
704704
#[must_use = "method returns a new number and does not mutate the original value"]
705705
pub fn hypot(self, other: f128) -> f128 {
706-
unsafe { cmath::hypotf128(self, other) }
706+
cmath::hypotf128(self, other)
707707
}
708708

709709
/// Computes the sine of a number (in radians).
@@ -789,7 +789,7 @@ impl f128 {
789789
#[unstable(feature = "f128", issue = "116909")]
790790
#[must_use = "method returns a new number and does not mutate the original value"]
791791
pub fn tan(self) -> f128 {
792-
unsafe { cmath::tanf128(self) }
792+
cmath::tanf128(self)
793793
}
794794

795795
/// Computes the arcsine of a number. Return value is in radians in
@@ -824,7 +824,7 @@ impl f128 {
824824
#[unstable(feature = "f128", issue = "116909")]
825825
#[must_use = "method returns a new number and does not mutate the original value"]
826826
pub fn asin(self) -> f128 {
827-
unsafe { cmath::asinf128(self) }
827+
cmath::asinf128(self)
828828
}
829829

830830
/// Computes the arccosine of a number. Return value is in radians in
@@ -859,7 +859,7 @@ impl f128 {
859859
#[unstable(feature = "f128", issue = "116909")]
860860
#[must_use = "method returns a new number and does not mutate the original value"]
861861
pub fn acos(self) -> f128 {
862-
unsafe { cmath::acosf128(self) }
862+
cmath::acosf128(self)
863863
}
864864

865865
/// Computes the arctangent of a number. Return value is in radians in the
@@ -893,7 +893,7 @@ impl f128 {
893893
#[unstable(feature = "f128", issue = "116909")]
894894
#[must_use = "method returns a new number and does not mutate the original value"]
895895
pub fn atan(self) -> f128 {
896-
unsafe { cmath::atanf128(self) }
896+
cmath::atanf128(self)
897897
}
898898

899899
/// Computes the four quadrant arctangent of `self` (`y`) and `other` (`x`) in radians.
@@ -939,7 +939,7 @@ impl f128 {
939939
#[unstable(feature = "f128", issue = "116909")]
940940
#[must_use = "method returns a new number and does not mutate the original value"]
941941
pub fn atan2(self, other: f128) -> f128 {
942-
unsafe { cmath::atan2f128(self, other) }
942+
cmath::atan2f128(self, other)
943943
}
944944

945945
/// Simultaneously computes the sine and cosine of the number, `x`. Returns
@@ -1008,7 +1008,7 @@ impl f128 {
10081008
#[unstable(feature = "f128", issue = "116909")]
10091009
#[must_use = "method returns a new number and does not mutate the original value"]
10101010
pub fn exp_m1(self) -> f128 {
1011-
unsafe { cmath::expm1f128(self) }
1011+
cmath::expm1f128(self)
10121012
}
10131013

10141014
/// Returns `ln(1+n)` (natural logarithm) more accurately than if
@@ -1055,7 +1055,7 @@ impl f128 {
10551055
#[rustc_allow_incoherent_impl]
10561056
#[unstable(feature = "f128", issue = "116909")]
10571057
pub fn ln_1p(self) -> f128 {
1058-
unsafe { cmath::log1pf128(self) }
1058+
cmath::log1pf128(self)
10591059
}
10601060

10611061
/// Hyperbolic sine function.
@@ -1090,7 +1090,7 @@ impl f128 {
10901090
#[unstable(feature = "f128", issue = "116909")]
10911091
#[must_use = "method returns a new number and does not mutate the original value"]
10921092
pub fn sinh(self) -> f128 {
1093-
unsafe { cmath::sinhf128(self) }
1093+
cmath::sinhf128(self)
10941094
}
10951095

10961096
/// Hyperbolic cosine function.
@@ -1125,7 +1125,7 @@ impl f128 {
11251125
#[unstable(feature = "f128", issue = "116909")]
11261126
#[must_use = "method returns a new number and does not mutate the original value"]
11271127
pub fn cosh(self) -> f128 {
1128-
unsafe { cmath::coshf128(self) }
1128+
cmath::coshf128(self)
11291129
}
11301130

11311131
/// Hyperbolic tangent function.
@@ -1160,7 +1160,7 @@ impl f128 {
11601160
#[unstable(feature = "f128", issue = "116909")]
11611161
#[must_use = "method returns a new number and does not mutate the original value"]
11621162
pub fn tanh(self) -> f128 {
1163-
unsafe { cmath::tanhf128(self) }
1163+
cmath::tanhf128(self)
11641164
}
11651165

11661166
/// Inverse hyperbolic sine function.
@@ -1289,7 +1289,7 @@ impl f128 {
12891289
// #[unstable(feature = "float_gamma", issue = "99842")]
12901290
#[must_use = "method returns a new number and does not mutate the original value"]
12911291
pub fn gamma(self) -> f128 {
1292-
unsafe { cmath::tgammaf128(self) }
1292+
cmath::tgammaf128(self)
12931293
}
12941294

12951295
/// Natural logarithm of the absolute value of the gamma function
@@ -1325,7 +1325,7 @@ impl f128 {
13251325
#[must_use = "method returns a new number and does not mutate the original value"]
13261326
pub fn ln_gamma(self) -> (f128, i32) {
13271327
let mut signgamp: i32 = 0;
1328-
let x = unsafe { cmath::lgammaf128_r(self, &mut signgamp) };
1328+
let x = cmath::lgammaf128_r(self, &mut signgamp);
13291329
(x, signgamp)
13301330
}
13311331

@@ -1365,7 +1365,7 @@ impl f128 {
13651365
// #[unstable(feature = "float_erf", issue = "136321")]
13661366
#[inline]
13671367
pub fn erf(self) -> f128 {
1368-
unsafe { cmath::erff128(self) }
1368+
cmath::erff128(self)
13691369
}
13701370

13711371
/// Complementary error function.
@@ -1398,6 +1398,6 @@ impl f128 {
13981398
// #[unstable(feature = "float_erf", issue = "136321")]
13991399
#[inline]
14001400
pub fn erfc(self) -> f128 {
1401-
unsafe { cmath::erfcf128(self) }
1401+
cmath::erfcf128(self)
14021402
}
14031403
}

‎library/std/src/f16.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ impl f16 {
665665
#[unstable(feature = "f16", issue = "116909")]
666666
#[must_use = "method returns a new number and does not mutate the original value"]
667667
pub fn cbrt(self) -> f16 {
668-
(unsafe { cmath::cbrtf(self as f32) }) as f16
668+
cmath::cbrtf(self as f32) as f16
669669
}
670670

671671
/// Compute the distance between the origin and a point (`x`, `y`) on the
@@ -701,7 +701,7 @@ impl f16 {
701701
#[unstable(feature = "f16", issue = "116909")]
702702
#[must_use = "method returns a new number and does not mutate the original value"]
703703
pub fn hypot(self, other: f16) -> f16 {
704-
(unsafe { cmath::hypotf(self as f32, other as f32) }) as f16
704+
cmath::hypotf(self as f32, other as f32) as f16
705705
}
706706

707707
/// Computes the sine of a number (in radians).
@@ -787,7 +787,7 @@ impl f16 {
787787
#[unstable(feature = "f16", issue = "116909")]
788788
#[must_use = "method returns a new number and does not mutate the original value"]
789789
pub fn tan(self) -> f16 {
790-
(unsafe { cmath::tanf(self as f32) }) as f16
790+
cmath::tanf(self as f32) as f16
791791
}
792792

793793
/// Computes the arcsine of a number. Return value is in radians in
@@ -822,7 +822,7 @@ impl f16 {
822822
#[unstable(feature = "f16", issue = "116909")]
823823
#[must_use = "method returns a new number and does not mutate the original value"]
824824
pub fn asin(self) -> f16 {
825-
(unsafe { cmath::asinf(self as f32) }) as f16
825+
cmath::asinf(self as f32) as f16
826826
}
827827

828828
/// Computes the arccosine of a number. Return value is in radians in
@@ -857,7 +857,7 @@ impl f16 {
857857
#[unstable(feature = "f16", issue = "116909")]
858858
#[must_use = "method returns a new number and does not mutate the original value"]
859859
pub fn acos(self) -> f16 {
860-
(unsafe { cmath::acosf(self as f32) }) as f16
860+
cmath::acosf(self as f32) as f16
861861
}
862862

863863
/// Computes the arctangent of a number. Return value is in radians in the
@@ -891,7 +891,7 @@ impl f16 {
891891
#[unstable(feature = "f16", issue = "116909")]
892892
#[must_use = "method returns a new number and does not mutate the original value"]
893893
pub fn atan(self) -> f16 {
894-
(unsafe { cmath::atanf(self as f32) }) as f16
894+
cmath::atanf(self as f32) as f16
895895
}
896896

897897
/// Computes the four quadrant arctangent of `self` (`y`) and `other` (`x`) in radians.
@@ -937,7 +937,7 @@ impl f16 {
937937
#[unstable(feature = "f16", issue = "116909")]
938938
#[must_use = "method returns a new number and does not mutate the original value"]
939939
pub fn atan2(self, other: f16) -> f16 {
940-
(unsafe { cmath::atan2f(self as f32, other as f32) }) as f16
940+
cmath::atan2f(self as f32, other as f32) as f16
941941
}
942942

943943
/// Simultaneously computes the sine and cosine of the number, `x`. Returns
@@ -1006,7 +1006,7 @@ impl f16 {
10061006
#[unstable(feature = "f16", issue = "116909")]
10071007
#[must_use = "method returns a new number and does not mutate the original value"]
10081008
pub fn exp_m1(self) -> f16 {
1009-
(unsafe { cmath::expm1f(self as f32) }) as f16
1009+
cmath::expm1f(self as f32) as f16
10101010
}
10111011

10121012
/// Returns `ln(1+n)` (natural logarithm) more accurately than if
@@ -1053,7 +1053,7 @@ impl f16 {
10531053
#[unstable(feature = "f16", issue = "116909")]
10541054
#[must_use = "method returns a new number and does not mutate the original value"]
10551055
pub fn ln_1p(self) -> f16 {
1056-
(unsafe { cmath::log1pf(self as f32) }) as f16
1056+
cmath::log1pf(self as f32) as f16
10571057
}
10581058

10591059
/// Hyperbolic sine function.
@@ -1088,7 +1088,7 @@ impl f16 {
10881088
#[unstable(feature = "f16", issue = "116909")]
10891089
#[must_use = "method returns a new number and does not mutate the original value"]
10901090
pub fn sinh(self) -> f16 {
1091-
(unsafe { cmath::sinhf(self as f32) }) as f16
1091+
cmath::sinhf(self as f32) as f16
10921092
}
10931093

10941094
/// Hyperbolic cosine function.
@@ -1123,7 +1123,7 @@ impl f16 {
11231123
#[unstable(feature = "f16", issue = "116909")]
11241124
#[must_use = "method returns a new number and does not mutate the original value"]
11251125
pub fn cosh(self) -> f16 {
1126-
(unsafe { cmath::coshf(self as f32) }) as f16
1126+
cmath::coshf(self as f32) as f16
11271127
}
11281128

11291129
/// Hyperbolic tangent function.
@@ -1158,7 +1158,7 @@ impl f16 {
11581158
#[unstable(feature = "f16", issue = "116909")]
11591159
#[must_use = "method returns a new number and does not mutate the original value"]
11601160
pub fn tanh(self) -> f16 {
1161-
(unsafe { cmath::tanhf(self as f32) }) as f16
1161+
cmath::tanhf(self as f32) as f16
11621162
}
11631163

11641164
/// Inverse hyperbolic sine function.
@@ -1287,7 +1287,7 @@ impl f16 {
12871287
// #[unstable(feature = "float_gamma", issue = "99842")]
12881288
#[must_use = "method returns a new number and does not mutate the original value"]
12891289
pub fn gamma(self) -> f16 {
1290-
(unsafe { cmath::tgammaf(self as f32) }) as f16
1290+
cmath::tgammaf(self as f32) as f16
12911291
}
12921292

12931293
/// Natural logarithm of the absolute value of the gamma function
@@ -1323,7 +1323,7 @@ impl f16 {
13231323
#[must_use = "method returns a new number and does not mutate the original value"]
13241324
pub fn ln_gamma(self) -> (f16, i32) {
13251325
let mut signgamp: i32 = 0;
1326-
let x = (unsafe { cmath::lgammaf_r(self as f32, &mut signgamp) }) as f16;
1326+
let x = cmath::lgammaf_r(self as f32, &mut signgamp) as f16;
13271327
(x, signgamp)
13281328
}
13291329

@@ -1363,7 +1363,7 @@ impl f16 {
13631363
// #[unstable(feature = "float_erf", issue = "136321")]
13641364
#[inline]
13651365
pub fn erf(self) -> f16 {
1366-
(unsafe { cmath::erff(self as f32) }) as f16
1366+
cmath::erff(self as f32) as f16
13671367
}
13681368

13691369
/// Complementary error function.
@@ -1396,6 +1396,6 @@ impl f16 {
13961396
// #[unstable(feature = "float_erf", issue = "136321")]
13971397
#[inline]
13981398
pub fn erfc(self) -> f16 {
1399-
(unsafe { cmath::erfcf(self as f32) }) as f16
1399+
cmath::erfcf(self as f32) as f16
14001400
}
14011401
}

‎library/std/src/f32.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ impl f32 {
599599
filing an issue describing your use-case too)."
600600
)]
601601
pub fn abs_sub(self, other: f32) -> f32 {
602-
unsafe { cmath::fdimf(self, other) }
602+
cmath::fdimf(self, other)
603603
}
604604

605605
/// Returns the cube root of a number.
@@ -626,7 +626,7 @@ impl f32 {
626626
#[stable(feature = "rust1", since = "1.0.0")]
627627
#[inline]
628628
pub fn cbrt(self) -> f32 {
629-
unsafe { cmath::cbrtf(self) }
629+
cmath::cbrtf(self)
630630
}
631631

632632
/// Compute the distance between the origin and a point (`x`, `y`) on the
@@ -657,7 +657,7 @@ impl f32 {
657657
#[stable(feature = "rust1", since = "1.0.0")]
658658
#[inline]
659659
pub fn hypot(self, other: f32) -> f32 {
660-
unsafe { cmath::hypotf(self, other) }
660+
cmath::hypotf(self, other)
661661
}
662662

663663
/// Computes the sine of a number (in radians).
@@ -730,7 +730,7 @@ impl f32 {
730730
#[stable(feature = "rust1", since = "1.0.0")]
731731
#[inline]
732732
pub fn tan(self) -> f32 {
733-
unsafe { cmath::tanf(self) }
733+
cmath::tanf(self)
734734
}
735735

736736
/// Computes the arcsine of a number. Return value is in radians in
@@ -760,7 +760,7 @@ impl f32 {
760760
#[stable(feature = "rust1", since = "1.0.0")]
761761
#[inline]
762762
pub fn asin(self) -> f32 {
763-
unsafe { cmath::asinf(self) }
763+
cmath::asinf(self)
764764
}
765765

766766
/// Computes the arccosine of a number. Return value is in radians in
@@ -790,7 +790,7 @@ impl f32 {
790790
#[stable(feature = "rust1", since = "1.0.0")]
791791
#[inline]
792792
pub fn acos(self) -> f32 {
793-
unsafe { cmath::acosf(self) }
793+
cmath::acosf(self)
794794
}
795795

796796
/// Computes the arctangent of a number. Return value is in radians in the
@@ -819,7 +819,7 @@ impl f32 {
819819
#[stable(feature = "rust1", since = "1.0.0")]
820820
#[inline]
821821
pub fn atan(self) -> f32 {
822-
unsafe { cmath::atanf(self) }
822+
cmath::atanf(self)
823823
}
824824

825825
/// Computes the four quadrant arctangent of `self` (`y`) and `other` (`x`) in radians.
@@ -860,7 +860,7 @@ impl f32 {
860860
#[stable(feature = "rust1", since = "1.0.0")]
861861
#[inline]
862862
pub fn atan2(self, other: f32) -> f32 {
863-
unsafe { cmath::atan2f(self, other) }
863+
cmath::atan2f(self, other)
864864
}
865865

866866
/// Simultaneously computes the sine and cosine of the number, `x`. Returns
@@ -919,7 +919,7 @@ impl f32 {
919919
#[stable(feature = "rust1", since = "1.0.0")]
920920
#[inline]
921921
pub fn exp_m1(self) -> f32 {
922-
unsafe { cmath::expm1f(self) }
922+
cmath::expm1f(self)
923923
}
924924

925925
/// Returns `ln(1+n)` (natural logarithm) more accurately than if
@@ -957,7 +957,7 @@ impl f32 {
957957
#[stable(feature = "rust1", since = "1.0.0")]
958958
#[inline]
959959
pub fn ln_1p(self) -> f32 {
960-
unsafe { cmath::log1pf(self) }
960+
cmath::log1pf(self)
961961
}
962962

963963
/// Hyperbolic sine function.
@@ -987,7 +987,7 @@ impl f32 {
987987
#[stable(feature = "rust1", since = "1.0.0")]
988988
#[inline]
989989
pub fn sinh(self) -> f32 {
990-
unsafe { cmath::sinhf(self) }
990+
cmath::sinhf(self)
991991
}
992992

993993
/// Hyperbolic cosine function.
@@ -1017,7 +1017,7 @@ impl f32 {
10171017
#[stable(feature = "rust1", since = "1.0.0")]
10181018
#[inline]
10191019
pub fn cosh(self) -> f32 {
1020-
unsafe { cmath::coshf(self) }
1020+
cmath::coshf(self)
10211021
}
10221022

10231023
/// Hyperbolic tangent function.
@@ -1047,7 +1047,7 @@ impl f32 {
10471047
#[stable(feature = "rust1", since = "1.0.0")]
10481048
#[inline]
10491049
pub fn tanh(self) -> f32 {
1050-
unsafe { cmath::tanhf(self) }
1050+
cmath::tanhf(self)
10511051
}
10521052

10531053
/// Inverse hyperbolic sine function.
@@ -1158,7 +1158,7 @@ impl f32 {
11581158
#[unstable(feature = "float_gamma", issue = "99842")]
11591159
#[inline]
11601160
pub fn gamma(self) -> f32 {
1161-
unsafe { cmath::tgammaf(self) }
1161+
cmath::tgammaf(self)
11621162
}
11631163

11641164
/// Natural logarithm of the absolute value of the gamma function
@@ -1188,7 +1188,7 @@ impl f32 {
11881188
#[inline]
11891189
pub fn ln_gamma(self) -> (f32, i32) {
11901190
let mut signgamp: i32 = 0;
1191-
let x = unsafe { cmath::lgammaf_r(self, &mut signgamp) };
1191+
let x = cmath::lgammaf_r(self, &mut signgamp);
11921192
(x, signgamp)
11931193
}
11941194

@@ -1224,7 +1224,7 @@ impl f32 {
12241224
#[unstable(feature = "float_erf", issue = "136321")]
12251225
#[inline]
12261226
pub fn erf(self) -> f32 {
1227-
unsafe { cmath::erff(self) }
1227+
cmath::erff(self)
12281228
}
12291229

12301230
/// Complementary error function.
@@ -1253,6 +1253,6 @@ impl f32 {
12531253
#[unstable(feature = "float_erf", issue = "136321")]
12541254
#[inline]
12551255
pub fn erfc(self) -> f32 {
1256-
unsafe { cmath::erfcf(self) }
1256+
cmath::erfcf(self)
12571257
}
12581258
}

‎library/std/src/f64.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ impl f64 {
599599
filing an issue describing your use-case too)."
600600
)]
601601
pub fn abs_sub(self, other: f64) -> f64 {
602-
unsafe { cmath::fdim(self, other) }
602+
cmath::fdim(self, other)
603603
}
604604

605605
/// Returns the cube root of a number.
@@ -626,7 +626,7 @@ impl f64 {
626626
#[stable(feature = "rust1", since = "1.0.0")]
627627
#[inline]
628628
pub fn cbrt(self) -> f64 {
629-
unsafe { cmath::cbrt(self) }
629+
cmath::cbrt(self)
630630
}
631631

632632
/// Compute the distance between the origin and a point (`x`, `y`) on the
@@ -657,7 +657,7 @@ impl f64 {
657657
#[stable(feature = "rust1", since = "1.0.0")]
658658
#[inline]
659659
pub fn hypot(self, other: f64) -> f64 {
660-
unsafe { cmath::hypot(self, other) }
660+
cmath::hypot(self, other)
661661
}
662662

663663
/// Computes the sine of a number (in radians).
@@ -730,7 +730,7 @@ impl f64 {
730730
#[stable(feature = "rust1", since = "1.0.0")]
731731
#[inline]
732732
pub fn tan(self) -> f64 {
733-
unsafe { cmath::tan(self) }
733+
cmath::tan(self)
734734
}
735735

736736
/// Computes the arcsine of a number. Return value is in radians in
@@ -760,7 +760,7 @@ impl f64 {
760760
#[stable(feature = "rust1", since = "1.0.0")]
761761
#[inline]
762762
pub fn asin(self) -> f64 {
763-
unsafe { cmath::asin(self) }
763+
cmath::asin(self)
764764
}
765765

766766
/// Computes the arccosine of a number. Return value is in radians in
@@ -790,7 +790,7 @@ impl f64 {
790790
#[stable(feature = "rust1", since = "1.0.0")]
791791
#[inline]
792792
pub fn acos(self) -> f64 {
793-
unsafe { cmath::acos(self) }
793+
cmath::acos(self)
794794
}
795795

796796
/// Computes the arctangent of a number. Return value is in radians in the
@@ -819,7 +819,7 @@ impl f64 {
819819
#[stable(feature = "rust1", since = "1.0.0")]
820820
#[inline]
821821
pub fn atan(self) -> f64 {
822-
unsafe { cmath::atan(self) }
822+
cmath::atan(self)
823823
}
824824

825825
/// Computes the four quadrant arctangent of `self` (`y`) and `other` (`x`) in radians.
@@ -860,7 +860,7 @@ impl f64 {
860860
#[stable(feature = "rust1", since = "1.0.0")]
861861
#[inline]
862862
pub fn atan2(self, other: f64) -> f64 {
863-
unsafe { cmath::atan2(self, other) }
863+
cmath::atan2(self, other)
864864
}
865865

866866
/// Simultaneously computes the sine and cosine of the number, `x`. Returns
@@ -919,7 +919,7 @@ impl f64 {
919919
#[stable(feature = "rust1", since = "1.0.0")]
920920
#[inline]
921921
pub fn exp_m1(self) -> f64 {
922-
unsafe { cmath::expm1(self) }
922+
cmath::expm1(self)
923923
}
924924

925925
/// Returns `ln(1+n)` (natural logarithm) more accurately than if
@@ -957,7 +957,7 @@ impl f64 {
957957
#[stable(feature = "rust1", since = "1.0.0")]
958958
#[inline]
959959
pub fn ln_1p(self) -> f64 {
960-
unsafe { cmath::log1p(self) }
960+
cmath::log1p(self)
961961
}
962962

963963
/// Hyperbolic sine function.
@@ -987,7 +987,7 @@ impl f64 {
987987
#[stable(feature = "rust1", since = "1.0.0")]
988988
#[inline]
989989
pub fn sinh(self) -> f64 {
990-
unsafe { cmath::sinh(self) }
990+
cmath::sinh(self)
991991
}
992992

993993
/// Hyperbolic cosine function.
@@ -1017,7 +1017,7 @@ impl f64 {
10171017
#[stable(feature = "rust1", since = "1.0.0")]
10181018
#[inline]
10191019
pub fn cosh(self) -> f64 {
1020-
unsafe { cmath::cosh(self) }
1020+
cmath::cosh(self)
10211021
}
10221022

10231023
/// Hyperbolic tangent function.
@@ -1047,7 +1047,7 @@ impl f64 {
10471047
#[stable(feature = "rust1", since = "1.0.0")]
10481048
#[inline]
10491049
pub fn tanh(self) -> f64 {
1050-
unsafe { cmath::tanh(self) }
1050+
cmath::tanh(self)
10511051
}
10521052

10531053
/// Inverse hyperbolic sine function.
@@ -1158,7 +1158,7 @@ impl f64 {
11581158
#[unstable(feature = "float_gamma", issue = "99842")]
11591159
#[inline]
11601160
pub fn gamma(self) -> f64 {
1161-
unsafe { cmath::tgamma(self) }
1161+
cmath::tgamma(self)
11621162
}
11631163

11641164
/// Natural logarithm of the absolute value of the gamma function
@@ -1188,7 +1188,7 @@ impl f64 {
11881188
#[inline]
11891189
pub fn ln_gamma(self) -> (f64, i32) {
11901190
let mut signgamp: i32 = 0;
1191-
let x = unsafe { cmath::lgamma_r(self, &mut signgamp) };
1191+
let x = cmath::lgamma_r(self, &mut signgamp);
11921192
(x, signgamp)
11931193
}
11941194

@@ -1224,7 +1224,7 @@ impl f64 {
12241224
#[unstable(feature = "float_erf", issue = "136321")]
12251225
#[inline]
12261226
pub fn erf(self) -> f64 {
1227-
unsafe { cmath::erf(self) }
1227+
cmath::erf(self)
12281228
}
12291229

12301230
/// Complementary error function.
@@ -1253,6 +1253,6 @@ impl f64 {
12531253
#[unstable(feature = "float_erf", issue = "136321")]
12541254
#[inline]
12551255
pub fn erfc(self) -> f64 {
1256-
unsafe { cmath::erfc(self) }
1256+
cmath::erfc(self)
12571257
}
12581258
}

‎library/std/src/sys/cmath.rs

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -3,70 +3,70 @@
33
// These symbols are all defined by `libm`,
44
// or by `compiler-builtins` on unsupported platforms.
55
unsafe extern "C" {
6-
pub fn acos(n: f64) -> f64;
7-
pub fn asin(n: f64) -> f64;
8-
pub fn atan(n: f64) -> f64;
9-
pub fn atan2(a: f64, b: f64) -> f64;
10-
pub fn cbrt(n: f64) -> f64;
11-
pub fn cbrtf(n: f32) -> f32;
12-
pub fn cosh(n: f64) -> f64;
13-
pub fn expm1(n: f64) -> f64;
14-
pub fn expm1f(n: f32) -> f32;
15-
pub fn fdim(a: f64, b: f64) -> f64;
16-
pub fn fdimf(a: f32, b: f32) -> f32;
6+
pub safe fn acos(n: f64) -> f64;
7+
pub safe fn asin(n: f64) -> f64;
8+
pub safe fn atan(n: f64) -> f64;
9+
pub safe fn atan2(a: f64, b: f64) -> f64;
10+
pub safe fn cbrt(n: f64) -> f64;
11+
pub safe fn cbrtf(n: f32) -> f32;
12+
pub safe fn cosh(n: f64) -> f64;
13+
pub safe fn expm1(n: f64) -> f64;
14+
pub safe fn expm1f(n: f32) -> f32;
15+
pub safe fn fdim(a: f64, b: f64) -> f64;
16+
pub safe fn fdimf(a: f32, b: f32) -> f32;
1717
#[cfg_attr(target_env = "msvc", link_name = "_hypot")]
18-
pub fn hypot(x: f64, y: f64) -> f64;
18+
pub safe fn hypot(x: f64, y: f64) -> f64;
1919
#[cfg_attr(target_env = "msvc", link_name = "_hypotf")]
20-
pub fn hypotf(x: f32, y: f32) -> f32;
21-
pub fn log1p(n: f64) -> f64;
22-
pub fn log1pf(n: f32) -> f32;
23-
pub fn sinh(n: f64) -> f64;
24-
pub fn tan(n: f64) -> f64;
25-
pub fn tanh(n: f64) -> f64;
26-
pub fn tgamma(n: f64) -> f64;
27-
pub fn tgammaf(n: f32) -> f32;
28-
pub fn lgamma_r(n: f64, s: &mut i32) -> f64;
20+
pub safe fn hypotf(x: f32, y: f32) -> f32;
21+
pub safe fn log1p(n: f64) -> f64;
22+
pub safe fn log1pf(n: f32) -> f32;
23+
pub safe fn sinh(n: f64) -> f64;
24+
pub safe fn tan(n: f64) -> f64;
25+
pub safe fn tanh(n: f64) -> f64;
26+
pub safe fn tgamma(n: f64) -> f64;
27+
pub safe fn tgammaf(n: f32) -> f32;
28+
pub safe fn lgamma_r(n: f64, s: &mut i32) -> f64;
2929
#[cfg(not(target_os = "aix"))]
30-
pub fn lgammaf_r(n: f32, s: &mut i32) -> f32;
31-
pub fn erf(n: f64) -> f64;
32-
pub fn erff(n: f32) -> f32;
33-
pub fn erfc(n: f64) -> f64;
34-
pub fn erfcf(n: f32) -> f32;
30+
pub safe fn lgammaf_r(n: f32, s: &mut i32) -> f32;
31+
pub safe fn erf(n: f64) -> f64;
32+
pub safe fn erff(n: f32) -> f32;
33+
pub safe fn erfc(n: f64) -> f64;
34+
pub safe fn erfcf(n: f32) -> f32;
3535

36-
pub fn acosf128(n: f128) -> f128;
37-
pub fn asinf128(n: f128) -> f128;
38-
pub fn atanf128(n: f128) -> f128;
39-
pub fn atan2f128(a: f128, b: f128) -> f128;
40-
pub fn cbrtf128(n: f128) -> f128;
41-
pub fn coshf128(n: f128) -> f128;
42-
pub fn expm1f128(n: f128) -> f128;
43-
pub fn hypotf128(x: f128, y: f128) -> f128;
44-
pub fn log1pf128(n: f128) -> f128;
45-
pub fn sinhf128(n: f128) -> f128;
46-
pub fn tanf128(n: f128) -> f128;
47-
pub fn tanhf128(n: f128) -> f128;
48-
pub fn tgammaf128(n: f128) -> f128;
49-
pub fn lgammaf128_r(n: f128, s: &mut i32) -> f128;
50-
pub fn erff128(n: f128) -> f128;
51-
pub fn erfcf128(n: f128) -> f128;
36+
pub safe fn acosf128(n: f128) -> f128;
37+
pub safe fn asinf128(n: f128) -> f128;
38+
pub safe fn atanf128(n: f128) -> f128;
39+
pub safe fn atan2f128(a: f128, b: f128) -> f128;
40+
pub safe fn cbrtf128(n: f128) -> f128;
41+
pub safe fn coshf128(n: f128) -> f128;
42+
pub safe fn expm1f128(n: f128) -> f128;
43+
pub safe fn hypotf128(x: f128, y: f128) -> f128;
44+
pub safe fn log1pf128(n: f128) -> f128;
45+
pub safe fn sinhf128(n: f128) -> f128;
46+
pub safe fn tanf128(n: f128) -> f128;
47+
pub safe fn tanhf128(n: f128) -> f128;
48+
pub safe fn tgammaf128(n: f128) -> f128;
49+
pub safe fn lgammaf128_r(n: f128, s: &mut i32) -> f128;
50+
pub safe fn erff128(n: f128) -> f128;
51+
pub safe fn erfcf128(n: f128) -> f128;
5252

5353
cfg_if::cfg_if! {
5454
if #[cfg(not(all(target_os = "windows", target_env = "msvc", target_arch = "x86")))] {
55-
pub fn acosf(n: f32) -> f32;
56-
pub fn asinf(n: f32) -> f32;
57-
pub fn atan2f(a: f32, b: f32) -> f32;
58-
pub fn atanf(n: f32) -> f32;
59-
pub fn coshf(n: f32) -> f32;
60-
pub fn sinhf(n: f32) -> f32;
61-
pub fn tanf(n: f32) -> f32;
62-
pub fn tanhf(n: f32) -> f32;
55+
pub safe fn acosf(n: f32) -> f32;
56+
pub safe fn asinf(n: f32) -> f32;
57+
pub safe fn atan2f(a: f32, b: f32) -> f32;
58+
pub safe fn atanf(n: f32) -> f32;
59+
pub safe fn coshf(n: f32) -> f32;
60+
pub safe fn sinhf(n: f32) -> f32;
61+
pub safe fn tanf(n: f32) -> f32;
62+
pub safe fn tanhf(n: f32) -> f32;
6363
}}
6464
}
6565

6666
// On AIX, we don't have lgammaf_r only the f64 version, so we can
6767
// use the f64 version lgamma_r
6868
#[cfg(target_os = "aix")]
69-
pub unsafe fn lgammaf_r(n: f32, s: &mut i32) -> f32 {
69+
pub fn lgammaf_r(n: f32, s: &mut i32) -> f32 {
7070
lgamma_r(n.into(), s) as f32
7171
}
7272

@@ -76,42 +76,42 @@ pub unsafe fn lgammaf_r(n: f32, s: &mut i32) -> f32 {
7676
cfg_if::cfg_if! {
7777
if #[cfg(all(target_os = "windows", target_env = "msvc", target_arch = "x86"))] {
7878
#[inline]
79-
pub unsafe fn acosf(n: f32) -> f32 {
79+
pub fn acosf(n: f32) -> f32 {
8080
f64::acos(n as f64) as f32
8181
}
8282

8383
#[inline]
84-
pub unsafe fn asinf(n: f32) -> f32 {
84+
pub fn asinf(n: f32) -> f32 {
8585
f64::asin(n as f64) as f32
8686
}
8787

8888
#[inline]
89-
pub unsafe fn atan2f(n: f32, b: f32) -> f32 {
89+
pub fn atan2f(n: f32, b: f32) -> f32 {
9090
f64::atan2(n as f64, b as f64) as f32
9191
}
9292

9393
#[inline]
94-
pub unsafe fn atanf(n: f32) -> f32 {
94+
pub fn atanf(n: f32) -> f32 {
9595
f64::atan(n as f64) as f32
9696
}
9797

9898
#[inline]
99-
pub unsafe fn coshf(n: f32) -> f32 {
99+
pub fn coshf(n: f32) -> f32 {
100100
f64::cosh(n as f64) as f32
101101
}
102102

103103
#[inline]
104-
pub unsafe fn sinhf(n: f32) -> f32 {
104+
pub fn sinhf(n: f32) -> f32 {
105105
f64::sinh(n as f64) as f32
106106
}
107107

108108
#[inline]
109-
pub unsafe fn tanf(n: f32) -> f32 {
109+
pub fn tanf(n: f32) -> f32 {
110110
f64::tan(n as f64) as f32
111111
}
112112

113113
#[inline]
114-
pub unsafe fn tanhf(n: f32) -> f32 {
114+
pub fn tanhf(n: f32) -> f32 {
115115
f64::tanh(n as f64) as f32
116116
}
117117
}}

‎src/bootstrap/src/core/build_steps/tool.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,7 @@ impl Step for ToolBuild {
150150

151151
// Rustc tools (miri, clippy, cargo, rustfmt, rust-analyzer)
152152
// could use the additional optimizations.
153-
if self.mode == Mode::ToolRustc &&
154-
// rustdoc is performance sensitive, so apply LTO to it.
155-
is_lto_stage(&self.compiler)
156-
{
153+
if self.mode == Mode::ToolRustc && is_lto_stage(&self.compiler) {
157154
let lto = match builder.config.rust_lto {
158155
RustcLto::Off => Some("off"),
159156
RustcLto::Thin => Some("thin"),

‎src/bootstrap/src/core/download.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ enum DownloadSource {
417417
Dist,
418418
}
419419

420-
/// Functions that are only ever called once, but named for clarify and to avoid thousand-line functions.
420+
/// Functions that are only ever called once, but named for clarity and to avoid thousand-line functions.
421421
impl Config {
422422
pub(crate) fn download_clippy(&self) -> PathBuf {
423423
self.verbose(|| println!("downloading stage0 clippy artifacts"));

‎src/doc/rustc-dev-guide/src/building/optimized-build.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,16 @@ like Python or LLVM.
109109

110110
Here is an example of how can `opt-dist` be used locally (outside of CI):
111111

112-
1. Build the tool with the following command:
112+
1. Enable metrics in your `bootstrap.toml` file, because `opt-dist` expects it to be enabled:
113+
```toml
114+
[build]
115+
metrics = true
116+
```
117+
2. Build the tool with the following command:
113118
```bash
114119
./x build tools/opt-dist
115120
```
116-
2. Run the tool with the `local` mode and provide necessary parameters:
121+
3. Run the tool with the `local` mode and provide necessary parameters:
117122
```bash
118123
./build/host/stage0-tools-bin/opt-dist local \
119124
--target-triple <target> \ # select target, e.g. "x86_64-unknown-linux-gnu"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Regression test for issue #127424
2+
3+
fn bar() -> impl Into<
4+
[u8; {
5+
//~^ ERROR mismatched types [E0308]
6+
let _ = for<'a, 'b> |x: &'a &'a Vec<&'b u32>, b: bool| -> &'a Vec<&'b u32> { *x };
7+
//~^ ERROR `for<...>` binders for closures are experimental [E0658]
8+
}],
9+
> {
10+
[89]
11+
}
12+
13+
fn main() {}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error[E0658]: `for<...>` binders for closures are experimental
2+
--> $DIR/const-generics-closure.rs:6:17
3+
|
4+
LL | let _ = for<'a, 'b> |x: &'a &'a Vec<&'b u32>, b: bool| -> &'a Vec<&'b u32> { *x };
5+
| ^^^^^^^^^^^
6+
|
7+
= note: see issue #97362 <https://github.com/rust-lang/rust/issues/97362> for more information
8+
= help: add `#![feature(closure_lifetime_binder)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
= help: consider removing `for<...>`
11+
12+
error[E0308]: mismatched types
13+
--> $DIR/const-generics-closure.rs:4:10
14+
|
15+
LL | [u8; {
16+
| __________^
17+
LL | |
18+
LL | | let _ = for<'a, 'b> |x: &'a &'a Vec<&'b u32>, b: bool| -> &'a Vec<&'b u32> { *x };
19+
LL | |
20+
LL | | }],
21+
| |_____^ expected `usize`, found `()`
22+
23+
error: aborting due to 2 previous errors
24+
25+
Some errors have detailed explanations: E0308, E0658.
26+
For more information about an error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)
Please sign in to comment.