File tree 2 files changed +9
-13
lines changed
2 files changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -1287,7 +1287,7 @@ impl<T, const N: usize> MaybeUninit<[T; N]> {
1287
1287
#[ inline]
1288
1288
pub const fn transpose ( self ) -> [ MaybeUninit < T > ; N ] {
1289
1289
// SAFETY: T and MaybeUninit<T> have the same layout
1290
- unsafe { super :: transmute_copy ( & ManuallyDrop :: new ( self ) ) }
1290
+ unsafe { intrinsics :: transmute_unchecked ( self ) }
1291
1291
}
1292
1292
}
1293
1293
@@ -1307,6 +1307,6 @@ impl<T, const N: usize> [MaybeUninit<T>; N] {
1307
1307
#[ inline]
1308
1308
pub const fn transpose ( self ) -> MaybeUninit < [ T ; N ] > {
1309
1309
// SAFETY: T and MaybeUninit<T> have the same layout
1310
- unsafe { super :: transmute_copy ( & ManuallyDrop :: new ( self ) ) }
1310
+ unsafe { intrinsics :: transmute_unchecked ( self ) }
1311
1311
}
1312
1312
}
Original file line number Diff line number Diff line change 1
1
// See src/libstd/primitive_docs.rs for documentation.
2
2
3
3
use crate :: cmp:: Ordering :: { self , * } ;
4
- use crate :: mem:: transmute;
5
4
6
5
// Recursive macro for implementing n-ary tuple functions and operations
7
6
//
@@ -142,16 +141,13 @@ macro_rules! maybe_tuple_doc {
142
141
#[ inline]
143
142
const fn ordering_is_some ( c : Option < Ordering > , x : Ordering ) -> bool {
144
143
// FIXME: Just use `==` once that's const-stable on `Option`s.
145
- // This isn't using `match` because that optimizes worse due to
146
- // making a two-step check (`Some` *then* the inner value).
147
-
148
- // SAFETY: There's no public guarantee for `Option<Ordering>`,
149
- // but we're core so we know that it's definitely a byte.
150
- unsafe {
151
- let c: i8 = transmute ( c) ;
152
- let x: i8 = transmute ( Some ( x) ) ;
153
- c == x
154
- }
144
+ // This is mapping `None` to 2 and then doing the comparison afterwards
145
+ // because it optimizes better (`None::<Ordering>` is represented as 2).
146
+ x as i8
147
+ == match c {
148
+ Some ( c) => c as i8 ,
149
+ None => 2 ,
150
+ }
155
151
}
156
152
157
153
// Constructs an expression that performs a lexical ordering using method `$rel`.
You can’t perform that action at this time.
0 commit comments