Skip to content

Commit cc18694

Browse files
committed
Add hacks to work around stacked borrows (revert after tree borrows)
Signed-off-by: Alex Saveau <[email protected]>
1 parent f2e9b40 commit cc18694

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

compiler/rustc_serialize/src/opaque.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl FileEncoder {
182182
// room to write the input to the buffer.
183183
unsafe {
184184
let src = buf.as_ptr();
185-
let dst = self.buf.get_unchecked_mut(buffered).as_mut_ptr();
185+
let dst = self.buf.as_mut_ptr().add(buffered).into_inner();
186186
ptr::copy_nonoverlapping(src, dst, buf_len);
187187
}
188188

library/core/src/fmt/num.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ macro_rules! impl_Exp {
397397
} else {
398398
let off = exponent << 1;
399399
// SAFETY: 1 + 2 <= 3
400-
unsafe { ptr::copy_nonoverlapping(lut_ptr.add(off), exp_buf[1].as_mut_ptr(), 2); }
400+
unsafe { ptr::copy_nonoverlapping(lut_ptr.add(off), exp_buf.as_mut_ptr().into_inner().add(1), 2); }
401401
3
402402
};
403403
// SAFETY: max(2, 3) <= 3
@@ -605,7 +605,7 @@ fn fmt_u128(n: u128, is_nonnegative: bool, f: &mut fmt::Formatter<'_>) -> fmt::R
605605
// SAFETY: Guaranteed that we wrote at most 19 bytes, and there must be space
606606
// remaining since it has length 39
607607
unsafe {
608-
ptr::write_bytes(buf[target].as_mut_ptr(), b'0', curr - target);
608+
ptr::write_bytes(buf.as_mut_ptr().add(target), b'0', curr - target);
609609
}
610610
curr = target;
611611

@@ -617,7 +617,7 @@ fn fmt_u128(n: u128, is_nonnegative: bool, f: &mut fmt::Formatter<'_>) -> fmt::R
617617
// SAFETY: At this point we wrote at most 38 bytes, pad up to that point,
618618
// There can only be at most 1 digit remaining.
619619
unsafe {
620-
ptr::write_bytes(buf[target].as_mut_ptr(), b'0', curr - target);
620+
ptr::write_bytes(buf.as_mut_ptr().add(target), b'0', curr - target);
621621
}
622622
curr = target - 1;
623623
buf[curr].write((n as u8) + b'0');
@@ -628,7 +628,7 @@ fn fmt_u128(n: u128, is_nonnegative: bool, f: &mut fmt::Formatter<'_>) -> fmt::R
628628
// UTF-8 since `DEC_DIGITS_LUT` is
629629
let buf_slice = unsafe {
630630
str::from_utf8_unchecked(slice::from_raw_parts(
631-
buf.get_unchecked_mut(curr).as_mut_ptr(),
631+
buf.as_mut_ptr().add(curr).into_inner(),
632632
buf.len() - curr,
633633
))
634634
};

0 commit comments

Comments
 (0)