Skip to content

Conversation

bjoernager
Copy link
Contributor

@bjoernager bjoernager commented Oct 9, 2025

Tracking issue: #133508

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

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]>;
}

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]>;
}

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
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. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants