Skip to content

Commit d10366f

Browse files
committed
avoid unnecessary use of MaybeUninit::get_ref, and expand comment on the others
1 parent 084ee7a commit d10366f

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/libcore/fmt/float.rs

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ fn float_to_decimal_common_exact<T>(fmt: &mut Formatter, num: &T,
1515
// FIXME(#53491): Technically, this is calling `get_mut` on an uninitialized
1616
// `MaybeUninit` (here and elsewhere in this file). Revisit this once
1717
// we decided whether that is valid or not.
18+
// Using `freeze` is *not enough*; `flt2dec::Part` is an enum!
1819
let formatted = flt2dec::to_exact_fixed_str(flt2dec::strategy::grisu::format_exact,
1920
*num, sign, precision,
2021
false, buf.get_mut(), parts.get_mut());
@@ -33,6 +34,7 @@ fn float_to_decimal_common_shortest<T>(fmt: &mut Formatter, num: &T,
3334
// enough for f32 and f64
3435
let mut buf = MaybeUninit::<[u8; flt2dec::MAX_SIG_DIGITS]>::uninitialized();
3536
let mut parts = MaybeUninit::<[flt2dec::Part; 4]>::uninitialized();
37+
// FIXME(#53491)
3638
let formatted = flt2dec::to_shortest_str(flt2dec::strategy::grisu::format_shortest, *num,
3739
sign, precision, false, buf.get_mut(),
3840
parts.get_mut());
@@ -71,6 +73,7 @@ fn float_to_exponential_common_exact<T>(fmt: &mut Formatter, num: &T,
7173
unsafe {
7274
let mut buf = MaybeUninit::<[u8; 1024]>::uninitialized(); // enough for f32 and f64
7375
let mut parts = MaybeUninit::<[flt2dec::Part; 6]>::uninitialized();
76+
// FIXME(#53491)
7477
let formatted = flt2dec::to_exact_exp_str(flt2dec::strategy::grisu::format_exact,
7578
*num, sign, precision,
7679
upper, buf.get_mut(), parts.get_mut());
@@ -90,6 +93,7 @@ fn float_to_exponential_common_shortest<T>(fmt: &mut Formatter,
9093
// enough for f32 and f64
9194
let mut buf = MaybeUninit::<[u8; flt2dec::MAX_SIG_DIGITS]>::uninitialized();
9295
let mut parts = MaybeUninit::<[flt2dec::Part; 6]>::uninitialized();
96+
// FIXME(#53491)
9397
let formatted = flt2dec::to_shortest_exp_str(flt2dec::strategy::grisu::format_shortest,
9498
*num, sign, (0, 0), upper,
9599
buf.get_mut(), parts.get_mut());

src/libcore/ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ pub unsafe fn swap<T>(x: *mut T, y: *mut T) {
301301
// Perform the swap
302302
copy_nonoverlapping(x, tmp.as_mut_ptr(), 1);
303303
copy(y, x, 1); // `x` and `y` may overlap
304-
copy_nonoverlapping(tmp.get_ref(), y, 1);
304+
copy_nonoverlapping(tmp.as_ptr(), y, 1);
305305
}
306306

307307
/// Swaps `count * size_of::<T>()` bytes between the two regions of memory

0 commit comments

Comments
 (0)