Skip to content

Migrate libraries from ptr::slice_from_raw_parts to .cast_slice#156109

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Paladynee:lib/cast-slice-improvements
May 31, 2026
Merged

Migrate libraries from ptr::slice_from_raw_parts to .cast_slice#156109
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Paladynee:lib/cast-slice-improvements

Conversation

@Paladynee

@Paladynee Paladynee commented May 3, 2026

Copy link
Copy Markdown
Contributor

View all comments

Tracking issue for #![feature(ptr_cast_slice)]: #149103
This commit updates most callsites of ptr::slice_from_raw_parts within ./library to the more concise but unstable postfix .cast_slice() method on raw pointers, using the ptr_cast_slice feature. Some tests in alloctests have also been updated.

No functional change, debatably improved readability.

@rustbot

rustbot commented May 3, 2026

Copy link
Copy Markdown
Collaborator

stdarch is developed in its own repository. If possible, consider making this change to rust-lang/stdarch instead.

cc @Amanieu, @folkertdev, @sayantn

@rustbot rustbot added O-SGX Target: SGX 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 May 3, 2026
@rustbot

rustbot commented May 3, 2026

Copy link
Copy Markdown
Collaborator

r? @jhpratt

rustbot has assigned @jhpratt.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 7 candidates
  • Random selection from Mark-Simulacrum, jhpratt, nia-e

@Paladynee

Copy link
Copy Markdown
Contributor Author

some notable places like core::slice::from_raw_parts have not been updated, because i felt like changing that would harm readability than improving it.

@rust-log-analyzer

This comment has been minimized.

@Paladynee

Copy link
Copy Markdown
Contributor Author

hmm wait let me revert that doc change, apparently it is exactly the same in std::ptr::slice_from_raw_parts. this is all so confusing since all the names are super similar lol

@rust-log-analyzer

This comment has been minimized.

@Paladynee Paladynee force-pushed the lib/cast-slice-improvements branch 3 times, most recently from 5533d7b to fced58f Compare May 3, 2026 15:10
@xtqqczze

xtqqczze commented May 3, 2026

Copy link
Copy Markdown
Contributor

Could &*ptr::slice_from_raw_parts be written as slice::from_raw_parts?

@jhpratt

jhpratt commented May 4, 2026

Copy link
Copy Markdown
Member

stdarch is developed in its own repository. If possible, consider making this change to rust-lang/stdarch instead.

Aside from this, r=me

@jhpratt

jhpratt commented May 4, 2026

Copy link
Copy Markdown
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 4, 2026
@rustbot

rustbot commented May 4, 2026

Copy link
Copy Markdown
Collaborator

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

@Paladynee

Paladynee commented May 4, 2026

Copy link
Copy Markdown
Contributor Author

Could &*ptr::slice_from_raw_parts be written as slice::from_raw_parts?

i believe they are equivalent other than the debug UB assertion, yes

@Paladynee

Paladynee commented May 4, 2026

Copy link
Copy Markdown
Contributor Author

I'm not touching anything in;

  • coretests
  • core::slice
  • any ptr::slice_from_raw_parts{_mut} call in stable documentations
  • believe i can revert the stdarch thing since it seems too complicated for me to change for now

with that, i think this pr is ready

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 4, 2026
@Paladynee Paladynee force-pushed the lib/cast-slice-improvements branch from fced58f to e030a3f Compare May 4, 2026 17:33
@xtqqczze

xtqqczze commented May 5, 2026

Copy link
Copy Markdown
Contributor

Could &*ptr::slice_from_raw_parts be written as slice::from_raw_parts?

The library/core/src/slice/sort/shared/smallsort.rs changes should be reverted as they conflict with #156192.

@Paladynee Paladynee force-pushed the lib/cast-slice-improvements branch from e030a3f to 14315f9 Compare May 6, 2026 01:47
@Paladynee

Copy link
Copy Markdown
Contributor Author

Could &*ptr::slice_from_raw_parts be written as slice::from_raw_parts?

The library/core/src/slice/sort/shared/smallsort.rs changes should be reverted as they conflict with #156192.

done

@jhpratt

jhpratt commented May 7, 2026

Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors

rust-bors Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 14315f9 has been approved by jhpratt

It is now in the queue for this repository.

@rust-bors rust-bors Bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label May 7, 2026
rust-bors Bot pushed a commit that referenced this pull request May 8, 2026
Migrate libraries from ptr::slice_from_raw_parts to .cast_slice

Tracking issue for `#![feature(ptr_cast_slice)]`: #149103 
This commit updates most callsites of ptr::slice_from_raw_parts within ./library to the more concise but unstable postfix `.cast_slice()` method on raw pointers, using the `ptr_cast_slice` feature. Some tests in alloctests have also been updated.

No functional change, debatably improved readability.
@rust-log-analyzer

This comment has been minimized.

@rust-bors rust-bors Bot 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 May 8, 2026
@rust-bors

rust-bors Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

💔 Test for bce7e50 failed: CI. Failed job:

@xtqqczze

xtqqczze commented May 8, 2026

Copy link
Copy Markdown
Contributor

Apparently this file requires changes:

+ scope 13 (inlined slice_from_raw_parts_mut::<A>) {
+ scope 14 (inlined std::ptr::from_raw_parts_mut::<[A], A>) {
+ }
+ }

@Paladynee Paladynee force-pushed the lib/cast-slice-improvements branch from 2ab86ba to e6cc90a Compare May 8, 2026 22:38
@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 8, 2026
@Paladynee

Copy link
Copy Markdown
Contributor Author

i ran all tests with --bless and the only change was that file, pushed the changes

@Paladynee Paladynee force-pushed the lib/cast-slice-improvements branch from e6cc90a to cd1f625 Compare May 10, 2026 17:38
@rustbot

rustbot commented May 10, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main 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.

@Paladynee

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 10, 2026
@Paladynee

Copy link
Copy Markdown
Contributor Author

any updates? @jhpratt

@jhpratt

jhpratt commented May 30, 2026

Copy link
Copy Markdown
Member

Sorry, I was travelling Europe for the past couple weeks :)

@bors r+

@rust-bors

rust-bors Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor

📌 Commit cd1f625 has been approved by jhpratt

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 May 30, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request May 30, 2026
…nts, r=jhpratt

Migrate libraries from ptr::slice_from_raw_parts to .cast_slice

Tracking issue for `#![feature(ptr_cast_slice)]`: rust-lang#149103
This commit updates most callsites of ptr::slice_from_raw_parts within ./library to the more concise but unstable postfix `.cast_slice()` method on raw pointers, using the `ptr_cast_slice` feature. Some tests in alloctests have also been updated.

No functional change, debatably improved readability.
rust-bors Bot pushed a commit that referenced this pull request May 30, 2026
Rollup of 6 pull requests

Successful merges:

 - #156832 (library: use strict provenance lints consistently)
 - #157006 (net tests: let the OS pick the port numbers)
 - #157126 (Avoid redundant note when a #[derive] is already suggested)
 - #151690 (std: Refactor `env::var` function)
 - #155826 (std::process: uefi: avoid panicking in Stdio From impls.)
 - #156109 (Migrate libraries from ptr::slice_from_raw_parts to .cast_slice)
rust-bors Bot pushed a commit that referenced this pull request May 30, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #157006 (net tests: let the OS pick the port numbers)
 - #157126 (Avoid redundant note when a #[derive] is already suggested)
 - #151690 (std: Refactor `env::var` function)
 - #155826 (std::process: uefi: avoid panicking in Stdio From impls.)
 - #156109 (Migrate libraries from ptr::slice_from_raw_parts to .cast_slice)
 - #156642 (`offload_kernel` macro expansion)
 - #156823 (Add regression test)
 - #157162 (elaborate_drop: Avoid as_mut.unwrap dance, empty vectors are cheap.)

Failed merges:

 - #157173 (rustc-dev-guide subtree update)
@rust-bors rust-bors Bot merged commit 694e1f9 into rust-lang:main May 31, 2026
11 checks passed
@rustbot rustbot added this to the 1.98.0 milestone May 31, 2026
rust-timer added a commit that referenced this pull request May 31, 2026
Rollup merge of #156109 - Paladynee:lib/cast-slice-improvements, r=jhpratt

Migrate libraries from ptr::slice_from_raw_parts to .cast_slice

Tracking issue for `#![feature(ptr_cast_slice)]`: #149103
This commit updates most callsites of ptr::slice_from_raw_parts within ./library to the more concise but unstable postfix `.cast_slice()` method on raw pointers, using the `ptr_cast_slice` feature. Some tests in alloctests have also been updated.

No functional change, debatably improved readability.
pull Bot pushed a commit to xtqqczze/rust-lang-rustc-dev-guide that referenced this pull request Jun 4, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#157006 (net tests: let the OS pick the port numbers)
 - rust-lang/rust#157126 (Avoid redundant note when a #[derive] is already suggested)
 - rust-lang/rust#151690 (std: Refactor `env::var` function)
 - rust-lang/rust#155826 (std::process: uefi: avoid panicking in Stdio From impls.)
 - rust-lang/rust#156109 (Migrate libraries from ptr::slice_from_raw_parts to .cast_slice)
 - rust-lang/rust#156642 (`offload_kernel` macro expansion)
 - rust-lang/rust#156823 (Add regression test)
 - rust-lang/rust#157162 (elaborate_drop: Avoid as_mut.unwrap dance, empty vectors are cheap.)

Failed merges:

 - rust-lang/rust#157173 (rustc-dev-guide subtree update)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-SGX Target: SGX 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.

5 participants