Skip to content

Commit d7c61d5

Browse files
author
The Miri Cronjob Bot
committed
Merge from rustc
2 parents 81eae48 + 558461d commit d7c61d5

File tree

22 files changed

+216
-78
lines changed

22 files changed

+216
-78
lines changed

alloc/src/collections/btree/set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ pub struct Iter<'a, T: 'a> {
139139
#[stable(feature = "collection_debug", since = "1.17.0")]
140140
impl<T: fmt::Debug> fmt::Debug for Iter<'_, T> {
141141
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
142-
f.debug_tuple("Iter").field(&self.iter.clone()).finish()
142+
f.debug_tuple("Iter").field(&self.iter).finish()
143143
}
144144
}
145145

alloctests/tests/fmt.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![deny(warnings)]
22
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
33
#![allow(static_mut_refs)]
4+
#![cfg_attr(not(bootstrap), allow(unnecessary_transmutes))]
45

56
use std::cell::RefCell;
67
use std::fmt::{self, Write};

core/src/cell.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -549,16 +549,14 @@ impl<T: Copy> Cell<T> {
549549
/// # Examples
550550
///
551551
/// ```
552-
/// #![feature(cell_update)]
553-
///
554552
/// use std::cell::Cell;
555553
///
556554
/// let c = Cell::new(5);
557555
/// c.update(|x| x + 1);
558556
/// assert_eq!(c.get(), 6);
559557
/// ```
560558
#[inline]
561-
#[unstable(feature = "cell_update", issue = "50186")]
559+
#[stable(feature = "cell_update", since = "CURRENT_RUSTC_VERSION")]
562560
pub fn update(&self, f: impl FnOnce(T) -> T) {
563561
let old = self.get();
564562
self.set(f(old));

core/src/char/convert.rs

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub(super) const fn from_u32(i: u32) -> Option<char> {
2121
/// Converts a `u32` to a `char`, ignoring validity. See [`char::from_u32_unchecked`].
2222
#[inline]
2323
#[must_use]
24+
#[cfg_attr(not(bootstrap), allow(unnecessary_transmutes))]
2425
pub(super) const unsafe fn from_u32_unchecked(i: u32) -> char {
2526
// SAFETY: the caller must guarantee that `i` is a valid char value.
2627
unsafe {
@@ -221,6 +222,7 @@ impl FromStr for char {
221222
}
222223

223224
#[inline]
225+
#[cfg_attr(not(bootstrap), allow(unnecessary_transmutes))]
224226
const fn char_try_from_u32(i: u32) -> Result<char, CharTryFromError> {
225227
// This is an optimized version of the check
226228
// (i > MAX as u32) || (i >= 0xD800 && i <= 0xDFFF),

core/src/intrinsics/mod.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,7 @@ pub const fn forget<T: ?Sized>(_: T);
14971497
/// Turning raw bytes (`[u8; SZ]`) into `u32`, `f64`, etc.:
14981498
///
14991499
/// ```
1500+
/// # #![cfg_attr(not(bootstrap), allow(unnecessary_transmutes))]
15001501
/// let raw_bytes = [0x78, 0x56, 0x34, 0x12];
15011502
///
15021503
/// let num = unsafe {
@@ -2429,35 +2430,35 @@ pub unsafe fn float_to_int_unchecked<Float: Copy, Int: Copy>(value: Float) -> In
24292430
/// Stabilized as [`f16::algebraic_add`], [`f32::algebraic_add`], [`f64::algebraic_add`] and [`f128::algebraic_add`].
24302431
#[rustc_nounwind]
24312432
#[rustc_intrinsic]
2432-
pub fn fadd_algebraic<T: Copy>(a: T, b: T) -> T;
2433+
pub const fn fadd_algebraic<T: Copy>(a: T, b: T) -> T;
24332434

24342435
/// Float subtraction that allows optimizations based on algebraic rules.
24352436
///
24362437
/// Stabilized as [`f16::algebraic_sub`], [`f32::algebraic_sub`], [`f64::algebraic_sub`] and [`f128::algebraic_sub`].
24372438
#[rustc_nounwind]
24382439
#[rustc_intrinsic]
2439-
pub fn fsub_algebraic<T: Copy>(a: T, b: T) -> T;
2440+
pub const fn fsub_algebraic<T: Copy>(a: T, b: T) -> T;
24402441

24412442
/// Float multiplication that allows optimizations based on algebraic rules.
24422443
///
24432444
/// Stabilized as [`f16::algebraic_mul`], [`f32::algebraic_mul`], [`f64::algebraic_mul`] and [`f128::algebraic_mul`].
24442445
#[rustc_nounwind]
24452446
#[rustc_intrinsic]
2446-
pub fn fmul_algebraic<T: Copy>(a: T, b: T) -> T;
2447+
pub const fn fmul_algebraic<T: Copy>(a: T, b: T) -> T;
24472448

24482449
/// Float division that allows optimizations based on algebraic rules.
24492450
///
24502451
/// Stabilized as [`f16::algebraic_div`], [`f32::algebraic_div`], [`f64::algebraic_div`] and [`f128::algebraic_div`].
24512452
#[rustc_nounwind]
24522453
#[rustc_intrinsic]
2453-
pub fn fdiv_algebraic<T: Copy>(a: T, b: T) -> T;
2454+
pub const fn fdiv_algebraic<T: Copy>(a: T, b: T) -> T;
24542455

24552456
/// Float remainder that allows optimizations based on algebraic rules.
24562457
///
24572458
/// Stabilized as [`f16::algebraic_rem`], [`f32::algebraic_rem`], [`f64::algebraic_rem`] and [`f128::algebraic_rem`].
24582459
#[rustc_nounwind]
24592460
#[rustc_intrinsic]
2460-
pub fn frem_algebraic<T: Copy>(a: T, b: T) -> T;
2461+
pub const fn frem_algebraic<T: Copy>(a: T, b: T) -> T;
24612462

24622463
/// Returns the number of bits set in an integer type `T`
24632464
///

core/src/num/f128.rs

+26-12
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,22 @@ impl f128 {
197197
#[unstable(feature = "f128", issue = "116909")]
198198
pub const MAX: f128 = 1.18973149535723176508575932662800702e+4932_f128;
199199

200-
/// One greater than the minimum possible normal power of 2 exponent.
200+
/// One greater than the minimum possible *normal* power of 2 exponent
201+
/// for a significand bounded by 1 ≤ x < 2 (i.e. the IEEE definition).
201202
///
202-
/// If <i>x</i>&nbsp;=&nbsp;`MIN_EXP`, then normal numbers
203-
/// ≥&nbsp;0.5&nbsp;×&nbsp;2<sup><i>x</i></sup>.
203+
/// This corresponds to the exact minimum possible *normal* power of 2 exponent
204+
/// for a significand bounded by 0.5 ≤ x < 1 (i.e. the C definition).
205+
/// In other words, all normal numbers representable by this type are
206+
/// greater than or equal to 0.5&nbsp;×&nbsp;2<sup><i>MIN_EXP</i></sup>.
204207
#[unstable(feature = "f128", issue = "116909")]
205208
pub const MIN_EXP: i32 = -16_381;
206-
/// Maximum possible power of 2 exponent.
209+
/// One greater than the maximum possible power of 2 exponent
210+
/// for a significand bounded by 1 ≤ x < 2 (i.e. the IEEE definition).
207211
///
208-
/// If <i>x</i>&nbsp;=&nbsp;`MAX_EXP`, then normal numbers
209-
/// &lt;&nbsp;1&nbsp;×&nbsp;2<sup><i>x</i></sup>.
212+
/// This corresponds to the exact maximum possible power of 2 exponent
213+
/// for a significand bounded by 0.5 ≤ x < 1 (i.e. the C definition).
214+
/// In other words, all numbers representable by this type are
215+
/// strictly less than 2<sup><i>MAX_EXP</i></sup>.
210216
#[unstable(feature = "f128", issue = "116909")]
211217
pub const MAX_EXP: i32 = 16_384;
212218

@@ -804,7 +810,7 @@ impl f128 {
804810
}
805811
}
806812

807-
/// Calculates the middle point of `self` and `rhs`.
813+
/// Calculates the midpoint (average) between `self` and `rhs`.
808814
///
809815
/// This returns NaN when *either* argument is NaN or if a combination of
810816
/// +inf and -inf is provided as arguments.
@@ -821,6 +827,7 @@ impl f128 {
821827
/// # }
822828
/// ```
823829
#[inline]
830+
#[doc(alias = "average")]
824831
#[unstable(feature = "f128", issue = "116909")]
825832
#[rustc_const_unstable(feature = "f128", issue = "116909")]
826833
pub const fn midpoint(self, other: f128) -> f128 {
@@ -903,6 +910,7 @@ impl f128 {
903910
#[inline]
904911
#[unstable(feature = "f128", issue = "116909")]
905912
#[must_use = "this returns the result of the operation, without modifying the original"]
913+
#[cfg_attr(not(bootstrap), allow(unnecessary_transmutes))]
906914
pub const fn to_bits(self) -> u128 {
907915
// SAFETY: `u128` is a plain old datatype so we can always transmute to it.
908916
unsafe { mem::transmute(self) }
@@ -950,6 +958,7 @@ impl f128 {
950958
#[inline]
951959
#[must_use]
952960
#[unstable(feature = "f128", issue = "116909")]
961+
#[cfg_attr(not(bootstrap), allow(unnecessary_transmutes))]
953962
pub const fn from_bits(v: u128) -> Self {
954963
// It turns out the safety issues with sNaN were overblown! Hooray!
955964
// SAFETY: `u128` is a plain old datatype so we can always transmute from it.
@@ -1373,8 +1382,9 @@ impl f128 {
13731382
/// See [algebraic operators](primitive@f32#algebraic-operators) for more info.
13741383
#[must_use = "method returns a new number and does not mutate the original value"]
13751384
#[unstable(feature = "float_algebraic", issue = "136469")]
1385+
#[rustc_const_unstable(feature = "float_algebraic", issue = "136469")]
13761386
#[inline]
1377-
pub fn algebraic_add(self, rhs: f128) -> f128 {
1387+
pub const fn algebraic_add(self, rhs: f128) -> f128 {
13781388
intrinsics::fadd_algebraic(self, rhs)
13791389
}
13801390

@@ -1383,8 +1393,9 @@ impl f128 {
13831393
/// See [algebraic operators](primitive@f32#algebraic-operators) for more info.
13841394
#[must_use = "method returns a new number and does not mutate the original value"]
13851395
#[unstable(feature = "float_algebraic", issue = "136469")]
1396+
#[rustc_const_unstable(feature = "float_algebraic", issue = "136469")]
13861397
#[inline]
1387-
pub fn algebraic_sub(self, rhs: f128) -> f128 {
1398+
pub const fn algebraic_sub(self, rhs: f128) -> f128 {
13881399
intrinsics::fsub_algebraic(self, rhs)
13891400
}
13901401

@@ -1393,8 +1404,9 @@ impl f128 {
13931404
/// See [algebraic operators](primitive@f32#algebraic-operators) for more info.
13941405
#[must_use = "method returns a new number and does not mutate the original value"]
13951406
#[unstable(feature = "float_algebraic", issue = "136469")]
1407+
#[rustc_const_unstable(feature = "float_algebraic", issue = "136469")]
13961408
#[inline]
1397-
pub fn algebraic_mul(self, rhs: f128) -> f128 {
1409+
pub const fn algebraic_mul(self, rhs: f128) -> f128 {
13981410
intrinsics::fmul_algebraic(self, rhs)
13991411
}
14001412

@@ -1403,8 +1415,9 @@ impl f128 {
14031415
/// See [algebraic operators](primitive@f32#algebraic-operators) for more info.
14041416
#[must_use = "method returns a new number and does not mutate the original value"]
14051417
#[unstable(feature = "float_algebraic", issue = "136469")]
1418+
#[rustc_const_unstable(feature = "float_algebraic", issue = "136469")]
14061419
#[inline]
1407-
pub fn algebraic_div(self, rhs: f128) -> f128 {
1420+
pub const fn algebraic_div(self, rhs: f128) -> f128 {
14081421
intrinsics::fdiv_algebraic(self, rhs)
14091422
}
14101423

@@ -1413,8 +1426,9 @@ impl f128 {
14131426
/// See [algebraic operators](primitive@f32#algebraic-operators) for more info.
14141427
#[must_use = "method returns a new number and does not mutate the original value"]
14151428
#[unstable(feature = "float_algebraic", issue = "136469")]
1429+
#[rustc_const_unstable(feature = "float_algebraic", issue = "136469")]
14161430
#[inline]
1417-
pub fn algebraic_rem(self, rhs: f128) -> f128 {
1431+
pub const fn algebraic_rem(self, rhs: f128) -> f128 {
14181432
intrinsics::frem_algebraic(self, rhs)
14191433
}
14201434
}

core/src/num/f16.rs

+26-12
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,22 @@ impl f16 {
192192
#[unstable(feature = "f16", issue = "116909")]
193193
pub const MAX: f16 = 6.5504e+4_f16;
194194

195-
/// One greater than the minimum possible normal power of 2 exponent.
195+
/// One greater than the minimum possible *normal* power of 2 exponent
196+
/// for a significand bounded by 1 ≤ x < 2 (i.e. the IEEE definition).
196197
///
197-
/// If <i>x</i>&nbsp;=&nbsp;`MIN_EXP`, then normal numbers
198-
/// ≥&nbsp;0.5&nbsp;×&nbsp;2<sup><i>x</i></sup>.
198+
/// This corresponds to the exact minimum possible *normal* power of 2 exponent
199+
/// for a significand bounded by 0.5 ≤ x < 1 (i.e. the C definition).
200+
/// In other words, all normal numbers representable by this type are
201+
/// greater than or equal to 0.5&nbsp;×&nbsp;2<sup><i>MIN_EXP</i></sup>.
199202
#[unstable(feature = "f16", issue = "116909")]
200203
pub const MIN_EXP: i32 = -13;
201-
/// Maximum possible power of 2 exponent.
204+
/// One greater than the maximum possible power of 2 exponent
205+
/// for a significand bounded by 1 ≤ x < 2 (i.e. the IEEE definition).
202206
///
203-
/// If <i>x</i>&nbsp;=&nbsp;`MAX_EXP`, then normal numbers
204-
/// &lt;&nbsp;1&nbsp;×&nbsp;2<sup><i>x</i></sup>.
207+
/// This corresponds to the exact maximum possible power of 2 exponent
208+
/// for a significand bounded by 0.5 ≤ x < 1 (i.e. the C definition).
209+
/// In other words, all numbers representable by this type are
210+
/// strictly less than 2<sup><i>MAX_EXP</i></sup>.
205211
#[unstable(feature = "f16", issue = "116909")]
206212
pub const MAX_EXP: i32 = 16;
207213

@@ -792,7 +798,7 @@ impl f16 {
792798
}
793799
}
794800

795-
/// Calculates the middle point of `self` and `rhs`.
801+
/// Calculates the midpoint (average) between `self` and `rhs`.
796802
///
797803
/// This returns NaN when *either* argument is NaN or if a combination of
798804
/// +inf and -inf is provided as arguments.
@@ -808,6 +814,7 @@ impl f16 {
808814
/// # }
809815
/// ```
810816
#[inline]
817+
#[doc(alias = "average")]
811818
#[unstable(feature = "f16", issue = "116909")]
812819
#[rustc_const_unstable(feature = "f16", issue = "116909")]
813820
pub const fn midpoint(self, other: f16) -> f16 {
@@ -891,6 +898,7 @@ impl f16 {
891898
#[inline]
892899
#[unstable(feature = "f16", issue = "116909")]
893900
#[must_use = "this returns the result of the operation, without modifying the original"]
901+
#[cfg_attr(not(bootstrap), allow(unnecessary_transmutes))]
894902
pub const fn to_bits(self) -> u16 {
895903
// SAFETY: `u16` is a plain old datatype so we can always transmute to it.
896904
unsafe { mem::transmute(self) }
@@ -937,6 +945,7 @@ impl f16 {
937945
#[inline]
938946
#[must_use]
939947
#[unstable(feature = "f16", issue = "116909")]
948+
#[cfg_attr(not(bootstrap), allow(unnecessary_transmutes))]
940949
pub const fn from_bits(v: u16) -> Self {
941950
// It turns out the safety issues with sNaN were overblown! Hooray!
942951
// SAFETY: `u16` is a plain old datatype so we can always transmute from it.
@@ -1349,8 +1358,9 @@ impl f16 {
13491358
/// See [algebraic operators](primitive@f32#algebraic-operators) for more info.
13501359
#[must_use = "method returns a new number and does not mutate the original value"]
13511360
#[unstable(feature = "float_algebraic", issue = "136469")]
1361+
#[rustc_const_unstable(feature = "float_algebraic", issue = "136469")]
13521362
#[inline]
1353-
pub fn algebraic_add(self, rhs: f16) -> f16 {
1363+
pub const fn algebraic_add(self, rhs: f16) -> f16 {
13541364
intrinsics::fadd_algebraic(self, rhs)
13551365
}
13561366

@@ -1359,8 +1369,9 @@ impl f16 {
13591369
/// See [algebraic operators](primitive@f32#algebraic-operators) for more info.
13601370
#[must_use = "method returns a new number and does not mutate the original value"]
13611371
#[unstable(feature = "float_algebraic", issue = "136469")]
1372+
#[rustc_const_unstable(feature = "float_algebraic", issue = "136469")]
13621373
#[inline]
1363-
pub fn algebraic_sub(self, rhs: f16) -> f16 {
1374+
pub const fn algebraic_sub(self, rhs: f16) -> f16 {
13641375
intrinsics::fsub_algebraic(self, rhs)
13651376
}
13661377

@@ -1369,8 +1380,9 @@ impl f16 {
13691380
/// See [algebraic operators](primitive@f32#algebraic-operators) for more info.
13701381
#[must_use = "method returns a new number and does not mutate the original value"]
13711382
#[unstable(feature = "float_algebraic", issue = "136469")]
1383+
#[rustc_const_unstable(feature = "float_algebraic", issue = "136469")]
13721384
#[inline]
1373-
pub fn algebraic_mul(self, rhs: f16) -> f16 {
1385+
pub const fn algebraic_mul(self, rhs: f16) -> f16 {
13741386
intrinsics::fmul_algebraic(self, rhs)
13751387
}
13761388

@@ -1379,8 +1391,9 @@ impl f16 {
13791391
/// See [algebraic operators](primitive@f32#algebraic-operators) for more info.
13801392
#[must_use = "method returns a new number and does not mutate the original value"]
13811393
#[unstable(feature = "float_algebraic", issue = "136469")]
1394+
#[rustc_const_unstable(feature = "float_algebraic", issue = "136469")]
13821395
#[inline]
1383-
pub fn algebraic_div(self, rhs: f16) -> f16 {
1396+
pub const fn algebraic_div(self, rhs: f16) -> f16 {
13841397
intrinsics::fdiv_algebraic(self, rhs)
13851398
}
13861399

@@ -1389,8 +1402,9 @@ impl f16 {
13891402
/// See [algebraic operators](primitive@f32#algebraic-operators) for more info.
13901403
#[must_use = "method returns a new number and does not mutate the original value"]
13911404
#[unstable(feature = "float_algebraic", issue = "136469")]
1405+
#[rustc_const_unstable(feature = "float_algebraic", issue = "136469")]
13921406
#[inline]
1393-
pub fn algebraic_rem(self, rhs: f16) -> f16 {
1407+
pub const fn algebraic_rem(self, rhs: f16) -> f16 {
13941408
intrinsics::frem_algebraic(self, rhs)
13951409
}
13961410
}

0 commit comments

Comments
 (0)