Skip to content

Commit 65fa0ab

Browse files
committed
Auto merge of rust-lang#139734 - ChrisDenton:rollup-28qn740, r=ChrisDenton
Rollup of 6 pull requests Successful merges: - rust-lang#139107 (std: make `cmath` functions safe) - rust-lang#139607 (Add regression test for rust-lang#127424) - rust-lang#139691 (Document that `opt-dist` requires metrics to be enabled) - rust-lang#139707 (Fix comment in bootstrap) - rust-lang#139708 (Fix name of field in doc comment) - rust-lang#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

Diff for: compiler/rustc_hir/src/hir.rs

+1-1
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

Diff for: library/std/src/f128.rs

+16-16
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
}

Diff for: library/std/src/f16.rs

+16-16
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
}

0 commit comments

Comments
 (0)