Uh oh!
There was an error while loading. Please reload this page.
Stabilize slice_as_chunks library feature - #139656
Conversation
rustbot
commented
Apr 11, 2025
r? @ibraheemdev rustbot has assigned @ibraheemdev. Use |
This comment has been minimized.
This comment has been minimized.
1f3dfae to
6cfdd53Comparerustbot
commented
Apr 13, 2025
The Miri subtree was changed cc @rust-lang/miri |
scottmcm
commented
Apr 13, 2025
@rust-lang/libs-api I wanted to drop you a ping because there has been a reasonable amount of discussion during the FCP, so if you want me to hold off this for a bit to give you discussion time, let me know. (I haven't seen any indication from comments that you've changed your minds, but it might just not have made it into the thread.) |
BurntSushi
commented
Apr 13, 2025
Aye yeah, I'm still good with this. But given the discussion, holding for a second from another libs-api member seems prudent. |
dtolnay
commented
Apr 13, 2025
LGTM as well. Thank you. We have talked about this feature across at least a half dozen library API team meetings and not diverged from favoring this design. |
| @@ -1314,7 +1314,6 @@ impl<T> [T] { | |||
| /// # Examples | |||
There was a problem hiding this comment.
In the section above (which I cannot comment because it is too far from the diff) we need to strike "This check will most probably get changed to a compile time error before this method gets stabilized."
There was a problem hiding this comment.
Oops, that had even been mentioned in #74985 (comment) and I forgot.
Did a pass over the docs to fix that bit, elaborate on the resulting lengths, and also add a cross-references between these methods and as_flattened(_mut).
@rustbot ready
Also mention them from `as_flattened(_mut)`.
scottmcm
commented
Apr 28, 2025
Friendly ping here, @dtolnay |
dtolnay
commented
Apr 28, 2025
@bors r+ |
bors
commented
Apr 28, 2025
…, r=dtolnay Stabilize `slice_as_chunks` library feature ~~Draft as this needs rust-lang#139163 to land first.~~ FCP: rust-lang#74985 (comment) Methods being stabilized are: ```rust impl [T] { const fn as_chunks<const N: usize>(&self) -> (&[[T; N]], &[T]); const fn as_rchunks<const N: usize>(&self) -> (&[T], &[[T; N]]); const unsafe fn as_chunks_unchecked<const N: usize>(&self) -> &[[T; N]]; const fn as_chunks_mut<const N: usize>(&mut self) -> (&mut [[T; N]], &mut [T]); const fn as_rchunks_mut<const N: usize>(&mut self) -> (&mut [T], &mut [[T; N]]); const unsafe fn as_chunks_unchecked_mut<const N: usize>(&mut self) -> &mut [[T; N]]; } ``` ~~(FCP's not done quite yet, but will in another day if I'm counting right.)~~ FCP Complete: rust-lang#74985 (comment)
…enton Rollup of 10 pull requests Successful merges: - rust-lang#139308 (add autodiff inline) - rust-lang#139656 (Stabilize `slice_as_chunks` library feature) - rust-lang#140022 (allow deref patterns to move out of boxes) - rust-lang#140276 (Do not compute type_of for impl item if impl where clauses are unsatisfied) - rust-lang#140302 (Move inline asm check to typeck, properly handle aliases) - rust-lang#140323 (Implement the internal feature `cfg_target_has_reliable_f16_f128`) - rust-lang#140391 (Rename sub_ptr to offset_from_unsigned in docs) - rust-lang#140394 (Make bootstrap git tests more self-contained) - rust-lang#140396 (Workaround for windows-gnu rust-lld test failure) - rust-lang#140402 (only return nested goals for `Certainty::Yes`) Failed merges: - rust-lang#139765 ([beta] Delay `hash_extract_if` stabilization from 1.87 to 1.88) r? `@ghost` `@rustbot` modify labels: rollup
…enton Rollup of 10 pull requests Successful merges: - rust-lang#139308 (add autodiff inline) - rust-lang#139656 (Stabilize `slice_as_chunks` library feature) - rust-lang#140022 (allow deref patterns to move out of boxes) - rust-lang#140276 (Do not compute type_of for impl item if impl where clauses are unsatisfied) - rust-lang#140302 (Move inline asm check to typeck, properly handle aliases) - rust-lang#140323 (Implement the internal feature `cfg_target_has_reliable_f16_f128`) - rust-lang#140391 (Rename sub_ptr to offset_from_unsigned in docs) - rust-lang#140394 (Make bootstrap git tests more self-contained) - rust-lang#140396 (Workaround for windows-gnu rust-lld test failure) - rust-lang#140402 (only return nested goals for `Certainty::Yes`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#139656 - scottmcm:stabilize-slice-as-chunks, r=dtolnay Stabilize `slice_as_chunks` library feature ~~Draft as this needs rust-lang#139163 to land first.~~ FCP: rust-lang#74985 (comment) Methods being stabilized are: ```rust impl [T] { const fn as_chunks<const N: usize>(&self) -> (&[[T; N]], &[T]); const fn as_rchunks<const N: usize>(&self) -> (&[T], &[[T; N]]); const unsafe fn as_chunks_unchecked<const N: usize>(&self) -> &[[T; N]]; const fn as_chunks_mut<const N: usize>(&mut self) -> (&mut [[T; N]], &mut [T]); const fn as_rchunks_mut<const N: usize>(&mut self) -> (&mut [T], &mut [[T; N]]); const unsafe fn as_chunks_unchecked_mut<const N: usize>(&mut self) -> &mut [[T; N]]; } ``` ~~(FCP's not done quite yet, but will in another day if I'm counting right.)~~ FCP Complete: rust-lang#74985 (comment)
…, r=dtolnay Stabilize `slice_as_chunks` library feature ~~Draft as this needs rust-lang#139163 to land first.~~ FCP: rust-lang#74985 (comment) Methods being stabilized are: ```rust impl [T] { const fn as_chunks<const N: usize>(&self) -> (&[[T; N]], &[T]); const fn as_rchunks<const N: usize>(&self) -> (&[T], &[[T; N]]); const unsafe fn as_chunks_unchecked<const N: usize>(&self) -> &[[T; N]]; const fn as_chunks_mut<const N: usize>(&mut self) -> (&mut [[T; N]], &mut [T]); const fn as_rchunks_mut<const N: usize>(&mut self) -> (&mut [T], &mut [[T; N]]); const unsafe fn as_chunks_unchecked_mut<const N: usize>(&mut self) -> &mut [[T; N]]; } ``` ~~(FCP's not done quite yet, but will in another day if I'm counting right.)~~ FCP Complete: rust-lang#74985 (comment)
Fix 1.88 relnotes
- Use stable std links for `impl Default for {*const,*mut} T`
- Add missing relnotes for rust-lang#139656
```rs
impl [T] {
const fn as_chunks<const N: usize>(&self) -> (&[[T; N]], &[T]);
const fn as_rchunks<const N: usize>(&self) -> (&[T], &[[T; N]]);
const unsafe fn as_chunks_unchecked<const N: usize>(&self) -> &[[T; N]];
const fn as_chunks_mut<const N: usize>(&mut self) -> (&mut [[T; N]], &mut [T]);
const fn as_rchunks_mut<const N: usize>(&mut self) -> (&mut [T], &mut [[T; N]]);
const unsafe fn as_chunks_unchecked_mut<const N: usize>(&mut self) -> &mut [[T; N]];
}
```
- Add missing `mod ffi::c_str` and `hint::select_unpredictable`
r? `@cuviper`Rollup merge of #143059 - jieyouxu:slice-as-chunks, r=cuviper Fix 1.88 relnotes - Use stable std links for `impl Default for {*const,*mut} T` - Add missing relnotes for #139656 ```rs impl [T] { const fn as_chunks<const N: usize>(&self) -> (&[[T; N]], &[T]); const fn as_rchunks<const N: usize>(&self) -> (&[T], &[[T; N]]); const unsafe fn as_chunks_unchecked<const N: usize>(&self) -> &[[T; N]]; const fn as_chunks_mut<const N: usize>(&mut self) -> (&mut [[T; N]], &mut [T]); const fn as_rchunks_mut<const N: usize>(&mut self) -> (&mut [T], &mut [[T; N]]); const unsafe fn as_chunks_unchecked_mut<const N: usize>(&mut self) -> &mut [[T; N]]; } ``` - Add missing `mod ffi::c_str` and `hint::select_unpredictable` r? `@cuviper`
main was red and no commit caused it. Identical SHA 63c9fbc: success on 2026-08-18, failure on 2026-08-24. CI resolves dtolnay/rust-toolchain@stable, which floated onto a Rust whose clippy adds `chunks_exact_to_as_chunks`; with `-D warnings` that is an immediate failure on untouched code, blocking every merge in the repo. Neither obvious fix was available. clippy's suggested `as_chunks::<4>()` was stabilized in Rust 1.88.0 (rust-lang/rust#139656) against this crate's declared rust-version = "1.75" — taking it would raise MSRV by thirteen minor versions, a breaking change for consumers. And `#[allow(clippy::chunks_exact_to_as_chunks)]` names a lint absent before clippy 1.98, so it would trip `unknown_lints` on older toolchains, trading one failure for another. The loop therefore indexes explicitly: correct on every toolchain from 1.75 upward, coupled to no lint name. Slice bounds cannot panic — bytes.len() == EMBEDDING_BYTE_LEN is checked immediately above, and EMBEDDING_BYTE_LEN == EMBEDDING_DIM * 4. Verified: fmt clean, clippy clean, 81 tests across 9 suites. Coverage of the rewritten line proven by injecting a one-character defect (i * 4 + 1), which fails 5 tests including test_embedding_byte_fidelity and test_strict_rejects_nan, then restoring from snapshot. CI on this PR is the check that matters, because the local toolchain is 1.95 and does not carry the lint: test passed 4m46s, build-deb passed 4m17s. REVIEW: merged without a second reviewer. sovren-software/visage requires one approving review, the maintainer is the sole write-access account, and GitHub forbids approving your own pull request, so no reviewer was available. Merged via bypass with the absence recorded here, per the project's documented escape for that case. No code review was silently skipped; this notice is the disclosure. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Draft as this needs #139163 to land first.FCP: #74985 (comment)
Methods being stabilized are:
(FCP's not done quite yet, but will in another day if I'm counting right.)FCP Complete: #74985 (comment)