Skip to content

Conversation

@bjoernager
Copy link
Contributor

@bjoernager bjoernager commented Oct 9, 2025

Tracking issue: #133508

Closes: #133508

This PR stabilises the as_array and as_mut_array associated functions from the core_slice_as_array feature gate:

// core::slice

impl<T> [T] {
    pub const fn as_array<const N: usize>(&self) -> Option<&[T; N]>;

    pub const fn as_mut_array<const N: usize>(&mut self) -> Option<&mut [T; N]>;
}

// core::ptr

impl<T> *const [T] {
    pub const fn as_array<const N: usize>(self) -> Option<*const [T; N]>;
}

impl<T> *mut [T] {
    pub const fn as_mut_array<const N: usize>(self) -> Option<*mut [T; N]>;
}

It also updates the feature gates and tracking issues for all items associated with the previous slice_as_array tracking issue (including these four that are being stabilised).

FCP missing.

@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, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 9, 2025

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@bjoernager
Copy link
Contributor Author

@rustbot label needs-fcp

@rustbot rustbot added the needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. label Oct 9, 2025
@rust-log-analyzer

This comment has been minimized.

@bjoernager bjoernager changed the title Stabilise as_array in [_] and *const [_] and as_mut_array in [_] and *mut [_]. Stabilise as_array in [_] and *const [_]; stabilise as_mut_array in [_] and *mut [_]. Oct 9, 2025
@rust-log-analyzer

This comment has been minimized.

@zachs18
Copy link
Contributor

zachs18 commented Oct 10, 2025

tidy [features]: /checkout/library/alloc/src/sync.rs:1229: feature gate slice_as_array has inconsistent `issue`: "133508" mismatches the previous `issue` of "none"

The specific tidy error is about Arc::into_array IIUC.

I think since this is a partial stabilization of feature(slice_as_array) (because it does not stabilize {Box, Rc, Arc}::into_array), it will need to change the feature name of either the newly-stable or the remaining-unstable functions to a different name, so they do not conflict.

IIUC, the intended workflow is to rename the feature on the being-stabilized functions, and leave the feature name the same on the remaining-unstable functions, like was done in #94640 (it stablized NonNull::len, and changed its feature from slice_ptr_len to slice_ptr_len_nonnull, while leaving slice_ptr_len unstable)

If you want to cherry-pick zachs18@e801f3e it should fix the tidy error I think.

@bjoernager
Copy link
Contributor Author

Oh, I wasn't aware. Thank you!

@rustbot rustbot added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Oct 10, 2025
@bjoernager

This comment was marked as outdated.

@rustbot rustbot removed the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Oct 10, 2025
@rust-log-analyzer

This comment has been minimized.

@bjoernager

This comment was marked as resolved.

@rustbot rustbot added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Oct 10, 2025
@ibraheemdev
Copy link
Member

r? libs-api

@rustbot rustbot added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Oct 22, 2025
@rustbot rustbot assigned Amanieu and unassigned ibraheemdev Oct 22, 2025
@bors
Copy link
Collaborator

bors commented Nov 5, 2025

☔ The latest upstream changes (presumably #148507) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Nov 6, 2025

☔ The latest upstream changes (presumably #148544) made this pull request unmergeable. Please resolve the merge conflicts.

@Amanieu
Copy link
Member

Amanieu commented Nov 6, 2025

r=me once conflicts are resolved.

@rustbot
Copy link
Collaborator

rustbot commented Nov 7, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

…ay' in '[_]' and '*mut [_]'; Update feature gate and tracking issue for 'alloc_slice_into_array' items;
@bjoernager
Copy link
Contributor Author

@bors r=Amanieu rollup

@bors
Copy link
Collaborator

bors commented Nov 7, 2025

@bjoernager: 🔑 Insufficient privileges: Not in reviewers

@bors
Copy link
Collaborator

bors commented Nov 7, 2025

@bjoernager: 🔑 Insufficient privileges: not in try users

@bjoernager
Copy link
Contributor Author

@rustbot label -needs-fcp

@rustbot rustbot removed the needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. label Nov 7, 2025
@joboet
Copy link
Member

joboet commented Nov 8, 2025

@bors r=@Amanieu rollup

@bors
Copy link
Collaborator

bors commented Nov 8, 2025

📌 Commit fa8e864 has been approved by Amanieu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 8, 2025
bors added a commit that referenced this pull request Nov 8, 2025
Rollup of 10 pull requests

Successful merges:

 - #145656 (Stabilize s390x `vector` target feature and `is_s390x_feature_detected!` macro)
 - #147024 (std_detect: Support run-time detection on OpenBSD using elf_aux_info)
 - #147534 (Implement SIMD funnel shifts in const-eval/Miri)
 - #147540 (Stabilise `as_array` in `[_]` and `*const [_]`; stabilise `as_mut_array` in `[_]` and `*mut [_]`.)
 - #147686 (update isolate_highest_one for NonZero<T>)
 - #148230 (rustdoc: Properly highlight shebang, frontmatter & weak keywords in source code pages and code blocks)
 - #148555 (Fix rust-by-example spanish translation)
 - #148556 (Fix suggestion for returning async closures)
 - #148585 ([rustdoc] Replace `print` methods with functions to improve code readability)
 - #148600 (re-use `self.get_all_attrs` result for pass indirectly attribute)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Nov 8, 2025
Rollup of 10 pull requests

Successful merges:

 - #145656 (Stabilize s390x `vector` target feature and `is_s390x_feature_detected!` macro)
 - #147024 (std_detect: Support run-time detection on OpenBSD using elf_aux_info)
 - #147534 (Implement SIMD funnel shifts in const-eval/Miri)
 - #147540 (Stabilise `as_array` in `[_]` and `*const [_]`; stabilise `as_mut_array` in `[_]` and `*mut [_]`.)
 - #147686 (update isolate_highest_one for NonZero<T>)
 - #148230 (rustdoc: Properly highlight shebang, frontmatter & weak keywords in source code pages and code blocks)
 - #148555 (Fix rust-by-example spanish translation)
 - #148556 (Fix suggestion for returning async closures)
 - #148585 ([rustdoc] Replace `print` methods with functions to improve code readability)
 - #148600 (re-use `self.get_all_attrs` result for pass indirectly attribute)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Nov 9, 2025
Rollup of 10 pull requests

Successful merges:

 - #145656 (Stabilize s390x `vector` target feature and `is_s390x_feature_detected!` macro)
 - #147024 (std_detect: Support run-time detection on OpenBSD using elf_aux_info)
 - #147534 (Implement SIMD funnel shifts in const-eval/Miri)
 - #147540 (Stabilise `as_array` in `[_]` and `*const [_]`; stabilise `as_mut_array` in `[_]` and `*mut [_]`.)
 - #147686 (update isolate_highest_one for NonZero<T>)
 - #148230 (rustdoc: Properly highlight shebang, frontmatter & weak keywords in source code pages and code blocks)
 - #148555 (Fix rust-by-example spanish translation)
 - #148556 (Fix suggestion for returning async closures)
 - #148585 ([rustdoc] Replace `print` methods with functions to improve code readability)
 - #148600 (re-use `self.get_all_attrs` result for pass indirectly attribute)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit da2e3aa into rust-lang:master Nov 9, 2025
11 checks passed
@rustbot rustbot added this to the 1.93.0 milestone Nov 9, 2025
rust-timer added a commit that referenced this pull request Nov 9, 2025
Rollup merge of #147540 - bjoernager:slice-as-array, r=Amanieu

Stabilise `as_array` in `[_]` and `*const [_]`; stabilise `as_mut_array` in `[_]` and `*mut [_]`.

Tracking issue: #133508

Closes: #133508

This PR stabilises the `as_array` and `as_mut_array` associated functions from the `core_slice_as_array` feature gate:

```rust
// core::slice

impl<T> [T] {
    pub const fn as_array<const N: usize>(&self) -> Option<&[T; N]>;

    pub const fn as_mut_array<const N: usize>(&mut self) -> Option<&mut [T; N]>;
}

// core::ptr

impl<T> *const [T] {
    pub const fn as_array<const N: usize>(self) -> Option<*const [T; N]>;
}

impl<T> *mut [T] {
    pub const fn as_mut_array<const N: usize>(self) -> Option<*mut [T; N]>;
}
```

It also updates the feature gates and tracking issues for all items associated with the previous `slice_as_array` tracking issue (including these four that are being stabilised).

~~FCP missing.~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tracking Issue for core_slice_as_array.

8 participants