Skip to content

Commit ef34f56

Browse files
committed
Auto merge of rust-lang#120170 - GuillaumeGomez:rollup-edqdf30, r=GuillaumeGomez
Rollup of 6 pull requests Successful merges: - rust-lang#119997 (Fix impl stripped in rustdoc HTML whereas it should not be in case the impl is implemented on a type alias) - rust-lang#120000 (Ensure `callee_id`s are body owners) - rust-lang#120063 (Remove special handling of `box` expressions from parser) - rust-lang#120116 (Remove alignment-changing in-place collect) - rust-lang#120138 (Increase vscode settings.json `git.detectSubmodulesLimit`) - rust-lang#120169 (Spelling fix) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0a10291 + 2064f25 commit ef34f56

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

alloc/src/vec/in_place_collect.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ const fn in_place_collectible<DEST, SRC>(
168168
step_merge: Option<NonZeroUsize>,
169169
step_expand: Option<NonZeroUsize>,
170170
) -> bool {
171-
if const { SRC::IS_ZST || DEST::IS_ZST || mem::align_of::<SRC>() < mem::align_of::<DEST>() } {
171+
// Require matching alignments because an alignment-changing realloc is inefficient on many
172+
// system allocators and better implementations would require the unstable Allocator trait.
173+
if const { SRC::IS_ZST || DEST::IS_ZST || mem::align_of::<SRC>() != mem::align_of::<DEST>() } {
172174
return false;
173175
}
174176

@@ -188,7 +190,8 @@ const fn in_place_collectible<DEST, SRC>(
188190

189191
const fn needs_realloc<SRC, DEST>(src_cap: usize, dst_cap: usize) -> bool {
190192
if const { mem::align_of::<SRC>() != mem::align_of::<DEST>() } {
191-
return src_cap > 0;
193+
// FIXME: use unreachable! once that works in const
194+
panic!("in_place_collectible() prevents this");
192195
}
193196

194197
// If src type size is an integer multiple of the destination type size then
@@ -276,8 +279,8 @@ where
276279
let dst_guard = InPlaceDstBufDrop { ptr: dst_buf, len, cap: dst_cap };
277280
src.forget_allocation_drop_remaining();
278281

279-
// Adjust the allocation if the alignment didn't match or the source had a capacity in bytes
280-
// that wasn't a multiple of the destination type size.
282+
// Adjust the allocation if the source had a capacity in bytes that wasn't a multiple
283+
// of the destination type size.
281284
// Since the discrepancy should generally be small this should only result in some
282285
// bookkeeping updates and no memmove.
283286
if needs_realloc::<I::Src, T>(src_cap, dst_cap) {
@@ -290,7 +293,7 @@ where
290293
let src_size = mem::size_of::<I::Src>().unchecked_mul(src_cap);
291294
let old_layout = Layout::from_size_align_unchecked(src_size, src_align);
292295

293-
// The must be equal or smaller for in-place iteration to be possible
296+
// The allocation must be equal or smaller for in-place iteration to be possible
294297
// therefore the new layout must be ≤ the old one and therefore valid.
295298
let dst_align = mem::align_of::<T>();
296299
let dst_size = mem::size_of::<T>().unchecked_mul(dst_cap);

alloc/src/vec/spec_from_iter.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ use super::{IntoIter, SpecExtend, SpecFromIterNested, Vec};
1313
/// +-+-----------+
1414
/// |
1515
/// v
16-
/// +-+-------------------------------+ +---------------------+
17-
/// |SpecFromIter +---->+SpecFromIterNested |
18-
/// |where I: | | |where I: |
19-
/// | Iterator (default)----------+ | | Iterator (default) |
20-
/// | vec::IntoIter | | | TrustedLen |
21-
/// | SourceIterMarker---fallback-+ | +---------------------+
22-
/// +---------------------------------+
16+
/// +-+---------------------------------+ +---------------------+
17+
/// |SpecFromIter +---->+SpecFromIterNested |
18+
/// |where I: | | |where I: |
19+
/// | Iterator (default)------------+ | | Iterator (default) |
20+
/// | vec::IntoIter | | | TrustedLen |
21+
/// | InPlaceCollect--(fallback to)-+ | +---------------------+
22+
/// +-----------------------------------+
2323
/// ```
2424
pub(super) trait SpecFromIter<T, I> {
2525
fn from_iter(iter: I) -> Self;

core/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ where
415415
// Request and its methods
416416
///////////////////////////////////////////////////////////////////////////////
417417

418-
/// `Request` supports generic, type-driven access to data. It's use is currently restricted to the
418+
/// `Request` supports generic, type-driven access to data. Its use is currently restricted to the
419419
/// standard library in cases where trait authors wish to allow trait implementors to share generic
420420
/// information across trait boundaries. The motivating and prototypical use case is
421421
/// `core::error::Error` which would otherwise require a method per concrete type (eg.

0 commit comments

Comments
 (0)