Skip to content

Commit

Permalink
RawVec::into_box: avoid unnecessary intermediate reference
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Mar 10, 2024
1 parent cdb775c commit 81ebaf2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions library/alloc/src/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use core::cmp;
use core::hint;
use core::mem::{self, ManuallyDrop, MaybeUninit, SizedTypeProperties};
use core::ptr::{self, NonNull, Unique};
use core::slice;

#[cfg(not(no_global_oom_handling))]
use crate::alloc::handle_alloc_error;
Expand Down Expand Up @@ -192,7 +191,7 @@ impl<T, A: Allocator> RawVec<T, A> {

let me = ManuallyDrop::new(self);
unsafe {
let slice = slice::from_raw_parts_mut(me.ptr() as *mut MaybeUninit<T>, len);
let slice = ptr::slice_from_raw_parts_mut(me.ptr() as *mut MaybeUninit<T>, len);
Box::from_raw_in(slice, ptr::read(&me.alloc))
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/ui/hygiene/panic-location.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//@ run-fail
//@ check-run-results
//@ exec-env:RUST_BACKTRACE=0
//@ normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC"
//
// Regression test for issue #70963
// The captured stderr from this test reports a location
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/hygiene/panic-location.run.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
thread 'main' panicked at library/alloc/src/raw_vec.rs:26:5:
thread 'main' panicked at library/alloc/src/raw_vec.rs:LL:CC:
capacity overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

0 comments on commit 81ebaf2

Please sign in to comment.