Skip to content

Commit 2c3fdc6

Browse files
committed
Auto merge of #110666 - JohnTitor:rollup-3pwilte, r=JohnTitor
Rollup of 7 pull requests Successful merges: - #109949 (rustdoc: migrate `document_type_layout` to askama) - #110622 (Stable hash tag (discriminant) of `GenericArg`) - #110635 (More `IS_ZST` in `library`) - #110640 (compiler/rustc_target: Raise m68k-linux-gnu baseline to 68020) - #110657 (nit: consistent naming for SimplifyConstCondition) - #110659 (rustdoc: clean up JS) - #110660 (Print ty placeholders pretty) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents ee53692 + de359b0 commit 2c3fdc6

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

alloc/src/boxed/thin.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use core::fmt::{self, Debug, Display, Formatter};
77
use core::marker::PhantomData;
88
#[cfg(not(no_global_oom_handling))]
99
use core::marker::Unsize;
10-
use core::mem;
10+
use core::mem::{self, SizedTypeProperties};
1111
use core::ops::{Deref, DerefMut};
1212
use core::ptr::Pointee;
1313
use core::ptr::{self, NonNull};
@@ -202,9 +202,7 @@ impl<H> WithHeader<H> {
202202
let ptr = if layout.size() == 0 {
203203
// Some paranoia checking, mostly so that the ThinBox tests are
204204
// more able to catch issues.
205-
debug_assert!(
206-
value_offset == 0 && mem::size_of::<T>() == 0 && mem::size_of::<H>() == 0
207-
);
205+
debug_assert!(value_offset == 0 && T::IS_ZST && H::IS_ZST);
208206
layout.dangling()
209207
} else {
210208
let ptr = alloc::alloc(layout);
@@ -249,9 +247,7 @@ impl<H> WithHeader<H> {
249247
alloc::dealloc(self.ptr.as_ptr().sub(value_offset), layout);
250248
} else {
251249
debug_assert!(
252-
value_offset == 0
253-
&& mem::size_of::<H>() == 0
254-
&& self.value_layout.size() == 0
250+
value_offset == 0 && H::IS_ZST && self.value_layout.size() == 0
255251
);
256252
}
257253
}

alloc/src/vec/drain.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ impl<'a, T, A: Allocator> Drain<'a, T, A> {
112112
let unyielded_ptr = this.iter.as_slice().as_ptr();
113113

114114
// ZSTs have no identity, so we don't need to move them around.
115-
let needs_move = mem::size_of::<T>() != 0;
116-
117-
if needs_move {
115+
if !T::IS_ZST {
118116
let start_ptr = source_vec.as_mut_ptr().add(start);
119117

120118
// memmove back unyielded elements

alloc/src/vec/drain_filter.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::alloc::{Allocator, Global};
2-
use core::mem::{self, ManuallyDrop};
2+
use core::mem::{ManuallyDrop, SizedTypeProperties};
33
use core::ptr;
44
use core::slice;
55

@@ -96,9 +96,7 @@ where
9696

9797
unsafe {
9898
// ZSTs have no identity, so we don't need to move them around.
99-
let needs_move = mem::size_of::<T>() != 0;
100-
101-
if needs_move && this.idx < this.old_len && this.del > 0 {
99+
if !T::IS_ZST && this.idx < this.old_len && this.del > 0 {
102100
let ptr = this.vec.as_mut_ptr();
103101
let src = ptr.add(this.idx);
104102
let dst = src.sub(this.del);

core/src/slice/iter/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ macro_rules! iterator {
7373
// Unsafe because the offset must not exceed `self.len()`.
7474
#[inline(always)]
7575
unsafe fn post_inc_start(&mut self, offset: usize) -> * $raw_mut T {
76-
if mem::size_of::<T>() == 0 {
76+
if T::IS_ZST {
7777
zst_shrink!(self, offset);
7878
self.ptr.as_ptr()
7979
} else {

0 commit comments

Comments
 (0)