Skip to content

alloc: Unstably add Vec::repeat and Vec::repeat_in - #164043

Merged
rust-bors[bot] merged 4 commits into
rust-lang:mainfrom
Gelbpunkt:from-elem-in
Nov 16, 2026
Merged

rust-bors[bot] merged 4 commits into
rust-lang:mainfrom
Gelbpunkt:from-elem-in

Conversation

@Gelbpunkt

@Gelbpunkt Gelbpunkt commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

Tracking issue: #164215

We also forward the existing std::vec::from_elem_global to Vec::repeat. The old module-level method std::vec::from_elem_in was unstable and unused, so I've removed it as per reviewer's request.

Zulip thread

r? @clarfonthey

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 9, 2026
Comment thread library/alloc/src/vec/mod.rs Resolved
@folkertdev folkertdev added the F-abi_custom `#![feature(abi_custom)]` label Oct 9, 2026
@rust-log-analyzer

This comment has been minimized.

@folkertdev folkertdev added A-allocators Area: Custom and system allocators and removed F-abi_custom `#![feature(abi_custom)]` labels Oct 9, 2026
Comment thread library/alloc/src/vec/mod.rs Resolved
@clarfonthey

Copy link
Copy Markdown
Contributor

r? ChrisDenton

Offloading a few PRs, Chris should have enough context to handle this.

@rust-log-analyzer

This comment has been minimized.

@ChrisDenton

Copy link
Copy Markdown
Member

I wouldn't be willing to support this without an accepted ACP that details the motivation. It is basically a new specialization wrapper (while it existed before, it was only for internal use). So I'll pass on review.

r? libs

@nia-e

nia-e commented Oct 13, 2026

Copy link
Copy Markdown
Member

Yup, this is major enough to need discussion as an ACP. @Gelbpunkt could you file one?

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 25, 2026
@rust-bors

This comment has been minimized.

@nia-e

nia-e commented Nov 9, 2026

Copy link
Copy Markdown
Member

per ACP, these should be renamed

@rustbot author

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Nov 9, 2026
@rustbot

rustbot commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@nia-e nia-e removed the S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. label Nov 9, 2026
@folkertdev

Copy link
Copy Markdown
Contributor

We can also remove from_elem_global in favor of the Vec::repeat method

#[doc(hidden)]
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "liballoc_internals", issue = "none")]
#[rustc_diagnostic_item = "vec_from_elem"]
pub fn from_elem_global<T: Clone>(elem: T, n: usize) -> Vec<T> {
<T as SpecFromElem>::from_elem(elem, n, Global)
}

We also forward the existing `std::vec::from_elem_global` and
`std::vec::from_elem_in` to these new associated methods on `Vec`. The
module-level methods could potentially be removed in a follow-up.
WaffleLapkin added a commit to WaffleLapkin/rust that referenced this pull request Nov 13, 2026
alloc: Unstably add `Vec::repeat` and `Vec::repeat_in`

Tracking issue: rust-lang#164215

We also forward the existing `std::vec::from_elem_global` to `Vec::repeat`. The old module-level method `std::vec::from_elem_in` was unstable and unused, so I've removed it as per reviewer's request.

[Zulip thread](https://rust-lang.zulipchat.com/#narrow/channel/197181-t-libs.2Fwg-allocators/topic/Custom.20allocators.20with.20vec.21.20and.20fallible.20allocations/with/630260935)

r? @clarfonthey
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 13, 2026
alloc: Unstably add `Vec::repeat` and `Vec::repeat_in`

Tracking issue: rust-lang#164215

We also forward the existing `std::vec::from_elem_global` to `Vec::repeat`. The old module-level method `std::vec::from_elem_in` was unstable and unused, so I've removed it as per reviewer's request.

[Zulip thread](https://rust-lang.zulipchat.com/#narrow/channel/197181-t-libs.2Fwg-allocators/topic/Custom.20allocators.20with.20vec.21.20and.20fallible.20allocations/with/630260935)

r? @clarfonthey
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 13, 2026
alloc: Unstably add `Vec::repeat` and `Vec::repeat_in`

Tracking issue: rust-lang#164215

We also forward the existing `std::vec::from_elem_global` to `Vec::repeat`. The old module-level method `std::vec::from_elem_in` was unstable and unused, so I've removed it as per reviewer's request.

[Zulip thread](https://rust-lang.zulipchat.com/#narrow/channel/197181-t-libs.2Fwg-allocators/topic/Custom.20allocators.20with.20vec.21.20and.20fallible.20allocations/with/630260935)

r? @clarfonthey
rust-bors Bot pushed a commit that referenced this pull request Nov 13, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #160618 (require a consistent codegen backend when -Zllvm-target-feature is present)
 - #164043 (alloc: Unstably add `Vec::repeat` and `Vec::repeat_in`)
 - #164823 (Use `DerefMut` and `IndexMut` before `&raw mut` autoborrow)
 - #165568 (rustdoc: Suggest corrections for reference label typos)
 - #165924 (rustc_codegen_gcc subtree update 2026-11-13)
 - #165927 (Remove `const_struct` from `rustc_codegen_ssa`)
 - #165928 (Replace most uses of `type_array` with `type_byte_array` in `rustc_codegen_llvm`)
 - #164362 (Emit note for `non_exhaustive` within defining crate for `unreachable_patterns`)
 - #164997 (Fix as str suggestion in subpattern)
 - #165868 (Small changes to dyn compatibility)
 - #165879 (Add `#[rustc_test_entrypoint_marker]` back !)
 - #165903 (Fix borrowck ICE when a borrow outlives a local in a const block)
 - #165914 (Use `trim_prefix` in bootstrap)
 - #165919 (tests: accept better behavior on underaligned accesses)
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 13, 2026
alloc: Unstably add `Vec::repeat` and `Vec::repeat_in`

Tracking issue: rust-lang#164215

We also forward the existing `std::vec::from_elem_global` to `Vec::repeat`. The old module-level method `std::vec::from_elem_in` was unstable and unused, so I've removed it as per reviewer's request.

[Zulip thread](https://rust-lang.zulipchat.com/#narrow/channel/197181-t-libs.2Fwg-allocators/topic/Custom.20allocators.20with.20vec.21.20and.20fallible.20allocations/with/630260935)

r? @clarfonthey
rust-bors Bot pushed a commit that referenced this pull request Nov 13, 2026
Rollup of 17 pull requests

Successful merges:

 - #160618 (require a consistent codegen backend when -Zllvm-target-feature is present)
 - #164043 (alloc: Unstably add `Vec::repeat` and `Vec::repeat_in`)
 - #164808 (asm const ptr: move name generation to asm-specific logic)
 - #164823 (Use `DerefMut` and `IndexMut` before `&raw mut` autoborrow)
 - #165475 (Add a `!type` annotation to a vtable for every supertrait that is a prefix of the vtable)
 - #165568 (rustdoc: Suggest corrections for reference label typos)
 - #165924 (rustc_codegen_gcc subtree update 2026-11-13)
 - #165927 (Remove `const_struct` from `rustc_codegen_ssa`)
 - #164362 (Emit note for `non_exhaustive` within defining crate for `unreachable_patterns`)
 - #164997 (Fix as str suggestion in subpattern)
 - #165825 (make `Complex<x87_f80>` ABI-compatible with C)
 - #165868 (Small changes to dyn compatibility)
 - #165879 (Add `#[rustc_test_entrypoint_marker]` back !)
 - #165903 (Fix borrowck ICE when a borrow outlives a local in a const block)
 - #165914 (Use `trim_prefix` in bootstrap)
 - #165919 (tests: accept better behavior on underaligned accesses)
 - #165936 (Enhance documentation for try_clone File implementation)
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 14, 2026
alloc: Unstably add `Vec::repeat` and `Vec::repeat_in`

Tracking issue: rust-lang#164215

We also forward the existing `std::vec::from_elem_global` to `Vec::repeat`. The old module-level method `std::vec::from_elem_in` was unstable and unused, so I've removed it as per reviewer's request.

[Zulip thread](https://rust-lang.zulipchat.com/#narrow/channel/197181-t-libs.2Fwg-allocators/topic/Custom.20allocators.20with.20vec.21.20and.20fallible.20allocations/with/630260935)

r? @clarfonthey
rust-bors Bot pushed a commit that referenced this pull request Nov 14, 2026
Rollup of 16 pull requests

Successful merges:

 - #160618 (require a consistent codegen backend when -Zllvm-target-feature is present)
 - #164043 (alloc: Unstably add `Vec::repeat` and `Vec::repeat_in`)
 - #164823 (Use `DerefMut` and `IndexMut` before `&raw mut` autoborrow)
 - #165475 (Add a `!type` annotation to a vtable for every supertrait that is a prefix of the vtable)
 - #165568 (rustdoc: Suggest corrections for reference label typos)
 - #165924 (rustc_codegen_gcc subtree update 2026-11-13)
 - #165927 (Remove `const_struct` from `rustc_codegen_ssa`)
 - #164362 (Emit note for `non_exhaustive` within defining crate for `unreachable_patterns`)
 - #164997 (Fix as str suggestion in subpattern)
 - #165825 (make `Complex<x87_f80>` ABI-compatible with C)
 - #165868 (Small changes to dyn compatibility)
 - #165879 (Add `#[rustc_test_entrypoint_marker]` back !)
 - #165903 (Fix borrowck ICE when a borrow outlives a local in a const block)
 - #165914 (Use `trim_prefix` in bootstrap)
 - #165919 (tests: accept better behavior on underaligned accesses)
 - #165936 (Enhance documentation for try_clone File implementation)
@rust-bors

rust-bors Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

rust-bors Bot pushed a commit that referenced this pull request Nov 14, 2026
alloc: Unstably add `Vec::repeat` and `Vec::repeat_in`

Tracking issue: #164215

We also forward the existing `std::vec::from_elem_global` to `Vec::repeat`. The old module-level method `std::vec::from_elem_in` was unstable and unused, so I've removed it as per reviewer's request.

[Zulip thread](https://rust-lang.zulipchat.com/#narrow/channel/197181-t-libs.2Fwg-allocators/topic/Custom.20allocators.20with.20vec.21.20and.20fallible.20allocations/with/630260935)

r? @clarfonthey
@Zalathar

Copy link
Copy Markdown
Member

@bors yield (treeclosed)

@rust-bors

rust-bors Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Auto build was cancelled. Cancelled workflows:

The next pull request likely to be tested is #164043.

jhpratt added a commit to jhpratt/rust that referenced this pull request Nov 14, 2026
alloc: Unstably add `Vec::repeat` and `Vec::repeat_in`

Tracking issue: rust-lang#164215

We also forward the existing `std::vec::from_elem_global` to `Vec::repeat`. The old module-level method `std::vec::from_elem_in` was unstable and unused, so I've removed it as per reviewer's request.

[Zulip thread](https://rust-lang.zulipchat.com/#narrow/channel/197181-t-libs.2Fwg-allocators/topic/Custom.20allocators.20with.20vec.21.20and.20fallible.20allocations/with/630260935)

r? @clarfonthey
jhpratt added a commit to jhpratt/rust that referenced this pull request Nov 14, 2026
alloc: Unstably add `Vec::repeat` and `Vec::repeat_in`

Tracking issue: rust-lang#164215

We also forward the existing `std::vec::from_elem_global` to `Vec::repeat`. The old module-level method `std::vec::from_elem_in` was unstable and unused, so I've removed it as per reviewer's request.

[Zulip thread](https://rust-lang.zulipchat.com/#narrow/channel/197181-t-libs.2Fwg-allocators/topic/Custom.20allocators.20with.20vec.21.20and.20fallible.20allocations/with/630260935)

r? @clarfonthey
rust-bors Bot pushed a commit that referenced this pull request Nov 16, 2026
…uwer

Rollup of 23 pull requests

Successful merges:

 - #165928 (Replace most uses of `type_array` with `type_byte_array` in `rustc_codegen_llvm`)
 - #160618 (require a consistent codegen backend when -Zllvm-target-feature is present)
 - #161950 (Ensure floats are returned losslessly by the C ABI on 32-bit x86)
 - #162267 (Fix an edge within `std::fs::create_dir_all` for certain platforms that views trailing cur dir components as a separate missing directory components)
 - #164043 (alloc: Unstably add `Vec::repeat` and `Vec::repeat_in`)
 - #164808 (asm const ptr: move name generation to asm-specific logic)
 - #164823 (Use `DerefMut` and `IndexMut` before `&raw mut` autoborrow)
 - #165568 (rustdoc: Suggest corrections for reference label typos)
 - #165641 (Treat all proc macro dependencies as host dependencies in bootstrap)
 - #165924 (rustc_codegen_gcc subtree update 2026-11-13)
 - #165927 (Remove `const_struct` from `rustc_codegen_ssa`)
 - #163696 (Stabilize `int_from_ascii`)
 - #163882 (docs(vec): clarify into_boxed_slice allocation guarantee)
 - #164362 (Emit note for `non_exhaustive` within defining crate for `unreachable_patterns`)
 - #164465 (Under `guard_patterns` allow parenthesized guarded patterns in match arms)
 - #164997 (Fix as str suggestion in subpattern)
 - #165825 (make `Complex<x87_f80>` ABI-compatible with C)
 - #165868 (Small changes to dyn compatibility)
 - #165879 (Add `#[rustc_test_entrypoint_marker]` back !)
 - #165902 (Add allocator() to vec_deque::IntoIter and vec_deque::Drain)
 - #165903 (Fix borrowck ICE when a borrow outlives a local in a const block)
 - #165914 (Use `trim_prefix` in bootstrap)
 - #165919 (tests: accept better behavior on underaligned accesses)

Failed merges:

 - #165893 (Prune un/under used methods of `ast::Attribute`)
rust-bors Bot pushed a commit that referenced this pull request Nov 16, 2026
…uwer

Rollup of 23 pull requests

Successful merges:

 - #165928 (Replace most uses of `type_array` with `type_byte_array` in `rustc_codegen_llvm`)
 - #160618 (require a consistent codegen backend when -Zllvm-target-feature is present)
 - #161950 (Ensure floats are returned losslessly by the C ABI on 32-bit x86)
 - #162267 (Fix an edge within `std::fs::create_dir_all` for certain platforms that views trailing cur dir components as a separate missing directory components)
 - #164043 (alloc: Unstably add `Vec::repeat` and `Vec::repeat_in`)
 - #164808 (asm const ptr: move name generation to asm-specific logic)
 - #164823 (Use `DerefMut` and `IndexMut` before `&raw mut` autoborrow)
 - #165568 (rustdoc: Suggest corrections for reference label typos)
 - #165641 (Treat all proc macro dependencies as host dependencies in bootstrap)
 - #165924 (rustc_codegen_gcc subtree update 2026-11-13)
 - #165927 (Remove `const_struct` from `rustc_codegen_ssa`)
 - #163696 (Stabilize `int_from_ascii`)
 - #163882 (docs(vec): clarify into_boxed_slice allocation guarantee)
 - #164362 (Emit note for `non_exhaustive` within defining crate for `unreachable_patterns`)
 - #164465 (Under `guard_patterns` allow parenthesized guarded patterns in match arms)
 - #164997 (Fix as str suggestion in subpattern)
 - #165825 (make `Complex<x87_f80>` ABI-compatible with C)
 - #165868 (Small changes to dyn compatibility)
 - #165879 (Add `#[rustc_test_entrypoint_marker]` back !)
 - #165902 (Add allocator() to vec_deque::IntoIter and vec_deque::Drain)
 - #165903 (Fix borrowck ICE when a borrow outlives a local in a const block)
 - #165914 (Use `trim_prefix` in bootstrap)
 - #165919 (tests: accept better behavior on underaligned accesses)

Failed merges:

 - #165893 (Prune un/under used methods of `ast::Attribute`)
@rust-bors
rust-bors Bot merged commit a66d730 into rust-lang:main Nov 16, 2026
14 of 15 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 16, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 16, 2026
Rollup merge of #164043 - Gelbpunkt:from-elem-in, r=nia-e

alloc: Unstably add `Vec::repeat` and `Vec::repeat_in`

Tracking issue: #164215

We also forward the existing `std::vec::from_elem_global` to `Vec::repeat`. The old module-level method `std::vec::from_elem_in` was unstable and unused, so I've removed it as per reviewer's request.

[Zulip thread](https://rust-lang.zulipchat.com/#narrow/channel/197181-t-libs.2Fwg-allocators/topic/Custom.20allocators.20with.20vec.21.20and.20fallible.20allocations/with/630260935)

r? @clarfonthey
sushink70 pushed a commit to sushink70/miri that referenced this pull request Nov 17, 2026
…uwer

Rollup of 23 pull requests

Successful merges:

 - rust-lang/rust#165928 (Replace most uses of `type_array` with `type_byte_array` in `rustc_codegen_llvm`)
 - rust-lang/rust#160618 (require a consistent codegen backend when -Zllvm-target-feature is present)
 - rust-lang/rust#161950 (Ensure floats are returned losslessly by the C ABI on 32-bit x86)
 - rust-lang/rust#162267 (Fix an edge within `std::fs::create_dir_all` for certain platforms that views trailing cur dir components as a separate missing directory components)
 - rust-lang/rust#164043 (alloc: Unstably add `Vec::repeat` and `Vec::repeat_in`)
 - rust-lang/rust#164808 (asm const ptr: move name generation to asm-specific logic)
 - rust-lang/rust#164823 (Use `DerefMut` and `IndexMut` before `&raw mut` autoborrow)
 - rust-lang/rust#165568 (rustdoc: Suggest corrections for reference label typos)
 - rust-lang/rust#165641 (Treat all proc macro dependencies as host dependencies in bootstrap)
 - rust-lang/rust#165924 (rustc_codegen_gcc subtree update 2026-11-13)
 - rust-lang/rust#165927 (Remove `const_struct` from `rustc_codegen_ssa`)
 - rust-lang/rust#163696 (Stabilize `int_from_ascii`)
 - rust-lang/rust#163882 (docs(vec): clarify into_boxed_slice allocation guarantee)
 - rust-lang/rust#164362 (Emit note for `non_exhaustive` within defining crate for `unreachable_patterns`)
 - rust-lang/rust#164465 (Under `guard_patterns` allow parenthesized guarded patterns in match arms)
 - rust-lang/rust#164997 (Fix as str suggestion in subpattern)
 - rust-lang/rust#165825 (make `Complex<x87_f80>` ABI-compatible with C)
 - rust-lang/rust#165868 (Small changes to dyn compatibility)
 - rust-lang/rust#165879 (Add `#[rustc_test_entrypoint_marker]` back !)
 - rust-lang/rust#165902 (Add allocator() to vec_deque::IntoIter and vec_deque::Drain)
 - rust-lang/rust#165903 (Fix borrowck ICE when a borrow outlives a local in a const block)
 - rust-lang/rust#165914 (Use `trim_prefix` in bootstrap)
 - rust-lang/rust#165919 (tests: accept better behavior on underaligned accesses)

Failed merges:

 - rust-lang/rust#165893 (Prune un/under used methods of `ast::Attribute`)
mehmettoplu-rs pushed a commit to mehmettoplu-rs/rustc_codegen_gcc that referenced this pull request Nov 27, 2026
…uwer

Rollup of 23 pull requests

Successful merges:

 - rust-lang/rust#165928 (Replace most uses of `type_array` with `type_byte_array` in `rustc_codegen_llvm`)
 - rust-lang/rust#160618 (require a consistent codegen backend when -Zllvm-target-feature is present)
 - rust-lang/rust#161950 (Ensure floats are returned losslessly by the C ABI on 32-bit x86)
 - rust-lang/rust#162267 (Fix an edge within `std::fs::create_dir_all` for certain platforms that views trailing cur dir components as a separate missing directory components)
 - rust-lang/rust#164043 (alloc: Unstably add `Vec::repeat` and `Vec::repeat_in`)
 - rust-lang/rust#164808 (asm const ptr: move name generation to asm-specific logic)
 - rust-lang/rust#164823 (Use `DerefMut` and `IndexMut` before `&raw mut` autoborrow)
 - rust-lang/rust#165568 (rustdoc: Suggest corrections for reference label typos)
 - rust-lang/rust#165641 (Treat all proc macro dependencies as host dependencies in bootstrap)
 - rust-lang/rust#165924 (rustc_codegen_gcc subtree update 2026-11-13)
 - rust-lang/rust#165927 (Remove `const_struct` from `rustc_codegen_ssa`)
 - rust-lang/rust#163696 (Stabilize `int_from_ascii`)
 - rust-lang/rust#163882 (docs(vec): clarify into_boxed_slice allocation guarantee)
 - rust-lang/rust#164362 (Emit note for `non_exhaustive` within defining crate for `unreachable_patterns`)
 - rust-lang/rust#164465 (Under `guard_patterns` allow parenthesized guarded patterns in match arms)
 - rust-lang/rust#164997 (Fix as str suggestion in subpattern)
 - rust-lang/rust#165825 (make `Complex<x87_f80>` ABI-compatible with C)
 - rust-lang/rust#165868 (Small changes to dyn compatibility)
 - rust-lang/rust#165879 (Add `#[rustc_test_entrypoint_marker]` back !)
 - rust-lang/rust#165902 (Add allocator() to vec_deque::IntoIter and vec_deque::Drain)
 - rust-lang/rust#165903 (Fix borrowck ICE when a borrow outlives a local in a const block)
 - rust-lang/rust#165914 (Use `trim_prefix` in bootstrap)
 - rust-lang/rust#165919 (tests: accept better behavior on underaligned accesses)

Failed merges:

 - rust-lang/rust#165893 (Prune un/under used methods of `ast::Attribute`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-allocators Area: Custom and system allocators A-slice-vec Area: `[T]` and `Vec<T>` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants