Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize const_slice_from_raw_parts_mut #130403

Merged

Conversation

eduardosm
Copy link
Contributor

Stabilizes #67456, since #57349 has been stabilized.

Stabilized const API:

// core::ptr
pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T];

// core::slice
pub const unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a mut [T];

// core::ptr::NonNull
pub const fn slice_from_raw_parts(data: NonNull<T>, len: usize) -> Self

Closes #67456.

r? libs-api

@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 Sep 15, 2024
@eduardosm
Copy link
Contributor Author

cc @RalfJung

Requires

#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]

and

#[rustc_allow_const_fn_unstable(ptr_metadata)]

@RalfJung
Copy link
Member

Cc @rust-lang/wg-const-eval

@RalfJung
Copy link
Member

Yeah seems fine to me. We should probably mark the ptr_metadata methods as const-stable to avoid the need for all these rustc_allow_const_fn_unstable (similar to #[rustc_const_stable(feature = "raw_vec_internals_const", since = "1.81")])... but that's orthogonal to this PR.

@onestacked
Copy link
Contributor

@eduardosm Now that #130966 is merged you should be able to remove the:
#[rustc_allow_const_fn_unstable(ptr_metadata)] usage.

@eduardosm eduardosm force-pushed the stabilize-const_slice_from_raw_parts_mut branch from d5aa3e4 to 0dc250c Compare October 1, 2024 20:11
@eduardosm
Copy link
Contributor Author

Rebased and removed #[rustc_allow_const_fn_unstable(ptr_metadata)].

@workingjubilee
Copy link
Member

FCP has completed.

@bors r+

@bors
Copy link
Contributor

bors commented Oct 4, 2024

📌 Commit 0dc250c has been approved by workingjubilee

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 Oct 4, 2024
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Oct 4, 2024
…om_raw_parts_mut, r=workingjubilee

Stabilize `const_slice_from_raw_parts_mut`

Stabilizes rust-lang#67456, since rust-lang#57349 has been stabilized.

Stabilized const API:
```rust
// core::ptr
pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T];

// core::slice
pub const unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a mut [T];

// core::ptr::NonNull
pub const fn slice_from_raw_parts(data: NonNull<T>, len: usize) -> Self
```

Closes rust-lang#67456.

r? libs-api
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Oct 4, 2024
…om_raw_parts_mut, r=workingjubilee

Stabilize `const_slice_from_raw_parts_mut`

Stabilizes rust-lang#67456, since rust-lang#57349 has been stabilized.

Stabilized const API:
```rust
// core::ptr
pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T];

// core::slice
pub const unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a mut [T];

// core::ptr::NonNull
pub const fn slice_from_raw_parts(data: NonNull<T>, len: usize) -> Self
```

Closes rust-lang#67456.

r? libs-api
@bors
Copy link
Contributor

bors commented Oct 4, 2024

⌛ Testing commit 0dc250c with merge 2588fc8...

bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 4, 2024
…_raw_parts_mut, r=workingjubilee

Stabilize `const_slice_from_raw_parts_mut`

Stabilizes rust-lang#67456, since rust-lang#57349 has been stabilized.

Stabilized const API:
```rust
// core::ptr
pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T];

// core::slice
pub const unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a mut [T];

// core::ptr::NonNull
pub const fn slice_from_raw_parts(data: NonNull<T>, len: usize) -> Self
```

Closes rust-lang#67456.

r? libs-api
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-msvc-ext failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@bors
Copy link
Contributor

bors commented Oct 4, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 4, 2024
@workingjubilee
Copy link
Member

...again? @bors retry

@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 Oct 4, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 5, 2024
…kingjubilee

Rollup of 9 pull requests

Successful merges:

 - rust-lang#129517 (Compute array length from type for unconditional panic lint. )
 - rust-lang#130367 (Check elaborated projections from dyn don't mention unconstrained late bound lifetimes)
 - rust-lang#130403 (Stabilize `const_slice_from_raw_parts_mut`)
 - rust-lang#130633 (Add support for reborrowing pinned method receivers)
 - rust-lang#131105 (update `Literal`'s intro)
 - rust-lang#131194 (Fix needless_lifetimes in stable_mir)
 - rust-lang#131260 (rustdoc: cleaner errors on disambiguator/namespace mismatches)
 - rust-lang#131267 (Stabilize `BufRead::skip_until`)
 - rust-lang#131273 (Account for `impl Trait {` when `impl Trait for Type {` was intended)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 49c6d78 into rust-lang:master Oct 5, 2024
6 of 7 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Oct 5, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Oct 5, 2024
Rollup merge of rust-lang#130403 - eduardosm:stabilize-const_slice_from_raw_parts_mut, r=workingjubilee

Stabilize `const_slice_from_raw_parts_mut`

Stabilizes rust-lang#67456, since rust-lang#57349 has been stabilized.

Stabilized const API:
```rust
// core::ptr
pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T];

// core::slice
pub const unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a mut [T];

// core::ptr::NonNull
pub const fn slice_from_raw_parts(data: NonNull<T>, len: usize) -> Self
```

Closes rust-lang#67456.

r? libs-api
@eduardosm eduardosm deleted the stabilize-const_slice_from_raw_parts_mut branch October 5, 2024 10:16
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 5, 2024
…lit-at-mut, r=RalfJung

Stabilize `const_slice_split_at_mut` and `const_slice_first_last_chunk`

Stabilizes rust-lang#101804 and the remainder of rust-lang#111774.

FCP proposed in the tracking issue.

Requires rust-lang#130403 (or it would need a rustc_allow_const_fn_unstable for it)

Stabilized const API:
```rust
// slice
impl [T] {
    pub const fn split_at_mut(&mut self, mid: usize) -> (&mut [T], &mut [T]);
    pub const fn split_at_mut_unchecked(&mut self, mid: usize) -> (&mut [T], &mut [T]);
    pub const fn split_at_mut_checked(&mut self, mid: usize) -> Option<(&mut [T], &mut [T])>;

    pub const fn first_chunk_mut<const N: usize>(&mut self) -> Option<&mut [T; N]>;
    pub const fn last_chunk_mut<const N: usize>(&mut self) -> Option<&mut [T; N]>;
    pub const fn split_first_chunk_mut<const N: usize>(&mut self) -> Option<(&mut [T; N], &mut [T])>;
    pub const fn split_last_chunk_mut<const N: usize>(&mut self) -> Option<(&mut [T; N], &mut [T])>;
}
```

Closes rust-lang#101804
Closes rust-lang#111774

cc `@RalfJung`
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Oct 5, 2024
Rollup merge of rust-lang#130428 - ink-feather-org:stabilize-const-split-at-mut, r=RalfJung

Stabilize `const_slice_split_at_mut` and `const_slice_first_last_chunk`

Stabilizes rust-lang#101804 and the remainder of rust-lang#111774.

FCP proposed in the tracking issue.

Requires rust-lang#130403 (or it would need a rustc_allow_const_fn_unstable for it)

Stabilized const API:
```rust
// slice
impl [T] {
    pub const fn split_at_mut(&mut self, mid: usize) -> (&mut [T], &mut [T]);
    pub const fn split_at_mut_unchecked(&mut self, mid: usize) -> (&mut [T], &mut [T]);
    pub const fn split_at_mut_checked(&mut self, mid: usize) -> Option<(&mut [T], &mut [T])>;

    pub const fn first_chunk_mut<const N: usize>(&mut self) -> Option<&mut [T; N]>;
    pub const fn last_chunk_mut<const N: usize>(&mut self) -> Option<&mut [T; N]>;
    pub const fn split_first_chunk_mut<const N: usize>(&mut self) -> Option<(&mut [T; N], &mut [T])>;
    pub const fn split_last_chunk_mut<const N: usize>(&mut self) -> Option<(&mut [T; N], &mut [T])>;
}
```

Closes rust-lang#101804
Closes rust-lang#111774

cc `@RalfJung`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-fcp This change is insta-stable, so needs a completed FCP to proceed. 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.

Tracking issue for const slice::from_raw_parts_mut (const_slice_from_raw_parts_mut)
8 participants