Auto merge of #77102 - Dylan-DPC:rollup-2jfrg3u, r=Dylan-DPC
Rollup of 9 pull requests Successful merges: - #76898 (Record `tcx.def_span` instead of `item.span` in crate metadata) - #76939 (emit errors during AbstractConst building) - #76965 (Add cfg(target_has_atomic_equal_alignment) and use it for Atomic::from_mut.) - #76993 (Changing the alloc() to accept &self instead of &mut self) - #76994 (fix small typo in docs and comments) - #77017 (Add missing examples on Vec iter types) - #77042 (Improve documentation for ToSocketAddrs) - #77047 (Miri: more informative deallocation error messages) - #77055 (Add #[track_caller] to more panicking Cell functions) Failed merges: r? `@ghost`
This commit is contained in:
commit
c35177582b
42 changed files with 552 additions and 199 deletions
|
@ -133,7 +133,7 @@ pub struct System;
|
|||
|
||||
impl System {
|
||||
#[inline]
|
||||
fn alloc_impl(&mut self, layout: Layout, zeroed: bool) -> Result<NonNull<[u8]>, AllocErr> {
|
||||
fn alloc_impl(&self, layout: Layout, zeroed: bool) -> Result<NonNull<[u8]>, AllocErr> {
|
||||
match layout.size() {
|
||||
0 => Ok(NonNull::slice_from_raw_parts(layout.dangling(), 0)),
|
||||
// SAFETY: `layout` is non-zero in size,
|
||||
|
@ -152,7 +152,7 @@ impl System {
|
|||
// SAFETY: Same as `AllocRef::grow`
|
||||
#[inline]
|
||||
unsafe fn grow_impl(
|
||||
&mut self,
|
||||
&self,
|
||||
ptr: NonNull<u8>,
|
||||
old_layout: Layout,
|
||||
new_layout: Layout,
|
||||
|
@ -190,7 +190,7 @@ impl System {
|
|||
old_size => unsafe {
|
||||
let new_ptr = self.alloc_impl(new_layout, zeroed)?;
|
||||
ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_mut_ptr(), old_size);
|
||||
self.dealloc(ptr, old_layout);
|
||||
AllocRef::dealloc(&self, ptr, old_layout);
|
||||
Ok(new_ptr)
|
||||
},
|
||||
}
|
||||
|
@ -202,17 +202,17 @@ impl System {
|
|||
#[unstable(feature = "allocator_api", issue = "32838")]
|
||||
unsafe impl AllocRef for System {
|
||||
#[inline]
|
||||
fn alloc(&mut self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
|
||||
fn alloc(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
|
||||
self.alloc_impl(layout, false)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn alloc_zeroed(&mut self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
|
||||
fn alloc_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
|
||||
self.alloc_impl(layout, true)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout) {
|
||||
unsafe fn dealloc(&self, ptr: NonNull<u8>, layout: Layout) {
|
||||
if layout.size() != 0 {
|
||||
// SAFETY: `layout` is non-zero in size,
|
||||
// other conditions must be upheld by the caller
|
||||
|
@ -222,7 +222,7 @@ unsafe impl AllocRef for System {
|
|||
|
||||
#[inline]
|
||||
unsafe fn grow(
|
||||
&mut self,
|
||||
&self,
|
||||
ptr: NonNull<u8>,
|
||||
old_layout: Layout,
|
||||
new_layout: Layout,
|
||||
|
@ -233,7 +233,7 @@ unsafe impl AllocRef for System {
|
|||
|
||||
#[inline]
|
||||
unsafe fn grow_zeroed(
|
||||
&mut self,
|
||||
&self,
|
||||
ptr: NonNull<u8>,
|
||||
old_layout: Layout,
|
||||
new_layout: Layout,
|
||||
|
@ -244,7 +244,7 @@ unsafe impl AllocRef for System {
|
|||
|
||||
#[inline]
|
||||
unsafe fn shrink(
|
||||
&mut self,
|
||||
&self,
|
||||
ptr: NonNull<u8>,
|
||||
old_layout: Layout,
|
||||
new_layout: Layout,
|
||||
|
@ -257,7 +257,7 @@ unsafe impl AllocRef for System {
|
|||
match new_layout.size() {
|
||||
// SAFETY: conditions must be upheld by the caller
|
||||
0 => unsafe {
|
||||
self.dealloc(ptr, old_layout);
|
||||
AllocRef::dealloc(&self, ptr, old_layout);
|
||||
Ok(NonNull::slice_from_raw_parts(new_layout.dangling(), 0))
|
||||
},
|
||||
|
||||
|
@ -277,9 +277,9 @@ unsafe impl AllocRef for System {
|
|||
// `new_ptr`. Thus, the call to `copy_nonoverlapping` is safe. The safety contract
|
||||
// for `dealloc` must be upheld by the caller.
|
||||
new_size => unsafe {
|
||||
let new_ptr = self.alloc(new_layout)?;
|
||||
let new_ptr = AllocRef::alloc(&self, new_layout)?;
|
||||
ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_mut_ptr(), new_size);
|
||||
self.dealloc(ptr, old_layout);
|
||||
AllocRef::dealloc(&self, ptr, old_layout);
|
||||
Ok(new_ptr)
|
||||
},
|
||||
}
|
||||
|
|
|
@ -745,9 +745,9 @@ impl hash::Hash for SocketAddrV6 {
|
|||
/// `(`[`Ipv4Addr`]`, `[`u16`]`)`, `(`[`Ipv6Addr`]`, `[`u16`]`)`:
|
||||
/// [`to_socket_addrs`] constructs a [`SocketAddr`] trivially.
|
||||
///
|
||||
/// * `(`[`&str`]`, `[`u16`]`)`: the string should be either a string representation
|
||||
/// * `(`[`&str`]`, `[`u16`]`)`: [`&str`] should be either a string representation
|
||||
/// of an [`IpAddr`] address as expected by [`FromStr`] implementation or a host
|
||||
/// name.
|
||||
/// name. [`u16`] is the port number.
|
||||
///
|
||||
/// * [`&str`]: the string should be either a string representation of a
|
||||
/// [`SocketAddr`] as expected by its [`FromStr`] implementation or a string like
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue